GroupsController.cs 722 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using EyeSoft.IO;
  6. using Microsoft.AspNetCore.SignalR;
  7. using MySqlX.XDevAPI.Relational;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.Format;
  10. using NPOI.SS.UserModel;
  11. using NPOI.SS.Util;
  12. using NPOI.XSSF.UserModel;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  19. using OASystem.Domain.Dtos.CRM;
  20. using OASystem.Domain.Dtos.FileDto;
  21. using OASystem.Domain.Dtos.Financial;
  22. using OASystem.Domain.Dtos.Groups;
  23. using OASystem.Domain.Entities.Customer;
  24. using OASystem.Domain.Entities.Financial;
  25. using OASystem.Domain.Entities.Groups;
  26. using OASystem.Domain.ViewModels;
  27. using OASystem.Domain.ViewModels.Groups;
  28. using OASystem.Domain.ViewModels.Statistics;
  29. using OASystem.Infrastructure.Repositories.Financial;
  30. using OASystem.Infrastructure.Repositories.Groups;
  31. using Quartz.Util;
  32. using SqlSugar;
  33. using SqlSugar.Extensions;
  34. using System.Collections;
  35. using System.Data;
  36. using System.Diagnostics;
  37. using System.Globalization;
  38. using System.IO;
  39. using System.IO.Compression;
  40. using System.Net.Http;
  41. using System.Reflection.PortableExecutable;
  42. using Ubiety.Dns.Core;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using Bookmark = Aspose.Words.Bookmark;
  46. using Cell = Aspose.Words.Tables.Cell;
  47. using Table = Aspose.Words.Tables.Table;
  48. namespace OASystem.API.Controllers
  49. {
  50. /// <summary>
  51. /// 团组相关
  52. /// </summary>
  53. //[Authorize]
  54. [Route("api/[controller]/[action]")]
  55. public class GroupsController : ControllerBase
  56. {
  57. private readonly ILogger<GroupsController> _logger;
  58. private readonly GrpScheduleRepository _grpScheduleRep;
  59. private readonly IMapper _mapper;
  60. private readonly DelegationInfoRepository _groupRepository;
  61. private readonly TaskAssignmentRepository _taskAssignmentRep;
  62. private readonly AirTicketResRepository _airTicketResRep;
  63. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  64. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  65. private readonly DelegationEnDataRepository _delegationEnDataRep;
  66. private readonly DelegationVisaRepository _delegationVisaRep;
  67. private readonly VisaPriceRepository _visaPriceRep;
  68. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  69. private readonly HotelPriceRepository _hotelPriceRep;
  70. private readonly CustomersRepository _customersRep;
  71. private readonly MessageRepository _message;
  72. private readonly SqlSugarClient _sqlSugar;
  73. private readonly TourClientListRepository _tourClientListRep;
  74. private readonly TeamRateRepository _teamRateRep;
  75. #region 成本相关
  76. private readonly CheckBoxsRepository _checkBoxs;
  77. private readonly GroupCostRepository _GroupCostRepository;
  78. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  79. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  80. #endregion
  81. private readonly SetDataRepository _setDataRep;
  82. private string url;
  83. private string path;
  84. private readonly EnterExitCostRepository _enterExitCostRep;
  85. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  86. private readonly UsersRepository _usersRep;
  87. private readonly IJuHeApiService _juHeApi;
  88. private readonly InvertedListRepository _invertedListRep;
  89. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  90. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  91. private readonly ThreeCodeRepository _threeCodeRepository;
  92. private readonly HotelInquiryRepository _hotelInquiryRep;
  93. private readonly FeeAuditRepository _feeAuditRep;
  94. private readonly VisaCommissionRepository _visaCommissionRep;
  95. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  96. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  97. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  98. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  99. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  100. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  101. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  102. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  103. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  104. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  105. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep,
  106. OpinionaireRepository opinionaireRep)
  107. {
  108. _logger = logger;
  109. _mapper = mapper;
  110. _grpScheduleRep = grpScheduleRep;
  111. _groupRepository = groupRepository;
  112. _taskAssignmentRep = taskAssignmentRep;
  113. _airTicketResRep = airTicketResRep;
  114. _sqlSugar = sqlSugar;
  115. url = AppSettingsHelper.Get("ExcelBaseUrl");
  116. path = AppSettingsHelper.Get("ExcelBasePath");
  117. if (!System.IO.Directory.Exists(path))
  118. {
  119. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  120. }
  121. _decreasePaymentsRep = decreasePaymentsRep;
  122. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  123. _delegationEnDataRep = delegationEnDataRep;
  124. _enterExitCostRep = enterExitCostRep;
  125. _delegationVisaRep = delegationVisaRep;
  126. _message = message;
  127. _visaPriceRep = visaPriceRep;
  128. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  129. _checkBoxs = checkBoxs;
  130. _GroupCostRepository = GroupCostRepository;
  131. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  132. _GroupCostParameterRepository = GroupCostParameterRepository;
  133. _hotelPriceRep = hotelPriceRep;
  134. _customersRep = customersRep;
  135. _setDataRep = setDataRep;
  136. _tourClientListRep = tourClientListRep;
  137. _teamRateRep = teamRateRep;
  138. _hubContext = hubContext;
  139. _usersRep = usersRep;
  140. _juHeApi = juHeApi;
  141. _invertedListRep = invertedListRep;
  142. _visaFeeInfoRep = visaFeeInfoRep;
  143. _ticketBlackCodeRep = ticketBlackCodeRep;
  144. _hotelInquiryRep = hotelInquiryRep;
  145. _threeCodeRepository = threeCodeRepository;
  146. _feeAuditRep = feeAuditRep;
  147. _visaCommissionRep = visaCommissionRep;
  148. _ffrRep = ffrRep;
  149. _opinionaireRep = opinionaireRep;
  150. }
  151. #region 流程管控
  152. /// <summary>
  153. /// 获取团组流程管控信息
  154. /// </summary>
  155. /// <param name="paras">参数Json字符串</param>
  156. /// <returns></returns>
  157. [HttpPost]
  158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  159. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  160. {
  161. if (string.IsNullOrEmpty(_jsonDto.Paras))
  162. {
  163. return Ok(JsonView(false, "参数为空"));
  164. }
  165. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  166. if (_ScheduleDto != null)
  167. {
  168. if (_ScheduleDto.SearchType == 2)//获取列表
  169. {
  170. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  171. return Ok(JsonView(_grpScheduleViewList));
  172. }
  173. else//获取对象
  174. {
  175. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  176. if (_grpScheduleView != null)
  177. {
  178. return Ok(JsonView(_grpScheduleView));
  179. }
  180. }
  181. }
  182. else
  183. {
  184. return Ok(JsonView(false, "参数反序列化失败"));
  185. }
  186. return Ok(JsonView(false, "暂无数据!"));
  187. }
  188. /// <summary>
  189. /// 修改团组流程管控详细表数据
  190. /// </summary>
  191. /// <param name="paras"></param>
  192. /// <returns></returns>
  193. [HttpPost]
  194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  195. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  196. {
  197. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  198. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  199. .SetColumns(it => it.Duty == _detail.Duty)
  200. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  201. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  202. .SetColumns(it => it.JobContent == _detail.JobContent)
  203. .SetColumns(it => it.Remark == _detail.Remark)
  204. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  205. .Where(s => s.Id == dto.Id)
  206. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  207. .ExecuteCommandAsync();
  208. if (result > 0)
  209. {
  210. return Ok(JsonView(true, "保存成功!"));
  211. }
  212. return Ok(JsonView(false, "保存失败!"));
  213. }
  214. /// <summary>
  215. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  216. /// </summary>
  217. /// <param name="dto"></param>
  218. /// <returns></returns>
  219. [HttpPost]
  220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  221. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  222. {
  223. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  224. _detail.IsDel = 1;
  225. _detail.DeleteUserId = dto.Duty;
  226. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  227. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  228. .SetColumns(it => it.IsDel == _detail.IsDel)
  229. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  230. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  231. .Where(it => it.Id == dto.Id)
  232. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  233. //.WhereColumns(s => s.Id == dto.Id)
  234. .ExecuteCommandAsync();
  235. if (result > 0)
  236. {
  237. return Ok(JsonView(true, "删除成功!"));
  238. }
  239. return Ok(JsonView(false, "删除失败!"));
  240. }
  241. /// <summary>
  242. /// 增加团组流程管控详细表数据
  243. /// </summary>
  244. /// <param name="dto"></param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  249. {
  250. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  251. if (DateTime.Now < _detail.ExpectBeginDt)
  252. {
  253. _detail.StepStatus = 0;
  254. }
  255. else
  256. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  257. _detail.StepStatus = 1;
  258. }
  259. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  260. if (result > 0)
  261. {
  262. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  263. return Ok(JsonView(true, "添加成功!", _result));
  264. }
  265. return Ok(JsonView(false, "添加失败!"));
  266. }
  267. #endregion
  268. #region 团组基本信息
  269. /// <summary>
  270. /// 接团信息列表
  271. /// </summary>
  272. /// <param name="dto">团组列表请求dto</param>
  273. /// <returns></returns>
  274. [HttpPost]
  275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  276. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  277. {
  278. var groupData = await _groupRepository.GetGroupList(dto);
  279. if (groupData.Code != 0)
  280. {
  281. return Ok(JsonView(false, groupData.Msg));
  282. }
  283. return Ok(JsonView(groupData.Data));
  284. }
  285. /// <summary>
  286. /// 分页查询团组列表
  287. /// </summary>
  288. /// <param name="dto"></param>
  289. /// <returns></returns>
  290. [HttpPost]
  291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  292. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  293. {
  294. var watch = new Stopwatch();
  295. watch.Start();
  296. RefAsync<int> total = 0;
  297. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  298. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  299. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  300. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  301. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  302. .Distinct()
  303. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  304. watch.Stop();
  305. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  306. }
  307. /// <summary>
  308. /// 接团信息列表 Page
  309. /// </summary>
  310. /// <param name="dto">团组列表请求dto</param>
  311. /// <returns></returns>
  312. [HttpPost]
  313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  314. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  315. {
  316. #region 参数验证
  317. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  318. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  320. #region 页面操作权限验证
  321. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  322. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  323. #endregion
  324. #endregion
  325. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  326. {
  327. string sqlWhere = string.Empty;
  328. if (dto.IsSure == 0) //未完成
  329. {
  330. sqlWhere += string.Format(@" And IsSure = 0");
  331. }
  332. else if (dto.IsSure == 1) //已完成
  333. {
  334. sqlWhere += string.Format(@" And IsSure = 1");
  335. }
  336. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  337. {
  338. string tj = dto.SearchCriteria;
  339. 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}%')",
  340. tj, tj, tj, tj, tj);
  341. }
  342. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  343. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  344. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  345. JietuanOperator,IsSure,CreateTime,IsBid
  346. From (
  347. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  348. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  349. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  350. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  351. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  352. From Grp_DelegationInfo gdi
  353. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  354. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  355. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  356. Where gdi.IsDel = 0 {0}
  357. ) temp", sqlWhere);
  358. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  359. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  360. #region 处理所属部门
  361. /*
  362. * 1.sq 和 gyy 等显示 市场部
  363. * 2.王鸽和主管及张总还有管理员号统一国交部
  364. * 2-1. 4 管理员 ,21 张海麟
  365. */
  366. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  367. List<int> userIds1 = new List<int>() { 4, 21 };
  368. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  369. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  370. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  371. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  372. .ToList();
  373. foreach (var item in _DelegationList)
  374. {
  375. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  376. }
  377. #endregion
  378. var _view = new
  379. {
  380. PageFuncAuth = pageFunAuthView,
  381. Data = _DelegationList
  382. };
  383. return Ok(JsonView(true, "查询成功!", _view, total));
  384. }
  385. else
  386. {
  387. return Ok(JsonView(false, "查询失败"));
  388. }
  389. }
  390. /// <summary>
  391. /// 团组列表
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpPost]
  395. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  396. {
  397. #region 参数验证
  398. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  399. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  400. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  401. #region 页面操作权限验证
  402. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  403. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  404. #endregion
  405. #endregion
  406. if (dto.PortType != 1 && dto.PortType != 2)
  407. {
  408. return Ok(JsonView(false, "查询失败!"));
  409. }
  410. string orderbyStr = "order by gdi.CreateTime Desc";
  411. string sqlWhere = string.Empty;
  412. if (dto.IsSure == 0) //未完成
  413. {
  414. sqlWhere += string.Format(@" And IsSure = 0");
  415. }
  416. else if (dto.IsSure == 1) //已完成
  417. {
  418. sqlWhere += string.Format(@" And IsSure = 1");
  419. }
  420. //团组类型
  421. if (dto.TeamDid > 0)
  422. {
  423. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  424. }
  425. //团组名称
  426. if (!string.IsNullOrEmpty(dto.TeamName))
  427. {
  428. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  429. }
  430. //客户名称
  431. if (!string.IsNullOrEmpty(dto.ClientName))
  432. {
  433. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  434. }
  435. //客户单位
  436. if (!string.IsNullOrEmpty(dto.ClientUnit))
  437. {
  438. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  439. }
  440. //出访时间
  441. if (!string.IsNullOrEmpty(dto.visitDataTime))
  442. {
  443. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  444. orderbyStr = "order by gdi.VisitDate";
  445. }
  446. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  447. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  448. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  449. JietuanOperator,IsSure,CreateTime
  450. From (
  451. Select row_number() over({0}) as Row_Number,
  452. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  453. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  454. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  455. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  456. From Grp_DelegationInfo gdi
  457. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  458. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  459. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  460. Where gdi.IsDel = 0 {1}
  461. ) temp ", orderbyStr, sqlWhere);
  462. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  463. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  464. #region 处理所属部门
  465. /*
  466. * 1.sq 和 gyy 等显示 市场部
  467. * 2.王鸽和主管及张总还有管理员号统一国交部
  468. * 2-1. 4 管理员 ,21 张海麟
  469. */
  470. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  471. List<int> userIds1 = new List<int>() { 4, 21 };
  472. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  473. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  474. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  475. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  476. .ToList();
  477. foreach (var item in _DelegationList)
  478. {
  479. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  480. }
  481. #endregion
  482. var _view = new
  483. {
  484. PageFuncAuth = pageFunAuthView,
  485. Data = _DelegationList
  486. };
  487. return Ok(JsonView(true, "查询成功!", _view, total));
  488. }
  489. /// <summary>
  490. /// 接团信息详情
  491. /// </summary>
  492. /// <param name="dto">团组info请求dto</param>
  493. /// <returns></returns>
  494. [HttpPost]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  497. {
  498. var groupData = await _groupRepository.GetGroupInfo(dto);
  499. if (groupData.Code != 0)
  500. {
  501. return Ok(JsonView(false, groupData.Msg));
  502. }
  503. return Ok(JsonView(groupData.Data));
  504. }
  505. /// <summary>
  506. /// 接团信息 编辑添加
  507. /// 基础信息数据源
  508. /// </summary>
  509. /// <param name="dto"></param>
  510. /// <returns></returns>
  511. [HttpPost]
  512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  513. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  514. {
  515. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  516. if (groupData.Code != 0)
  517. {
  518. return Ok(JsonView(false, groupData.Msg));
  519. }
  520. return Ok(JsonView(groupData.Data));
  521. }
  522. /// <summary>
  523. /// 接团信息 操作(增改)
  524. /// </summary>
  525. /// <param name="dto"></param>
  526. /// <returns></returns>
  527. [HttpPost]
  528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  529. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  530. {
  531. try
  532. {
  533. decimal ffrPrice = 0.00M;
  534. DateTime? visitDt = null;
  535. if (dto.Status == 2)
  536. {
  537. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  538. if (groupInfo != null)
  539. {
  540. ffrPrice = groupInfo.PaymentMoney;
  541. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  542. }
  543. }
  544. var groupData = await _groupRepository.GroupOperation(dto);
  545. if (groupData.Code != 0)
  546. {
  547. return Ok(JsonView(false, groupData.Msg));
  548. }
  549. int diId = 0;
  550. //添加时 默认加入团组汇率
  551. if (dto.Status == 1) //添加
  552. {
  553. diId = groupData.Data;
  554. //添加默认币种
  555. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  556. //默认分配权限
  557. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  558. //消息提示 王鸽 主管号
  559. List<int> _managerIds = new List<int>() { 22, 32 };
  560. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  561. if (userIds.Count > 0)
  562. {
  563. userIds.Add(208);
  564. //创建团组管控
  565. GroupStepForDelegation.CreateWorkStep(diId);
  566. //发送消息
  567. string groupName = dto.TeamName;
  568. string createGroupUser = string.Empty;
  569. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  570. if (userInfo != null) createGroupUser = userInfo.CnName;
  571. string title = $"系统通知";
  572. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  573. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  574. }
  575. //默认创建倒推表
  576. await _invertedListRep._Create(dto.UserId, diId);
  577. }
  578. else if (dto.Status == 2)
  579. {
  580. diId = dto.Id;
  581. }
  582. #region 签证人员团组时间通知
  583. #region 计算出访起止时间
  584. var startTime = new DateTime();
  585. var endTime = new DateTime();
  586. if (DateTime.TryParse(dto.VisitDate, out startTime))
  587. {
  588. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  589. }
  590. #endregion
  591. if (diId > 0)
  592. {
  593. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  594. }
  595. #endregion
  596. #region 团组操作默认添加/修改收款账单
  597. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  598. {
  599. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  600. .Where(x => x.IsDel == 0 &&
  601. x.Diid == diId &&
  602. x.Remark.Equals("预付款")
  603. )
  604. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  605. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  606. .FirstAsync();
  607. ffrInfo = new Fin_ForeignReceivables()
  608. {
  609. Diid = diId,
  610. PriceName = dto.ClientUnit,
  611. Price = dto.PaymentMoney,
  612. Count = 1,
  613. Unit = $"元",
  614. ItemSumPrice = dto.PaymentMoney,
  615. Rate = 1.0000M,
  616. Currency = 836,
  617. AddingWay = 0,
  618. CreateUserId = dto.UserId,
  619. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  620. Remark = $"预付款"
  621. };
  622. if (ffrInfo == null) //Add
  623. {
  624. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  625. }
  626. else //修改
  627. {
  628. await _sqlSugar.Updateable(ffrInfo)
  629. .UpdateColumns(x => new
  630. {
  631. x.PriceName,
  632. x.Price,
  633. x.ItemSumPrice,
  634. x.CreateTime,
  635. x.CreateUserId
  636. })
  637. .WhereColumns(x => x.Id)
  638. .ExecuteCommandAsync();
  639. }
  640. }
  641. #endregion
  642. return Ok(JsonView(true, "操作成功!", diId));
  643. }
  644. catch (Exception ex)
  645. {
  646. Logs("[response]" + JsonConvert.SerializeObject(dto));
  647. Logs(ex.Message);
  648. return Ok(JsonView(false, ex.Message));
  649. }
  650. }
  651. /// <summary>
  652. /// 接团流程操作(增改)
  653. /// 安卓端使用 建团时添加客户名单
  654. /// </summary>
  655. /// <param name="dto"></param>
  656. /// <returns></returns>
  657. [HttpPost]
  658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  659. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  660. {
  661. try
  662. {
  663. #region 参数验证
  664. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  665. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  666. #region 页面操作权限验证
  667. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  668. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  669. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  670. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  671. #endregion
  672. #endregion
  673. _sqlSugar.BeginTran();
  674. decimal ffrPrice = 0.00M;
  675. DateTime? visitDt = null;
  676. if (dto.Status == 2)
  677. {
  678. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  679. if (groupInfo != null)
  680. {
  681. ffrPrice = groupInfo.PaymentMoney;
  682. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  683. }
  684. }
  685. var _dto = new GroupOperationDto();
  686. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  687. var groupData = await _groupRepository.GroupOperation(_dto);
  688. if (groupData.Code != 0)
  689. {
  690. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  691. }
  692. int diId = 0;
  693. //添加时 默认加入团组汇率
  694. if (dto.Status == 1) //添加
  695. {
  696. diId = groupData.Data;
  697. //添加默认币种
  698. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  699. //默认分配权限
  700. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  701. //消息提示 王鸽 主管号
  702. List<int> _managerIds = new List<int>() { 22, 32 };
  703. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  704. if (userIds.Count > 0)
  705. {
  706. userIds.Add(208);
  707. //创建团组管控
  708. GroupStepForDelegation.CreateWorkStep(diId);
  709. //发送消息
  710. string groupName = dto.TeamName;
  711. string createGroupUser = string.Empty;
  712. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  713. if (userInfo != null) createGroupUser = userInfo.CnName;
  714. string title = $"系统通知";
  715. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  716. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  717. }
  718. #region 应用推送
  719. try
  720. {
  721. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  722. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  723. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  724. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  725. {
  726. List<string> userList = new List<string>() { users.QiyeChatUserId };
  727. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  728. }
  729. }
  730. catch (Exception ex)
  731. {
  732. }
  733. #endregion
  734. //默认创建倒推表
  735. await _invertedListRep._Create(dto.UserId, diId);
  736. }
  737. if (dto.Status == 2)
  738. {
  739. diId = dto.Id;
  740. if (diId == 0)
  741. {
  742. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  743. }
  744. }
  745. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  746. if (viewData.Code != 0)
  747. {
  748. _sqlSugar.RollbackTran();
  749. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  750. }
  751. #region 团组操作默认添加/修改收款账单
  752. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  753. {
  754. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  755. .Where(x => x.IsDel == 0 &&
  756. x.Diid == diId &&
  757. x.Remark.Equals("预付款")
  758. )
  759. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  760. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  761. .FirstAsync();
  762. ffrInfo = new Fin_ForeignReceivables()
  763. {
  764. Diid = diId,
  765. PriceName = dto.ClientUnit,
  766. Price = dto.PaymentMoney,
  767. Count = 1,
  768. Unit = $"元",
  769. ItemSumPrice = dto.PaymentMoney,
  770. Rate = 1.0000M,
  771. Currency = 836,
  772. AddingWay = 0,
  773. CreateUserId = dto.UserId,
  774. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  775. Remark = $"预付款"
  776. };
  777. if (ffrInfo == null) //Add
  778. {
  779. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  780. }
  781. else //修改
  782. {
  783. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  784. .UpdateColumns(x => new
  785. {
  786. x.PriceName,
  787. x.Price,
  788. x.ItemSumPrice,
  789. x.CreateTime,
  790. x.CreateUserId
  791. })
  792. .WhereColumns(x => x.Id)
  793. .ExecuteCommandAsync();
  794. }
  795. }
  796. #endregion
  797. #region 签证人员团组时间通知
  798. #region 计算出访起止时间
  799. var startTime = new DateTime();
  800. var endTime = new DateTime();
  801. if (DateTime.TryParse(dto.VisitDate, out startTime))
  802. {
  803. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  804. }
  805. #endregion
  806. if (diId > 0)
  807. {
  808. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  809. }
  810. #endregion
  811. _sqlSugar.CommitTran();
  812. return Ok(JsonView(true, "添加成功"));
  813. }
  814. catch (Exception ex)
  815. {
  816. _sqlSugar.RollbackTran();
  817. return Ok(JsonView(false, ex.Message));
  818. }
  819. }
  820. /// <summary>
  821. /// 接团信息 操作(删除)
  822. /// </summary>
  823. /// <param name="dto"></param>
  824. /// <returns></returns>
  825. [HttpPost]
  826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  827. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  828. {
  829. try
  830. {
  831. var groupData = await _groupRepository.GroupDel(dto);
  832. if (groupData.Code != 0)
  833. {
  834. return Ok(JsonView(false, groupData.Msg));
  835. }
  836. return Ok(JsonView(true));
  837. }
  838. catch (Exception ex)
  839. {
  840. Logs("[response]" + JsonConvert.SerializeObject(dto));
  841. Logs(ex.Message);
  842. return Ok(JsonView(false, ex.Message));
  843. }
  844. }
  845. /// <summary>
  846. /// 获取团组销售报价号
  847. /// 团组添加时 使用
  848. /// </summary>
  849. /// <returns></returns>
  850. [HttpPost]
  851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  852. public async Task<IActionResult> GetGroupSalesQuoteNo()
  853. {
  854. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  855. if (groupData.Code != 0)
  856. {
  857. return Ok(JsonView(false, groupData.Msg));
  858. }
  859. object salesQuoteNo = new
  860. {
  861. SalesQuoteNo = groupData.Data
  862. };
  863. return Ok(JsonView(salesQuoteNo));
  864. }
  865. /// <summary>
  866. /// 设置确认出团
  867. /// </summary>
  868. /// <param name="dto"></param>
  869. /// <returns></returns>
  870. [HttpPost]
  871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  872. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  873. {
  874. var groupData = await _groupRepository.ConfirmationGroup(dto);
  875. if (groupData.Code != 0)
  876. {
  877. return Ok(JsonView(false, groupData.Msg));
  878. }
  879. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  880. #region OA消息推送
  881. try
  882. {
  883. string groupName = groupInfo.TeamName;
  884. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  885. List<int> userIds = new List<int>();
  886. listUser.ForEach(s => userIds.Add(s.Id));
  887. string title = $"系统通知";
  888. string content = $"团组[{groupName}]已确认出团!";
  889. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  890. }
  891. catch (Exception ex)
  892. {
  893. }
  894. #endregion
  895. #region 应用推送
  896. try
  897. {
  898. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  899. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  900. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  901. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  902. {
  903. List<string> userList = new List<string>() { users.QiyeChatUserId };
  904. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  905. }
  906. }
  907. catch (Exception ex)
  908. {
  909. }
  910. #endregion
  911. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  912. return Ok(JsonView(true, "操作成功!", groupData.Data));
  913. }
  914. /// <summary>
  915. /// 获取团组名称data And 签证国别Data
  916. /// </summary>
  917. /// <param name="dto"></param>
  918. /// <returns></returns>
  919. [HttpPost]
  920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  921. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  922. {
  923. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  924. if (groupData.Code != 0)
  925. {
  926. return Ok(JsonView(false, groupData.Msg));
  927. }
  928. return Ok(JsonView(groupData.Data));
  929. }
  930. /// <summary>
  931. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  932. /// </summary>
  933. /// <returns></returns>
  934. [HttpPost]
  935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  936. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  937. {
  938. try
  939. {
  940. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  941. if (groupData.Code != 0)
  942. {
  943. return Ok(JsonView(false, groupData.Msg));
  944. }
  945. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  946. }
  947. catch (Exception ex)
  948. {
  949. return Ok(JsonView(false, "程序错误!"));
  950. throw;
  951. }
  952. }
  953. /// <summary>
  954. /// 团组清单 Excel
  955. /// </summary>
  956. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  957. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  958. /// <returns></returns>
  959. [HttpGet]
  960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  961. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  962. {
  963. DateTime _beginDt, _endDt;
  964. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  965. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  966. if (!beginBool && !endBool)
  967. {
  968. return Ok(JsonView(false, "开始或结束时间不正确!"));
  969. }
  970. string sql = string.Format(@"
  971. SELECT
  972. ROW_NUMBER,
  973. Id,
  974. SalesQuoteNo,
  975. TourCode,
  976. TeamTypeId,
  977. TeamType,
  978. TeamLevId,
  979. TeamLev,
  980. TeamName,
  981. ClientName,
  982. ClientUnit,
  983. VisitDate,
  984. VisitDays,
  985. VisitPNumber,
  986. JietuanOperatorId,
  987. JietuanOperator,
  988. IsSure,
  989. CreateTime,
  990. IsBid
  991. FROM
  992. (
  993. SELECT
  994. ROW_NUMBER() OVER(
  995. ORDER BY
  996. gdi.CreateTime Desc
  997. ) AS ROW_NUMBER,
  998. gdi.Id,
  999. SalesQuoteNo,
  1000. TourCode,
  1001. ssd.Id TeamTypeId,
  1002. ssd.Name TeamType,
  1003. ssd1.Id TeamLevId,
  1004. ssd1.Name TeamLev,
  1005. TeamName,
  1006. ClientName,
  1007. ClientUnit,
  1008. VisitDate,
  1009. VisitDays,
  1010. VisitPNumber,
  1011. JietuanOperator JietuanOperatorId,
  1012. su.CnName JietuanOperator,
  1013. IsSure,
  1014. gdi.CreateTime,
  1015. gdi.IsBid
  1016. FROM
  1017. Grp_DelegationInfo gdi
  1018. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1019. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1020. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1021. WHERE
  1022. gdi.IsDel = 0
  1023. AND gdi.IsBid = 0
  1024. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1025. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1026. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1027. #region 处理所属部门
  1028. /*
  1029. * 1.sq 和 gyy 等显示 市场部
  1030. * 2.王鸽和主管及张总还有管理员号统一国交部
  1031. * 2-1. 4 管理员 ,21 张海麟
  1032. */
  1033. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1034. List<int> userIds1 = new List<int>() { 4, 21 };
  1035. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1036. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1037. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1038. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1039. .ToListAsync();
  1040. foreach (var item in groupList)
  1041. {
  1042. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1043. }
  1044. #endregion
  1045. #region Excel
  1046. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1047. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1048. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1049. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1050. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1051. //载入模板
  1052. WorkbookDesigner designer = new WorkbookDesigner();
  1053. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1054. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1055. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1056. dt.TableName = "GroupList";
  1057. designer.SetDataSource(dt);
  1058. designer.Process();
  1059. if (!Directory.Exists(savePath))
  1060. {
  1061. Directory.CreateDirectory(savePath);
  1062. }
  1063. string serverPath = $"{savePath}{fileName}";
  1064. designer.Workbook.Save(serverPath);
  1065. string rst = $"{servicePath}{ftpPath}{fileName}";
  1066. #endregion
  1067. return Ok(JsonView(true, "操作成功!", rst));
  1068. }
  1069. #endregion
  1070. #region 团组&签证
  1071. /// <summary>
  1072. /// 根据团组Id获取签证客户信息List
  1073. /// </summary>
  1074. /// <param name="dto">请求dto</param>
  1075. /// <returns></returns>
  1076. [HttpPost]
  1077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1078. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1079. {
  1080. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1081. if (groupData.Code != 0)
  1082. {
  1083. return Ok(JsonView(false, groupData.Msg));
  1084. }
  1085. return Ok(JsonView(groupData.Data));
  1086. }
  1087. /// <summary>
  1088. /// IOS获取团组签证拍照上传进度01(团组列表)
  1089. /// </summary>
  1090. /// <param name="dto">请求dto</param>
  1091. /// <returns></returns>
  1092. [HttpPost]
  1093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1094. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1095. {
  1096. if (dto == null)
  1097. {
  1098. return Ok(JsonView(false, "参数为空"));
  1099. }
  1100. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1101. return Ok(JsonView(visaList));
  1102. }
  1103. /// <summary>
  1104. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1105. /// </summary>
  1106. /// <returns></returns>
  1107. [HttpPost]
  1108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1109. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1110. {
  1111. if (dto == null)
  1112. {
  1113. return Ok(JsonView(false, "请求错误:"));
  1114. }
  1115. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1116. return Ok(JsonView(list));
  1117. }
  1118. /// <summary>
  1119. /// IOS获取团组签证拍照上传进度03(相册)
  1120. /// </summary>
  1121. /// <returns></returns>
  1122. [HttpPost]
  1123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1124. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1125. {
  1126. if (dto == null)
  1127. {
  1128. return Ok(JsonView(false, "请求错误:"));
  1129. }
  1130. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1131. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1132. list.ForEach(s => s.url = url);
  1133. return Ok(JsonView(list));
  1134. }
  1135. /// <summary>
  1136. /// IOS获取团组签证拍照上传进度04(图片上传)
  1137. /// </summary>
  1138. /// <param name="dto"></param>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1143. {
  1144. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1145. //if (!string.IsNullOrEmpty(result))
  1146. //{
  1147. //}
  1148. //else {
  1149. // return Ok(JsonView(false, "上传失败"));
  1150. //}
  1151. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1152. int sucNum = 0;
  1153. try
  1154. {
  1155. foreach (var item in dto.base64DataList)
  1156. {
  1157. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1158. string result = decodeBase64ToImage(item, imageName);
  1159. if (!string.IsNullOrEmpty(result))
  1160. {
  1161. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1162. pic.CreateUserId = dto.CreateUserId;
  1163. pic.PicName = imageName;
  1164. pic.PicPath = result;
  1165. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1166. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1167. if (insertResult > 0)
  1168. {
  1169. sucNum++;
  1170. }
  1171. }
  1172. }
  1173. }
  1174. catch (Exception ex)
  1175. {
  1176. return Ok(JsonView(false, ex.Message));
  1177. }
  1178. string msg = string.Format(@"成功上传{0}张", sucNum);
  1179. return Ok(JsonView(true, msg));
  1180. }
  1181. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1182. {
  1183. string filename = "";//声明一个string类型的相对路径
  1184. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1185. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1186. try//会有异常抛出,try,catch一下
  1187. {
  1188. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1189. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1190. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1191. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1192. //文件名称
  1193. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1194. //上传的文件的路径
  1195. string filePath = "";
  1196. if (!Directory.Exists(fileDir))
  1197. {
  1198. Directory.CreateDirectory(fileDir);
  1199. }
  1200. //上传的文件的路径
  1201. filePath = fileDir + filename;
  1202. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1203. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1204. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1205. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1206. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1207. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1208. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1209. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1210. bitmap.Dispose();
  1211. }
  1212. catch (Exception e)
  1213. {
  1214. string massage = e.Message;
  1215. Logs("IOS图片上传Error:" + massage);
  1216. //filename = e.Message;
  1217. }
  1218. return filename;//返回相对路径
  1219. }
  1220. /// <summary>
  1221. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1222. /// </summary>
  1223. /// <param name="dto"></param>
  1224. /// <returns></returns>
  1225. [HttpPost]
  1226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1227. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1228. {
  1229. if (dto == null)
  1230. {
  1231. return Ok(JsonView(false, "请求错误:"));
  1232. }
  1233. string msg = "参数错误";
  1234. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1235. {
  1236. try
  1237. {
  1238. //_delegationVisaRep.BeginTran();
  1239. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1240. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1241. .Where(s => s.Id == dto.visaProgressCustomerId)
  1242. .ExecuteCommandAsync();
  1243. if (updCount > 0 && dto.publishCode == 1)
  1244. {
  1245. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1246. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1247. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1248. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1249. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1250. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1251. if (groupData == null)
  1252. {
  1253. _delegationVisaRep.RollbackTran();
  1254. }
  1255. string title = string.Format(@"[签证进度更新]");
  1256. string content = string.Format(@"测试文本");
  1257. bool rst = await _message.AddMsg(new MessageDto()
  1258. {
  1259. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1260. IssuerId = dto.publisher,
  1261. Title = title,
  1262. Content = content,
  1263. ReleaseTime = DateTime.Now,
  1264. UIdList = new List<int> {
  1265. 234
  1266. }
  1267. });
  1268. if (rst)
  1269. {
  1270. return Ok(JsonView(true, "发送通知成功"));
  1271. }
  1272. }
  1273. //_delegationVisaRep.CommitTran();
  1274. }
  1275. catch (Exception)
  1276. {
  1277. //_delegationVisaRep.RollbackTran();
  1278. }
  1279. }
  1280. return Ok(JsonView(true, msg));
  1281. }
  1282. #endregion
  1283. #region 团组任务分配
  1284. /// <summary>
  1285. /// 团组任务分配初始化
  1286. /// </summary>
  1287. /// <param name="dto"></param>
  1288. /// <returns></returns>
  1289. [HttpPost]
  1290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1291. public async Task<IActionResult> GetTaskAssignmen()
  1292. {
  1293. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1294. if (groupData.Code != 0)
  1295. {
  1296. return Ok(JsonView(false, groupData.Msg));
  1297. }
  1298. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1299. }
  1300. /// <summary>
  1301. /// 团组任务分配查询
  1302. /// </summary>
  1303. /// <param name="dto"></param>
  1304. /// <returns></returns>
  1305. [HttpPost]
  1306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1307. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1308. {
  1309. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1310. if (groupData.Code != 0)
  1311. {
  1312. return Ok(JsonView(false, groupData.Msg));
  1313. }
  1314. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1315. }
  1316. /// <summary>
  1317. /// 团组任务分配操作
  1318. /// </summary>
  1319. /// <param name="dto"></param>
  1320. /// <returns></returns>
  1321. [HttpPost]
  1322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1323. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1324. {
  1325. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1326. if (groupData.Code != 0)
  1327. {
  1328. return Ok(JsonView(false, groupData.Msg));
  1329. }
  1330. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1331. }
  1332. /// <summary>
  1333. /// 团组任务分配
  1334. /// 批量分配
  1335. /// 查询团组
  1336. /// </summary>
  1337. /// <param name="dto"></param>
  1338. /// <returns></returns>
  1339. [HttpPost]
  1340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1341. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1342. {
  1343. //参数验证
  1344. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1345. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1346. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1347. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1348. }
  1349. /// <summary>
  1350. /// 团组任务分配
  1351. /// 批量分配
  1352. /// </summary>
  1353. /// <param name="dto"></param>
  1354. /// <returns></returns>
  1355. [HttpPost]
  1356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1357. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1358. {
  1359. //参数验证
  1360. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1361. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1362. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1363. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1364. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1365. }
  1366. #endregion
  1367. #region 团组费用审核
  1368. /// <summary>
  1369. /// 费用审核
  1370. /// 团组列表 Page
  1371. /// </summary>
  1372. /// <param name="_dto">团组列表请求dto</param>
  1373. /// <returns></returns>
  1374. [HttpPost]
  1375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1376. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1377. {
  1378. #region 参数验证
  1379. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1380. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1381. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1382. #region 页面操作权限验证
  1383. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1384. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1385. #endregion
  1386. #endregion
  1387. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1388. {
  1389. string sqlWhere = string.Empty;
  1390. if (_dto.IsSure == 0) //未完成
  1391. {
  1392. sqlWhere += string.Format(@" And IsSure = 0");
  1393. }
  1394. else if (_dto.IsSure == 1) //已完成
  1395. {
  1396. sqlWhere += string.Format(@" And IsSure = 1");
  1397. }
  1398. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1399. {
  1400. string tj = _dto.SearchCriteria;
  1401. 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}%')",
  1402. tj, tj, tj, tj, tj);
  1403. }
  1404. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1405. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1406. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1407. From (
  1408. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1409. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1410. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1411. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1412. From Grp_DelegationInfo gdi
  1413. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1414. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1415. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1416. Where gdi.IsDel = 0 {0}
  1417. ) temp ", sqlWhere);
  1418. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1419. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1420. var _view = new
  1421. {
  1422. PageFuncAuth = pageFunAuthView,
  1423. Data = _DelegationList
  1424. };
  1425. return Ok(JsonView(true, "查询成功!", _view, total));
  1426. }
  1427. else
  1428. {
  1429. return Ok(JsonView(false, "查询失败"));
  1430. }
  1431. }
  1432. /// <summary>
  1433. /// 获取团组费用审核
  1434. /// </summary>
  1435. /// <param name="paras">参数Json字符串</param>
  1436. /// <returns></returns>
  1437. [HttpPost]
  1438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1439. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1440. {
  1441. try
  1442. {
  1443. #region 参数验证
  1444. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1445. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1446. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1447. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1448. #region 页面操作权限验证
  1449. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1450. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1451. #endregion
  1452. #endregion
  1453. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1454. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1455. #region 费用清单
  1456. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1457. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1458. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1459. List<Grp_CreditCardPayment> entityList = _groupRepository
  1460. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1461. .Where(exp.ToExpression())
  1462. .ToList();
  1463. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1464. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1465. /*
  1466. * 76://酒店预订
  1467. */
  1468. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1469. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1470. .ToListAsync();
  1471. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1472. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1473. .ToListAsync();
  1474. /*
  1475. * 79://车/导游地接
  1476. */
  1477. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1478. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1479. .ToListAsync();
  1480. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1481. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1482. .ToListAsync();
  1483. /*
  1484. * 80: //签证
  1485. */
  1486. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1487. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1488. .ToListAsync();
  1489. /*
  1490. *81: //邀请/公务活动
  1491. */
  1492. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1493. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1494. .ToListAsync();
  1495. /*
  1496. * 82: //团组客户保险
  1497. */
  1498. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1499. /*
  1500. * Lable = 85 机票预订
  1501. */
  1502. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1503. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1504. .ToListAsync();
  1505. /*
  1506. * 85 机票预定
  1507. */
  1508. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1509. /*
  1510. * 98 其他款项
  1511. */
  1512. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1513. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1514. .ToListAsync();
  1515. /*
  1516. * 285:收款退还
  1517. */
  1518. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1519. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1520. .ToListAsync();
  1521. /*
  1522. * 1015: //超支费用
  1523. */
  1524. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1525. /*
  1526. * 币种信息
  1527. */
  1528. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1529. /*
  1530. * 车/导游地接 费用类型
  1531. */
  1532. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1533. /*
  1534. * 车/导游地接 费用类型
  1535. */
  1536. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1537. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1538. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1539. /*
  1540. * 用户信息
  1541. */
  1542. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1543. /*
  1544. * 费用模块
  1545. */
  1546. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1547. string priceModule = string.Empty;
  1548. if (sdPriceName != null)
  1549. {
  1550. priceModule = sdPriceName.Name;
  1551. }
  1552. /*
  1553. * 成本信息
  1554. */
  1555. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1556. decimal _groupRate = 0.0000M;
  1557. string _groupCurrencyCode = "-";
  1558. if (groupCost != null)
  1559. {
  1560. _groupRate = groupCost.Rate;
  1561. if (int.TryParse(groupCost.Currency, out int _currency))
  1562. {
  1563. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1564. }
  1565. else _groupCurrencyCode = groupCost.Currency;
  1566. }
  1567. string costContentSql = $"Select * From Grp_GroupCost";
  1568. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1569. //处理日期为空的天数
  1570. for (int i = 0; i < groupCostDetails.Count; i++)
  1571. if (i != 0)
  1572. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1573. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1574. /*
  1575. * 处理详情数据
  1576. */
  1577. foreach (var entity in entityList)
  1578. {
  1579. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1580. _detail.Id = entity.Id;
  1581. _detail.PriceName = priceModule;
  1582. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1583. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1584. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1585. //处理金额
  1586. if (entity.CTable == 1015)
  1587. {
  1588. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1589. if (czInfo != null)
  1590. {
  1591. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1592. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1593. }
  1594. }
  1595. /*
  1596. * 应付款金额
  1597. */
  1598. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1599. string PaymentCurrency_WaitPay = "Unknown";
  1600. string hotelCurrncyCode = "Unknown";
  1601. string hotelCurrncyName = "Unknown";
  1602. if (sdPaymentCurrency_WaitPay != null)
  1603. {
  1604. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1605. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1606. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1607. if (hotelCurrncyCode.Equals("CNY"))
  1608. {
  1609. entity.DayRate = 1.0000M;
  1610. }
  1611. }
  1612. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1613. /*
  1614. * 此次付款金额
  1615. */
  1616. decimal CurrPayStr = 0.00M,
  1617. OriginalCurrPay = 0.00M;
  1618. if (entity.PayPercentage == 0)
  1619. {
  1620. if (entity.PayThenMoney != 0)
  1621. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1622. }
  1623. else
  1624. {
  1625. if (entity.PayMoney != 0)
  1626. {
  1627. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1628. }
  1629. }
  1630. if (_dto.Label == 79)
  1631. {
  1632. string original = string.Empty;
  1633. if (hotelCurrncyCode.Equals("CNY"))
  1634. {
  1635. OriginalCurrPay = CurrPayStr;
  1636. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1637. }
  1638. else
  1639. {
  1640. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1641. //760 EUR(7600.00 CNY)
  1642. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1643. }
  1644. }
  1645. else
  1646. {
  1647. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1648. }
  1649. /*
  1650. * 剩余尾款
  1651. */
  1652. decimal BalanceStr = 0;
  1653. if (CurrPayStr != 0)
  1654. {
  1655. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1656. BalanceStr = 0;
  1657. else
  1658. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1659. }
  1660. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1661. /*
  1662. * Bus名称
  1663. */
  1664. _detail.BusName = "待增加";
  1665. /*
  1666. *费用所属
  1667. */
  1668. switch (entity.CTable)
  1669. {
  1670. case 76://酒店预订
  1671. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1672. if (hotelReservations != null)
  1673. {
  1674. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1675. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1676. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1677. string roomFeeStr = "", roomFeestr1 = "";
  1678. //是否比较房型价格
  1679. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1680. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1681. roomFeeStr += $"<br/>";
  1682. if (hotelReservations.SingleRoomPrice > 0)
  1683. {
  1684. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1685. __isSingle = true;
  1686. }
  1687. if (hotelReservations.DoubleRoomPrice > 0)
  1688. {
  1689. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1690. __isDouble = true;
  1691. }
  1692. if (hotelReservations.SuiteRoomPrice > 0)
  1693. {
  1694. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1695. __isSuite = true;
  1696. }
  1697. if (hotelReservations.OtherRoomPrice > 0)
  1698. {
  1699. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1700. __isOther = true;
  1701. }
  1702. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1703. else roomFeeStr += " 0.00 * 0";
  1704. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1705. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1706. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1707. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1708. /*
  1709. * 费用类型
  1710. * 1:房费
  1711. * 2:早餐
  1712. * 3:地税
  1713. * 4:城市税
  1714. * </summary>
  1715. */
  1716. //地税
  1717. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1718. if (governmentRentData != null)
  1719. {
  1720. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1721. governmentRentFee = governmentRentData.Price;
  1722. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1723. if (governmentRentCurrData != null)
  1724. {
  1725. governmentRentCode = governmentRentCurrData.Name;
  1726. governmentRentName = $"({governmentRentCurrData.Remark})";
  1727. }
  1728. }
  1729. //城市税
  1730. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1731. if (cityTaxData != null)
  1732. {
  1733. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1734. cityTaxFee = cityTaxData.Price;
  1735. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1736. if (cityTaxCurrData != null)
  1737. {
  1738. cityTaxCode = cityTaxCurrData.Name;
  1739. cityTaxName = $"({cityTaxCurrData.Remark})";
  1740. }
  1741. }
  1742. //酒店早餐
  1743. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1744. if (breakfastData != null)
  1745. {
  1746. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1747. breakfastFee = breakfastData.Price;
  1748. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1749. if (breakfastCurrData != null)
  1750. {
  1751. breakfastCode = breakfastCurrData.Name;
  1752. breakfastName = $"({breakfastCurrData.Remark})";
  1753. }
  1754. }
  1755. //房间费用
  1756. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1757. if (roomData != null)
  1758. {
  1759. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1760. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1761. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1762. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1763. roomFee = roomData.Price;
  1764. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1765. if (roomCurrData != null)
  1766. {
  1767. roomCode = roomCurrData.Name;
  1768. roomName = $"({roomCurrData.Remark})";
  1769. }
  1770. }
  1771. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1772. string hotelCostStr = "";
  1773. decimal hotelCsotTotal = 0.00M;
  1774. if (groupCost != null)
  1775. {
  1776. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1777. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1778. }
  1779. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1780. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1781. string hotelCost_day = "";
  1782. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1783. foreach (var item in hotelCostDetails1)
  1784. {
  1785. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1786. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1787. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1788. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1789. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1790. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1791. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1792. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1793. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1794. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1795. hotelCost_day += @$"<br/>";
  1796. }
  1797. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1798. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1799. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1800. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1801. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1802. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1803. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1804. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1805. $"房间说明: {hotelReservations.Remark} <br/>" +
  1806. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1807. $"{hotelBreakfastStr}" +
  1808. $"{hotelGovernmentRentStr}" +
  1809. $"{hotelCityTaxStr}";
  1810. _detail.PriceNameContent = hotelReservations.HotelName;
  1811. }
  1812. break;
  1813. case 79://车/导游地接
  1814. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1815. if (touristGuideGroundReservations != null)
  1816. {
  1817. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1818. {
  1819. _detail.BusName = touristGuideGroundReservations.BusName;
  1820. }
  1821. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1822. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1823. //if (isInt)
  1824. //{
  1825. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1826. // if (cityInfo != null)
  1827. // {
  1828. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1829. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1830. // if (carFeeItem != null)
  1831. // {
  1832. // nameContent += $@"({carFeeItem.Name})";
  1833. // }
  1834. // _detail.PriceNameContent = nameContent;
  1835. // }
  1836. //}
  1837. //else
  1838. //{
  1839. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1840. //}
  1841. var touristGuideGroundReservationsContents =
  1842. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1843. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1844. foreach (var item in touristGuideGroundReservationsContents)
  1845. {
  1846. string typeName = "Unknown";
  1847. string carCurrencyCode = "Unknown";
  1848. string carCurrencyName = "Unknown";
  1849. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1850. if (carTypeData != null) typeName = carTypeData.Name;
  1851. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1852. if (currencyData != null)
  1853. {
  1854. carCurrencyCode = currencyData.Name;
  1855. carCurrencyName = currencyData.Remark;
  1856. }
  1857. //op、成本 币种是否一致
  1858. bool IsCurrencyAgreement = false;
  1859. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1860. string opCostStr = string.Empty;
  1861. decimal opCostTypePrice = 0.00M;
  1862. #region 处理成本各项费用
  1863. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1864. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1865. if (opCost.Count > 0)
  1866. {
  1867. switch (item.SId)
  1868. {
  1869. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1870. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1871. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1872. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1873. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1874. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1875. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1876. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1877. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1878. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1879. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1880. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1881. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1882. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1883. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1884. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1885. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1886. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1887. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1888. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1889. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1890. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1891. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1892. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1893. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1894. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1895. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1896. }
  1897. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1898. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1899. }
  1900. #endregion
  1901. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1902. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1903. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1904. $"{opTypeStr} {opCostStr}<br/>" +
  1905. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1906. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1907. }
  1908. _detail.PriceMsgContent = priceMsg;
  1909. }
  1910. break;
  1911. case 80: //签证
  1912. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1913. if (visaInfo != null)
  1914. {
  1915. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1916. _detail.PriceNameContent = visaInfo.VisaDescription;
  1917. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1918. }
  1919. break;
  1920. case 81: //邀请/公务活动
  1921. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1922. if (_ioa != null)
  1923. {
  1924. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1925. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1926. sendCurrName = "Unknown", //快递费用币种 Name
  1927. sendCurrCode = "Unknown", //快递费用币种 Code
  1928. eventsCurrName = "Unknown", //公务活动费币种 Name
  1929. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1930. translateCurrName = "Unknown", //公务翻译费 Name
  1931. translateCurrCode = "Unknown"; //公务翻译费 Code
  1932. #region 处理费用币种
  1933. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1934. if (inviteCurrData != null)
  1935. {
  1936. inviteCurrName = inviteCurrData.Remark;
  1937. inviteCurrCode = inviteCurrData.Name;
  1938. }
  1939. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1940. if (sendCurrData != null)
  1941. {
  1942. sendCurrName = sendCurrData.Remark;
  1943. sendCurrCode = sendCurrData.Name;
  1944. }
  1945. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1946. if (eventsCurrData != null)
  1947. {
  1948. eventsCurrName = eventsCurrData.Remark;
  1949. eventsCurrCode = eventsCurrData.Name;
  1950. }
  1951. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1952. if (translateCurrData != null)
  1953. {
  1954. translateCurrName = translateCurrData.Remark;
  1955. translateCurrCode = translateCurrData.Name;
  1956. }
  1957. #endregion
  1958. _detail.PriceNameContent = _ioa.InviterArea;
  1959. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1960. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1961. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1962. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1963. $@"备注:" + _ioa.Remark + "<br/>";
  1964. }
  1965. break;
  1966. case 82: //团组客户保险
  1967. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1968. if (customers != null)
  1969. {
  1970. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1971. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1972. }
  1973. break;
  1974. case 85: //机票预订
  1975. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1976. if (jpRes != null)
  1977. {
  1978. string FlightsDescription = jpRes.FlightsDescription;
  1979. string PriceDescription = jpRes.PriceDescription;
  1980. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1981. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1982. }
  1983. break;
  1984. case 98://其他款项
  1985. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1986. if (gdpRes != null)
  1987. {
  1988. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1989. _detail.PriceNameContent = gdpRes.PriceName;
  1990. }
  1991. break;
  1992. case 285://收款退还
  1993. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1994. if (refundAndOtherMoney != null)
  1995. {
  1996. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1997. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1998. }
  1999. break;
  2000. case 751://酒店早餐
  2001. break;
  2002. case 1015://超支费用
  2003. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2004. if (groupExtraCost != null)
  2005. {
  2006. _detail.PriceNameContent = groupExtraCost.PriceName;
  2007. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2008. }
  2009. break;
  2010. default:
  2011. break;
  2012. }
  2013. /*
  2014. * 申请人
  2015. */
  2016. string operatorName = " - ";
  2017. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2018. if (_opUser != null)
  2019. {
  2020. operatorName = _opUser.CnName;
  2021. }
  2022. _detail.OperatorName = operatorName;
  2023. /*
  2024. * 审核人
  2025. */
  2026. string auditOperatorName = "Unknown";
  2027. if (entity.AuditGMOperate == 0)
  2028. auditOperatorName = " - ";
  2029. else if (entity.AuditGMOperate == 4)
  2030. auditOperatorName = "自动审核";
  2031. else
  2032. {
  2033. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2034. if (_adUser != null)
  2035. {
  2036. auditOperatorName = _adUser.CnName;
  2037. }
  2038. }
  2039. _detail.AuditOperatorName = auditOperatorName;
  2040. /*
  2041. * 超预算比例
  2042. */
  2043. string overBudgetStr = "";
  2044. if (entity.ExceedBudget == -1)
  2045. overBudgetStr = sdPriceName.Name + "尚无预算";
  2046. else if (entity.ExceedBudget == 0)
  2047. {
  2048. if (entity.CTable == 76 || entity.CTable == 79)
  2049. {
  2050. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2051. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2052. }
  2053. else
  2054. {
  2055. overBudgetStr = "未超预算";
  2056. }
  2057. }
  2058. else
  2059. overBudgetStr = entity.ExceedBudget.ToString("P");
  2060. _detail.OverBudget = overBudgetStr;
  2061. /*
  2062. * 已审核金额
  2063. */
  2064. decimal auditFee = 0.00M;
  2065. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2066. /*
  2067. * 费用总计
  2068. */
  2069. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2070. {
  2071. CurrencyId = entity.PaymentCurrency,
  2072. CurrencyName = PaymentCurrency_WaitPay,
  2073. AmountPayable = entity.PayMoney,
  2074. ThisPayment = OriginalCurrPay,
  2075. BalancePayment = BalanceStr,
  2076. AuditedFunds = auditFee
  2077. });
  2078. _detail.IsAuditGM = entity.IsAuditGM;
  2079. detailList.Add(_detail);
  2080. }
  2081. #endregion
  2082. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2083. /*
  2084. * 下方描述处理
  2085. */
  2086. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2087. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2088. if (ccpCurrencyPrice != null)
  2089. {
  2090. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2091. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2092. }
  2093. else
  2094. {
  2095. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2096. }
  2097. string amountPayableStr = string.Format(@"应付款总金额: ");
  2098. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2099. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2100. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2101. foreach (var item in nonDuplicat)
  2102. {
  2103. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2104. if (strs.Count > 0)
  2105. {
  2106. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2107. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2108. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2109. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2110. //单独处理此次付款金额
  2111. if (item.CurrencyId == 836) //人民币
  2112. {
  2113. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2114. }
  2115. else
  2116. {
  2117. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2118. }
  2119. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2120. //单独处理已审核费用
  2121. if (item.CurrencyId == 836) //人民币
  2122. {
  2123. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2124. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2125. }
  2126. else
  2127. {
  2128. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2129. }
  2130. }
  2131. }
  2132. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2133. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2134. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2135. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2136. var _view1 = new
  2137. {
  2138. PageFuncAuth = pageFunAuthView,
  2139. Data = _view
  2140. };
  2141. return Ok(JsonView(_view1));
  2142. }
  2143. catch (Exception ex)
  2144. {
  2145. return Ok(JsonView(false, ex.Message));
  2146. }
  2147. }
  2148. /// <summary>
  2149. /// 费用审核
  2150. /// 修改团组费用审核状态
  2151. /// </summary>
  2152. /// <param name="_dto">参数Json字符串</param>
  2153. /// <returns></returns>
  2154. [HttpPost]
  2155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2156. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2157. {
  2158. #region 参数验证
  2159. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2160. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2161. #endregion
  2162. #region 页面操作权限验证
  2163. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2164. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2165. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2166. #endregion
  2167. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2168. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2169. DateTime dtNow = DateTime.Now;
  2170. _groupRepository.BeginTran();
  2171. int rst = 0;
  2172. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2173. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2174. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2175. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2176. List<dynamic> msgDatas = new List<dynamic>();
  2177. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2178. foreach (var item in idList)
  2179. {
  2180. int CreditId = int.Parse(item);
  2181. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2182. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2183. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2184. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2185. .Where(s => s.Id == CreditId)
  2186. .ExecuteCommandAsync();
  2187. if (result < 1)
  2188. {
  2189. rst = -1;
  2190. _groupRepository.RollbackTran();
  2191. return Ok(JsonView(false, "操作失败并回滚!"));
  2192. }
  2193. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2194. if (creditData != null)
  2195. {
  2196. #region 应用通知配置
  2197. try
  2198. {
  2199. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2200. }
  2201. catch (Exception ex)
  2202. {
  2203. }
  2204. #endregion
  2205. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2206. string groupNameStr = string.Empty;
  2207. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2208. if (groupData != null) groupNameStr = groupData.TeamName;
  2209. string creditTypeStr = string.Empty;
  2210. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2211. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2212. string creditCurrency = string.Empty;
  2213. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2214. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2215. if (creditCurrency.Equals("CNY"))
  2216. {
  2217. creditData.DayRate = 1.0000M;
  2218. }
  2219. if (creditData.PayPercentage == 0.00M)
  2220. {
  2221. creditData.PayPercentage = 100M;
  2222. }
  2223. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2224. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2225. string msgContent = "";
  2226. if (creditCurrency.Equals("CNY"))
  2227. {
  2228. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2229. }
  2230. else
  2231. {
  2232. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2233. }
  2234. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2235. }
  2236. }
  2237. if (rst == 0)
  2238. {
  2239. _groupRepository.CommitTran();
  2240. foreach (var item in msgDatas)
  2241. {
  2242. //发送消息
  2243. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2244. }
  2245. #region 应用推送
  2246. try
  2247. {
  2248. foreach (var ccpId in dic_ccp_user.Keys)
  2249. {
  2250. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2251. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2252. }
  2253. }
  2254. catch (Exception)
  2255. {
  2256. }
  2257. #endregion
  2258. return Ok(JsonView(true, "操作成功!"));
  2259. }
  2260. return Ok(JsonView(false, "操作失败!"));
  2261. }
  2262. #endregion
  2263. #region 机票费用录入
  2264. /// <summary>
  2265. /// 机票录入当前登录人可操作团组
  2266. /// </summary>
  2267. /// <param name="dto"></param>
  2268. /// <returns></returns>
  2269. [HttpPost]
  2270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2271. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2272. {
  2273. try
  2274. {
  2275. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2276. if (groupData.Code != 0)
  2277. {
  2278. return Ok(JsonView(false, groupData.Msg));
  2279. }
  2280. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2281. }
  2282. catch (Exception ex)
  2283. {
  2284. return Ok(JsonView(false, "程序错误!"));
  2285. throw;
  2286. }
  2287. }
  2288. /// <summary>
  2289. /// 机票费用录入列表
  2290. /// </summary>
  2291. /// <param name="dto"></param>
  2292. /// <returns></returns>
  2293. [HttpPost]
  2294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2295. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2296. {
  2297. try
  2298. {
  2299. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2300. if (groupData.Code != 0)
  2301. {
  2302. return Ok(JsonView(false, groupData.Msg));
  2303. }
  2304. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2305. }
  2306. catch (Exception ex)
  2307. {
  2308. return Ok(JsonView(false, ex.Message));
  2309. throw;
  2310. }
  2311. }
  2312. /// <summary>
  2313. /// 根据id查询费用录入信息
  2314. /// </summary>
  2315. /// <param name="dto"></param>
  2316. /// <returns></returns>
  2317. [HttpPost]
  2318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2319. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2320. {
  2321. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2322. if (groupData.Code != 0)
  2323. {
  2324. return Ok(JsonView(false, groupData.Msg));
  2325. }
  2326. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2327. }
  2328. /// <summary>
  2329. /// 机票费用录入操作(Status:1.新增,2.修改)
  2330. /// </summary>
  2331. /// <param name="dto"></param>
  2332. /// <returns></returns>
  2333. [HttpPost]
  2334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2335. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2336. {
  2337. try
  2338. {
  2339. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2340. if (groupData.Code != 0)
  2341. {
  2342. return Ok(JsonView(false, groupData.Msg));
  2343. }
  2344. #region 应用推送
  2345. try
  2346. {
  2347. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2348. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2349. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2350. }
  2351. catch (Exception ex)
  2352. {
  2353. }
  2354. #endregion
  2355. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2356. }
  2357. catch (Exception ex)
  2358. {
  2359. return Ok(JsonView(false, "程序错误!"));
  2360. throw;
  2361. }
  2362. }
  2363. /// <summary>
  2364. /// 根据舱位类型查询接团客户名单信息
  2365. /// </summary>
  2366. /// <param name="dto"></param>
  2367. /// <returns></returns>
  2368. [HttpPost]
  2369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2370. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2371. {
  2372. try
  2373. {
  2374. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2375. if (crm_Groups.Count != 0)
  2376. {
  2377. List<dynamic> Customer = new List<dynamic>();
  2378. foreach (var item in crm_Groups)
  2379. {
  2380. var data = new
  2381. {
  2382. Id = item.Id,
  2383. Pinyin = item.Pinyin,
  2384. Name = item.LastName + item.FirstName
  2385. };
  2386. Customer.Add(data);
  2387. }
  2388. return Ok(JsonView(true, "查询成功!", Customer));
  2389. }
  2390. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2391. }
  2392. catch (Exception ex)
  2393. {
  2394. return Ok(JsonView(false, "程序错误!"));
  2395. throw;
  2396. }
  2397. }
  2398. /// <summary>
  2399. /// 根据团号获取客户信息
  2400. /// </summary>
  2401. /// <param name="dto"></param>
  2402. /// <returns></returns>
  2403. [HttpPost]
  2404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2405. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2406. {
  2407. var jw = JsonView(false);
  2408. if (dto.DIID < 1)
  2409. {
  2410. jw.Msg += "请输入正确的diid";
  2411. return Ok(jw);
  2412. }
  2413. var arr = getSimplClientList(dto.DIID);
  2414. jw = JsonView(true, "获取成功!", arr);
  2415. return Ok(jw);
  2416. }
  2417. private List<SimplClientInfo> getSimplClientList(int diId)
  2418. {
  2419. 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);
  2420. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2421. return arr;
  2422. }
  2423. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2424. {
  2425. string result = origin;
  2426. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2427. {
  2428. string[] temparr = origin.Split(',');
  2429. string fistrStr = temparr[0];
  2430. int count = temparr.Count();
  2431. int tempId;
  2432. bool success = int.TryParse(fistrStr, out tempId);
  2433. if (success)
  2434. {
  2435. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2436. if (tempInfo != null)
  2437. {
  2438. if (count > 1)
  2439. {
  2440. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2441. }
  2442. else
  2443. {
  2444. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2445. }
  2446. }
  2447. }
  2448. }
  2449. return result;
  2450. }
  2451. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2452. {
  2453. string result = origin;
  2454. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2455. {
  2456. string[] temparr = origin.Split(',');
  2457. result = "";
  2458. foreach (var item in temparr)
  2459. {
  2460. int tempId;
  2461. bool success = int.TryParse(item, out tempId);
  2462. if (success)
  2463. {
  2464. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2465. if (tempInfo != null)
  2466. {
  2467. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2468. }
  2469. }
  2470. }
  2471. }
  2472. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2473. return result;
  2474. }
  2475. /// <summary>
  2476. /// 机票费用录入,删除
  2477. /// </summary>
  2478. /// <param name="dto"></param>
  2479. /// <returns></returns>
  2480. [HttpPost]
  2481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2482. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2483. {
  2484. try
  2485. {
  2486. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2487. if (res)
  2488. {
  2489. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2490. {
  2491. IsDel = 1,
  2492. DeleteUserId = dto.DeleteUserId,
  2493. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2494. }).ExecuteCommandAsync();
  2495. return Ok(JsonView(true, "删除成功!"));
  2496. }
  2497. return Ok(JsonView(false, "删除失败!"));
  2498. }
  2499. catch (Exception ex)
  2500. {
  2501. return Ok(JsonView(false, "程序错误!"));
  2502. throw;
  2503. }
  2504. }
  2505. /// <summary>
  2506. /// 导出机票录入报表
  2507. /// </summary>
  2508. /// <param name="dto"></param>
  2509. /// <returns></returns>
  2510. [HttpPost]
  2511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2512. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2513. {
  2514. try
  2515. {
  2516. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2517. if (groupData.Code != 0)
  2518. {
  2519. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2520. }
  2521. else
  2522. {
  2523. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2524. if (AirTicketReservations.Count != 0)
  2525. {
  2526. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2527. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2528. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2529. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2530. WorkbookDesigner designer = new WorkbookDesigner();
  2531. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2532. decimal countCost = 0;
  2533. foreach (var item in AirTicketReservations)
  2534. {
  2535. #region 处理客人姓名
  2536. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2537. item.ClientName = clientNames;
  2538. #endregion
  2539. if (item.BankType == "其他")
  2540. {
  2541. item.BankNo = "--";
  2542. }
  2543. else
  2544. {
  2545. if (!string.IsNullOrEmpty(item.BankType))
  2546. {
  2547. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2548. }
  2549. }
  2550. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2551. item.Price = System.Decimal.Round(item.Price, 2);
  2552. countCost += Convert.ToDecimal(item.Price);
  2553. }
  2554. designer.SetDataSource("Export", AirTicketReservations);
  2555. designer.SetDataSource("ExportDiCode", diCode);
  2556. designer.SetDataSource("ExportDiName", diName);
  2557. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2558. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2559. designer.Process();
  2560. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2561. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2562. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2563. return Ok(JsonView(true, "成功", url = rst));
  2564. }
  2565. else
  2566. {
  2567. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2568. }
  2569. }
  2570. }
  2571. catch (Exception ex)
  2572. {
  2573. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2574. throw;
  2575. }
  2576. }
  2577. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2578. /// <summary>
  2579. /// 行程单导出
  2580. /// </summary>
  2581. /// <param name="dto"></param>
  2582. /// <returns></returns>
  2583. [HttpPost]
  2584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2585. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2586. {
  2587. try
  2588. {
  2589. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2590. if (groupData.Code != 0)
  2591. {
  2592. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2593. }
  2594. else
  2595. {
  2596. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2597. if (dto.Language == "CN")
  2598. {
  2599. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2600. DocumentBuilder builder = new DocumentBuilder(doc);
  2601. int tableIndex = 0;//表格索引
  2602. //得到文档中的第一个表格
  2603. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2604. foreach (var item in _AirTicketReservations)
  2605. {
  2606. #region 处理固定数据
  2607. string[] FlightsCode = item.FlightsCode.Split('/');
  2608. if (FlightsCode.Length != 0)
  2609. {
  2610. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2611. if (_AirCompany != null)
  2612. {
  2613. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2614. }
  2615. else
  2616. {
  2617. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2618. }
  2619. }
  2620. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2621. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2622. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2623. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2624. string name = "";
  2625. foreach (string clientName in nameArray)
  2626. {
  2627. if (!name.Contains(clientName))
  2628. {
  2629. name += clientName + ",";
  2630. }
  2631. }
  2632. if (!string.IsNullOrWhiteSpace(name))
  2633. {
  2634. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2635. }
  2636. else
  2637. {
  2638. table.Range.Bookmarks["ClientName"].Text = "--";
  2639. }
  2640. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2641. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2642. table.Range.Bookmarks["JointTicket"].Text = "--";
  2643. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2644. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2645. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2646. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2647. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2648. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2649. #endregion
  2650. #region 循环数据处理
  2651. List<AirInfo> airs = new List<AirInfo>();
  2652. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2653. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2654. for (int i = 0; i < FlightsCode.Length; i++)
  2655. {
  2656. AirInfo air = new AirInfo();
  2657. string[] tempstr = DayArray[i]
  2658. .Replace("\r\n", string.Empty)
  2659. .Replace("\\r\\n", string.Empty)
  2660. .TrimStart().TrimEnd()
  2661. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2662. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2663. string starCity = "";
  2664. if (star_Three != null)
  2665. {
  2666. starCity = star_Three.AirPort;
  2667. }
  2668. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2669. string EndCity = "";
  2670. if (End_Three != null)
  2671. {
  2672. EndCity = End_Three.AirPort;
  2673. }
  2674. air.Destination = starCity + "/" + EndCity;
  2675. air.Flight = FlightsCode[i];
  2676. air.SeatingClass = item.CTypeName;
  2677. string dateTime = tempstr[2];
  2678. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2679. air.FlightDate = DateTemp;
  2680. air.DepartureTime = tempstr[5];
  2681. air.LandingTime = tempstr[6];
  2682. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2683. air.TicketStatus = "--";
  2684. air.Luggage = "--";
  2685. air.DepartureTerminal = "--";
  2686. air.LandingTerminal = "--";
  2687. airs.Add(air);
  2688. }
  2689. int row = 13;
  2690. for (int i = 0; i < airs.Count; i++)
  2691. {
  2692. if (airs.Count > 2)
  2693. {
  2694. for (int j = 0; j < airs.Count - 2; j++)
  2695. {
  2696. var CopyRow = table.Rows[12].Clone(true);
  2697. table.Rows.Add(CopyRow);
  2698. }
  2699. }
  2700. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2701. int index = 0;
  2702. foreach (PropertyInfo property in properties)
  2703. {
  2704. string value = property.GetValue(airs[i]).ToString();
  2705. Cell ishcel0 = table.Rows[row].Cells[index];
  2706. Paragraph p = new Paragraph(doc);
  2707. string s = value;
  2708. p.AppendChild(new Run(doc, s));
  2709. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2710. ishcel0.AppendChild(p);
  2711. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2712. index++;
  2713. }
  2714. row++;
  2715. }
  2716. #endregion
  2717. Paragraph lastParagraph = new Paragraph(doc);
  2718. //第一个表格末尾加段落
  2719. table.ParentNode.InsertAfter(lastParagraph, table);
  2720. //复制第一个表格
  2721. Table cloneTable = (Table)table.Clone(true);
  2722. //在文档末尾段落后面加入复制的表格
  2723. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2724. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2725. {
  2726. int rownewsIndex = 13;
  2727. for (int i = 0; i < 2; i++)
  2728. {
  2729. var CopyRow = table.Rows[12].Clone(true);
  2730. table.Rows.RemoveAt(13);
  2731. table.Rows.Add(CopyRow);
  2732. rownewsIndex++;
  2733. }
  2734. }
  2735. else
  2736. {
  2737. table.Rows.RemoveAt(12);
  2738. }
  2739. cloneTable.Rows.RemoveAt(12);
  2740. }
  2741. if (_AirTicketReservations.Count != 0)
  2742. {
  2743. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2744. if (FlightsCode.Length != 0)
  2745. {
  2746. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2747. if (_AirCompany != null)
  2748. {
  2749. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2750. }
  2751. else
  2752. {
  2753. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2754. }
  2755. }
  2756. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2757. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2758. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2759. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2760. string name = "";
  2761. foreach (string clientName in nameArray)
  2762. {
  2763. if (!name.Contains(clientName))
  2764. {
  2765. name += clientName + ",";
  2766. }
  2767. }
  2768. if (!string.IsNullOrWhiteSpace(name))
  2769. {
  2770. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2771. }
  2772. else
  2773. {
  2774. table.Range.Bookmarks["ClientName"].Text = "--";
  2775. }
  2776. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2777. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2778. table.Range.Bookmarks["JointTicket"].Text = "--";
  2779. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2780. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2781. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2782. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2783. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2784. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2785. }
  2786. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2787. //保存合并后的文档
  2788. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2789. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2790. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2791. return Ok(JsonView(true, "成功!", rst));
  2792. }
  2793. else
  2794. {
  2795. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2796. DocumentBuilder builder = new DocumentBuilder(doc);
  2797. int tableIndex = 0;//表格索引
  2798. //得到文档中的第一个表格
  2799. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2800. List<string> texts = new List<string>();
  2801. foreach (var item in _AirTicketReservations)
  2802. {
  2803. string[] FlightsCode = item.FlightsCode.Split('/');
  2804. if (FlightsCode.Length != 0)
  2805. {
  2806. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2807. if (_AirCompany != null)
  2808. {
  2809. if (!transDic.ContainsKey(_AirCompany.CnName))
  2810. {
  2811. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2812. }
  2813. }
  2814. else
  2815. {
  2816. if (!transDic.ContainsKey("--"))
  2817. {
  2818. transDic.Add("--", "--");
  2819. }
  2820. }
  2821. }
  2822. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2823. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2824. string name = "";
  2825. foreach (string clientName in nameArray)
  2826. {
  2827. name += clientName + ",";
  2828. }
  2829. if (!texts.Contains(name))
  2830. {
  2831. texts.Add(name);
  2832. }
  2833. List<AirInfo> airs = new List<AirInfo>();
  2834. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2835. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2836. for (int i = 0; i < FlightsCode.Length; i++)
  2837. {
  2838. AirInfo air = new AirInfo();
  2839. string[] tempstr = DayArray[i]
  2840. .Replace("\r\n", string.Empty)
  2841. .Replace("\\r\\n", string.Empty)
  2842. .TrimStart().TrimEnd()
  2843. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2844. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2845. if (star_Three != null)
  2846. {
  2847. if (!transDic.ContainsKey(star_Three.AirPort))
  2848. {
  2849. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2850. }
  2851. }
  2852. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2853. if (End_Three != null)
  2854. {
  2855. if (!transDic.ContainsKey(End_Three.AirPort))
  2856. {
  2857. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2858. }
  2859. }
  2860. if (!texts.Contains(item.CTypeName))
  2861. {
  2862. texts.Add(item.CTypeName);
  2863. }
  2864. }
  2865. }
  2866. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2867. if (transData.Count > 0)
  2868. {
  2869. foreach (TranslateResult item in transData)
  2870. {
  2871. if (!transDic.ContainsKey(item.Query))
  2872. {
  2873. transDic.Add(item.Query, item.Translation);
  2874. }
  2875. }
  2876. }
  2877. foreach (var item in _AirTicketReservations)
  2878. {
  2879. #region 处理固定数据
  2880. string[] FlightsCode = item.FlightsCode.Split('/');
  2881. if (FlightsCode.Length != 0)
  2882. {
  2883. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2884. if (_AirCompany != null)
  2885. {
  2886. string str = "--";
  2887. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2888. if (!string.IsNullOrEmpty(translateResult))
  2889. {
  2890. str = translateResult;
  2891. str = _airTicketResRep.Processing(str);
  2892. }
  2893. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2894. }
  2895. else
  2896. {
  2897. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2898. }
  2899. }
  2900. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2901. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2902. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2903. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2904. string names = "";
  2905. foreach (string clientName in nameArray)
  2906. {
  2907. names += clientName + ",";
  2908. }
  2909. if (!string.IsNullOrWhiteSpace(names))
  2910. {
  2911. string str = "--";
  2912. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2913. if (!string.IsNullOrEmpty(translateResult))
  2914. {
  2915. str = translateResult;
  2916. str = _airTicketResRep.Processing(str);
  2917. }
  2918. table.Range.Bookmarks["ClientName"].Text = str;
  2919. }
  2920. else
  2921. {
  2922. table.Range.Bookmarks["ClientName"].Text = "--";
  2923. }
  2924. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2925. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2926. table.Range.Bookmarks["JointTicket"].Text = "--";
  2927. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2928. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2929. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2930. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2931. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2932. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2933. #endregion
  2934. #region 循环数据处理
  2935. List<AirInfo> airs = new List<AirInfo>();
  2936. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2937. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2938. for (int i = 0; i < FlightsCode.Length; i++)
  2939. {
  2940. AirInfo air = new AirInfo();
  2941. string[] tempstr = DayArray[i]
  2942. .Replace("\r\n", string.Empty)
  2943. .Replace("\\r\\n", string.Empty)
  2944. .TrimStart().TrimEnd()
  2945. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2946. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2947. string starCity = "";
  2948. if (star_Three != null)
  2949. {
  2950. string str2 = "--";
  2951. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2952. if (!string.IsNullOrEmpty(translateResult2))
  2953. {
  2954. str2 = translateResult2;
  2955. str2 = _airTicketResRep.Processing(str2);
  2956. }
  2957. starCity = str2;
  2958. }
  2959. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2960. string EndCity = "";
  2961. if (End_Three != null)
  2962. {
  2963. string str1 = "--";
  2964. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2965. if (!string.IsNullOrEmpty(translateResult1))
  2966. {
  2967. str1 = translateResult1;
  2968. str1 = _airTicketResRep.Processing(str1);
  2969. }
  2970. EndCity = str1;
  2971. }
  2972. air.Destination = starCity + "/" + EndCity;
  2973. air.Flight = FlightsCode[i];
  2974. string str = "--";
  2975. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2976. if (!string.IsNullOrEmpty(translateResult))
  2977. {
  2978. str = translateResult;
  2979. str = _airTicketResRep.Processing(str);
  2980. }
  2981. air.SeatingClass = str;
  2982. string dateTime = tempstr[2];
  2983. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2984. air.FlightDate = DateTemp;
  2985. air.DepartureTime = tempstr[5];
  2986. air.LandingTime = tempstr[6];
  2987. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2988. air.TicketStatus = "--";
  2989. air.Luggage = "--";
  2990. air.DepartureTerminal = "--";
  2991. air.LandingTerminal = "--";
  2992. airs.Add(air);
  2993. }
  2994. int row = 13;
  2995. for (int i = 0; i < airs.Count; i++)
  2996. {
  2997. if (airs.Count > 2)
  2998. {
  2999. for (int j = 0; j < airs.Count - 2; j++)
  3000. {
  3001. var CopyRow = table.Rows[12].Clone(true);
  3002. table.Rows.Add(CopyRow);
  3003. }
  3004. }
  3005. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3006. int index = 0;
  3007. foreach (PropertyInfo property in properties)
  3008. {
  3009. string value = property.GetValue(airs[i]).ToString();
  3010. Cell ishcel0 = table.Rows[row].Cells[index];
  3011. Paragraph p = new Paragraph(doc);
  3012. string s = value;
  3013. p.AppendChild(new Run(doc, s));
  3014. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3015. ishcel0.AppendChild(p);
  3016. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3017. //ishcel0.CellFormat.VerticalAlignment=
  3018. index++;
  3019. }
  3020. row++;
  3021. }
  3022. #endregion
  3023. Paragraph lastParagraph = new Paragraph(doc);
  3024. //第一个表格末尾加段落
  3025. table.ParentNode.InsertAfter(lastParagraph, table);
  3026. //复制第一个表格
  3027. Table cloneTable = (Table)table.Clone(true);
  3028. //在文档末尾段落后面加入复制的表格
  3029. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3030. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3031. {
  3032. int rownewsIndex = 13;
  3033. for (int i = 0; i < 2; i++)
  3034. {
  3035. var CopyRow = table.Rows[12].Clone(true);
  3036. table.Rows.RemoveAt(13);
  3037. table.Rows.Add(CopyRow);
  3038. rownewsIndex++;
  3039. }
  3040. }
  3041. else
  3042. {
  3043. table.Rows.RemoveAt(12);
  3044. }
  3045. cloneTable.Rows.RemoveAt(12);
  3046. }
  3047. if (_AirTicketReservations.Count != 0)
  3048. {
  3049. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3050. if (FlightsCode.Length != 0)
  3051. {
  3052. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3053. if (_AirCompany != null)
  3054. {
  3055. string str = "--";
  3056. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3057. if (!string.IsNullOrEmpty(translateResult))
  3058. {
  3059. str = translateResult;
  3060. str = _airTicketResRep.Processing(str);
  3061. }
  3062. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3063. }
  3064. else
  3065. {
  3066. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3067. }
  3068. }
  3069. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3070. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3071. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3072. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3073. string names = "";
  3074. foreach (string clientName in nameArray)
  3075. {
  3076. names += clientName + ",";
  3077. }
  3078. if (!string.IsNullOrWhiteSpace(names))
  3079. {
  3080. string str = "--";
  3081. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3082. if (!string.IsNullOrEmpty(translateResult))
  3083. {
  3084. str = translateResult;
  3085. str = _airTicketResRep.Processing(str);
  3086. }
  3087. table.Range.Bookmarks["ClientName"].Text = str;
  3088. }
  3089. else
  3090. {
  3091. table.Range.Bookmarks["ClientName"].Text = "--";
  3092. }
  3093. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3094. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3095. table.Range.Bookmarks["JointTicket"].Text = "--";
  3096. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3097. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3098. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3099. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3100. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3101. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3102. }
  3103. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3104. //保存合并后的文档
  3105. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3106. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3107. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3108. return Ok(JsonView(true, "成功!", rst));
  3109. }
  3110. }
  3111. }
  3112. catch (Exception ex)
  3113. {
  3114. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3115. throw;
  3116. }
  3117. }
  3118. #endregion
  3119. #region 团组增减款项 --> 其他款项
  3120. /// <summary>
  3121. /// 团组增减款项下拉框绑定
  3122. /// </summary>
  3123. /// <param name="dto"></param>
  3124. /// <returns></returns>
  3125. [HttpPost]
  3126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3127. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3128. {
  3129. #region 参数验证
  3130. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3131. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3132. #endregion
  3133. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3134. }
  3135. /// <summary>
  3136. /// 根据团组Id查询团组增减款项
  3137. /// </summary>
  3138. /// <param name="dto"></param>
  3139. /// <returns></returns>
  3140. [HttpPost]
  3141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3142. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3143. {
  3144. #region 参数验证
  3145. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3146. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3147. #endregion
  3148. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3149. }
  3150. /// <summary>
  3151. /// 团组增减款项操作(Status:1.新增,2.修改)
  3152. /// </summary>
  3153. /// <param name="dto"></param>
  3154. /// <returns></returns>
  3155. [HttpPost]
  3156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3157. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3158. {
  3159. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3160. if (groupData.Code != 200)
  3161. {
  3162. return Ok(JsonView(false, groupData.Msg));
  3163. }
  3164. #region 应用推送
  3165. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3166. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3167. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3168. #endregion
  3169. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3170. }
  3171. /// <summary>
  3172. /// 团组增减款项操作 删除
  3173. /// </summary>
  3174. /// <param name="dto"></param>
  3175. /// <returns></returns>
  3176. [HttpPost]
  3177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3178. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3179. {
  3180. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3181. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3182. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3183. if (res.Code == 0)
  3184. {
  3185. return Ok(JsonView(true, "删除成功!"));
  3186. }
  3187. return Ok(JsonView(false, "删除失败!"));
  3188. }
  3189. /// <summary>
  3190. /// 根据团组增减款项Id查询
  3191. /// </summary>
  3192. /// <param name="dto"></param>
  3193. /// <returns></returns>
  3194. [HttpPost]
  3195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3196. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3197. {
  3198. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3199. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3200. }
  3201. /// <summary>
  3202. /// 查询供应商名称
  3203. /// </summary>
  3204. /// <param name="dto"></param>
  3205. /// <returns></returns>
  3206. [HttpPost]
  3207. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3208. {
  3209. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3210. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3211. ?? new List<Grp_DecreasePayments>();
  3212. dbResult = dbResult.Distinct(new
  3213. ProductComparer()).ToList();
  3214. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3215. {
  3216. x.Id,
  3217. x.SupplierAddress,
  3218. x.SupplierArea,
  3219. x.SupplierContact,
  3220. x.SupplierContactNumber,
  3221. x.SupplierEmail,
  3222. x.SupplierName,
  3223. x.SupplierSocialAccount,
  3224. x.SupplierTypeId,
  3225. }).ToList());
  3226. return Ok(jw);
  3227. }
  3228. #endregion
  3229. #region 文件上传、删除
  3230. /// <summary>
  3231. /// region 文件上传 可以带参数
  3232. /// </summary>
  3233. /// <param name="file"></param>
  3234. /// <returns></returns>
  3235. [HttpPost]
  3236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3237. public async Task<IActionResult> UploadProject(IFormFile file)
  3238. {
  3239. //var TypeName = Request.Headers["TypeName"].ToString();
  3240. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3241. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3242. ////文件名称
  3243. //string projectFileName = file.FileName;
  3244. ////上传的文件的路径
  3245. //string filePath = $"{fileDir}/{projectFileName}";
  3246. //if (TypeName == "A")//A代表团组增减款项
  3247. //{
  3248. // filePath = fileDir + $@"\团组增减款项相关文件";
  3249. // if (!Directory.Exists(filePath))
  3250. // {
  3251. // Directory.CreateDirectory(filePath);
  3252. // }
  3253. // //上传的文件的路径
  3254. // filePath += $@"\{projectFileName}";
  3255. //}
  3256. //else if (TypeName == "B")//B代表商邀相关文件
  3257. //{
  3258. // //上传的文件的路径
  3259. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3260. // if (!Directory.Exists(filePath))
  3261. // {
  3262. // Directory.CreateDirectory(filePath);
  3263. // }
  3264. // //上传的文件的路径
  3265. // filePath = $@"\{projectFileName}";
  3266. //}
  3267. //try
  3268. //{
  3269. // using (FileStream fs = System.IO.File.Create(filePath))
  3270. // {
  3271. // file.CopyTo(fs);
  3272. // fs.Flush();
  3273. // }
  3274. //}
  3275. //catch (Exception ex)
  3276. //{
  3277. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3278. //}
  3279. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3280. try
  3281. {
  3282. var TypeName = Request.Headers["TypeName"].ToString();
  3283. if (file != null)
  3284. {
  3285. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3286. //文件名称
  3287. string projectFileName = file.FileName;
  3288. //上传的文件的路径
  3289. string filePath = $"{fileDir}/{projectFileName}";
  3290. if (TypeName == "A")//A代表团组增减款项
  3291. {
  3292. if (!Directory.Exists(fileDir))
  3293. {
  3294. Directory.CreateDirectory(fileDir);
  3295. }
  3296. //上传的文件的路径
  3297. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3298. }
  3299. else if (TypeName == "B")//B代表商邀相关文件
  3300. {
  3301. if (!Directory.Exists(fileDir))
  3302. {
  3303. Directory.CreateDirectory(fileDir);
  3304. }
  3305. //上传的文件的路径
  3306. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3307. }
  3308. using (FileStream fs = System.IO.File.Create(filePath))
  3309. {
  3310. file.CopyTo(fs);
  3311. fs.Flush();
  3312. }
  3313. return Ok(JsonView(true, "上传成功!", projectFileName));
  3314. }
  3315. else
  3316. {
  3317. return Ok(JsonView(false, "上传失败!"));
  3318. }
  3319. }
  3320. catch (Exception ex)
  3321. {
  3322. return Ok(JsonView(false, "程序错误!"));
  3323. }
  3324. }
  3325. /// <summary>
  3326. /// 删除指定文件
  3327. /// </summary>
  3328. /// <param name="dto"></param>
  3329. /// <returns></returns>
  3330. [HttpPost]
  3331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3332. public async Task<IActionResult> DelFile(DelFileDto dto)
  3333. {
  3334. try
  3335. {
  3336. var TypeName = Request.Headers["TypeName"].ToString();
  3337. string filePath = "";
  3338. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3339. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3340. int id = 0;
  3341. if (TypeName == "A")
  3342. {
  3343. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3344. // 删除该文件
  3345. System.IO.File.Delete(filePath);
  3346. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3347. .Where(a => a.Id == dto.Id)
  3348. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3349. .ExecuteCommandAsync();
  3350. }
  3351. else if (TypeName == "B")
  3352. {
  3353. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3354. // 删除该文件
  3355. System.IO.File.Delete(filePath);
  3356. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3357. .Where(a => a.Id == dto.Id)
  3358. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" })
  3359. .ExecuteCommandAsync();
  3360. }
  3361. if (id != 0)
  3362. {
  3363. return Ok(JsonView(true, "成功!"));
  3364. }
  3365. else
  3366. {
  3367. return Ok(JsonView(false, "失败!"));
  3368. }
  3369. }
  3370. catch (Exception ex)
  3371. {
  3372. return Ok(JsonView(false, "程序错误!"));
  3373. throw;
  3374. }
  3375. }
  3376. /// <summary>
  3377. /// 文件上传多个文件 可以带参数
  3378. /// </summary>
  3379. /// <param name="file"></param>
  3380. /// <returns></returns>
  3381. [HttpPost]
  3382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3383. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3384. {
  3385. try
  3386. {
  3387. var TypeName = Request.Headers["TypeName"].ToString();
  3388. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3389. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3390. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3391. var filePahts = new List<string>();
  3392. foreach (var file in files)
  3393. {
  3394. //文件名称
  3395. string projectFileName = file.FileName;
  3396. //上传的文件的路径
  3397. string filePath = $"{fileDir}/{projectFileName}";
  3398. if (TypeName == "A")//A代表团组增减款项
  3399. {
  3400. if (!Directory.Exists(fileDir))
  3401. {
  3402. Directory.CreateDirectory(fileDir);
  3403. }
  3404. //上传的文件的路径
  3405. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3406. }
  3407. else if (TypeName == "B")//B代表商邀相关文件
  3408. {
  3409. if (!Directory.Exists(fileDir))
  3410. {
  3411. Directory.CreateDirectory(fileDir);
  3412. }
  3413. //上传的文件的路径
  3414. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3415. }
  3416. using (FileStream fs = System.IO.File.Create(filePath))
  3417. {
  3418. file.CopyTo(fs);
  3419. fs.Flush();
  3420. }
  3421. filePahts.Add(projectFileName);
  3422. }
  3423. return Ok(JsonView(true, "上传成功!", filePahts));
  3424. }
  3425. catch (Exception ex)
  3426. {
  3427. return Ok(JsonView(false, "程序错误!"));
  3428. }
  3429. }
  3430. #endregion
  3431. #region 商邀费用录入
  3432. /// <summary>
  3433. /// 根据团组Id查询商邀费用列表
  3434. /// </summary>
  3435. /// <param name="dto"></param>
  3436. /// <returns></returns>
  3437. [HttpPost]
  3438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3439. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3440. {
  3441. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3442. if (groupData.Code != 0)
  3443. {
  3444. return Ok(JsonView(false, groupData.Msg));
  3445. }
  3446. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3447. }
  3448. /// <summary>
  3449. /// 商邀费用 Info Page 基础数据源
  3450. /// </summary>
  3451. /// <param name="dto"></param>
  3452. /// <returns></returns>
  3453. [HttpPost]
  3454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3455. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3456. {
  3457. try
  3458. {
  3459. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3460. if (groupData.Code != 0)
  3461. {
  3462. return Ok(JsonView(false, groupData.Msg));
  3463. }
  3464. return Ok(JsonView(true, "操作成功", groupData.Data));
  3465. }
  3466. catch (Exception ex)
  3467. {
  3468. return Ok(JsonView(false, ex.Message));
  3469. throw;
  3470. }
  3471. }
  3472. /// <summary>
  3473. /// 根据商邀费用ID查询C表和商邀费用数据
  3474. /// </summary>
  3475. /// <param name="dto"></param>
  3476. /// <returns></returns>
  3477. [HttpPost]
  3478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3479. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3480. {
  3481. try
  3482. {
  3483. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3484. if (groupData.Code != 0)
  3485. {
  3486. return Ok(JsonView(false, groupData.Msg));
  3487. }
  3488. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3489. }
  3490. catch (Exception ex)
  3491. {
  3492. return Ok(JsonView(false, ex.Message));
  3493. throw;
  3494. }
  3495. }
  3496. /// <summary>
  3497. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3498. /// </summary>
  3499. /// <param name="dto"></param>
  3500. /// <returns></returns>
  3501. [HttpPost]
  3502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3503. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3504. {
  3505. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3506. if (groupData.Code != 0)
  3507. {
  3508. return Ok(JsonView(false, groupData.Msg));
  3509. }
  3510. #region 应用推送
  3511. try
  3512. {
  3513. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3514. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3515. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3516. }
  3517. catch (Exception ex)
  3518. {
  3519. }
  3520. #endregion
  3521. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3522. }
  3523. /// <summary>
  3524. /// 商邀删除
  3525. /// </summary>
  3526. /// <param name="dto"></param>
  3527. /// <returns></returns>
  3528. [HttpPost]
  3529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3530. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3531. {
  3532. try
  3533. {
  3534. _sqlSugar.BeginTran();
  3535. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3536. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3537. {
  3538. IsDel = 1,
  3539. DeleteUserId = dto.DeleteUserId,
  3540. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3541. })
  3542. .Where(it => it.Id == dto.Id)
  3543. .ExecuteCommand();
  3544. if (res1 > 0)
  3545. {
  3546. int _diId = 0;
  3547. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3548. if (_ioaInfo != null)
  3549. {
  3550. _diId = _ioaInfo.DiId;
  3551. }
  3552. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3553. .SetColumns(a => new Grp_CreditCardPayment()
  3554. {
  3555. IsDel = 1,
  3556. DeleteUserId = dto.DeleteUserId,
  3557. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3558. })
  3559. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3560. .ExecuteCommand();
  3561. if (res2 > 0)
  3562. {
  3563. _sqlSugar.CommitTran();
  3564. return Ok(JsonView(true, "删除成功!"));
  3565. }
  3566. }
  3567. _sqlSugar.RollbackTran();
  3568. return Ok(JsonView(false, "删除失败"));
  3569. }
  3570. catch (Exception ex)
  3571. {
  3572. _sqlSugar.RollbackTran();
  3573. return Ok(JsonView(false, ex.Message));
  3574. }
  3575. }
  3576. /// <summary>
  3577. /// 团组模块文件上传
  3578. /// </summary>
  3579. /// <param name="dto"></param>
  3580. /// <returns></returns>
  3581. [HttpPost]
  3582. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3583. {
  3584. var jw = JsonView(false);
  3585. long M = 1024 * 1024;
  3586. if (dto.Files == null || dto.Files.Count == 0)
  3587. {
  3588. jw.Msg = "无文件信息!";
  3589. return Ok(jw);
  3590. }
  3591. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3592. {
  3593. jw.Msg = "文件大小超过20M!";
  3594. return Ok(jw);
  3595. }
  3596. //var nameSp = dto.File.FileName.Split(".");
  3597. //if (nameSp.Length < 2)
  3598. //{
  3599. // jw.Msg = "拓展名称有误!";
  3600. // return Ok(jw);
  3601. //}
  3602. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3603. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3604. //{
  3605. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3606. // return Ok(jw);
  3607. //}
  3608. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3609. if (Ctable == null)
  3610. {
  3611. jw.Msg = "Ctable指向有误!";
  3612. return Ok(jw);
  3613. }
  3614. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3615. if (groupInfo == null)
  3616. {
  3617. jw.Msg = "团组信息不存在!";
  3618. return Ok(jw);
  3619. }
  3620. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3621. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3622. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3623. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3624. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3625. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3626. try
  3627. {
  3628. if (!Directory.Exists(fileBase))
  3629. {
  3630. Directory.CreateDirectory(fileBase);
  3631. }
  3632. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3633. foreach (var fileStream in dto.Files)
  3634. {
  3635. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3636. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3637. {
  3638. Cid = dto.Cid,
  3639. CreateTime = DateTime.Now,
  3640. CreateUserId = dto.Userid,
  3641. Ctable = dto.Ctable,
  3642. Diid = dto.Diid,
  3643. IsDel = 0,
  3644. FilePath = saveFilePath,
  3645. FileName = fileStream.FileName
  3646. };
  3647. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3648. {
  3649. fileStream.CopyTo(fs);
  3650. fs.Flush();
  3651. }
  3652. saveArr.Add(file);
  3653. }
  3654. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3655. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3656. jw = JsonView(true, "保存成功!", new
  3657. {
  3658. count = addResult,
  3659. filesName = saveArr.Select(x => x.FileName)
  3660. });
  3661. }
  3662. catch (Exception ex)
  3663. {
  3664. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3665. {
  3666. count = 0,
  3667. filesName = new string[0],
  3668. });
  3669. }
  3670. return Ok(jw);
  3671. }
  3672. /// <summary>
  3673. /// 查询各模块已保存文件
  3674. /// </summary>
  3675. /// <param name="dto"></param>
  3676. /// <returns></returns>
  3677. [HttpPost]
  3678. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3679. {
  3680. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3681. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3682. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3683. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3684. {
  3685. expression = Expressionable.Create<Grp_GroupModelFile>()
  3686. .And(x => visaIds.Contains(x.CreateUserId));
  3687. }
  3688. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3689. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3690. .Where(expression.ToExpression())
  3691. .ToList();
  3692. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3693. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3694. {
  3695. x.FileName,
  3696. x.Id,
  3697. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3698. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3699. })));
  3700. }
  3701. /// <summary>
  3702. /// 下载该团组下的所有文件
  3703. /// </summary>
  3704. /// <param name="dto"></param>
  3705. /// <returns></returns>
  3706. [HttpPost]
  3707. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3708. {
  3709. var jw = JsonView(false);
  3710. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3711. if (groupInfo == null)
  3712. {
  3713. jw.Msg = "团组信息不存在!";
  3714. return Ok(jw);
  3715. }
  3716. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3717. var isModule = Convert.ToBoolean(dto.isModule);
  3718. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3719. IOOperatorHelper io = new IOOperatorHelper();
  3720. if (isModule)
  3721. {
  3722. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3723. foreach (var moduleArr in moduleGroup)
  3724. {
  3725. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3726. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3727. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3728. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3729. foreach (var item in moduleArr)
  3730. {
  3731. if (System.IO.File.Exists(item.FilePath))
  3732. {
  3733. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3734. {
  3735. byte[] bytes = new byte[fileStream.Length];
  3736. fileStream.Read(bytes, 0, bytes.Length);
  3737. fileStream.Close();
  3738. Stream stream = new MemoryStream(bytes);
  3739. chiZips.Add(item.FileName, stream);
  3740. }
  3741. }
  3742. }
  3743. if (chiZips.Count > 0)
  3744. {
  3745. var byts = io.ConvertZipStream(chiZips);
  3746. Stream stream = new MemoryStream(byts);
  3747. Zips.Add(key.Name + "_.zip", stream);
  3748. }
  3749. }
  3750. }
  3751. else
  3752. {
  3753. foreach (var item in dbQuery)
  3754. {
  3755. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3756. {
  3757. byte[] bytes = new byte[fileStream.Length];
  3758. fileStream.Read(bytes, 0, bytes.Length);
  3759. fileStream.Close();
  3760. Stream stream = new MemoryStream(bytes);
  3761. while (Zips.Keys.Contains(item.FileName))
  3762. {
  3763. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3764. }
  3765. Zips.Add(item.FileName, stream);
  3766. }
  3767. }
  3768. }
  3769. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3770. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3771. if (Zips.Count > 0)
  3772. {
  3773. var byts = io.ConvertZipStream(Zips);
  3774. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3775. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3776. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3777. }
  3778. else
  3779. {
  3780. jw.Msg = "暂无生成文件!";
  3781. }
  3782. return Ok(jw);
  3783. }
  3784. /// <summary>
  3785. /// 下载该团组下此模块的所有文件
  3786. /// </summary>
  3787. /// <param name="dto"></param>
  3788. /// <returns></returns>
  3789. [HttpPost]
  3790. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3791. {
  3792. var jw = JsonView(false);
  3793. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3794. if (groupInfo == null)
  3795. {
  3796. jw.Msg = "团组信息不存在!";
  3797. return Ok(jw);
  3798. }
  3799. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3800. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3801. && x.IsDel == 0);
  3802. if (key == null)
  3803. {
  3804. jw.Msg = "Ctable指向错误!";
  3805. return Ok(jw);
  3806. }
  3807. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3808. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3809. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3810. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3811. IOOperatorHelper io = new IOOperatorHelper();
  3812. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3813. foreach (var item in dbQuery)
  3814. {
  3815. if (System.IO.File.Exists(item.FilePath))
  3816. {
  3817. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3818. {
  3819. byte[] bytes = new byte[fileStream.Length];
  3820. fileStream.Read(bytes, 0, bytes.Length);
  3821. fileStream.Close();
  3822. Stream stream = new MemoryStream(bytes);
  3823. while (Zips.Keys.Contains(item.FileName))
  3824. {
  3825. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3826. }
  3827. Zips.Add(item.FileName, stream);
  3828. }
  3829. }
  3830. }
  3831. if (Zips.Count > 0)
  3832. {
  3833. var byts = io.ConvertZipStream(Zips);
  3834. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3835. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3836. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3837. }
  3838. else
  3839. {
  3840. jw.Msg = "暂无生成文件!";
  3841. }
  3842. return Ok(jw);
  3843. }
  3844. /// <summary>
  3845. /// 删除该团组下的指定文件
  3846. /// </summary>
  3847. /// <param name="dto"></param>
  3848. /// <returns></returns>
  3849. [HttpPost]
  3850. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3851. {
  3852. var jw = JsonView(false);
  3853. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3854. if (sing == null)
  3855. {
  3856. jw.Msg = "暂无";
  3857. return Ok(jw);
  3858. }
  3859. if (System.IO.File.Exists(sing.FilePath))
  3860. {
  3861. try
  3862. {
  3863. System.IO.File.Delete(sing.FilePath);
  3864. }
  3865. catch (Exception ex)
  3866. {
  3867. jw.Msg = "删除失败!" + ex.Message;
  3868. return Ok(jw);
  3869. }
  3870. }
  3871. sing.IsDel = 1;
  3872. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3873. sing.DeleteUserId = dto.UserId;
  3874. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3875. jw = JsonView(true, "删除成功!");
  3876. return Ok(jw);
  3877. }
  3878. #endregion
  3879. #region 团组英文资料
  3880. /// <summary>
  3881. /// 查询团组英文所有资料
  3882. /// </summary>
  3883. /// <param name="dto"></param>
  3884. /// <returns></returns>
  3885. [HttpPost]
  3886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3887. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3888. {
  3889. try
  3890. {
  3891. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3892. if (groupData.Code != 0)
  3893. {
  3894. return Ok(JsonView(false, groupData.Msg));
  3895. }
  3896. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3897. }
  3898. catch (Exception ex)
  3899. {
  3900. return Ok(JsonView(false, "程序错误!"));
  3901. throw;
  3902. }
  3903. }
  3904. /// <summary>
  3905. /// 团组英文资料操作(Status:1.新增,2.修改)
  3906. /// </summary>
  3907. /// <param name="dto"></param>
  3908. /// <returns></returns>
  3909. [HttpPost]
  3910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3911. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3912. {
  3913. try
  3914. {
  3915. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3916. if (groupData.Code != 0)
  3917. {
  3918. return Ok(JsonView(false, groupData.Msg));
  3919. }
  3920. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3921. }
  3922. catch (Exception ex)
  3923. {
  3924. return Ok(JsonView(false, "程序错误!"));
  3925. throw;
  3926. }
  3927. }
  3928. /// <summary>
  3929. /// 团组英文资料Id查询数据
  3930. /// </summary>
  3931. /// <param name="dto"></param>
  3932. /// <returns></returns>
  3933. [HttpPost]
  3934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3935. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3936. {
  3937. try
  3938. {
  3939. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3940. if (_DelegationEnData != null)
  3941. {
  3942. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3943. }
  3944. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3945. }
  3946. catch (Exception ex)
  3947. {
  3948. return Ok(JsonView(false, "程序错误!"));
  3949. throw;
  3950. }
  3951. }
  3952. /// <summary>
  3953. /// 团组英文资料删除
  3954. /// </summary>
  3955. /// <param name="dto"></param>
  3956. /// <returns></returns>
  3957. [HttpPost]
  3958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3959. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3960. {
  3961. try
  3962. {
  3963. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3964. if (!res)
  3965. {
  3966. return Ok(JsonView(false, "删除失败"));
  3967. }
  3968. return Ok(JsonView(true, "删除成功!"));
  3969. }
  3970. catch (Exception ex)
  3971. {
  3972. return Ok(JsonView(false, "程序错误!"));
  3973. throw;
  3974. }
  3975. }
  3976. #endregion
  3977. #region 导出邀请函
  3978. /// <summary>
  3979. /// 导出邀请函页面初始化
  3980. /// </summary>
  3981. /// <param name="dto"></param>
  3982. /// <returns></returns>
  3983. [HttpPost]
  3984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3985. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3986. {
  3987. try
  3988. {
  3989. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3990. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3991. if (dto.DiId == 0)
  3992. {
  3993. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3994. }
  3995. else
  3996. {
  3997. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3998. }
  3999. return Ok(JsonView(true, "查询成功!", new
  4000. {
  4001. deleClient = crm_Deles,
  4002. delegations = grp_Delegations
  4003. }));
  4004. }
  4005. catch (Exception ex)
  4006. {
  4007. return Ok(JsonView(false, "程序错误!"));
  4008. throw;
  4009. }
  4010. }
  4011. /// <summary>
  4012. /// 导出邀请函
  4013. /// </summary>
  4014. /// <param name="dto"></param>
  4015. /// <returns></returns>
  4016. [HttpPost]
  4017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4018. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4019. {
  4020. #region 参数验证
  4021. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4022. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4023. #endregion
  4024. try
  4025. {
  4026. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4027. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4028. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4029. From Grp_TourClientList tcl
  4030. Left Join
  4031. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4032. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4033. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4034. From Crm_DeleClient dc
  4035. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4036. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4037. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4038. Where dc.IsDel = 0) temp
  4039. On temp.DcId =tcl.ClientId
  4040. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4041. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4042. List<string> texts = new List<string>();
  4043. if (datas.Count != 0)
  4044. {
  4045. foreach (TourClientListDetailsView item in datas)
  4046. {
  4047. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4048. {
  4049. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4050. }
  4051. else
  4052. {
  4053. string name = item.LastName + item.FirstName;
  4054. texts.Add(name);
  4055. }
  4056. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4057. {
  4058. if (!transDic.ContainsKey(item.Job))
  4059. {
  4060. texts.Add(item.Job);
  4061. }
  4062. }
  4063. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4064. {
  4065. texts.Add(item.CompanyFullName);
  4066. }
  4067. }
  4068. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4069. if (transData.Count > 0)
  4070. {
  4071. foreach (TranslateResult item in transData)
  4072. {
  4073. if (!transDic.ContainsKey(item.Query))
  4074. {
  4075. transDic.Add(item.Query, item.Translation);
  4076. }
  4077. }
  4078. }
  4079. List<GuestList> list = new List<GuestList>();
  4080. foreach (TourClientListDetailsView dele in datas)
  4081. {
  4082. GuestList guestList = new GuestList();
  4083. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4084. {
  4085. guestList.Name = dele.Pinyin;
  4086. }
  4087. else
  4088. {
  4089. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4090. guestList.Name = Name;
  4091. }
  4092. if (dele.Sex == 0)
  4093. {
  4094. guestList.Sex = "Male";
  4095. }
  4096. else if (dele.Sex == 1)
  4097. {
  4098. guestList.Sex = "Female";
  4099. }
  4100. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4101. if (!string.IsNullOrEmpty(dele.Job))
  4102. {
  4103. guestList.Job = dele.Job;
  4104. }
  4105. list.Add(guestList);
  4106. }
  4107. //载入模板
  4108. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4109. DocumentBuilder builder = new DocumentBuilder(doc);
  4110. //获取word里所有表格
  4111. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4112. //获取所填表格的序数
  4113. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4114. var rowStart = tableOne.Rows[0]; //获取第1行
  4115. //循环赋值
  4116. for (int i = 0; i < list.Count; i++)
  4117. {
  4118. builder.MoveToCell(0, i + 1, 0, 0);
  4119. builder.Write(list[i].Name.ToString());
  4120. builder.MoveToCell(0, i + 1, 1, 0);
  4121. builder.Write(list[i].Sex.ToString());
  4122. builder.MoveToCell(0, i + 1, 2, 0);
  4123. builder.Write(list[i].DOB.ToString());
  4124. builder.MoveToCell(0, i + 1, 3, 0);
  4125. builder.Write(list[i].Job.ToString());
  4126. }
  4127. //删除多余行
  4128. while (tableOne.Rows.Count > list.Count + 1)
  4129. {
  4130. tableOne.Rows.RemoveAt(list.Count + 1);
  4131. }
  4132. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4133. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4134. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4135. doc.Save(filePath);
  4136. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4137. return Ok(JsonView(true, "操作成功!", Url));
  4138. }
  4139. else
  4140. {
  4141. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4142. }
  4143. }
  4144. catch (Exception ex)
  4145. {
  4146. return Ok(JsonView(false, ex.Message));
  4147. throw;
  4148. }
  4149. }
  4150. #endregion
  4151. #region 团组经理模块 出入境费用
  4152. ///// <summary>
  4153. ///// 团组模块 - 出入境费用
  4154. ///// </summary>
  4155. ///// <returns></returns>
  4156. //[HttpPost]
  4157. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4158. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4159. //{
  4160. // try
  4161. // {
  4162. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4163. // if (data.Code != 0)
  4164. // {
  4165. // return Ok(JsonView(false, data.Msg));
  4166. // }
  4167. // return Ok(JsonView(true, "查询成功!"));
  4168. // }
  4169. // catch (Exception ex)
  4170. // {
  4171. // return Ok(JsonView(false, ex.Message));
  4172. // throw;
  4173. // }
  4174. //}
  4175. /// <summary>
  4176. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4177. /// </summary>
  4178. /// <returns></returns>
  4179. [HttpPost]
  4180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4181. public async Task<IActionResult> SetDayAndCostAreaChange()
  4182. {
  4183. try
  4184. {
  4185. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4186. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4187. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4188. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4189. foreach (var item in unite) //处理交集数据
  4190. {
  4191. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4192. }
  4193. foreach (var item in merge) //处理差集数据
  4194. {
  4195. int nationalTravelFeeId = 0;
  4196. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4197. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4198. else
  4199. {
  4200. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4201. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4202. }
  4203. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4204. }
  4205. //只更新dayAndCost 的 nationalTravelFeeId;
  4206. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4207. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4208. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4209. }
  4210. catch (Exception ex)
  4211. {
  4212. return Ok(JsonView(false, ex.Message));
  4213. throw;
  4214. }
  4215. }
  4216. /// <summary>
  4217. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4218. /// </summary>
  4219. /// <returns></returns>
  4220. [HttpPost]
  4221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4222. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4223. {
  4224. try
  4225. {
  4226. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4227. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4228. //SetDataInfoView
  4229. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4230. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4231. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4232. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4233. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4234. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4235. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4236. //默认币种显示
  4237. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4238. {
  4239. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4240. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4241. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4242. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4243. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4244. };
  4245. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4246. if (_currencyRate.Count > 0)
  4247. {
  4248. foreach (var item in _currencyInfos)
  4249. {
  4250. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4251. if (rateInfo != null)
  4252. {
  4253. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4254. rate1 *= 1.035M;
  4255. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4256. }
  4257. }
  4258. }
  4259. return Ok(JsonView(true, "查询成功!", new
  4260. {
  4261. GroupNameData = groupNameData.Data,
  4262. CurrencyData = _CurrencyData,
  4263. WordTypeData = _WordTypeData,
  4264. ExcelTypeData = _ExcelTypeData,
  4265. CurrencyInit = _currencyInfos
  4266. }));
  4267. }
  4268. catch (Exception ex)
  4269. {
  4270. return Ok(JsonView(false, ex.Message));
  4271. throw;
  4272. }
  4273. }
  4274. /// <summary>
  4275. /// 团组模块 - 出入境费用
  4276. /// 实时汇率 tips
  4277. /// 签证费用 tips
  4278. /// </summary>
  4279. /// <returns></returns>
  4280. [HttpPost]
  4281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4282. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4283. {
  4284. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4285. //默认币种显示
  4286. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4287. {
  4288. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4289. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4290. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4291. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4292. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4293. };
  4294. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4295. List<dynamic> reteInfos = new List<dynamic>();
  4296. if (_currencyRate.Count > 0)
  4297. {
  4298. foreach (var item in _currencyInfos)
  4299. {
  4300. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4301. if (rateInfo != null)
  4302. {
  4303. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4304. decimal rate1 = item.Rate;
  4305. rate1 *= 1.03M;
  4306. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4307. reteInfos.Add(new
  4308. {
  4309. currCode = item.CurrencyCode,
  4310. currName = item.CurrencyName,
  4311. rate = rate2,
  4312. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4313. });
  4314. }
  4315. }
  4316. }
  4317. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4318. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4319. return Ok(JsonView(true, "查询成功!", new
  4320. {
  4321. //GroupNameData = groupNameData.Data,
  4322. visaData = visaData.Data,
  4323. airData = airData.Data,
  4324. reteInfos = reteInfos
  4325. }));
  4326. }
  4327. /// <summary>
  4328. /// 团组模块 - 出入境费用 - Info
  4329. /// </summary>
  4330. /// <returns></returns>
  4331. [HttpPost]
  4332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4333. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4334. {
  4335. try
  4336. {
  4337. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4338. if (data.Code != 0)
  4339. {
  4340. return Ok(JsonView(false, data.Msg));
  4341. }
  4342. return Ok(JsonView(true, "查询成功!", data.Data));
  4343. }
  4344. catch (Exception ex)
  4345. {
  4346. return Ok(JsonView(false, ex.Message));
  4347. }
  4348. }
  4349. /// <summary>
  4350. /// 团组模块 - 出入境费用 - Add And Update
  4351. /// </summary>
  4352. /// <returns></returns>
  4353. [HttpPost]
  4354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4355. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4356. {
  4357. try
  4358. {
  4359. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4360. if (data.Code != 0)
  4361. {
  4362. return Ok(JsonView(false, data.Msg));
  4363. }
  4364. //生成默认文件pdf并且通知人员
  4365. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4366. {
  4367. DiId = dto.DiId,
  4368. ExportType = 1,
  4369. SubTypeId = 1005
  4370. }, "pdf");
  4371. //发送通知
  4372. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4373. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4374. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4375. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4376. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4377. //汇率信息记录
  4378. await GeneralMethod.RateRecordSave(dto.UserId,sign,"出入境费用");
  4379. return Ok(JsonView(true, data.Msg, data.Data));
  4380. }
  4381. catch (Exception ex)
  4382. {
  4383. return Ok(JsonView(false, ex.Message));
  4384. }
  4385. }
  4386. /// <summary>
  4387. /// 团组模块 - 出入境费用 - Confirm 费用
  4388. /// </summary>
  4389. /// <returns></returns>
  4390. [HttpPost]
  4391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4392. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4393. {
  4394. //TODO:测试完毕需把对应的用户ID更改
  4395. //1、数据表添加字段
  4396. //2、更改字段接口()
  4397. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4398. //3、确认成功 给财务发送消息
  4399. if (_view.Code == 200)
  4400. {
  4401. if (dto.Type == 1)
  4402. {
  4403. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4404. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4405. }
  4406. }
  4407. return Ok(_view);
  4408. }
  4409. /// <summary>
  4410. /// 团组模块 - 出入境费用 - File downlaod
  4411. /// </summary>
  4412. /// <param name="dto"></param>
  4413. /// <returns></returns>
  4414. [HttpPost]
  4415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4416. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4417. {
  4418. try
  4419. {
  4420. if (dto.DiId < 1)
  4421. {
  4422. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4423. }
  4424. if (dto.ExportType < 1)
  4425. {
  4426. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4427. }
  4428. if (dto.SubTypeId < 1)
  4429. {
  4430. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4431. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4432. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4433. 3 团组成员名单 1 团组成员名单"));
  4434. }
  4435. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4436. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4437. if (_EnterExitCosts == null)
  4438. {
  4439. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4440. }
  4441. //数据源
  4442. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4443. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4444. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4445. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4446. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4447. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4448. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4449. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4450. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4451. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4452. .Select((tcl, dc, cc) => new
  4453. {
  4454. Name = dc.LastName + dc.FirstName,
  4455. Sex = dc.Sex,
  4456. Birthday = dc.BirthDay,
  4457. Company = cc.CompanyFullName,
  4458. Job = dc.Job
  4459. })
  4460. .ToList();
  4461. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4462. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4463. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4464. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4465. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4466. if (dto.ExportType == 1) //明细表
  4467. {
  4468. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4469. {
  4470. //获取模板
  4471. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4472. //载入模板
  4473. Document doc = new Document(tempPath);
  4474. DocumentBuilder builder = new DocumentBuilder(doc);
  4475. //利用键值对存放数据
  4476. Dictionary<string, string> dic = new Dictionary<string, string>();
  4477. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4478. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4479. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4480. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4481. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4482. //境内费用(其他费用)
  4483. if (_EnterExitCosts.ChoiceOne == 1)
  4484. {
  4485. string row1_1 = "";
  4486. if (_EnterExitCosts.Visa > 0)
  4487. {
  4488. //insidePayTotal += _EnterExitCosts.Visa;
  4489. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4490. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4491. {
  4492. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4493. }
  4494. }
  4495. string row1_2 = "";
  4496. if (_EnterExitCosts.YiMiao > 0)
  4497. {
  4498. //insidePayTotal += _EnterExitCosts.YiMiao;
  4499. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4500. }
  4501. if (_EnterExitCosts.HeSuan > 0)
  4502. {
  4503. //insidePayTotal += _EnterExitCosts.HeSuan;
  4504. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4505. }
  4506. if (_EnterExitCosts.Service > 0)
  4507. {
  4508. //insidePayTotal += _EnterExitCosts.Service;
  4509. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4510. }
  4511. string row1_3 = "";
  4512. if (_EnterExitCosts.Safe > 0)
  4513. {
  4514. //insidePayTotal += _EnterExitCosts.Safe;
  4515. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4516. }
  4517. if (_EnterExitCosts.Ticket > 0)
  4518. {
  4519. //insidePayTotal += _EnterExitCosts.Ticket;
  4520. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4521. }
  4522. string row1 = "";
  4523. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4524. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4525. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4526. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4527. dic.Add("Row1Str", row1);
  4528. }
  4529. string airTotalStr = string.Empty,
  4530. airPriceStr = string.Empty;
  4531. //经济舱
  4532. if (_EnterExitCosts.SumJJC == 1)
  4533. {
  4534. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4535. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4536. }
  4537. //公务舱
  4538. if (_EnterExitCosts.SumGWC == 1)
  4539. {
  4540. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4541. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4542. }
  4543. //头等舱
  4544. if (_EnterExitCosts.SumTDC == 1)
  4545. {
  4546. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4547. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4548. }
  4549. dic.Add("AirTotalStr", airTotalStr);
  4550. dic.Add("AirPriceStr", airPriceStr);
  4551. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4552. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4553. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4554. int table1Row = 0,
  4555. table2Row = 0,
  4556. table3Row = 0,
  4557. table4Row = 0;
  4558. //住宿费
  4559. if (_EnterExitCosts.ChoiceThree == 1)
  4560. {
  4561. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4562. table1Row = dac1.Count;
  4563. #region 填充word表格内容
  4564. for (int i = 0; i < dac1.Count; i++)
  4565. {
  4566. Grp_DayAndCost dac = dac1[i];
  4567. if (dac == null) continue;
  4568. builder.MoveToCell(0, i, 0, 0);
  4569. builder.Write("第" + dac.Days.ToString() + "晚:");
  4570. builder.MoveToCell(0, i, 1, 0);
  4571. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4572. //builder.Write(dac.Place == null ? "" : dac.Place);
  4573. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4574. builder.MoveToCell(0, i, 2, 0);
  4575. builder.Write("费用标准:");
  4576. string curr = "";
  4577. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4578. if (currData != null)
  4579. {
  4580. curr = currData.Name;
  4581. }
  4582. builder.MoveToCell(0, i, 3, 0);
  4583. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4584. builder.MoveToCell(0, i, 4, 0);
  4585. builder.Write("费用小计:");
  4586. builder.MoveToCell(0, i, 5, 0);
  4587. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4588. }
  4589. #endregion
  4590. }
  4591. else dic.Add("SubZS", "0.00");
  4592. //删除多余行
  4593. while (table1.Rows.Count > table1Row)
  4594. {
  4595. table1.Rows.RemoveAt(table1Row);
  4596. }
  4597. //伙食费
  4598. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4599. if (_EnterExitCosts.ChoiceFour == 1)
  4600. {
  4601. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4602. table2Row = dac2.Count;
  4603. #region 填充word表格内容
  4604. for (int i = 0; i < dac2.Count; i++)
  4605. {
  4606. Grp_DayAndCost dac = dac2[i];
  4607. if (dac == null) continue;
  4608. builder.MoveToCell(1, i, 0, 0);
  4609. builder.Write("第" + dac.Days.ToString() + "天:");
  4610. builder.MoveToCell(1, i, 1, 0);
  4611. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4612. builder.MoveToCell(1, i, 2, 0);
  4613. builder.Write("费用标准:");
  4614. string curr = "";
  4615. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4616. if (currData != null)
  4617. {
  4618. curr = currData.Name;
  4619. }
  4620. builder.MoveToCell(1, i, 3, 0);
  4621. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4622. builder.MoveToCell(1, i, 4, 0);
  4623. builder.Write("费用小计:");
  4624. builder.MoveToCell(1, i, 5, 0);
  4625. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4626. }
  4627. #endregion
  4628. }
  4629. else dic.Add("SubHS", "0.00");
  4630. //删除多余行
  4631. while (table2.Rows.Count > table2Row)
  4632. {
  4633. table2.Rows.RemoveAt(table2Row);
  4634. }
  4635. //公杂费
  4636. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4637. if (_EnterExitCosts.ChoiceFive == 1)
  4638. {
  4639. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4640. table3Row = dac3.Count;
  4641. #region 填充word表格内容
  4642. for (int i = 0; i < dac3.Count; i++)
  4643. {
  4644. Grp_DayAndCost dac = dac3[i];
  4645. if (dac == null) continue;
  4646. builder.MoveToCell(2, i, 0, 0);
  4647. builder.Write("第" + dac.Days.ToString() + "天:");
  4648. builder.MoveToCell(2, i, 1, 0);
  4649. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4650. builder.MoveToCell(2, i, 2, 0);
  4651. builder.Write("费用标准:");
  4652. string curr = "";
  4653. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4654. if (currData != null)
  4655. {
  4656. curr = currData.Name;
  4657. }
  4658. builder.MoveToCell(2, i, 3, 0);
  4659. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4660. builder.MoveToCell(2, i, 4, 0);
  4661. builder.Write("费用小计:");
  4662. builder.MoveToCell(2, i, 5, 0);
  4663. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4664. }
  4665. //删除多余行
  4666. while (table3.Rows.Count > table3Row)
  4667. {
  4668. table3.Rows.RemoveAt(table3Row);
  4669. }
  4670. #endregion
  4671. }
  4672. else dic.Add("SubGZF", "0.00");
  4673. //删除多余行
  4674. while (table3.Rows.Count > table3Row)
  4675. {
  4676. table3.Rows.RemoveAt(table3Row);
  4677. }
  4678. //培训费
  4679. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4680. if (_EnterExitCosts.ChoiceSix == 1)
  4681. {
  4682. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4683. dic.Add("SubPX", pxStr);
  4684. table4Row = dac4.Count;
  4685. #region 填充word表格内容
  4686. for (int i = 0; i < dac4.Count; i++)
  4687. {
  4688. Grp_DayAndCost dac = dac4[i];
  4689. if (dac == null) continue;
  4690. builder.MoveToCell(3, i, 0, 0);
  4691. builder.Write("第" + dac.Days.ToString() + "天:");
  4692. builder.MoveToCell(3, i, 1, 0);
  4693. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4694. builder.MoveToCell(3, i, 2, 0);
  4695. builder.Write("费用标准:");
  4696. string curr = "";
  4697. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4698. if (currData != null)
  4699. {
  4700. curr = currData.Name;
  4701. }
  4702. builder.MoveToCell(3, i, 3, 0);
  4703. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4704. builder.MoveToCell(3, i, 4, 0);
  4705. builder.Write("费用小计:");
  4706. builder.MoveToCell(3, i, 5, 0);
  4707. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4708. }
  4709. #endregion
  4710. }
  4711. //else dic.Add("SubPX","0.00");
  4712. //删除多余行
  4713. while (table4.Rows.Count > table4Row)
  4714. {
  4715. table4.Rows.RemoveAt(table4Row);
  4716. }
  4717. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4718. decimal subJJC = 0.00M,
  4719. subGWC = 0.00M,
  4720. subTDC = 0.00M;
  4721. //经济舱
  4722. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4723. //公务舱
  4724. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4725. //头等舱
  4726. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4727. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4728. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4729. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4730. #region 填充word模板书签内容
  4731. foreach (var key in dic.Keys)
  4732. {
  4733. builder.MoveToBookmark(key);
  4734. builder.Write(dic[key]);
  4735. }
  4736. #endregion
  4737. //文件名
  4738. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4739. AsposeHelper.removewatermark_v2180();
  4740. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4741. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4742. return Ok(JsonView(true, "成功", new { Url = url }));
  4743. }
  4744. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4745. {
  4746. //获取模板
  4747. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4748. //载入模板
  4749. Document doc = new Document(tempPath);
  4750. DocumentBuilder builder = new DocumentBuilder(doc);
  4751. Dictionary<string, string> dic = new Dictionary<string, string>();
  4752. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4753. {
  4754. List<string> list = new List<string>();
  4755. try
  4756. {
  4757. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4758. foreach (var item in spilitArr)
  4759. {
  4760. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4761. var depCode = spDotandEmpty[2].Substring(0, 3);
  4762. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4763. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4764. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4765. list.Add(depName);
  4766. list.Add(arrName);
  4767. }
  4768. list = list.Distinct().ToList();
  4769. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4770. }
  4771. catch (Exception)
  4772. {
  4773. dic.Add("ReturnCode", "行程录入不正确!");
  4774. }
  4775. }
  4776. else
  4777. {
  4778. dic.Add("ReturnCode", "未录入行程!");
  4779. }
  4780. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4781. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4782. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4783. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4784. {
  4785. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4786. dic.Add("Day", sp.Days.ToString());
  4787. }
  4788. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4789. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4790. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4791. //dic.Add("Names", Names);
  4792. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4793. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4794. decimal dac1totalPrice = 0.00M;
  4795. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4796. foreach (var dac in dac1)
  4797. {
  4798. if (dac.SubTotal == 0.00M)
  4799. {
  4800. continue;
  4801. }
  4802. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4803. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4804. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4805. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4806. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4807. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4808. builder.Write(currency);//币种
  4809. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4810. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4811. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4812. builder.Write("");//人数
  4813. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4814. builder.Write("");//天数
  4815. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4816. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4817. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4818. decimal rate = 0.00M;
  4819. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4820. builder.Write(rate.ToString("#0.0000"));//汇率
  4821. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4822. decimal rbmPrice = dac.SubTotal;
  4823. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4824. accommodationStartIndex++;
  4825. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4826. }
  4827. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4828. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4829. {
  4830. table1.Rows.RemoveAt(i - 1);
  4831. foodandotherStartIndex--;
  4832. }
  4833. if (dac2.Count == dac3.Count)//国家 币种 金额
  4834. {
  4835. for (int i = 0; i < dac2.Count; i++)
  4836. {
  4837. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4838. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4839. }
  4840. }
  4841. decimal dac2totalPrice = 0.00M;
  4842. foreach (var dac in dac2)
  4843. {
  4844. if (dac.SubTotal == 0)
  4845. {
  4846. continue;
  4847. }
  4848. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4849. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4850. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4851. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4852. builder.Write(currency);//币种
  4853. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4854. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4855. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4856. builder.Write("");//人数
  4857. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4858. builder.Write("");//天数
  4859. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4860. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4861. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4862. decimal rate = 0.00M;
  4863. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4864. builder.Write(rate.ToString("#0.0000"));//汇率
  4865. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4866. decimal rbmPrice = dac.SubTotal;
  4867. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4868. foodandotherStartIndex++;
  4869. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4870. }
  4871. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4872. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4873. {
  4874. table1.Rows.RemoveAt(i - 1);
  4875. }
  4876. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4877. string otherFeeStr = "";
  4878. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4879. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4880. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4881. if (otherFeeStr.Length > 0)
  4882. {
  4883. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4884. otherFeeStr = $"({otherFeeStr})";
  4885. dic.Add("OtherFeeStr", otherFeeStr);
  4886. }
  4887. //总计
  4888. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4889. //国际旅费
  4890. string outsideAir = string.Empty;
  4891. string allPriceAir = string.Empty;
  4892. if (_EnterExitCosts.SumJJC == 1)
  4893. {
  4894. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4895. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4896. }
  4897. if (_EnterExitCosts.SumGWC == 1)
  4898. {
  4899. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4900. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4901. }
  4902. if (_EnterExitCosts.SumTDC == 1)
  4903. {
  4904. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4905. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4906. }
  4907. dic.Add("InTravelPrice", $"({outsideAir})");
  4908. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4909. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4910. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4911. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4912. foreach (var key in dic.Keys)
  4913. {
  4914. builder.MoveToBookmark(key);
  4915. builder.Write(dic[key]);
  4916. }
  4917. //模板文件名
  4918. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4919. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4920. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4921. return Ok(JsonView(true, "成功", new { Url = url }));
  4922. }
  4923. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4924. {
  4925. //获取模板
  4926. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4927. //载入模板
  4928. WorkbookDesigner designer = new WorkbookDesigner();
  4929. designer.Workbook = new Workbook(tempPath);
  4930. Dictionary<string, string> dic = new Dictionary<string, string>();
  4931. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4932. {
  4933. List<string> list = new List<string>();
  4934. try
  4935. {
  4936. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4937. foreach (var item in spilitArr)
  4938. {
  4939. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4940. var depCode = spDotandEmpty[2].Substring(0, 3);
  4941. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4942. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4943. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4944. list.Add(depName);
  4945. list.Add(arrName);
  4946. }
  4947. list = list.Distinct().ToList();
  4948. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4949. }
  4950. catch (Exception)
  4951. {
  4952. dic.Add("ReturnCode", "行程录入不正确!");
  4953. }
  4954. }
  4955. else
  4956. {
  4957. dic.Add("ReturnCode", "未录入行程!");
  4958. }
  4959. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4960. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4961. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4962. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4963. {
  4964. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4965. dic.Add("Day", sp.Days.ToString());
  4966. }
  4967. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4968. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4969. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4970. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4971. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4972. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4973. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4974. designer.SetDataSource("Name", Names);
  4975. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4976. designer.SetDataSource("Day", dic["Day"] + "天");
  4977. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4978. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4979. int startIndex = 10;
  4980. const int startIndexcopy = 10;
  4981. if (dac2.Count == dac3.Count)//国家 币种 金额
  4982. {
  4983. for (int i = 0; i < dac2.Count; i++)
  4984. {
  4985. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4986. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4987. }
  4988. }
  4989. DataTable dtdac1 = new DataTable();
  4990. List<string> place = new List<string>();
  4991. dtdac1.Columns.AddRange(new DataColumn[] {
  4992. new DataColumn(){ ColumnName = "city"},
  4993. new DataColumn(){ ColumnName = "curr"},
  4994. new DataColumn(){ ColumnName = "criterion"},
  4995. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4996. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4997. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4998. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4999. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5000. });
  5001. DataTable dtdac2 = new DataTable();
  5002. dtdac2.Columns.AddRange(new DataColumn[] {
  5003. new DataColumn(){ ColumnName = "city"},
  5004. new DataColumn(){ ColumnName = "curr"},
  5005. new DataColumn(){ ColumnName = "criterion"},
  5006. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5007. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5008. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5009. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5010. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5011. });
  5012. dtdac1.TableName = "tb1";
  5013. dtdac2.TableName = "tb2";
  5014. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5015. foreach (var item in dac1)
  5016. {
  5017. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5018. if (place.Contains(item.Place))
  5019. {
  5020. continue;
  5021. }
  5022. DataRow row = dtdac1.NewRow();
  5023. row["city"] = item.Place;
  5024. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5025. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5026. row["curr"] = currency;
  5027. row["rate"] = rate.ToString("#0.0000");
  5028. row["criterion"] = item.Cost.ToString("#0.00");
  5029. row["number"] = 1;
  5030. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5031. //row["costRMB"] = rbmPrice;
  5032. dtdac1.Rows.Add(row);
  5033. place.Add(item.Place);
  5034. }
  5035. place = new List<string>();
  5036. foreach (var item in dac2)
  5037. {
  5038. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5039. if (place.Contains(item.Place))
  5040. {
  5041. continue;
  5042. }
  5043. DataRow row = dtdac2.NewRow();
  5044. row["city"] = item.Place;
  5045. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5046. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5047. row["curr"] = currency;
  5048. row["rate"] = rate.ToString("#0.0000");
  5049. row["criterion"] = item.Cost.ToString("#0.00");
  5050. row["number"] = 1;
  5051. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5052. //row["cost"] = item.SubTotal;
  5053. //row["costRMB"] = rbmPrice;
  5054. dtdac2.Rows.Add(row);
  5055. place.Add(item.Place);
  5056. //dac2totalPrice += rbmPrice;
  5057. }
  5058. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5059. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5060. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5061. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5062. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5063. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5064. string cell4Str1 = string.Empty;
  5065. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5066. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5067. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5068. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5069. string cellStr = $" 5.其他费用(";
  5070. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5071. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5072. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5073. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5074. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5075. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5076. if (cellStr.Length > 8)
  5077. {
  5078. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5079. }
  5080. cellStr += ")";
  5081. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5082. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5083. decimal pxFee = dac4.Sum(it => it.Cost);
  5084. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5085. string celllastStr1 = "";
  5086. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5087. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5088. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5089. celllastStr1 += $",国际旅费 元";
  5090. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5091. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5092. designer.SetDataSource("cell4Str", cell4Str);
  5093. designer.SetDataSource("cellStr", cellStr);
  5094. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5095. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5096. designer.SetDataSource("celllastStr", celllastStr);
  5097. Workbook wb = designer.Workbook;
  5098. var sheet = wb.Worksheets[0];
  5099. //绑定datatable数据集
  5100. designer.SetDataSource(dtdac1);
  5101. designer.SetDataSource(dtdac2);
  5102. designer.Process();
  5103. var rowStart = dtdac1.Rows.Count;
  5104. while (rowStart > 0)
  5105. {
  5106. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5107. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5108. startIndex++;
  5109. rowStart--;
  5110. }
  5111. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5112. startIndex += 1; //总计行
  5113. rowStart = dtdac2.Rows.Count;
  5114. while (rowStart > 0)
  5115. {
  5116. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5117. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5118. startIndex++;
  5119. rowStart--;
  5120. }
  5121. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5122. wb.CalculateFormula(true);
  5123. //模板文件名
  5124. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5125. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5126. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5127. return Ok(JsonView(true, "成功", new { Url = url }));
  5128. }
  5129. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5130. {
  5131. //获取模板
  5132. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5133. //载入模板
  5134. Document doc = new Document(tempPath);
  5135. DocumentBuilder builder = new DocumentBuilder(doc);
  5136. Dictionary<string, string> dic = new Dictionary<string, string>();
  5137. dic.Add("GroupName", _DelegationInfo.TeamName);
  5138. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5139. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5140. string missionLeaderJob = "";//负责人job
  5141. int groupNumber = 0; //团人数
  5142. if (DeleClientList.Count > 0)
  5143. {
  5144. missionLeader = DeleClientList[0]?.Name ?? "";
  5145. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5146. }
  5147. dic.Add("MissionLeader", missionLeader); //团负责人
  5148. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5149. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5150. #region MyRegion
  5151. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5152. //{
  5153. // List<string> list = new List<string>();
  5154. // try
  5155. // {
  5156. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5157. // foreach (var item in spilitArr)
  5158. // {
  5159. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5160. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5161. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5162. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5163. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5164. // list.Add(depName);
  5165. // list.Add(arrName);
  5166. // }
  5167. // list = list.Distinct().ToList();
  5168. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5169. // }
  5170. // catch (Exception)
  5171. // {
  5172. // dic.Add("ReturnCode", "行程录入不正确!");
  5173. // }
  5174. //}
  5175. //else
  5176. //{
  5177. // dic.Add("ReturnCode", "未录入行程!");
  5178. //}
  5179. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5180. dic.Add("ReturnCode", string.Join("、", countrys));
  5181. #endregion
  5182. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5183. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5184. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5185. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5186. //{
  5187. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5188. // dic.Add("Day", sp.Days.ToString());
  5189. //}
  5190. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5191. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5192. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5193. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5194. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5195. //培训人员名单
  5196. int cultivateRowIndex = 7;
  5197. foreach (var item in DeleClientList)
  5198. {
  5199. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5200. builder.Write(item.Name);
  5201. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5202. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5203. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5204. string birthDay = "";
  5205. if (item.Birthday != null)
  5206. {
  5207. DateTime dt = Convert.ToDateTime(item.Birthday);
  5208. birthDay = $"{dt.Year}.{dt.Month}";
  5209. }
  5210. builder.Write(birthDay);
  5211. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5212. builder.Write(item.Company);
  5213. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5214. builder.Write(item.Job);
  5215. cultivateRowIndex++;
  5216. }
  5217. //删除多余行
  5218. //cultivateRowIndex -= 2;
  5219. int delRows = 10 + 7 - cultivateRowIndex;
  5220. if (delRows > 0)
  5221. {
  5222. for (int i = 0; i < delRows; i++)
  5223. {
  5224. table1.Rows.RemoveAt(cultivateRowIndex);
  5225. //cultivateRowIndex++;
  5226. }
  5227. }
  5228. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5229. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5230. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5231. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5232. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5233. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5234. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5235. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5236. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5237. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5238. //其他费用
  5239. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5240. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5241. //其他费用合计
  5242. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5243. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5244. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5245. //公务舱合计
  5246. //国际旅费
  5247. string outsideJJ = "";
  5248. string allPriceJJ = "";
  5249. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5250. {
  5251. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5252. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5253. }
  5254. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5255. {
  5256. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5257. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5258. }
  5259. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5260. {
  5261. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5262. dic.Add("AirFeeTotal", airFeeTotalStr);
  5263. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5264. dic.Add("FeeTotal", feeTotalStr);
  5265. }
  5266. foreach (var key in dic.Keys)
  5267. {
  5268. builder.MoveToBookmark(key);
  5269. builder.Write(dic[key]);
  5270. }
  5271. //模板文件名
  5272. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5273. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5274. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5275. return Ok(JsonView(true, "成功", new { Url = url }));
  5276. }
  5277. }
  5278. else if (dto.ExportType == 2) //表格
  5279. {
  5280. //利用键值对存放数据
  5281. Dictionary<string, string> dic = new Dictionary<string, string>();
  5282. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5283. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5284. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5285. dic.Add("Day", sp.Days.ToString());
  5286. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5287. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5288. {
  5289. //获取模板
  5290. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5291. //载入模板
  5292. Document doc = new Document(tempPath);
  5293. DocumentBuilder builder = new DocumentBuilder(doc);
  5294. dic.Add("TeamName", _DelegationInfo.TeamName);
  5295. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5296. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5297. string missionLeaderName = "",
  5298. missionLeaderJob = "";
  5299. if (DeleClientList.Count > 0)
  5300. {
  5301. missionLeaderName = DeleClientList[0].Name;
  5302. missionLeaderJob = DeleClientList[0].Job;
  5303. }
  5304. dic.Add("MissionLeaderName", missionLeaderName);
  5305. dic.Add("MissionLeaderJob", missionLeaderJob);
  5306. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5307. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5308. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5309. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5310. int rowCount = 10;//总人数行
  5311. int startRowIndex = 7; //起始行
  5312. for (int i = 0; i < DeleClientList.Count; i++)
  5313. {
  5314. builder.MoveToCell(0, startRowIndex, 0, 0);
  5315. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5316. builder.MoveToCell(0, startRowIndex, 1, 0);
  5317. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5318. builder.Write(sex);//性别
  5319. builder.MoveToCell(0, startRowIndex, 2, 0);
  5320. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5321. builder.MoveToCell(0, startRowIndex, 3, 0);
  5322. builder.Write(DeleClientList[i].Company);//工作单位
  5323. builder.MoveToCell(0, startRowIndex, 4, 0);
  5324. builder.Write(DeleClientList[i].Job);//职务及级别
  5325. builder.MoveToCell(0, startRowIndex, 5, 0);
  5326. builder.Write("");//人员属性
  5327. builder.MoveToCell(0, startRowIndex, 6, 0);
  5328. builder.Write("");//上次出国时间
  5329. startRowIndex++;
  5330. }
  5331. int nullRow = rowCount - DeleClientList.Count;//空行
  5332. for (int i = 0; i < nullRow; i++)
  5333. {
  5334. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5335. }
  5336. foreach (var key in dic.Keys)
  5337. {
  5338. builder.MoveToBookmark(key);
  5339. builder.Write(dic[key]);
  5340. }
  5341. //模板文件名
  5342. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5343. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5344. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5345. return Ok(JsonView(true, "成功", new { Url = url }));
  5346. }
  5347. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5348. {
  5349. //获取模板
  5350. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5351. //载入模板
  5352. Document doc = new Document(tempPath);
  5353. DocumentBuilder builder = new DocumentBuilder(doc);
  5354. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5355. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5356. dic.Add("Names", Names);
  5357. int accommodationRows = 12, foodandotherRows = 12;
  5358. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5359. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5360. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5361. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5362. int accommodationStartIndex = 6;
  5363. decimal dac1totalPrice = 0.00M;
  5364. foreach (var dac in dac1)
  5365. {
  5366. if (dac.SubTotal == 0)
  5367. {
  5368. continue;
  5369. }
  5370. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5371. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5372. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5373. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5374. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5375. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5376. builder.Write(currency);//币种
  5377. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5378. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5379. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5380. builder.Write("");//人数
  5381. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5382. builder.Write("");//天数
  5383. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5384. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5385. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5386. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5387. builder.Write(rate.ToString("#0.0000"));//汇率
  5388. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5389. decimal rbmPrice = rate * dac.SubTotal;
  5390. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5391. accommodationStartIndex++;
  5392. dac1totalPrice += rbmPrice;
  5393. }
  5394. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5395. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5396. builder.Write("小计");
  5397. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5398. builder.Write(dac1totalPrice.ToString("#0.00"));
  5399. accommodationStartIndex++;
  5400. int nullRow = accommodationRows - dac1.Count;
  5401. //删除空行
  5402. //if (nullRow > 0)
  5403. //{
  5404. // int rowIndex = accommodationStartIndex;
  5405. // for (int i = 0; i < nullRow; i++)
  5406. // {
  5407. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5408. // row.Remove();
  5409. // rowIndex++;
  5410. // }
  5411. //}
  5412. if (dac2.Count == dac3.Count)//国家 币种 金额
  5413. {
  5414. for (int i = 0; i < dac2.Count; i++)
  5415. {
  5416. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5417. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5418. }
  5419. }
  5420. int foodandotherStartIndex = 19;//
  5421. decimal dac2totalPrice = 0.00M;
  5422. foreach (var dac in dac2)
  5423. {
  5424. if (dac.SubTotal == 0)
  5425. {
  5426. continue;
  5427. }
  5428. //foodandotherStartIndex = 12;
  5429. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5430. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5431. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5432. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5433. builder.Write(currency);//币种
  5434. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5435. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5436. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5437. builder.Write("");//人数
  5438. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5439. builder.Write("");//天数
  5440. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5441. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5442. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5443. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5444. builder.Write(rate.ToString("#0.0000"));//汇率
  5445. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5446. decimal rbmPrice = rate * dac.SubTotal;
  5447. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5448. foodandotherStartIndex++;
  5449. dac2totalPrice += rbmPrice;
  5450. }
  5451. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5452. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5453. //删除空行
  5454. //if (dac2.Count < foodandotherRows)
  5455. //{
  5456. // while (table2.Rows.Count > dac2.Count)
  5457. // {
  5458. // table2.Rows.RemoveAt(dac2.Count);
  5459. // }
  5460. //}
  5461. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5462. string otherFeeStr = "";
  5463. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5464. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5465. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5466. if (otherFeeStr.Length > 0)
  5467. {
  5468. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5469. otherFeeStr = $"({otherFeeStr})";
  5470. dic.Add("OtherFeeStr", otherFeeStr);
  5471. }
  5472. foreach (var key in dic.Keys)
  5473. {
  5474. builder.MoveToBookmark(key);
  5475. builder.Write(dic[key]);
  5476. }
  5477. //模板文件名
  5478. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5479. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5480. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5481. return Ok(JsonView(true, "成功", new { Url = url }));
  5482. }
  5483. }
  5484. else if (dto.ExportType == 3)
  5485. {
  5486. if (dto.SubTypeId == 1) //团组成员名单
  5487. {
  5488. if (DeleClientList.Count < 1)
  5489. {
  5490. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5491. }
  5492. //获取模板
  5493. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5494. //载入模板
  5495. Document doc = new Document(tempPath);
  5496. DocumentBuilder builder = new DocumentBuilder(doc);
  5497. //获取word里所有表格
  5498. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5499. //获取所填表格的序数
  5500. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5501. var rowStart = tableOne.Rows[0]; //获取第1行
  5502. //循环赋值
  5503. for (int i = 0; i < DeleClientList.Count; i++)
  5504. {
  5505. builder.MoveToCell(0, i + 1, 0, 0);
  5506. builder.Write(DeleClientList[i].Name);
  5507. builder.MoveToCell(0, i + 1, 1, 0);
  5508. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5509. builder.Write(sex);
  5510. builder.MoveToCell(0, i + 1, 2, 0);
  5511. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5512. builder.MoveToCell(0, i + 1, 3, 0);
  5513. builder.Write(DeleClientList[i].Company);
  5514. builder.MoveToCell(0, i + 1, 4, 0);
  5515. builder.Write(DeleClientList[i].Job);
  5516. }
  5517. //删除多余行
  5518. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5519. {
  5520. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5521. }
  5522. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5523. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5524. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5525. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5526. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5527. return Ok(JsonView(true, "成功", new { Url = url }));
  5528. }
  5529. }
  5530. return Ok(JsonView(false, "操作失败!"));
  5531. }
  5532. catch (Exception ex)
  5533. {
  5534. return Ok(JsonView(false, ex.Message));
  5535. }
  5536. }
  5537. /// <summary>
  5538. /// 获取三公费用标准city
  5539. /// </summary>
  5540. /// <param name="placeData"></param>
  5541. /// <param name="nationalTravelFeeId"></param>
  5542. /// <returns></returns>
  5543. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5544. {
  5545. string _city = string.Empty;
  5546. if (placeData.Count < 1) return _city;
  5547. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5548. if (data == null) return _city;
  5549. string country = data.Country;
  5550. string city = data.City;
  5551. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5552. else _city = city;
  5553. return _city;
  5554. }
  5555. /// <summary>
  5556. /// 团组模块 - 出入境费用 - 明细表导出
  5557. /// </summary>
  5558. /// <returns></returns>
  5559. [HttpPost]
  5560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5561. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5562. {
  5563. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5564. if (data.Code != 0)
  5565. {
  5566. return Ok(JsonView(false, data.Msg));
  5567. }
  5568. return Ok(JsonView(true, data.Msg, data.Data));
  5569. }
  5570. /// <summary>
  5571. /// 团组模块 - 出入境费用 - 一键清空
  5572. /// </summary>
  5573. /// <returns></returns>
  5574. [HttpPost]
  5575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5576. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5577. {
  5578. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5579. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5580. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5581. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5582. if (_view.Code == 0)
  5583. {
  5584. return Ok(JsonView(true, "操作成功"));
  5585. }
  5586. return Ok(JsonView(false, "操作失败"));
  5587. }
  5588. /// <summary>
  5589. /// 团组模块 - 出入境费用 - 子项删除
  5590. /// </summary>
  5591. /// <returns></returns>
  5592. [HttpPost]
  5593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5594. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5595. {
  5596. try
  5597. {
  5598. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5599. if (data.Code != 0)
  5600. {
  5601. return Ok(JsonView(false, data.Msg));
  5602. }
  5603. return Ok(JsonView(true, "操作成功!", data.Data));
  5604. }
  5605. catch (Exception ex)
  5606. {
  5607. return Ok(JsonView(false, ex.Message));
  5608. }
  5609. }
  5610. /// <summary>
  5611. /// 团组模块 - 出入境国家费用标准 List
  5612. /// </summary>
  5613. /// <returns></returns>
  5614. [HttpPost]
  5615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5616. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5617. {
  5618. try
  5619. {
  5620. Stopwatch sw = new Stopwatch();
  5621. sw.Start();
  5622. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5623. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5624. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5625. Where gntf.Isdel = 0");
  5626. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5627. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5628. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5629. //foreach (var item in nationalTravel)
  5630. //{
  5631. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5632. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5633. // if (otherData != null)
  5634. // {
  5635. // cityData.Remove(otherData);
  5636. // cityData.Add(otherData);
  5637. // }
  5638. // nationalTravelFeeData1.Add(new
  5639. // {
  5640. // Country = item.Country,
  5641. // CityData = cityData
  5642. // });
  5643. //}
  5644. sw.Stop();
  5645. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5646. }
  5647. catch (Exception ex)
  5648. {
  5649. return Ok(JsonView(false, ex.Message));
  5650. throw;
  5651. }
  5652. }
  5653. /// <summary>
  5654. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5655. /// </summary>
  5656. /// <returns></returns>
  5657. [HttpPost]
  5658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5659. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5660. {
  5661. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5662. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5663. List<string> countryData = new List<string>();
  5664. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5665. countryData = countryData.Distinct().ToList();
  5666. List<dynamic> dataSource = new List<dynamic>();
  5667. foreach (var item in countryData)
  5668. {
  5669. List<string> cityData1 = new List<string>();
  5670. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5671. var countryData2 = new
  5672. {
  5673. CountryName = item,
  5674. CityData = cityData1
  5675. };
  5676. dataSource.Add(countryData2);
  5677. }
  5678. return Ok(JsonView(true, "查询成功!", dataSource));
  5679. }
  5680. /// <summary>
  5681. /// 团组模块 - 出入境国家费用标准 Page List
  5682. /// </summary>
  5683. /// <returns></returns>
  5684. [HttpPost]
  5685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5686. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5687. {
  5688. int portId = dto.PortType;
  5689. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5690. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5691. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5692. string whereSql = string.Empty;
  5693. if (!string.IsNullOrEmpty(dto.Country))
  5694. {
  5695. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5696. }
  5697. if (!string.IsNullOrEmpty(dto.City))
  5698. {
  5699. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5700. }
  5701. string pageSql = string.Format(@"Select * From (
  5702. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5703. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5704. From Grp_NationalTravelFee gntf
  5705. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5706. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5707. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5708. RefAsync<int> total = 0;
  5709. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5710. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5711. }
  5712. /// <summary>
  5713. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5714. /// </summary>
  5715. /// <returns></returns>
  5716. [HttpPost]
  5717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5718. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5719. {
  5720. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5721. int portId = dto.PortType;
  5722. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5723. string whereSql = string.Empty;
  5724. if (!string.IsNullOrEmpty(dto.Country))
  5725. {
  5726. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5727. }
  5728. if (!string.IsNullOrEmpty(dto.City))
  5729. {
  5730. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5731. }
  5732. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5733. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5734. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5735. From Grp_NationalTravelFee gntf
  5736. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5737. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5738. Where gntf.Isdel = 0 {0} ", whereSql);
  5739. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5740. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5741. }
  5742. /// <summary>
  5743. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5744. /// </summary>
  5745. /// <returns></returns>
  5746. [HttpPost]
  5747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5748. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5749. {
  5750. try
  5751. {
  5752. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5753. if (data.Code != 0)
  5754. {
  5755. return Ok(JsonView(false, data.Msg));
  5756. }
  5757. return Ok(JsonView(true, "操作成功!", data.Data));
  5758. }
  5759. catch (Exception ex)
  5760. {
  5761. return Ok(JsonView(false, ex.Message));
  5762. }
  5763. }
  5764. /// <summary>
  5765. /// 团组模块 - 出入境国家费用标准 - Del
  5766. /// </summary>
  5767. /// <returns></returns>
  5768. [HttpPost]
  5769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5770. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5771. {
  5772. try
  5773. {
  5774. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5775. {
  5776. Id = dto.Id,
  5777. DeleteUserId = dto.DeleteUserId,
  5778. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5779. IsDel = 1
  5780. };
  5781. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5782. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5783. .WhereColumns(it => new { it.Id })
  5784. .ExecuteCommandAsync();
  5785. if (delStatus <= 0)
  5786. {
  5787. return Ok(JsonView(false, "删除失败!"));
  5788. }
  5789. return Ok(JsonView(true, "操作成功!"));
  5790. }
  5791. catch (Exception ex)
  5792. {
  5793. return Ok(JsonView(false, ex.Message));
  5794. }
  5795. }
  5796. /// <summary>
  5797. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  5798. /// 注:Get 请求Headers 加 Token
  5799. /// </summary>
  5800. /// <param name="groupId"></param>
  5801. /// <returns></returns>
  5802. [HttpGet("{groupId}")]
  5803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5804. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  5805. {
  5806. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5807. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  5808. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  5809. data.ForEach(x =>
  5810. {
  5811. x.CreateUserId = _currUserInfo.UserId;
  5812. });
  5813. if (data.Count > 0)
  5814. {
  5815. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  5816. if (add > 0)
  5817. {
  5818. return Ok(JsonView(true, "操作成功!"));
  5819. }
  5820. }
  5821. return Ok(JsonView(false, "未操作!"));
  5822. }
  5823. #endregion
  5824. #region 签证费用录入
  5825. /// <summary>
  5826. /// 根据diid查询签证费用列表
  5827. /// </summary>
  5828. /// <param name="dto"></param>
  5829. /// <returns></returns>
  5830. [HttpPost]
  5831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5832. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5833. {
  5834. try
  5835. {
  5836. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5837. if (groupData.Code != 0)
  5838. {
  5839. return Ok(JsonView(false, groupData.Msg));
  5840. }
  5841. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5842. }
  5843. catch (Exception ex)
  5844. {
  5845. return Ok(JsonView(false, ex.Message));
  5846. }
  5847. }
  5848. /// <summary>
  5849. /// 根据签证费用Id查询单条数据及c表数据
  5850. /// </summary>
  5851. /// <param name="dto"></param>
  5852. /// <returns></returns>
  5853. [HttpPost]
  5854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5855. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5856. {
  5857. try
  5858. {
  5859. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5860. if (groupData.Code != 0)
  5861. {
  5862. return Ok(JsonView(false, groupData.Msg));
  5863. }
  5864. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5865. }
  5866. catch (Exception ex)
  5867. {
  5868. return Ok(JsonView(false, ex.Message));
  5869. }
  5870. }
  5871. /// <summary>
  5872. /// 签证费用删除
  5873. /// </summary>
  5874. /// <param name="dto"></param>
  5875. /// <returns></returns>
  5876. [HttpPost]
  5877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5878. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5879. {
  5880. _sqlSugar.BeginTran();
  5881. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5882. if (!res)
  5883. {
  5884. _sqlSugar.RollbackTran();
  5885. return Ok(JsonView(false, "删除失败"));
  5886. }
  5887. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5888. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5889. .SetColumns(a => new Grp_CreditCardPayment()
  5890. {
  5891. IsDel = 1,
  5892. DeleteUserId = dto.DeleteUserId,
  5893. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5894. })
  5895. .ExecuteCommand();
  5896. if (resSub < 1)
  5897. {
  5898. _sqlSugar.RollbackTran();
  5899. return Ok(JsonView(false, "删除失败"));
  5900. }
  5901. _sqlSugar.CommitTran();
  5902. return Ok(JsonView(true, "删除成功!"));
  5903. }
  5904. /// <summary>
  5905. /// 签证费用录入下拉框初始化
  5906. /// </summary>
  5907. /// <returns></returns>
  5908. [HttpPost]
  5909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5910. public async Task<IActionResult> VisaPriceAddSelect()
  5911. {
  5912. //支付方式
  5913. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5914. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5915. //币种
  5916. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5917. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5918. //乘客类型
  5919. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5920. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5921. //卡类型
  5922. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5923. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5924. var data = new
  5925. {
  5926. Payment = _Payment,
  5927. CurrencyList = _CurrencyList,
  5928. PassengerType = _PassengerType,
  5929. BankCard = _BankCard
  5930. };
  5931. return Ok(JsonView(true, "查询成功!", data));
  5932. }
  5933. /// <summary>
  5934. /// 签证费用录入操作(Status:1.新增,2.修改)
  5935. /// </summary>
  5936. /// <param name="dto"></param>
  5937. /// <returns></returns>
  5938. [HttpPost]
  5939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5940. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5941. {
  5942. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5943. if (groupData.Code != 0)
  5944. {
  5945. return Ok(JsonView(false, groupData.Msg));
  5946. }
  5947. #region 应用推送
  5948. try
  5949. {
  5950. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5951. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5952. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5953. }
  5954. catch (Exception ex)
  5955. {
  5956. }
  5957. #endregion
  5958. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5959. }
  5960. #endregion
  5961. #region 签证提成录入
  5962. /// <summary>
  5963. /// 签证提成录入
  5964. /// 基础数据
  5965. /// </summary>
  5966. /// <param name="_dto"></param>
  5967. /// <returns></returns>
  5968. [HttpGet]
  5969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5970. public async Task<IActionResult> VisaCommissionInit()
  5971. {
  5972. return Ok(await _visaCommissionRep.Init());
  5973. }
  5974. /// <summary>
  5975. /// 签证提成录入
  5976. /// Item
  5977. /// </summary>
  5978. /// <param name="_dto"></param>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5982. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5983. {
  5984. var validator = new VisaCommissionItemDtoValidator();
  5985. var validatorRes = await validator.ValidateAsync(_dto);
  5986. if (!validatorRes.IsValid)
  5987. {
  5988. StringBuilder sb = new StringBuilder();
  5989. foreach (var item in validatorRes.Errors)
  5990. {
  5991. sb.AppendLine(item.ErrorMessage);
  5992. }
  5993. return Ok(JsonView(false, sb.ToString()));
  5994. }
  5995. return Ok(await _visaCommissionRep.Item(_dto));
  5996. }
  5997. /// <summary>
  5998. /// 签证提成录入
  5999. /// Save
  6000. /// </summary>
  6001. /// <param name="_dto"></param>
  6002. /// <returns></returns>
  6003. [HttpPost]
  6004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6005. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6006. {
  6007. //参数验证
  6008. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6009. foreach (var item in _dto.Items)
  6010. {
  6011. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6012. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6013. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6014. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6015. }
  6016. return Ok(await _visaCommissionRep.Save(_dto));
  6017. }
  6018. /// <summary>
  6019. /// 签证提成录入
  6020. /// Create
  6021. /// </summary>
  6022. /// <param name="_dto"></param>
  6023. /// <returns></returns>
  6024. [HttpPost]
  6025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6026. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6027. {
  6028. var validator = new VisaCommissionCreateDtoValidator();
  6029. var validatorRes = await validator.ValidateAsync(_dto);
  6030. if (!validatorRes.IsValid)
  6031. {
  6032. StringBuilder sb = new StringBuilder();
  6033. foreach (var item in validatorRes.Errors)
  6034. {
  6035. sb.AppendLine(item.ErrorMessage);
  6036. }
  6037. return Ok(JsonView(false, sb.ToString()));
  6038. }
  6039. return Ok(await _visaCommissionRep.Create(_dto));
  6040. }
  6041. /// <summary>
  6042. /// 签证提成录入
  6043. /// Put(编辑)
  6044. /// </summary>
  6045. /// <param name="id"></param>
  6046. /// <param name="_dto"></param>
  6047. /// <returns></returns>
  6048. [HttpPut]
  6049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6050. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6051. {
  6052. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6053. var validator = new VisaCommissionCreateDtoValidator();
  6054. var validatorRes = await validator.ValidateAsync(_dto);
  6055. if (!validatorRes.IsValid)
  6056. {
  6057. StringBuilder sb = new StringBuilder();
  6058. foreach (var item in validatorRes.Errors)
  6059. {
  6060. sb.AppendLine(item.ErrorMessage);
  6061. }
  6062. return Ok(JsonView(false, sb.ToString()));
  6063. }
  6064. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6065. }
  6066. /// <summary>
  6067. /// 签证提成录入
  6068. /// Del
  6069. /// </summary>
  6070. /// <param name="id"></param>
  6071. /// <param name="currUserId"></param>
  6072. /// <returns></returns>
  6073. [HttpPost]
  6074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6075. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6076. {
  6077. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6078. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6079. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6080. }
  6081. #endregion
  6082. #region op费用录入
  6083. /// <summary>
  6084. /// 根据diid查询op费用列表
  6085. /// </summary>
  6086. /// <param name="dto"></param>
  6087. /// <returns></returns>
  6088. [HttpPost]
  6089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6090. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6091. {
  6092. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6093. if (groupData.Code != 0)
  6094. {
  6095. return Ok(JsonView(false, groupData.Msg));
  6096. }
  6097. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6098. }
  6099. /// <summary>
  6100. /// 根据op费用Id查询单条数据及c表数据
  6101. /// </summary>
  6102. /// <param name="dto"></param>
  6103. /// <returns></returns>
  6104. [HttpPost]
  6105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6106. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6107. {
  6108. try
  6109. {
  6110. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6111. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6112. var data = new
  6113. {
  6114. CarTouristGuideGround = _groupData,
  6115. CreditCardPayment = _creditCardPayment
  6116. };
  6117. return Ok(JsonView(true, "查询成功!", data));
  6118. }
  6119. catch (Exception ex)
  6120. {
  6121. return Ok(JsonView(false, "程序错误!"));
  6122. }
  6123. }
  6124. /// <summary>
  6125. /// op费用删除
  6126. /// </summary>
  6127. /// <param name="dto"></param>
  6128. /// <returns></returns>
  6129. [HttpPost]
  6130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6131. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6132. {
  6133. try
  6134. {
  6135. _sqlSugar.BeginTran();
  6136. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6137. if (!res)
  6138. {
  6139. return Ok(JsonView(false, "删除失败"));
  6140. }
  6141. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6142. {
  6143. IsDel = 1,
  6144. DeleteUserId = dto.DeleteUserId,
  6145. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6146. }).ExecuteCommandAsync();
  6147. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6148. {
  6149. IsDel = 1,
  6150. DeleteUserId = dto.DeleteUserId,
  6151. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6152. }).ExecuteCommandAsync();
  6153. #region 删除超支相关数据
  6154. //删除导入的超支数据
  6155. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6156. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6157. {
  6158. IsDel = 1,
  6159. DeleteUserId = dto.DeleteUserId,
  6160. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6161. }).ExecuteCommand();
  6162. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6163. {
  6164. IsDel = 1,
  6165. DeleteUserId = dto.DeleteUserId,
  6166. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6167. }).ExecuteCommand();
  6168. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6169. {
  6170. IsDel = 1,
  6171. DeleteUserId = dto.DeleteUserId,
  6172. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6173. }).ExecuteCommand();
  6174. #endregion
  6175. _sqlSugar.CommitTran();
  6176. return Ok(JsonView(true, "删除成功!"));
  6177. }
  6178. catch (Exception ex)
  6179. {
  6180. _sqlSugar.RollbackTran();
  6181. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6182. }
  6183. }
  6184. /// <summary>
  6185. /// op费用录入操作(Status:1.新增,2.修改)
  6186. /// </summary>
  6187. /// <param name="dto"></param>
  6188. /// <returns></returns>
  6189. [HttpPost]
  6190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6191. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6192. {
  6193. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6194. if (groupData.Code != 0)
  6195. {
  6196. return Ok(JsonView(false, groupData.Msg));
  6197. }
  6198. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6199. }
  6200. /// <summary>
  6201. /// 填写费用详细页面初始化绑定
  6202. /// </summary>
  6203. /// <param name="dto"></param>
  6204. /// <returns></returns>
  6205. [HttpPost]
  6206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6207. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6208. {
  6209. try
  6210. {
  6211. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6212. if (groupData.Code != 0)
  6213. {
  6214. return Ok(JsonView(false, groupData.Msg));
  6215. }
  6216. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6217. }
  6218. catch (Exception ex)
  6219. {
  6220. return Ok(JsonView(false, ex.Message));
  6221. }
  6222. }
  6223. /// <summary>
  6224. /// 根据op费用Id查询详细数据
  6225. /// </summary>
  6226. /// <param name="dto"></param>
  6227. /// <returns></returns>
  6228. [HttpPost]
  6229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6230. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6231. {
  6232. try
  6233. {
  6234. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6235. if (groupData.Code != 0)
  6236. {
  6237. return Ok(JsonView(false, groupData.Msg));
  6238. }
  6239. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6240. }
  6241. catch (Exception ex)
  6242. {
  6243. return Ok(JsonView(false, ex.Message));
  6244. }
  6245. }
  6246. /// <summary>
  6247. /// OP费用录入填写详情
  6248. /// </summary>
  6249. /// <param name="dto"></param>
  6250. /// <returns></returns>
  6251. [HttpPost]
  6252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6253. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6254. {
  6255. try
  6256. {
  6257. #region 参数校验
  6258. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6259. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6260. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6261. #endregion
  6262. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6263. if (groupData.Code != 0)
  6264. {
  6265. return Ok(JsonView(false, groupData.Msg));
  6266. }
  6267. //自动审核
  6268. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6269. #region 应用推送
  6270. try
  6271. {
  6272. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6273. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6274. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6275. }
  6276. catch (Exception ex)
  6277. {
  6278. }
  6279. #endregion
  6280. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6281. }
  6282. catch (Exception ex)
  6283. {
  6284. return Ok(JsonView(false, ex.Message));
  6285. }
  6286. }
  6287. /// <summary>
  6288. /// 获取三公详细所有城市
  6289. /// </summary>
  6290. /// <returns></returns>
  6291. [HttpGet]
  6292. public IActionResult OpCarCityResult()
  6293. {
  6294. var jw = JsonView(false);
  6295. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6296. {
  6297. x.Id,
  6298. x.Country,
  6299. x.City,
  6300. }).ToList();
  6301. if (data.Count > 0)
  6302. {
  6303. jw = JsonView(true, "获取成功!", data);
  6304. }
  6305. else
  6306. {
  6307. jw.Msg = "城市数据为空!";
  6308. jw.Data = new string[0];
  6309. }
  6310. return Ok(jw);
  6311. }
  6312. /// <summary>
  6313. /// 导出地接费用明细
  6314. /// </summary>
  6315. /// <param name="dto"></param>
  6316. /// <returns></returns>
  6317. [HttpPost]
  6318. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6319. {
  6320. var jw = JsonView(false);
  6321. if (dto.Diid < 1)
  6322. {
  6323. jw.Msg = "请输入正确的diid!";
  6324. return Ok(jw);
  6325. }
  6326. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6327. if (group == null)
  6328. {
  6329. jw.Msg = "未找到团组信息!";
  6330. return Ok(jw);
  6331. }
  6332. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6333. if (localGuideArr.Count == 0)
  6334. {
  6335. jw.Msg = "该团组暂无地接信息!";
  6336. return Ok(jw);
  6337. }
  6338. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6339. var overspendSoure = new Dictionary<int, int>
  6340. {
  6341. { 91, 982 }, //车
  6342. { 92 , 1059} ,//导游
  6343. { 994 , 1073}, //翻译
  6344. { 988 , 1074 }, //早餐
  6345. { 93 , 1075 }, //午餐
  6346. { 989 , 1076 }, //晚餐
  6347. };
  6348. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6349. foreach (var groupArr in localGroup)
  6350. {
  6351. var keyValue = groupArr.Key;
  6352. if (int.TryParse(keyValue, out int cityid))
  6353. {
  6354. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6355. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6356. }
  6357. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6358. foreach (var item in groupArr)
  6359. {
  6360. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6361. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6362. new Grp_CarTouristGuideGroundReservationsContentExtend
  6363. {
  6364. Count = a.Count,
  6365. CreateTime = a.CreateTime,
  6366. CreateUserId = a.CreateUserId,
  6367. CTGGRId = a.CTGGRId,
  6368. Currency = a.Currency,
  6369. DatePrice = a.DatePrice,
  6370. DeleteTime = a.DeleteTime,
  6371. DeleteUserId = a.DeleteUserId,
  6372. DiId = a.DiId,
  6373. Id = a.Id,
  6374. IsDel = a.IsDel,
  6375. Price = a.Price,
  6376. PriceContent = a.PriceContent,
  6377. Remark = a.Remark,
  6378. SId = a.SId,
  6379. SidName = b.Name,
  6380. Units = a.Units,
  6381. }
  6382. ).ToList();
  6383. if (content.Count > 0)
  6384. {
  6385. contentArr.Add(content);
  6386. }
  6387. }
  6388. //open excel
  6389. //set excel
  6390. //save excel
  6391. try
  6392. {
  6393. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6394. IWorkbook workbook;
  6395. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6396. {
  6397. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6398. }
  6399. else
  6400. {
  6401. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6402. }
  6403. ISheet sheet = workbook.GetSheetAt(0);
  6404. var rowStartIndex = 2;
  6405. var clounmCount = 10;
  6406. var initStyleRow = sheet.GetRow(2);
  6407. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6408. //var overspendArrDetail =
  6409. var existsId = new List<CarCompare>();
  6410. var lastElem = arr.Last();
  6411. var thisSid = -1;
  6412. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6413. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6414. {
  6415. Name = "未知币种!",
  6416. Remark = "未知币种!",
  6417. };
  6418. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6419. Action cloneRowFn = () =>
  6420. {
  6421. rowStartIndex++;
  6422. var cloneRow = sheet.CreateRow(rowStartIndex);
  6423. // 复制样式
  6424. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6425. {
  6426. ICell sourceCell = initStyleRow.GetCell(i);
  6427. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6428. // 确保单元格存在样式
  6429. if (sourceCell.CellStyle != null)
  6430. {
  6431. targetCell.CellStyle = sourceCell.CellStyle;
  6432. }
  6433. }
  6434. };
  6435. var mergeRow = () =>
  6436. {
  6437. for (int i = 2; i < sheet.LastRowNum; i++)
  6438. {
  6439. var row = sheet.GetRow(i);
  6440. var cellFirst = row.GetCell(0);
  6441. var thisIndex = i + 1;
  6442. while (thisIndex < sheet.LastRowNum)
  6443. {
  6444. var nextRow = sheet.GetRow(thisIndex);
  6445. var nextCellFirst = nextRow.GetCell(0);
  6446. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6447. {
  6448. thisIndex++;
  6449. }
  6450. else
  6451. {
  6452. break;
  6453. }
  6454. }
  6455. thisIndex--;
  6456. if (thisIndex != i)
  6457. {
  6458. //合并row
  6459. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6460. i, // 起始行索引(0-based)
  6461. thisIndex, // 结束行索引(0-based)
  6462. 0, // 起始列索引(0-based)
  6463. 0 // 结束列索引(0-based)
  6464. );
  6465. sheet.AddMergedRegion(cellRangeAddress);
  6466. i = thisIndex;
  6467. }
  6468. }
  6469. };
  6470. var chaoshiNumber = 0;
  6471. var totalNumber = 0.00M;
  6472. string lastStr = "";
  6473. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6474. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6475. {
  6476. b.IsAuditGM,
  6477. x.Id,
  6478. x.Area,
  6479. b.PayPercentage,
  6480. b.PayMoney,
  6481. }).ToList();
  6482. string yesPayment = "", noPayment = "";
  6483. foreach (var item in queryCarArrByCityAndDiid)
  6484. {
  6485. if (item.IsAuditGM == 1)
  6486. {
  6487. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6488. }
  6489. else
  6490. {
  6491. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6492. }
  6493. }
  6494. lastStr = yesPayment + noPayment;
  6495. foreach (var item in arr)
  6496. {
  6497. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6498. {
  6499. if (thisSid != item.SId)
  6500. {
  6501. if (thisSid == -1)
  6502. {
  6503. thisSid = item.SId;
  6504. }
  6505. else
  6506. {
  6507. //合并小计行
  6508. //创建合并区域的实例
  6509. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6510. rowStartIndex, // 起始行索引(0-based)
  6511. rowStartIndex, // 结束行索引(0-based)
  6512. 0, // 起始列索引(0-based)
  6513. 3 // 结束列索引(0-based)
  6514. );
  6515. sheet.AddMergedRegion(cellRangeAddress);
  6516. var CellStyle = workbook.CreateCellStyle();
  6517. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6518. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6519. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6520. for (int i = 0; i <= clounmCount; i++)
  6521. {
  6522. if (i > 6)
  6523. {
  6524. var CellStyle1 = workbook.CreateCellStyle();
  6525. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6526. IFont Font = workbook.CreateFont(); // 创建字体
  6527. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6528. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6529. CellStyle1.SetFont(Font);
  6530. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6531. }
  6532. else
  6533. {
  6534. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6535. }
  6536. }
  6537. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6538. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6539. //超时合计
  6540. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6541. //超时数
  6542. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6543. //超时合计费用
  6544. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6545. thisSid = item.SId;
  6546. cloneRowFn();
  6547. chaoshiNumber = 0;
  6548. totalNumber = 0;
  6549. }
  6550. }
  6551. IRow row = sheet.GetRow(rowStartIndex);
  6552. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6553. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6554. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6555. if (isOpenOverspendSoure)
  6556. {
  6557. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6558. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6559. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6560. }
  6561. for (int i = 0; i <= clounmCount; i++)
  6562. {
  6563. var cell = row.GetCell(i);
  6564. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6565. if (cell == null)
  6566. {
  6567. cell = row.CreateCell(i);
  6568. }
  6569. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6570. fontRed.CloneStyleFrom(cell.CellStyle);
  6571. IFont Font = workbook.CreateFont(); // 创建字体
  6572. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6573. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6574. fontRed.SetFont(Font);
  6575. byte[] rgb = new byte[3] { 255, 242, 204 };
  6576. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6577. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6578. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6579. if (workbook is XSSFWorkbook)
  6580. {
  6581. BackgroundColor255_242_204.FillForegroundColor = 0;
  6582. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6583. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6584. }
  6585. else
  6586. {
  6587. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6588. }
  6589. if (i == 1 || i > 6)
  6590. {
  6591. if (i > 6)
  6592. {
  6593. fontRed.FillForegroundColor = 0;
  6594. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6595. fontRed.FillPattern = FillPattern.SolidForeground;
  6596. }
  6597. cell.CellStyle = fontRed;
  6598. }
  6599. if (i > 2 && i < 7)
  6600. {
  6601. cell.CellStyle = BackgroundColor255_242_204;
  6602. }
  6603. cell.SetCellValue(setCellValue); //写入单元格
  6604. }
  6605. if (overspendSoure.ContainsKey(thisSid))
  6606. {
  6607. var overspendId = overspendSoure[thisSid];
  6608. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6609. }
  6610. cloneRowFn();
  6611. existsId.Add(new CarCompare
  6612. {
  6613. DataPrice = item.DatePrice.ObjToDate(),
  6614. Sid = item.SId
  6615. });
  6616. }
  6617. if (item.Equals(lastElem))
  6618. {
  6619. //合并小计行
  6620. //创建合并区域的实例
  6621. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6622. rowStartIndex, // 起始行索引(0-based)
  6623. rowStartIndex, // 结束行索引(0-based)
  6624. 0, // 起始列索引(0-based)
  6625. 3 // 结束列索引(0-based)
  6626. );
  6627. sheet.AddMergedRegion(cellRangeAddress);
  6628. var CellStyle = workbook.CreateCellStyle();
  6629. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6630. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6631. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6632. for (int i = 0; i <= clounmCount; i++)
  6633. {
  6634. if (i > 6)
  6635. {
  6636. var CellStyle1 = workbook.CreateCellStyle();
  6637. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6638. IFont Font = workbook.CreateFont(); // 创建字体
  6639. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6640. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6641. CellStyle1.SetFont(Font);
  6642. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6643. }
  6644. else
  6645. {
  6646. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6647. }
  6648. }
  6649. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6650. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6651. //超时合计
  6652. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6653. //超时数
  6654. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6655. //超时合计费用
  6656. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6657. cloneRowFn();
  6658. // 创建合并区域的实例
  6659. cellRangeAddress = new CellRangeAddress(
  6660. rowStartIndex, // 起始行索引(0-based)
  6661. rowStartIndex, // 结束行索引(0-based)
  6662. 0, // 起始列索引(0-based)
  6663. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6664. );
  6665. // 添加合并区域
  6666. sheet.AddMergedRegion(cellRangeAddress);
  6667. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6668. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6669. }
  6670. }
  6671. mergeRow();
  6672. // 保存修改后的Excel文件到新文件
  6673. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6674. // new FileStream(newFilePath, FileMode.CreateNew)
  6675. using (var stream = new MemoryStream())
  6676. {
  6677. workbook.Write(stream, true);
  6678. stream.Flush();
  6679. stream.Seek(0, SeekOrigin.Begin);
  6680. MemoryStream memoryStream = new MemoryStream();
  6681. stream.CopyTo(memoryStream);
  6682. memoryStream.Seek(0, SeekOrigin.Begin);
  6683. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6684. }
  6685. workbook.Close();
  6686. workbook.Dispose();
  6687. }
  6688. catch (Exception ex)
  6689. {
  6690. jw.Msg = "出现异常!" + ex.Message;
  6691. return Ok(jw);
  6692. }
  6693. }
  6694. if (Zips.Count > 0)
  6695. {
  6696. IOOperatorHelper io = new IOOperatorHelper();
  6697. var byts = io.ConvertZipStream(Zips);
  6698. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6699. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6700. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6701. }
  6702. else
  6703. {
  6704. jw.Msg = "暂无生成文件!";
  6705. }
  6706. return Ok(jw);
  6707. }
  6708. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6709. {
  6710. string outStr = string.Empty;
  6711. switch (i)
  6712. {
  6713. case 0:
  6714. outStr = arr[0].SidName;
  6715. break;
  6716. case 1:
  6717. outStr = arr[0].DataPriceStr;
  6718. break;
  6719. case 2:
  6720. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6721. break;
  6722. case 4:
  6723. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6724. break;
  6725. case 7:
  6726. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6727. {
  6728. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6729. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6730. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6731. }
  6732. break;
  6733. case 8:
  6734. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6735. {
  6736. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6737. }
  6738. break;
  6739. case 9:
  6740. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6741. {
  6742. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6743. }
  6744. break;
  6745. case 10:
  6746. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6747. {
  6748. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6749. }
  6750. break;
  6751. }
  6752. return outStr;
  6753. }
  6754. #region OP行程单
  6755. /// <summary>
  6756. /// OP行程单初始化
  6757. /// </summary>
  6758. /// <param name="dto"></param>
  6759. /// <returns></returns>
  6760. [HttpPost]
  6761. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6762. {
  6763. var jw = JsonView(false);
  6764. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6765. var group = groupList.First();
  6766. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6767. if (group == null)
  6768. {
  6769. jw.Msg = "暂无团组!";
  6770. return Ok(jw);
  6771. }
  6772. group = groupList.Find(x => x.Id == diid);
  6773. if (group == null)
  6774. {
  6775. jw.Msg = "请输入正确的团组ID!";
  6776. return Ok(jw);
  6777. }
  6778. string city = string.Empty;
  6779. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6780. if (blackCode.Count > 0)
  6781. {
  6782. var black = blackCode.First();
  6783. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6784. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6785. if (blackSp.Length > 0)
  6786. {
  6787. try
  6788. {
  6789. var cityArrCode = new List<string>(20);
  6790. foreach (var item in blackSp)
  6791. {
  6792. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6793. var IndexSelect = itemSp[2];
  6794. var cityArrCodeLength = cityArrCode.Count - 1;
  6795. var startCity = IndexSelect.Substring(0, 3);
  6796. if (cityArrCodeLength > 0)
  6797. {
  6798. var arrEndCity = cityArrCode[cityArrCodeLength];
  6799. if (arrEndCity != startCity)
  6800. {
  6801. cityArrCode.Add(startCity.ToUpper());
  6802. }
  6803. }
  6804. else
  6805. {
  6806. cityArrCode.Add(startCity.ToUpper());
  6807. }
  6808. var endCity = IndexSelect.Substring(3, 3);
  6809. cityArrCode.Add(endCity.ToUpper());
  6810. }
  6811. var cityThree = string.Empty;
  6812. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6813. cityThree = cityThree.TrimEnd(',');
  6814. if (string.IsNullOrWhiteSpace(cityThree))
  6815. {
  6816. throw new
  6817. Exception("error");
  6818. }
  6819. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6820. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6821. foreach (var item in cityArrCode)
  6822. {
  6823. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6824. if (find != null)
  6825. {
  6826. city += find.City + "/";
  6827. }
  6828. else
  6829. {
  6830. city += item + "三字码未收入/";
  6831. }
  6832. }
  6833. city = city.TrimEnd('/');
  6834. }
  6835. catch (Exception e)
  6836. {
  6837. city = "黑屏代码格式不正确!";
  6838. }
  6839. }
  6840. }
  6841. else
  6842. {
  6843. city = "未录入黑屏代码";
  6844. }
  6845. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6846. {
  6847. Date = x.Date,
  6848. Days = x.Days,
  6849. Diffgroup = x.Diffgroup,
  6850. Diid = x.Diid,
  6851. Traffic_First = x.Traffic_First,
  6852. Traffic_Second = x.Traffic_Second,
  6853. Trip = x.Trip,
  6854. WeekDay = x.WeekDay,
  6855. Id = x.Id
  6856. }).ToList();
  6857. jw.Data = new
  6858. {
  6859. groupList = groupList.Select(x => new
  6860. {
  6861. x.Id,
  6862. x.TeamName,
  6863. x.TourCode
  6864. }).ToList(),
  6865. groupInfo = new
  6866. {
  6867. group.VisitDays,
  6868. group.TourCode,
  6869. group.VisitPNumber,
  6870. group.TeamName,
  6871. city
  6872. },
  6873. OpTravelList
  6874. };
  6875. jw.Code = 200;
  6876. jw.Msg = "操作成功!";
  6877. return Ok(jw);
  6878. }
  6879. /// <summary>
  6880. /// 删除团组行程单
  6881. /// </summary>
  6882. /// <returns></returns>
  6883. [HttpPost]
  6884. public IActionResult DelTravel(DelOpTravelDto dto)
  6885. {
  6886. var jw = JsonView(false);
  6887. if (dto.UserId <= 0 || dto.Diid <= 0)
  6888. {
  6889. jw.Msg = "请输入正确的参数!";
  6890. return Ok(jw);
  6891. }
  6892. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6893. .SetColumns(x => new Grp_TravelList
  6894. {
  6895. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6896. DeleteUserId = dto.UserId,
  6897. IsDel = 1,
  6898. }).ExecuteCommand();
  6899. jw = JsonView(true);
  6900. return Ok(jw);
  6901. }
  6902. /// <summary>
  6903. /// 行程单保存
  6904. /// </summary>
  6905. /// <returns></returns>
  6906. [HttpPost]
  6907. public IActionResult TravelSave(TravelSaveDto dto)
  6908. {
  6909. var jw = JsonView(false);
  6910. if (dto.Arr.Count > 0)
  6911. {
  6912. try
  6913. {
  6914. _sqlSugar.BeginTran();
  6915. foreach (var item in dto.Arr)
  6916. {
  6917. if (item.Id == 0)
  6918. {
  6919. throw new Exception("请传入正确的Id");
  6920. }
  6921. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6922. .SetColumns(x => new Grp_TravelList
  6923. {
  6924. Trip = item.Trip
  6925. }).ExecuteCommand();
  6926. }
  6927. _sqlSugar.CommitTran();
  6928. jw = JsonView(true);
  6929. }
  6930. catch (Exception ex)
  6931. {
  6932. _sqlSugar.RollbackTran();
  6933. jw.Msg = "程序异常!" + ex.Message;
  6934. }
  6935. }
  6936. else
  6937. {
  6938. jw.Msg = "请传入正确的参数!";
  6939. }
  6940. return Ok(jw);
  6941. }
  6942. /// <summary>
  6943. /// 导出行程单
  6944. /// </summary>
  6945. /// <param name="dto"></param>
  6946. /// <returns></returns>
  6947. [HttpPost]
  6948. public IActionResult ExportTravel(ExportTravelDto dto)
  6949. {
  6950. var jw = JsonView(false);
  6951. jw.Data = "";
  6952. int diid = 0;
  6953. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6954. if (Find == null)
  6955. {
  6956. jw.Msg = "请选择正确的团组!";
  6957. return Ok(jw);
  6958. }
  6959. else
  6960. {
  6961. diid = Find.Id;
  6962. }
  6963. //数据源
  6964. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6965. DataTable dtBlack = null;
  6966. try
  6967. {
  6968. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6969. }
  6970. catch (Exception)
  6971. {
  6972. jw.Msg = "机票黑屏代码有误!";
  6973. return Ok(jw);
  6974. }
  6975. string CityStr = string.Empty;
  6976. if (dtBlack.Rows.Count == 0)
  6977. {
  6978. jw.Msg = "机票黑屏代码有误!";
  6979. return Ok(jw);
  6980. }
  6981. else
  6982. {
  6983. foreach (DataRow row in dtBlack.Rows)
  6984. {
  6985. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6986. {
  6987. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6988. return Ok(jw);
  6989. }
  6990. }
  6991. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6992. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6993. }
  6994. //创建数据源Table
  6995. DataTable dtSource = new DataTable();
  6996. dtSource.Columns.Add("Days", typeof(string));
  6997. dtSource.Columns.Add("Date", typeof(string));
  6998. dtSource.Columns.Add("Week", typeof(string));
  6999. dtSource.Columns.Add("Traffic", typeof(string));
  7000. dtSource.Columns.Add("Trip", typeof(string));
  7001. //获取数据,放到datatable
  7002. foreach (var item in _travelList)
  7003. {
  7004. DataRow dr = dtSource.NewRow();
  7005. dr["Days"] = item.Days;
  7006. dr["Date"] = item.Date;
  7007. dr["Week"] = item.WeekDay;
  7008. dr["Traffic"] = item.Traffic_First
  7009. + "\r\n"
  7010. + item.Traffic_Second;
  7011. dr["Trip"] = item.Trip;
  7012. dtSource.Rows.Add(dr);
  7013. }
  7014. Dictionary<string, string> dic = new Dictionary<string, string>();
  7015. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7016. dic.Add("City", CityStr);
  7017. dic.Add("Days", Find.VisitDays.ToString());
  7018. dic.Add("DeleCode", Find.TourCode);
  7019. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7020. //模板路径
  7021. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7022. //载入模板
  7023. Document doc = null;
  7024. DocumentBuilder builder = null;
  7025. try
  7026. {
  7027. //载入模板
  7028. doc = new Document(tempPath);
  7029. builder = new DocumentBuilder(doc);
  7030. }
  7031. catch (Exception)
  7032. {
  7033. jw.Msg = "模板位置不存在!";
  7034. return Ok(jw);
  7035. }
  7036. foreach (var key in dic.Keys)
  7037. {
  7038. Bookmark bookmark = doc.Range.Bookmarks[key];
  7039. if (bookmark != null)
  7040. {
  7041. builder.MoveToBookmark(key);
  7042. builder.Write(dic[key]);
  7043. }
  7044. }
  7045. //获取word里所有表格
  7046. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7047. //获取所填表格的序数
  7048. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7049. try
  7050. {
  7051. //循环赋值
  7052. for (int i = 0; i < dtSource.Rows.Count; i++)
  7053. {
  7054. builder.MoveToCell(0, i + 1, 0, 0);
  7055. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7056. builder.MoveToCell(0, i + 1, 1, 0);
  7057. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7058. builder.MoveToCell(0, i + 1, 2, 0);
  7059. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7060. var trip = dtSource.Rows[i]["Trip"].ToString();
  7061. builder.MoveToCell(0, i + 1, 3, 0);
  7062. builder.Write(trip);
  7063. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7064. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7065. // 获取特定索引的段落
  7066. Paragraph paragraph = (Paragraph)paragraphs[0];
  7067. Run run = paragraph.Runs[0];
  7068. Aspose.Words.Font font = run.Font;
  7069. font.Name = "黑体";
  7070. //设置双休红色
  7071. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7072. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7073. paragraph = (Paragraph)paragraphs[1];
  7074. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7075. {
  7076. run = paragraph.Runs[0];
  7077. font = run.Font;
  7078. font.Color = Color.Red;
  7079. }
  7080. }
  7081. }
  7082. catch (Exception ex)
  7083. {
  7084. }
  7085. //删除多余行
  7086. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7087. {
  7088. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7089. }
  7090. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7091. if (!Directory.Exists(savePath))
  7092. {
  7093. try
  7094. {
  7095. Directory.CreateDirectory(savePath);
  7096. }
  7097. catch
  7098. {
  7099. }
  7100. }
  7101. string path = savePath + Find.TeamName + "出访日程";
  7102. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7103. try
  7104. {
  7105. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7106. string postfix = ".docx";
  7107. if (dto.IsPDF == 1)
  7108. {
  7109. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7110. postfix = ".pdf";
  7111. }
  7112. doc.Save(path + postfix, saveFormat);
  7113. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7114. }
  7115. catch (Exception)
  7116. {
  7117. jw = JsonView(false);
  7118. }
  7119. return Ok(jw);
  7120. }
  7121. /// <summary>
  7122. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7123. /// </summary>
  7124. /// <param name="num"></param>
  7125. /// <returns></returns>
  7126. string GetNum(string num)
  7127. {
  7128. string str = "";
  7129. switch (num)
  7130. {
  7131. case "1":
  7132. str = "一";
  7133. break;
  7134. case "2":
  7135. str = "二";
  7136. break;
  7137. case "3":
  7138. str = "三";
  7139. break;
  7140. case "4":
  7141. str = "四";
  7142. break;
  7143. case "5":
  7144. str = "五";
  7145. break;
  7146. case "6":
  7147. str = "六";
  7148. break;
  7149. case "7":
  7150. str = "七";
  7151. break;
  7152. case "8":
  7153. str = "八";
  7154. break;
  7155. case "9":
  7156. str = "九";
  7157. break;
  7158. case "10":
  7159. str = "十";
  7160. break;
  7161. case "11":
  7162. str = "十一";
  7163. break;
  7164. case "12":
  7165. str = "十二";
  7166. break;
  7167. case "一":
  7168. str = "1";
  7169. break;
  7170. case "二":
  7171. str = "2";
  7172. break;
  7173. case "三":
  7174. str = "3";
  7175. break;
  7176. case "四":
  7177. str = "4";
  7178. break;
  7179. case "五":
  7180. str = "5";
  7181. break;
  7182. case "六":
  7183. str = "6";
  7184. break;
  7185. case "七":
  7186. str = "7";
  7187. break;
  7188. case "八":
  7189. str = "8";
  7190. break;
  7191. case "九":
  7192. str = "9";
  7193. break;
  7194. case "十":
  7195. str = "10";
  7196. break;
  7197. case "十一":
  7198. str = "11";
  7199. break;
  7200. case "十二":
  7201. str = "12";
  7202. break;
  7203. }
  7204. return str;
  7205. }
  7206. #endregion
  7207. #endregion
  7208. #region 团组成本
  7209. /// <summary>
  7210. /// 团组成本数据初始化
  7211. /// </summary>
  7212. /// <param name="dto"></param>
  7213. /// <returns></returns>
  7214. [HttpPost]
  7215. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7216. {
  7217. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7218. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7219. WHEN COUNT(*) >= 0 THEN 'True'
  7220. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7221. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7222. ").ToList(); //团组列表
  7223. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7224. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7225. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7226. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7227. if (groupinfoValue != null)
  7228. {
  7229. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7230. var spArr = new string[1] { countryArr };
  7231. if (countryArr.Contains("|"))
  7232. {
  7233. spArr = countryArr.Split("|");
  7234. }
  7235. else if (countryArr.Contains("、"))
  7236. {
  7237. spArr = countryArr.Split("、");
  7238. }
  7239. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7240. {
  7241. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7242. if (dbQueryCountry != null)
  7243. {
  7244. visaCountryInfoArr.Add(dbQueryCountry);
  7245. }
  7246. }
  7247. }
  7248. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7249. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7250. var create = _GroupCostRepository.
  7251. CreateGroupCostByBlackCode(dto.Diid);
  7252. if (groupCost.Count == 0 && create.Code == 0)
  7253. {
  7254. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7255. }
  7256. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7257. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7258. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7259. groupCostMap = groupCostMap.Select(x =>
  7260. {
  7261. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7262. {
  7263. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7264. }
  7265. return x;
  7266. }).ToList();
  7267. //GroupCostParameter.Add(new
  7268. // Grp_GroupCostParameter());
  7269. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7270. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7271. return Ok(JsonView(new
  7272. {
  7273. groupList,
  7274. groupInfo,
  7275. groupChecks,
  7276. groupCost = groupCostMap,
  7277. hotelNumber,
  7278. GroupCostParameter = GroupCostParameterMap,
  7279. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7280. {
  7281. x.VisaCountry,
  7282. x.VisaPrice,
  7283. x.Id,
  7284. }).ToList(),
  7285. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7286. blackCodeIsTrue = create.Code == 0 ? true : false,
  7287. hotelIsTrue = hotelIsTrue,
  7288. }));
  7289. }
  7290. /// <summary>
  7291. /// 团组成本信息保存
  7292. /// </summary>
  7293. /// <param name="dto"></param>
  7294. /// <returns></returns>
  7295. [HttpPost]
  7296. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7297. {
  7298. if (dto.Diid <= 0 || dto.Userid <= 0)
  7299. {
  7300. return Ok(JsonView(false));
  7301. }
  7302. JsonView jw = null;
  7303. bool isTrue = false;
  7304. #region 复制团组成本
  7305. //if (dto.Diid == 2581)
  7306. //{
  7307. // dto.Diid = 2599;
  7308. // dto.CheckBoxs.ForEach(x =>
  7309. // {
  7310. // x.Diid = 2599;
  7311. // });
  7312. // dto.GroupCosts.ForEach(x =>
  7313. // {
  7314. // x.Diid = 2599;
  7315. // });
  7316. // dto.CostTypeHotelNumbers.ForEach(x =>
  7317. // {
  7318. // x.Diid = 2599;
  7319. // });
  7320. // dto.GroupCostParameters.ForEach(x =>
  7321. // {
  7322. // x.DiId = 2599;
  7323. // });
  7324. //}
  7325. #endregion
  7326. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7327. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7328. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7329. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7330. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7331. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7332. try
  7333. {
  7334. _sqlSugar.BeginTran();
  7335. isTrue = await _GroupCostRepository.
  7336. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7337. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7338. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7339. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7340. _sqlSugar.CommitTran();
  7341. jw = JsonView(true, "保存成功!", isTrue);
  7342. }
  7343. catch (Exception)
  7344. {
  7345. _sqlSugar.RollbackTran();
  7346. jw = JsonView(false);
  7347. }
  7348. return Ok(jw);
  7349. }
  7350. /// <summary>
  7351. /// 司兼导数据
  7352. /// </summary>
  7353. /// <param name="dto"></param>
  7354. /// <returns></returns>
  7355. [HttpPost]
  7356. public IActionResult GetCarGuides(CarGuidesDto dto)
  7357. {
  7358. JsonView jw = null;
  7359. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7360. jw = JsonView(true, "获取成功!", Data);
  7361. return Ok(jw);
  7362. }
  7363. /// <summary>
  7364. /// 导游数据
  7365. /// </summary>
  7366. /// <param name="dto"></param>
  7367. /// <returns></returns>
  7368. [HttpPost]
  7369. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7370. {
  7371. JsonView jw = null;
  7372. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7373. // 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
  7374. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7375. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7376. jw = JsonView(true, "获取成功!", Data);
  7377. return Ok(jw);
  7378. }
  7379. /// <summary>
  7380. /// 成本车数据
  7381. /// </summary>
  7382. /// <param name="dto"></param>
  7383. /// <returns></returns>
  7384. [HttpPost]
  7385. public IActionResult GetCarInfo(CarGuidesDto dto)
  7386. {
  7387. JsonView jw = null;
  7388. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7389. jw = JsonView(true, "获取成功!", Data);
  7390. return Ok(jw);
  7391. }
  7392. /// <summary>
  7393. /// 景点数据
  7394. /// </summary>
  7395. /// <param name="dto"></param>
  7396. /// <returns></returns>
  7397. [HttpPost]
  7398. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7399. {
  7400. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7401. return Ok(JsonView(true, "获取成功!", Data));
  7402. }
  7403. /// <summary>
  7404. /// 成本通知
  7405. /// </summary>
  7406. /// <param name="dto"></param>
  7407. /// <returns></returns>
  7408. [HttpPost]
  7409. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7410. {
  7411. if (dto.Diid < 0)
  7412. {
  7413. return Ok(JsonView(false));
  7414. }
  7415. JsonView jw = null;
  7416. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7417. if (GroupCostParameter != null)
  7418. {
  7419. int IsShare = 0;
  7420. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7421. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7422. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7423. string msg = string.Empty;
  7424. if (isTrue)
  7425. {
  7426. if (IsShare == 0)
  7427. {
  7428. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7429. }
  7430. else
  7431. {
  7432. #region 企微通知对应岗位用户
  7433. try
  7434. {
  7435. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7436. }
  7437. catch (Exception ex)
  7438. {
  7439. }
  7440. #endregion
  7441. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7442. }
  7443. jw = JsonView(isTrue, msg, new { IsShare });
  7444. }
  7445. else
  7446. {
  7447. msg = "修改失败!";
  7448. jw = JsonView(isTrue, msg);
  7449. }
  7450. }
  7451. else
  7452. {
  7453. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7454. }
  7455. return Ok(jw);
  7456. }
  7457. /// <summary>
  7458. /// 导出报价单
  7459. /// </summary>
  7460. /// <param name="dto"></param>
  7461. /// <returns></returns>
  7462. [HttpPost]
  7463. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7464. {
  7465. if (dto.Diid == 0)
  7466. {
  7467. return Ok(JsonView(false, "请传递团组id"));
  7468. }
  7469. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7470. if (deleInfo.Code != 0)
  7471. {
  7472. return Ok(JsonView(false, "团组信息查询失败!"));
  7473. }
  7474. var di = deleInfo.Data as DelegationInfoWebView;
  7475. if (di != null)
  7476. {
  7477. di.TeamName = di.TeamName.Replace("|", "、");
  7478. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7479. //文件名
  7480. string strFileName = di.TeamName + "-收款账单.doc";
  7481. //获取模板
  7482. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7483. //载入模板
  7484. Document doc = new Document(tmppath);
  7485. decimal TotalPrice = 0.00M;
  7486. string itemStr = string.Empty;
  7487. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7488. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7489. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7490. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7491. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7492. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7493. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7494. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7495. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7496. foreach (var cost in groupCostType)
  7497. {
  7498. var List = cost.ToList();
  7499. if (cost.Key == "A")
  7500. {
  7501. foreach (var ListItem in List)
  7502. {
  7503. if (ListItem.number > 0)
  7504. {
  7505. if (ListItem.code.Contains("TBR"))
  7506. {
  7507. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7508. }
  7509. else
  7510. {
  7511. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7512. }
  7513. TotalPrice += (ListItem.number * ListItem.price);
  7514. }
  7515. }
  7516. }
  7517. else
  7518. {
  7519. itemStr = itemStr.Insert(0, "A段\r\n");
  7520. itemStr += "B段\r\n";
  7521. foreach (var ListItem in List)
  7522. {
  7523. if (ListItem.number > 0)
  7524. {
  7525. if (ListItem.code.Contains("TBR"))
  7526. {
  7527. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7528. }
  7529. else
  7530. {
  7531. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7532. }
  7533. TotalPrice += (ListItem.number * ListItem.price);
  7534. }
  7535. }
  7536. }
  7537. }
  7538. #region 替换Word模板书签内容
  7539. Dictionary<string, string> marks = new Dictionary<string, string>();
  7540. marks.Add("To", di.ClientUnit);//付款方
  7541. marks.Add("ToTel", di.TellPhone);//付款方电话
  7542. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7543. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7544. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7545. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7546. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7547. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7548. marks.Add("PayItemContent", itemStr);//详细信息
  7549. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7550. #endregion
  7551. ////注
  7552. //if (doc.Range.Bookmarks["Attention"] != null)
  7553. //{
  7554. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7555. // mark.Text = frList[0].Attention;
  7556. //}
  7557. foreach (var item in marks.Keys)
  7558. {
  7559. if (doc.Range.Bookmarks[item] != null)
  7560. {
  7561. Bookmark mark = doc.Range.Bookmarks[item];
  7562. mark.Text = marks[item];
  7563. }
  7564. }
  7565. byte[] bytes = null;
  7566. using (MemoryStream stream = new MemoryStream())
  7567. {
  7568. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7569. bytes = stream.ToArray();
  7570. }
  7571. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7572. return Ok(JsonView(true, "", new
  7573. {
  7574. Data = bytes,
  7575. strFileName,
  7576. }));
  7577. }
  7578. else
  7579. {
  7580. return Ok(JsonView(false, "团组信息不存在!"));
  7581. }
  7582. }
  7583. /// <summary>
  7584. /// 导出团组成本
  7585. /// </summary>
  7586. /// <param name="dto"></param>
  7587. /// <returns></returns>
  7588. [HttpPost]
  7589. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7590. {
  7591. var jw = JsonView(false);
  7592. if (dto.Diid == 0)
  7593. {
  7594. return Ok(JsonView(false, "请传递团组id"));
  7595. }
  7596. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7597. if (deleInfo.Code != 0)
  7598. {
  7599. return Ok(JsonView(false, "团组信息查询失败!"));
  7600. }
  7601. var di = deleInfo.Data as DelegationInfoWebView;
  7602. if (di == null)
  7603. {
  7604. return Ok(JsonView(false, "团组信息查询失败!"));
  7605. }
  7606. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7607. WorkbookDesigner designer = new WorkbookDesigner();
  7608. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7609. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7610. for (int i = 0; i < List_GC.Count; i++)
  7611. {
  7612. GroupCost_Excel gc = new GroupCost_Excel();
  7613. gc.Id = List_GC[i].Id;
  7614. gc.Diid = List_GC[i].Diid.ToString();
  7615. gc.DAY = List_GC[i].DAY;
  7616. string week = "";
  7617. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7618. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7619. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7620. gc.ITIN = List_GC[i].ITIN;
  7621. gc.CarType = List_GC[i].CarType;
  7622. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7623. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7624. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7625. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7626. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7627. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7628. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7629. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7630. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7631. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7632. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7633. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7634. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7635. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7636. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7637. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7638. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7639. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7640. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7641. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7642. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7643. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7644. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7645. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7646. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7647. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7648. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7649. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7650. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7651. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7652. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7653. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7654. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7655. List_GC1.Add(gc);
  7656. }
  7657. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7658. dt.TableName = "TB";
  7659. //报表标题等不用dt的值
  7660. designer.SetDataSource("TeamName", dto.title.TeamName);
  7661. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7662. designer.SetDataSource("Tax", dto.title.Tax);
  7663. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7664. designer.SetDataSource("Currency", dto.title.Currency);
  7665. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7666. designer.SetDataSource("Rate", dto.title.Rate);
  7667. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7668. var Aparams = hotels.Find(x => x.Type == "Default");
  7669. if (Aparams == null)
  7670. {
  7671. return Ok(jw);
  7672. }
  7673. //酒店数量
  7674. var txtSGRNumber = Aparams.SGR.ToString();
  7675. var txtTBRNumber = Aparams.TBR.ToString();
  7676. var txtJSESNumber = Aparams.JSES.ToString();
  7677. var txtSUITENumbe = Aparams.SUITE.ToString();
  7678. if (dto.costType == "B")
  7679. {
  7680. Aparams = hotels.Find(x => x.Type == "A");
  7681. var Bparams = hotels.Find(x => x.Type == "B");
  7682. if (Aparams == null || Bparams == null)
  7683. {
  7684. return Ok(jw);
  7685. }
  7686. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7687. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7688. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7689. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7690. }
  7691. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7692. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7693. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7694. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7695. var ws = designer.Workbook.Worksheets[0];
  7696. int Row = List_GC.Count;
  7697. int startIndex = 11;
  7698. int HideRows = 0;
  7699. List<int> hideRowsList = new List<int>();
  7700. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7701. #region A段left数据
  7702. var left = dto.leftInfo.Find(x => x.Type == "A");
  7703. if (left == null)
  7704. {
  7705. return Ok(jw);
  7706. }
  7707. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7708. if (leftBindData != null)
  7709. {
  7710. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7711. designer.SetDataSource("VisaRS", leftBindData.rs);
  7712. designer.SetDataSource("VisaXS", leftBindData.xs);
  7713. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7714. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7715. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7716. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7717. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7718. }
  7719. else
  7720. {
  7721. hideRowsList.Add(Row + startIndex + HideRows);
  7722. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7723. }
  7724. HideRows += 2;
  7725. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7726. if (leftBindData != null)
  7727. {
  7728. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7729. designer.SetDataSource("BXRS", leftBindData.rs);
  7730. designer.SetDataSource("BXXS", leftBindData.xs);
  7731. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7732. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7733. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7734. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7735. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7736. }
  7737. else
  7738. {
  7739. hideRowsList.Add(Row + startIndex + HideRows);
  7740. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7741. }
  7742. HideRows += 2;
  7743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7744. if (leftBindData != null)
  7745. {
  7746. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7747. designer.SetDataSource("HSRS", leftBindData.rs);
  7748. designer.SetDataSource("HSXS", leftBindData.xs);
  7749. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7750. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7751. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7752. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7753. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7754. }
  7755. else
  7756. {
  7757. hideRowsList.Add(Row + startIndex + HideRows);
  7758. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7759. }
  7760. HideRows += 2;
  7761. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7762. if (leftBindData != null)
  7763. {
  7764. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7765. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7766. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7767. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7768. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7769. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7770. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7771. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7772. }
  7773. else
  7774. {
  7775. hideRowsList.Add(Row + startIndex + HideRows);
  7776. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7777. }
  7778. HideRows += 2;
  7779. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7780. if (leftBindData != null)
  7781. {
  7782. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7783. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7784. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7785. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7786. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7787. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7788. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7789. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7790. }
  7791. else
  7792. {
  7793. hideRowsList.Add(Row + startIndex + HideRows);
  7794. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7795. }
  7796. HideRows += 2;
  7797. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7798. if (leftBindData != null)
  7799. {
  7800. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7801. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7802. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7803. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7804. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7805. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7806. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7807. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7808. }
  7809. else
  7810. {
  7811. hideRowsList.Add(Row + startIndex + HideRows);
  7812. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7813. }
  7814. HideRows += 2;
  7815. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7816. if (leftBindData != null)
  7817. {
  7818. ////TBR
  7819. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7820. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7821. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7822. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7823. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7824. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7825. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7826. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7827. }
  7828. else
  7829. {
  7830. hideRowsList.Add(Row + startIndex + HideRows);
  7831. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7832. }
  7833. HideRows += 2;
  7834. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7835. if (leftBindData != null)
  7836. {
  7837. ////SGR
  7838. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7839. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7840. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7841. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7842. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7843. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7844. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7845. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7846. }
  7847. else
  7848. {
  7849. hideRowsList.Add(Row + startIndex + HideRows);
  7850. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7851. }
  7852. HideRows += 2;
  7853. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7854. if (leftBindData != null)
  7855. {
  7856. ////JS/ES
  7857. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7858. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7859. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7860. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7861. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7862. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7863. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7864. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7865. }
  7866. else
  7867. {
  7868. hideRowsList.Add(Row + startIndex + HideRows);
  7869. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7870. }
  7871. HideRows += 2;
  7872. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7873. if (leftBindData != null)
  7874. {
  7875. ////SUITE
  7876. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7877. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7878. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7879. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7880. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7881. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7882. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7883. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7884. }
  7885. else
  7886. {
  7887. hideRowsList.Add(Row + startIndex + HideRows);
  7888. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7889. }
  7890. HideRows += 2;
  7891. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7892. if (leftBindData != null)
  7893. {
  7894. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7895. designer.SetDataSource("DJRS", leftBindData.rs);
  7896. designer.SetDataSource("DJXS", leftBindData.xs);
  7897. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7898. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7899. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7900. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7901. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7902. }
  7903. else
  7904. {
  7905. hideRowsList.Add(Row + startIndex + HideRows);
  7906. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7907. }
  7908. HideRows += 2;
  7909. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7910. if (leftBindData != null)
  7911. {
  7912. designer.SetDataSource("HCPCB", leftBindData.cb);
  7913. designer.SetDataSource("HCPRS", leftBindData.rs);
  7914. designer.SetDataSource("HCPXS", leftBindData.xs);
  7915. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7916. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7917. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7918. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7919. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7920. }
  7921. else
  7922. {
  7923. hideRowsList.Add(Row + startIndex + HideRows);
  7924. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7925. }
  7926. HideRows += 2;
  7927. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7928. if (leftBindData != null)
  7929. {
  7930. designer.SetDataSource("CPCB", leftBindData.cb);
  7931. designer.SetDataSource("CPRS", leftBindData.rs);
  7932. designer.SetDataSource("CPXS", leftBindData.xs);
  7933. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7934. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7935. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7936. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7937. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7938. }
  7939. else
  7940. {
  7941. hideRowsList.Add(Row + startIndex + HideRows);
  7942. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7943. }
  7944. HideRows += 2;
  7945. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7946. if (leftBindData != null)
  7947. {
  7948. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7949. designer.SetDataSource("GWRS", leftBindData.rs);
  7950. designer.SetDataSource("GWXS", leftBindData.xs);
  7951. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7952. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7953. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7954. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7955. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7956. }
  7957. else
  7958. {
  7959. hideRowsList.Add(Row + startIndex + HideRows);
  7960. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7961. }
  7962. HideRows += 2;
  7963. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7964. if (leftBindData != null)
  7965. {
  7966. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7967. designer.SetDataSource("LYJRS", leftBindData.rs);
  7968. designer.SetDataSource("LYJXS", leftBindData.xs);
  7969. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7970. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7971. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7972. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7973. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7974. }
  7975. else
  7976. {
  7977. hideRowsList.Add(Row + startIndex + HideRows);
  7978. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7979. }
  7980. #endregion
  7981. #region A段Right信息
  7982. var right = dto.rightInfo.Find(x => x.Type == "A");
  7983. if (right == null)
  7984. {
  7985. return Ok(jw);
  7986. }
  7987. HideRows += 4;
  7988. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7989. if (rightBindData != null)
  7990. {
  7991. //经济舱 + 双人间 TBR
  7992. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7993. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7994. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7995. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7996. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7997. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7998. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7999. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8000. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8001. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8002. }
  8003. else
  8004. {
  8005. hideRowsList.Add(Row + startIndex + HideRows);
  8006. }
  8007. HideRows += 2;
  8008. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8009. if (rightBindData != null)
  8010. {
  8011. //经济舱 + 单人间 SGR
  8012. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8013. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8014. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8015. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8016. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8017. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8018. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8019. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8020. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8021. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8022. }
  8023. else
  8024. {
  8025. hideRowsList.Add(Row + startIndex + HideRows);
  8026. }
  8027. HideRows += 2;
  8028. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8029. if (rightBindData != null)
  8030. {
  8031. //公务舱 + 单人间 SGR
  8032. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8033. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8034. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8035. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8036. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8037. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8038. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8039. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8040. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8041. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8042. }
  8043. else
  8044. {
  8045. hideRowsList.Add(Row + startIndex + HideRows);
  8046. }
  8047. HideRows += 2;
  8048. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8049. if (rightBindData != null)
  8050. {
  8051. //公务舱 + 小套房 JSES
  8052. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8053. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8054. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8055. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8056. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8057. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8058. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8059. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8060. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8061. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8062. }
  8063. else
  8064. {
  8065. hideRowsList.Add(Row + startIndex + HideRows);
  8066. }
  8067. HideRows += 2;
  8068. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8069. if (rightBindData != null)
  8070. {
  8071. //公务舱 + 小套房 JSES
  8072. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8073. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8074. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8075. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8076. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8077. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8078. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8079. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8080. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8081. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8082. }
  8083. else
  8084. {
  8085. hideRowsList.Add(Row + startIndex + HideRows);
  8086. }
  8087. HideRows += 2;
  8088. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8089. if (rightBindData != null)
  8090. {
  8091. //经济舱 + 大套房
  8092. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8093. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8094. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8095. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8096. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8097. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8098. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8099. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8100. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8101. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8102. }
  8103. else
  8104. {
  8105. hideRowsList.Add(Row + startIndex + HideRows);
  8106. }
  8107. HideRows += 2;
  8108. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8109. if (rightBindData != null)
  8110. {
  8111. //头等舱 + 小套房 JSES
  8112. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8113. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8114. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8115. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8116. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8117. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8118. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8119. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8120. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8121. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8122. }
  8123. else
  8124. {
  8125. hideRowsList.Add(Row + startIndex + HideRows);
  8126. }
  8127. HideRows += 2;
  8128. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8129. if (rightBindData != null)
  8130. {
  8131. //头等舱 + 大套房
  8132. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8133. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8134. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8135. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8136. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8137. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8138. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8139. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8140. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8141. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8142. }
  8143. else
  8144. {
  8145. hideRowsList.Add(Row + startIndex + HideRows);
  8146. }
  8147. #endregion
  8148. #region B段标题清空
  8149. designer.SetDataSource("CostBDRCB", "");
  8150. designer.SetDataSource("CostBRS", "");
  8151. designer.SetDataSource("CostBXS", "");
  8152. designer.SetDataSource("CostBZCB", "");
  8153. designer.SetDataSource("CostBDRBJ", "");
  8154. designer.SetDataSource("CostBZBJ", "");
  8155. designer.SetDataSource("CostBDRLR", "");
  8156. designer.SetDataSource("CostBZLR", "");
  8157. designer.SetDataSource("CostBDRCBOM", "");
  8158. designer.SetDataSource("CostBRSOM", "");
  8159. designer.SetDataSource("CostBZCBOM", "");
  8160. designer.SetDataSource("CostBDRBJOM", "");
  8161. designer.SetDataSource("CostBZBJOM", "");
  8162. designer.SetDataSource("CostBDRLROM", "");
  8163. designer.SetDataSource("CostBZLROM", "");
  8164. #endregion
  8165. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8166. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8167. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8168. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8169. designer.SetDataSource("DJName", "地接(CNY)");
  8170. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8171. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8172. designer.SetDataSource("GWName", "公务(CNY)");
  8173. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8174. designer.SetDataSource("LYJName", "零用金(CNY)");
  8175. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8176. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8177. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8178. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8179. designer.SetDataSource("BXName", "保险(CNY)");
  8180. designer.SetDataSource("VisaName", "签证(CNY)");
  8181. #region B段基本数据
  8182. if (dto.costType == "B")
  8183. {
  8184. left = dto.leftInfo.Find(x => x.Type == "B");
  8185. if (left == null)
  8186. {
  8187. return Ok(jw);
  8188. }
  8189. #region B段left数据
  8190. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8191. if (leftBindData != null)
  8192. {
  8193. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8194. designer.SetDataSource("BHSRS", leftBindData.rs);
  8195. designer.SetDataSource("BHSXS", leftBindData.xs);
  8196. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8197. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8198. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8199. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8200. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8201. }
  8202. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8203. if (leftBindData != null)
  8204. {
  8205. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8206. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8207. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8208. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8209. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8210. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8211. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8212. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8213. }
  8214. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8215. if (leftBindData != null)
  8216. {
  8217. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8218. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8219. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8220. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8221. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8222. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8223. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8224. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8225. }
  8226. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8227. if (leftBindData != null)
  8228. {
  8229. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8230. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8231. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8232. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8233. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8234. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8235. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8236. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8237. }
  8238. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8239. if (leftBindData != null)
  8240. {
  8241. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8242. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8243. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8244. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8245. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8246. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8247. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8248. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8249. }
  8250. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8251. if (leftBindData != null)
  8252. {
  8253. designer.SetDataSource("BCPCB", leftBindData.cb);
  8254. designer.SetDataSource("BCPRS", leftBindData.rs);
  8255. designer.SetDataSource("BCPXS", leftBindData.xs);
  8256. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8257. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8258. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8259. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8260. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8261. }
  8262. //TBR
  8263. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8264. if (leftBindData != null)
  8265. {
  8266. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8267. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8268. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8269. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8270. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8271. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8272. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8273. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8274. }
  8275. //SGR
  8276. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8277. if (leftBindData != null)
  8278. {
  8279. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8280. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8281. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8282. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8283. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8284. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8285. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8286. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8287. }
  8288. //JS/ES
  8289. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8290. if (leftBindData != null)
  8291. {
  8292. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8293. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8294. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8295. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8296. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8297. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8298. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8299. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8300. }
  8301. //SUITE
  8302. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8303. if (leftBindData != null)
  8304. {
  8305. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8306. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8307. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8308. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8309. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8310. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8311. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8312. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8313. }
  8314. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8315. if (leftBindData != null)
  8316. {
  8317. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8318. designer.SetDataSource("BDJRS", leftBindData.rs);
  8319. designer.SetDataSource("BDJXS", leftBindData.xs);
  8320. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8321. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8322. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8323. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8324. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8325. }
  8326. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8327. if (leftBindData != null)
  8328. {
  8329. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8330. designer.SetDataSource("BGWRS", leftBindData.rs);
  8331. designer.SetDataSource("BGWXS", leftBindData.xs);
  8332. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8333. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8334. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8335. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8336. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8337. }
  8338. #region 优化方案
  8339. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8340. //excelBind.Add("零用金", new {
  8341. //cb="",
  8342. //rs="",
  8343. //xs ="",
  8344. //zcb = "",
  8345. //});
  8346. #endregion
  8347. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8348. if (leftBindData != null)
  8349. {
  8350. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8351. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8352. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8353. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8354. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8355. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8356. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8357. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8358. }
  8359. #endregion
  8360. #region B段Right信息
  8361. right = dto.rightInfo.Find(x => x.Type == "B");
  8362. if (right == null)
  8363. {
  8364. return Ok(jw);
  8365. }
  8366. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8367. if (rightBindData != null)
  8368. {
  8369. //经济舱 + 双人间 TBR
  8370. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8371. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8372. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8373. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8374. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8375. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8376. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8377. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8378. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8379. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8380. }
  8381. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8382. if (rightBindData != null)
  8383. {
  8384. //经济舱 + 单人间 SGR
  8385. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8386. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8387. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8388. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8389. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8390. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8391. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8392. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8393. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8394. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8395. }
  8396. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8397. if (rightBindData != null)
  8398. {
  8399. //公务舱 + 单人间 SGR
  8400. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8401. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8402. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8403. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8404. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8405. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8406. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8407. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8408. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8409. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8410. }
  8411. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8412. if (rightBindData != null)
  8413. {
  8414. //公务舱 + 小套房 JSES
  8415. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8416. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8417. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8418. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8419. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8420. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8421. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8422. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8423. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8424. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8425. }
  8426. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8427. if (rightBindData != null)
  8428. {
  8429. //公务舱 + 小套房 JSES
  8430. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8431. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8432. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8433. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8434. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8435. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8436. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8437. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8438. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8439. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8440. }
  8441. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8442. if (rightBindData != null)
  8443. {
  8444. //经济舱 + 大套房
  8445. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8446. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8447. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8448. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8449. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8450. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8451. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8452. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8453. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8454. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8455. }
  8456. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8457. if (rightBindData != null)
  8458. {
  8459. //头等舱 + 小套房 JSES
  8460. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8461. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8462. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8463. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8464. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8465. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8466. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8467. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8468. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8469. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8470. }
  8471. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8472. if (rightBindData != null)
  8473. {
  8474. //头等舱 + 大套房
  8475. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8476. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8477. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8478. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8479. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8480. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8481. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8482. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8483. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8484. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8485. }
  8486. #endregion
  8487. #region 标题
  8488. designer.SetDataSource("CostBDRCB", "单人成本");
  8489. designer.SetDataSource("CostBRS", "人数");
  8490. designer.SetDataSource("CostBXS", "系数");
  8491. designer.SetDataSource("CostBZCB", "总成本");
  8492. designer.SetDataSource("CostBDRBJ", "单人报价");
  8493. designer.SetDataSource("CostBZBJ", "总报价");
  8494. designer.SetDataSource("CostBDRLR", "单人利润");
  8495. designer.SetDataSource("CostBZLR", "总利润");
  8496. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8497. designer.SetDataSource("CostBRSOM", "人数");
  8498. designer.SetDataSource("CostBZCBOM", "总成本");
  8499. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8500. designer.SetDataSource("CostBZBJOM", "总报价");
  8501. designer.SetDataSource("CostBDRLROM", "单人利润");
  8502. designer.SetDataSource("CostBZLROM", "总利润");
  8503. #endregion
  8504. }
  8505. #endregion
  8506. designer.SetDataSource("TzZCB2", TzZCB2);
  8507. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8508. designer.SetDataSource("TzZLR2", TzZLR2);
  8509. string[] dataSourceKeys = new string[]
  8510. {
  8511. "VF",
  8512. "TGS",
  8513. "TGOF",
  8514. "TGM",
  8515. "TGA",
  8516. "TGTF",
  8517. "TGEF",
  8518. "CFM",
  8519. "CFOF",
  8520. "B",
  8521. "L",
  8522. "D",
  8523. "TBR",
  8524. "SGR",
  8525. "JSES",
  8526. "Suite",
  8527. "TV",
  8528. "1L",
  8529. "IF",
  8530. "EF",
  8531. "BRF",
  8532. "TE",
  8533. "TGT",
  8534. "DRVT",
  8535. "PC",
  8536. "TLF",
  8537. "ECT"
  8538. };
  8539. foreach (var item in dataSourceKeys)
  8540. {
  8541. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8542. if (find != null)
  8543. {
  8544. designer.SetDataSource(item, find.text);
  8545. }
  8546. else
  8547. {
  8548. designer.SetDataSource(item, 0);
  8549. }
  8550. }
  8551. designer.SetDataSource(dt);
  8552. //根据数据源处理生成报表内容
  8553. designer.Process();
  8554. designer.Workbook.Worksheets[0].Name = "清单";
  8555. Worksheet sheet = designer.Workbook.Worksheets[0];
  8556. foreach (var Rowindex in hideRowsList)
  8557. {
  8558. ws.Cells.HideRows(Rowindex, 2);
  8559. }
  8560. byte[] bytes = null;
  8561. string strFileName = di.TeamName + "-团组-成本.xls";
  8562. using (MemoryStream stream = new MemoryStream())
  8563. {
  8564. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8565. bytes = stream.ToArray();
  8566. }
  8567. return Ok(JsonView(true, "", new
  8568. {
  8569. Data = bytes,
  8570. strFileName,
  8571. }));
  8572. }
  8573. /// <summary>
  8574. /// 导出客户报表
  8575. /// </summary>
  8576. /// <returns></returns>
  8577. [HttpPost]
  8578. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8579. {
  8580. var jw = JsonView(false);
  8581. if (dto.Diid == 0)
  8582. {
  8583. return Ok(JsonView(false, "请传递团组id"));
  8584. }
  8585. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8586. if (deleInfo.Code != 0)
  8587. {
  8588. return Ok(JsonView(false, "团组信息查询失败!"));
  8589. }
  8590. var di = deleInfo.Data as DelegationInfoWebView;
  8591. if (di == null)
  8592. {
  8593. return Ok(JsonView(false, "团组信息查询失败!"));
  8594. }
  8595. //文件名
  8596. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8597. //获取模板
  8598. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8599. //载入模板
  8600. Document doc = new Document(tmppath);
  8601. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8602. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8603. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8604. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8605. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8606. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8607. if (AParameter == null)
  8608. {
  8609. return Ok(JsonView(false, "系数不存在!"));
  8610. }
  8611. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8612. , TzAirDesc, TzZCost;
  8613. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8614. = TzAirDesc = TzZCost = string.Empty;
  8615. TzNumber = AParameter.CostTypenumber.ToString();
  8616. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8617. CarGuides1 = dto.CarGuides1;
  8618. Meal = dto.Meal;
  8619. SubsidizedMeals = dto.SubsidizedMeals;
  8620. NightRepair = dto.NightRepair;
  8621. AttractionsTickets = dto.AttractionsTickets;
  8622. MiscellaneousFees = dto.MiscellaneousFees;
  8623. ATip = dto.ATip;
  8624. TzHotelDesc = "";
  8625. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8626. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8627. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8628. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8629. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8630. TzAirDesc = "";
  8631. TzZCost = dto.TzZCost;
  8632. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8633. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8634. var index = 1;
  8635. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8636. foreach (var item in TzHotelDescArr)
  8637. {
  8638. if (AinfoArr != null)
  8639. {
  8640. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8641. if (Ainfo != null)
  8642. {
  8643. if (int.Parse(Ainfo.rs) <= 0)
  8644. {
  8645. continue;
  8646. }
  8647. var hotelText = string.Empty;
  8648. switch (item)
  8649. {
  8650. case "SGR":
  8651. hotelText = "单人间";
  8652. break;
  8653. case "JSES":
  8654. hotelText = "小套房";
  8655. break;
  8656. case "SUITE":
  8657. hotelText = "套房";
  8658. break;
  8659. case "TBR":
  8660. hotelText = "双人间";
  8661. break;
  8662. }
  8663. if (item != "TBR")
  8664. {
  8665. 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";
  8666. }
  8667. else
  8668. {
  8669. 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";
  8670. }
  8671. index++;
  8672. }
  8673. }
  8674. }
  8675. index = 1;
  8676. foreach (var item in TzAirDescArr)
  8677. {
  8678. if (AinfoArr != null)
  8679. {
  8680. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8681. if (Ainfo != null)
  8682. {
  8683. if (int.Parse(Ainfo.rs) <= 0)
  8684. {
  8685. continue;
  8686. }
  8687. 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";
  8688. index++;
  8689. }
  8690. }
  8691. }
  8692. if (dto.costType == "B")
  8693. {
  8694. if (BParameter == null)
  8695. {
  8696. return Ok(JsonView(false, "B段系数不存在!"));
  8697. }
  8698. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8699. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8700. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8701. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8702. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8703. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8704. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8705. foreach (var item in TzHotelDescArr)
  8706. {
  8707. if (AinfoArr != null)
  8708. {
  8709. TzHotelDesc += "B段信息 \r\n";
  8710. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8711. if (Ainfo != null)
  8712. {
  8713. if (int.Parse(Ainfo.rs) <= 0)
  8714. {
  8715. continue;
  8716. }
  8717. var hotelText = string.Empty;
  8718. switch (item)
  8719. {
  8720. case "SGR":
  8721. hotelText = "单人间";
  8722. break;
  8723. case "JSES":
  8724. hotelText = "小套房";
  8725. break;
  8726. case "SUITE":
  8727. hotelText = "套房";
  8728. break;
  8729. case "TBR":
  8730. hotelText = "双人间";
  8731. break;
  8732. }
  8733. if (item != "TBR")
  8734. {
  8735. 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";
  8736. }
  8737. else
  8738. {
  8739. 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";
  8740. }
  8741. index++;
  8742. }
  8743. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8744. }
  8745. }
  8746. index = 1;
  8747. foreach (var item in TzAirDescArr)
  8748. {
  8749. if (AinfoArr != null)
  8750. {
  8751. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8752. if (Ainfo != null)
  8753. {
  8754. if (int.Parse(Ainfo.rs) <= 0)
  8755. {
  8756. continue;
  8757. }
  8758. 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";
  8759. index++;
  8760. }
  8761. }
  8762. }
  8763. }
  8764. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8765. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8766. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8767. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8768. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8769. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8770. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8771. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8772. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8773. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8774. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8775. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8776. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8777. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8778. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8779. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8780. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8781. DickeyValue.Add("TzZCost", TzZCost);
  8782. foreach (var key in DickeyValue.Keys)
  8783. {
  8784. if (doc.Range.Bookmarks[key] != null)
  8785. {
  8786. Bookmark mark = doc.Range.Bookmarks[key];
  8787. mark.Text = DickeyValue[key];
  8788. }
  8789. }
  8790. byte[] bytes = null;
  8791. string strFileName = di.TeamName + "-客户报价.doc";
  8792. using (MemoryStream stream = new MemoryStream())
  8793. {
  8794. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8795. bytes = stream.ToArray();
  8796. }
  8797. return Ok(JsonView(true, "", new
  8798. {
  8799. Data = bytes,
  8800. strFileName,
  8801. }));
  8802. }
  8803. /// <summary>
  8804. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8805. /// </summary>
  8806. /// <param name="dto"></param>
  8807. /// <returns></returns>
  8808. [HttpPost]
  8809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8810. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8811. {
  8812. try
  8813. {
  8814. #region 参数验证
  8815. if (dto.DiId < 0)
  8816. {
  8817. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8818. }
  8819. List<int> cTableIds = new List<int>() {
  8820. 76 ,//酒店预订
  8821. 77 ,//行程
  8822. 79 ,//车/导游地接
  8823. 80 ,//签证
  8824. 81 ,//邀请/公务活
  8825. 82 ,//团组客户保险
  8826. 85 ,//机票预订
  8827. 98 ,//其他款项
  8828. 285 ,//收款退还
  8829. 751 ,//酒店早餐
  8830. 1015 // 超支费用
  8831. };
  8832. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8833. {
  8834. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8835. }
  8836. #endregion
  8837. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8838. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8839. if (_GroupCostParameters.Count <= 0)
  8840. {
  8841. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8842. }
  8843. if (_GroupCostParameters[0].IsShare == 0)
  8844. {
  8845. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8846. }
  8847. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8848. //处理date为空问题
  8849. if (_GroupCosts.Count > 0)
  8850. {
  8851. for (int i = 0; i < _GroupCosts.Count; i++)
  8852. {
  8853. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8854. {
  8855. if (i > 0)
  8856. {
  8857. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8858. }
  8859. }
  8860. }
  8861. }
  8862. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8863. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8864. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8865. string currCode = "";
  8866. #region currCode 验证
  8867. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8868. if (isInt)
  8869. {
  8870. var currData = currDatas.Find(it => it.Id == intCurrency);
  8871. if (currData != null)
  8872. {
  8873. currCode = currData.Name;
  8874. }
  8875. }
  8876. else
  8877. {
  8878. currCode = _GroupCostParameters[0].Currency.Trim();
  8879. }
  8880. #endregion
  8881. //op,酒店单段模式存储
  8882. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8883. {
  8884. CurrencyCode = currCode,
  8885. Rate = _GroupCostParameters[0].Rate,
  8886. CostType = _GroupCostParameters[0].CostType,
  8887. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8888. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8889. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8890. };
  8891. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8892. if (_GroupCostParameters.Count == 2)
  8893. {
  8894. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8895. }
  8896. foreach (var item in _GroupCostParameters)
  8897. {
  8898. decimal _rate = 1;
  8899. decimal _rate1 = item.Rate;
  8900. decimal _scale = 1;
  8901. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8902. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8903. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8904. //if (userInfo != null)
  8905. //{
  8906. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8907. // {
  8908. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8909. // {
  8910. // _scale = 1.00M;
  8911. // }
  8912. // }
  8913. //}
  8914. #endregion
  8915. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8916. {
  8917. CurrencyCode = currCode,
  8918. Rate = _rate1,
  8919. CostType = item.CostType,
  8920. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8921. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8922. CostTypeNumber = item.CostTypenumber
  8923. };
  8924. if (_GroupCostParameters.Count > 1)
  8925. {
  8926. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8927. }
  8928. else
  8929. {
  8930. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8931. }
  8932. if (dto.CTable == 79)//
  8933. {
  8934. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8935. modulePromptInfo.TotalCost = item.DJCB;
  8936. }
  8937. List<string> costTypes = new List<string>() { "A", "B" };
  8938. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8939. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8940. if (_GroupCostsDuplicates.Count() == 1)
  8941. {
  8942. _GroupCostsTypeData = _GroupCosts;
  8943. }
  8944. else
  8945. {
  8946. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8947. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8948. }
  8949. /*
  8950. * 76 酒店预订
  8951. * 77 行程
  8952. * 79 车/导游地接
  8953. * 80 签证
  8954. * 81 邀请/公务活动
  8955. * 82 团组客户保险
  8956. * 85 机票预订
  8957. * 98 其他款项
  8958. * 285 收款退还
  8959. * 751 酒店早餐
  8960. * 1015 超支费用
  8961. */
  8962. switch (dto.CTable)
  8963. {
  8964. case 76: // 酒店预订
  8965. _ModuleSubPromptInfo.AddRange(
  8966. _GroupCostsTypeData.Select(it => new
  8967. {
  8968. it.DAY,
  8969. it.Date,
  8970. it.ACCON,
  8971. it.ITIN,
  8972. it.SGR,
  8973. it.TBR,
  8974. it.JS_ES,
  8975. it.Suite
  8976. })
  8977. );
  8978. break;
  8979. case 79: // 车/导游地接
  8980. _ModuleSubPromptInfo.AddRange(
  8981. _GroupCostsTypeData.Select(it => new
  8982. {
  8983. Date = it.Date, //日期
  8984. CarFee = it.CarCost * _rate * _scale, //车费用
  8985. CarType = it.CarType, //车型
  8986. DriverFee = it.CFS * _rate * _scale, //司机工资
  8987. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8988. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8989. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8990. GuideFee = it.TGS * _rate * _scale, //导游费用
  8991. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8992. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8993. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8994. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8995. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8996. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8997. Breakfast = it.B * _rate * _scale, //早餐费
  8998. Lunch = it.L * _rate * _scale, //午餐费
  8999. Dinner = it.D * _rate * _scale, //晚餐费
  9000. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9001. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9002. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9003. TicketFee = it.EF * _rate * _scale, //门票费
  9004. TicketRemark = it.EFR, //门票费描述
  9005. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9006. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9007. SpentCash = it.PC * _rate * _scale, //零用金
  9008. LeadersFee = it.TLF * _rate * _scale, //领队费
  9009. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9010. })
  9011. );
  9012. break;
  9013. case 85: // 机票
  9014. List<dynamic> datas = new List<dynamic>();
  9015. datas.Add(
  9016. new
  9017. {
  9018. AirType = "经济舱",
  9019. AirNum = item.JJCRS,
  9020. AirDRCB = item.JJCCB,
  9021. AirZCB = (item.JJCRS * item.JJCCB)
  9022. }
  9023. );
  9024. datas.Add(
  9025. new
  9026. {
  9027. AirType = "公务舱",
  9028. AirNum = item.GWCRS,
  9029. AirDRCB = item.GWCCB,
  9030. AirZCB = (item.GWCRS * item.GWCCB)
  9031. }
  9032. );
  9033. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9034. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9035. modulePromptInfo.Data = new
  9036. {
  9037. airFeeData = datas,
  9038. airInitData = initDatas
  9039. };
  9040. _ModulePromptInfos.Add(modulePromptInfo);
  9041. break;
  9042. default:
  9043. break;
  9044. }
  9045. }
  9046. if (dto.CTable != 85)
  9047. {
  9048. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9049. _ModulePromptInfos.Add(_ModulePromptInfo);
  9050. }
  9051. _view.ModulePromptInfos = _ModulePromptInfos;
  9052. return Ok(JsonView(true, "操作成功!", _view));
  9053. }
  9054. catch (Exception ex)
  9055. {
  9056. return Ok(JsonView(false, ex.Message));
  9057. }
  9058. }
  9059. /// <summary>
  9060. /// 根据黑屏代码重新生成行程
  9061. /// </summary>
  9062. /// <param name="dto"></param>
  9063. /// <returns></returns>
  9064. [HttpPost]
  9065. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9066. {
  9067. var jw = JsonView(false);
  9068. var Create = _GroupCostRepository.
  9069. CreateGroupCostByBlackCode(dto.Diid);
  9070. jw.Msg = Create.Msg;
  9071. if (Create.Code == 0)
  9072. {
  9073. jw.Code = 200;
  9074. jw.Data = new
  9075. {
  9076. groupCost = Create.Data,
  9077. blackCodeIsTrue = true
  9078. };
  9079. }
  9080. else
  9081. {
  9082. jw.Code = 400;
  9083. jw.Data = new
  9084. {
  9085. groupCost = Create.Data,
  9086. blackCodeIsTrue = false,
  9087. };
  9088. }
  9089. return Ok(jw);
  9090. }
  9091. /// <summary>
  9092. /// 成本获取OP历史车费用
  9093. /// </summary>
  9094. /// <param name="dto"></param>
  9095. /// <returns></returns>
  9096. [HttpPost]
  9097. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9098. {
  9099. var jw = JsonView(false);
  9100. try
  9101. {
  9102. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9103. //获取现有所有车的数据
  9104. if (!dto.Param.IsNullOrWhiteSpace())
  9105. {
  9106. string sql = $@"
  9107. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9108. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9109. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9110. 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
  9111. AND gctggr.ServiceEndTime is not NULL
  9112. ORDER by gctggrc.id DESC
  9113. ";
  9114. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9115. var numeberResult = await Task.Run(() =>
  9116. {
  9117. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9118. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9119. return numberArr;
  9120. });
  9121. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9122. foreach (var item in numeberResult)
  9123. {
  9124. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9125. {
  9126. Country = "数据异常!",
  9127. City = string.Empty,
  9128. };
  9129. item.Area = find.Country + " " + find.City;
  9130. }
  9131. dbResult.AddRange(numeberResult);
  9132. if (dto.Param.Contains("、"))
  9133. {
  9134. var sp = dto.Param.Split("、");
  9135. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9136. .Where(x =>
  9137. {
  9138. return System.Array.Exists(sp, e =>
  9139. {
  9140. bool where = false;
  9141. if (x.Area != null)
  9142. {
  9143. where = x.Area.Contains(e);
  9144. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9145. {
  9146. return false;
  9147. }
  9148. }
  9149. if (x.PriceName != null && !where)
  9150. {
  9151. where = x.PriceName.Contains(e);
  9152. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9153. {
  9154. return false;
  9155. }
  9156. }
  9157. return where;
  9158. });
  9159. }).ToList();
  9160. }
  9161. else
  9162. {
  9163. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9164. .Where(x =>
  9165. {
  9166. bool where = false;
  9167. if (x.Area != null)
  9168. {
  9169. where = x.Area.Contains(dto.Param);
  9170. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9171. {
  9172. return false;
  9173. }
  9174. }
  9175. if (x.PriceName != null && !where)
  9176. {
  9177. where = x.PriceName.Contains(dto.Param);
  9178. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9179. {
  9180. return false;
  9181. }
  9182. }
  9183. return where;
  9184. }
  9185. )
  9186. .ToList();
  9187. }
  9188. }
  9189. var view = dbResult.Select(x =>
  9190. {
  9191. decimal dp = 0.00M;
  9192. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9193. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9194. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9195. {
  9196. if (startB && endB)
  9197. {
  9198. var timesp = endD.Subtract(startD);
  9199. if ((timesp.Days + 1) != 0)
  9200. {
  9201. dp = x.Price / (timesp.Days + 1);
  9202. }
  9203. }
  9204. }
  9205. else
  9206. {
  9207. dp = x.Price;
  9208. }
  9209. return new
  9210. {
  9211. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9212. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9213. x.Area,
  9214. x.id,
  9215. price = x.Price.ToString("F2"),
  9216. x.PriceName,
  9217. x.PriceContent,
  9218. x.TeamName,
  9219. x.DatePrice,
  9220. dayPrice = dp.ToString("F2"),
  9221. };
  9222. }).OrderByDescending(x => x.id).ToList();
  9223. jw = JsonView(true, "获取成功!", view);
  9224. }
  9225. catch (Exception e)
  9226. {
  9227. jw = JsonView(false, e.Message);
  9228. }
  9229. return Ok(jw);
  9230. }
  9231. #endregion
  9232. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9233. /// <summary>
  9234. /// 酒店预订
  9235. /// 酒店费用列表 根据团组Id查询
  9236. /// </summary>
  9237. /// <param name="_dto"></param>
  9238. /// <returns></returns>
  9239. [HttpPost]
  9240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9241. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9242. {
  9243. #region 参数验证
  9244. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9245. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9246. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9247. #region 团组操作权限验证 76 酒店预定模块
  9248. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9249. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9250. #endregion
  9251. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9252. #region 页面操作权限验证
  9253. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9254. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9255. #endregion
  9256. #endregion
  9257. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9258. }
  9259. /// <summary>
  9260. /// 酒店预订
  9261. /// 基础数据
  9262. /// </summary>
  9263. /// <param name="_dto"></param>
  9264. /// <returns></returns>
  9265. [HttpPost]
  9266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9267. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9268. {
  9269. #region 参数验证
  9270. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9271. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9272. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9273. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9274. #region 页面操作权限验证
  9275. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9276. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9277. #endregion
  9278. #region 团组操作权限验证 76 酒店预定模块
  9279. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9280. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9281. #endregion
  9282. #endregion
  9283. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9284. }
  9285. /// <summary>
  9286. /// 酒店预订
  9287. /// 创建 入住卷号码
  9288. /// </summary>
  9289. /// <param name="_dto"></param>
  9290. /// <returns></returns>
  9291. [HttpPost]
  9292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9293. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9294. {
  9295. #region 参数验证
  9296. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9297. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9298. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9299. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9300. #region 页面操作权限验证
  9301. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9302. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9303. #endregion
  9304. #region 团组操作权限验证 76 酒店预定模块
  9305. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9306. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9307. #endregion
  9308. #endregion
  9309. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9310. if (data.Code != 0)
  9311. {
  9312. return Ok(JsonView(false, data.Msg));
  9313. }
  9314. return Ok(JsonView(true, data.Msg, data.Data));
  9315. }
  9316. /// <summary>
  9317. /// 酒店预订
  9318. /// 详情
  9319. /// </summary>
  9320. /// <param name="_dto"></param>
  9321. /// <returns></returns>
  9322. [HttpPost]
  9323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9324. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9325. {
  9326. #region 参数验证
  9327. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9328. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9329. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9330. #region 团组操作权限验证 76 酒店预定模块
  9331. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9332. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9333. #endregion
  9334. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9335. #region 页面操作权限验证
  9336. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9337. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9338. #endregion
  9339. #endregion
  9340. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9341. }
  9342. /// <summary>
  9343. /// 酒店预订
  9344. /// Add Or Edit
  9345. /// </summary>
  9346. /// <param name="_dto"></param>
  9347. /// <returns></returns>
  9348. [HttpPost]
  9349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9350. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9351. {
  9352. #region 参数验证
  9353. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9354. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9355. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9356. #region 团组操作权限验证 76 酒店预定模块
  9357. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9358. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9359. #endregion
  9360. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9361. #region 页面操作权限验证
  9362. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9363. if (_dto.Id == 0) // Add
  9364. {
  9365. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9366. }
  9367. else if (_dto.Id > 1) // Edit
  9368. {
  9369. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9370. }
  9371. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9372. #endregion
  9373. #endregion
  9374. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9375. if (_view.Code != 200)
  9376. {
  9377. return Ok(_view);
  9378. }
  9379. #region 应用推送
  9380. try
  9381. {
  9382. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9383. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9384. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9385. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9386. //自动审核
  9387. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9388. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9389. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9390. }
  9391. catch (Exception ex)
  9392. {
  9393. }
  9394. #endregion
  9395. return Ok(_view);
  9396. }
  9397. /// <summary>
  9398. /// 酒店自动审核测试
  9399. /// Add Or Edit
  9400. /// </summary>
  9401. /// <param name="_dto"></param>
  9402. /// <returns></returns>
  9403. [HttpPost]
  9404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9405. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9406. {
  9407. #region 应用推送
  9408. try
  9409. {
  9410. //自动审核
  9411. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9412. }
  9413. catch (Exception ex)
  9414. {
  9415. return Ok(JsonView(false, "操作失败"));
  9416. }
  9417. #endregion
  9418. return Ok(JsonView(false, "操作成功"));
  9419. }
  9420. /// <summary>
  9421. /// 酒店预订
  9422. /// Del
  9423. /// </summary>
  9424. /// <param name="_dto"></param>
  9425. /// <returns></returns>
  9426. [HttpPost]
  9427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9428. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9429. {
  9430. #region 参数验证
  9431. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9432. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9433. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9434. #region 团组操作权限验证 76 酒店预定模块
  9435. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9436. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9437. #endregion
  9438. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9439. #region 页面操作权限验证
  9440. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9441. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9442. #endregion
  9443. #endregion
  9444. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9445. }
  9446. /// <summary>
  9447. /// 酒店预订
  9448. /// 生成VOUCHER
  9449. /// 2024.05.06 之前版本
  9450. /// </summary>
  9451. /// <param name="_dto"></param>
  9452. /// <returns></returns>
  9453. [HttpPost]
  9454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9455. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9456. {
  9457. try
  9458. {
  9459. #region 参数验证
  9460. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9461. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9462. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9463. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9464. #region 团组操作权限验证 76 酒店预定模块
  9465. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9466. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9467. #endregion
  9468. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9469. #region 页面操作权限验证
  9470. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9471. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9472. #endregion
  9473. #endregion
  9474. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9475. //判断数据是否完整
  9476. if (hr != null)
  9477. {
  9478. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9479. {
  9480. string strFileName = "HotelStatement/";
  9481. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9482. if (dele != null)
  9483. strFileName += dele.TourCode;
  9484. //载入模板
  9485. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9486. Document doc = new Document(sss);
  9487. DocumentBuilder builder = new DocumentBuilder(doc);
  9488. #region 替换Word模板书签内容
  9489. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9490. //入住卷预定号码
  9491. if (doc.Range.Bookmarks["VNO"] != null)
  9492. {
  9493. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9494. mark.Text = hr.CheckNumber;
  9495. }
  9496. //酒店时间
  9497. if (doc.Range.Bookmarks["Date"] != null)
  9498. {
  9499. Bookmark mark = doc.Range.Bookmarks["Date"];
  9500. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9501. }
  9502. //团号
  9503. if (doc.Range.Bookmarks["TNo"] != null)
  9504. {
  9505. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9506. mark.Text = dele.TourCode;
  9507. }
  9508. //预定号码
  9509. if (doc.Range.Bookmarks["BookingId"] != null)
  9510. {
  9511. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9512. mark.Text = hr.ReservationsNo;
  9513. }
  9514. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9515. {
  9516. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9517. mark.Text = hr.DetermineNo;
  9518. }
  9519. //酒店城市
  9520. if (doc.Range.Bookmarks["City"] != null)
  9521. {
  9522. Bookmark mark = doc.Range.Bookmarks["City"];
  9523. mark.Text = hr.City;
  9524. }
  9525. //酒店名称
  9526. if (doc.Range.Bookmarks["HName"] != null)
  9527. {
  9528. Bookmark mark = doc.Range.Bookmarks["HName"];
  9529. mark.Text = hr.HotelName;
  9530. }
  9531. //酒店地址
  9532. if (doc.Range.Bookmarks["Address"] != null)
  9533. {
  9534. Bookmark mark = doc.Range.Bookmarks["Address"];
  9535. mark.Text = hr.HotelAddress;
  9536. }
  9537. //酒店电话
  9538. if (doc.Range.Bookmarks["Tel"] != null)
  9539. {
  9540. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9541. mark.Text = hr.HotelTel;
  9542. }
  9543. //酒店传真
  9544. if (doc.Range.Bookmarks["Fax"] != null)
  9545. {
  9546. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9547. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9548. {
  9549. mark.Text = hr.HotelFax;
  9550. }
  9551. }
  9552. //入住时间
  9553. if (doc.Range.Bookmarks["CIn"] != null)
  9554. {
  9555. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9556. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9557. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9558. }
  9559. //退房时间
  9560. if (doc.Range.Bookmarks["COut"] != null)
  9561. {
  9562. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9563. Bookmark mark = doc.Range.Bookmarks["COut"];
  9564. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9565. }
  9566. //客户名称
  9567. if (doc.Range.Bookmarks["GName"] != null)
  9568. {
  9569. string guestName = "";
  9570. string[] clients = new string[] { };
  9571. if (hr.GuestName.Contains(","))
  9572. {
  9573. clients = hr.GuestName.Split(",");
  9574. }
  9575. else
  9576. {
  9577. clients = new string[] { hr.GuestName };
  9578. }
  9579. List<int> clientIds_int = new List<int>();
  9580. if (clients.Length > 0)
  9581. {
  9582. foreach (var item in clients)
  9583. {
  9584. if (item.IsNumeric())
  9585. {
  9586. clientIds_int.Add(int.Parse(item));
  9587. }
  9588. }
  9589. }
  9590. if (clientIds_int.Count > 0)
  9591. {
  9592. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9593. foreach (var client in _clientDatas)
  9594. {
  9595. //男
  9596. if (client.Sex == 0) guestName += $"Mr.";
  9597. //女
  9598. else if (client.Sex == 1) guestName += $"Ms.";
  9599. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9600. {
  9601. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9602. }
  9603. //guestName += $"{client.Pinyin},";
  9604. }
  9605. if (guestName.Length > 0)
  9606. {
  9607. guestName = guestName.Substring(0, guestName.Length - 1);
  9608. }
  9609. }
  9610. else
  9611. {
  9612. guestName = hr.GuestName;
  9613. }
  9614. Bookmark mark = doc.Range.Bookmarks["GName"];
  9615. mark.Text = guestName;
  9616. }
  9617. //房间介绍
  9618. if (doc.Range.Bookmarks["ROOM"] != null)
  9619. {
  9620. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9621. mark.Text = hr.RoomExplanation;
  9622. }
  9623. //报价描述
  9624. if (doc.Range.Bookmarks["NOTE"] != null)
  9625. {
  9626. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9627. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9628. if (ss != null)
  9629. mark.Text = ss.Name;
  9630. }
  9631. //入住时间
  9632. if (doc.Range.Bookmarks["CheckIn"] != null)
  9633. {
  9634. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9635. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9636. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9637. }
  9638. //退房时间
  9639. if (doc.Range.Bookmarks["CheckOut"] != null)
  9640. {
  9641. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9642. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9643. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9644. }
  9645. //日期
  9646. if (doc.Range.Bookmarks["DT"] != null)
  9647. {
  9648. Bookmark mark = doc.Range.Bookmarks["DT"];
  9649. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9650. }
  9651. //名称
  9652. if (doc.Range.Bookmarks["VName"] != null)
  9653. {
  9654. Bookmark mark = doc.Range.Bookmarks["VName"];
  9655. mark.Text = hr.HotelName;
  9656. }
  9657. //号码
  9658. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9659. {
  9660. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9661. mark.Text = hr.CheckNumber;
  9662. }
  9663. #endregion
  9664. strFileName += "VOUCHER.doc";
  9665. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9666. doc.Save(fileDir);
  9667. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9668. return Ok(JsonView(true, "操作成功!", Url));
  9669. }
  9670. else
  9671. {
  9672. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9673. }
  9674. }
  9675. else
  9676. {
  9677. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9678. }
  9679. }
  9680. catch (Exception ex)
  9681. {
  9682. return Ok(JsonView(false, ex.Message));
  9683. }
  9684. }
  9685. /// <summary>
  9686. /// 酒店预订
  9687. /// 生成VOUCHER
  9688. /// 2024.05.06 之后版本
  9689. /// </summary>
  9690. /// <param name="_dto"></param>
  9691. /// <returns></returns>
  9692. [HttpPost]
  9693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9694. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9695. {
  9696. #region 参数验证
  9697. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9698. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9699. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9700. #region 团组操作权限验证 76 酒店预定模块
  9701. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9702. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9703. #endregion
  9704. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9705. #region 页面操作权限验证
  9706. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9707. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9708. #endregion
  9709. #endregion
  9710. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9711. //判断数据是否完整
  9712. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9713. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9714. string strFileName = "HotelStatement/";
  9715. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9716. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9717. #region 数据处理
  9718. List<int> guestIds = new List<int>();
  9719. int index = 0;
  9720. foreach (var item in hrDtas)
  9721. {
  9722. if (item.GuestName.Contains(","))
  9723. {
  9724. string[] guestIdArr = item.GuestName.Split(',');
  9725. foreach (var guestIdStr in guestIdArr)
  9726. {
  9727. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9728. if (guestBool)
  9729. {
  9730. guestIds.Add(guestId);
  9731. }
  9732. }
  9733. }
  9734. else guestNames += item.GuestName;
  9735. var voucherInfo = new HotelVoucherInfoView()
  9736. {
  9737. HotelName = item.HotelName,
  9738. CheckInDate = item.CheckInDate,
  9739. CheckOutDate = item.CheckOutDate,
  9740. ConfirmationNumber = item.DetermineNo.Trim(),
  9741. RoomType = item.RoomExplanation
  9742. };
  9743. vouchers.Add(voucherInfo);
  9744. }
  9745. if (guestIds.Count > 0)
  9746. {
  9747. guestIds = guestIds.Distinct().ToList();
  9748. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9749. if (guestDatas.Count > 0)
  9750. {
  9751. guestNames = "";
  9752. foreach (var guest in guestDatas)
  9753. {
  9754. string guestName = "";
  9755. if (guest.Sex == 0) guestName += @"MR.";
  9756. else if (guest.Sex == 1) guestName += @"MS.";
  9757. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9758. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9759. guestNames += @$"{guestName.Trim()}、";
  9760. }
  9761. if (guestNames.Length > 0)
  9762. {
  9763. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9764. }
  9765. }
  9766. }
  9767. #endregion
  9768. //载入模板
  9769. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9770. Document doc = new Document(sss);
  9771. DocumentBuilder builder = new DocumentBuilder(doc);
  9772. if (doc.Range.Bookmarks["GuestName"] != null)
  9773. {
  9774. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9775. mark.Text = guestNames;
  9776. }
  9777. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9778. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9779. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9780. for (int i = 1; i <= vouchers.Count; i++)
  9781. {
  9782. HotelVoucherInfoView hviv = vouchers[i - 1];
  9783. builder.MoveToCell(0, i, 0, 0);
  9784. builder.Write(hviv.HotelName);
  9785. builder.MoveToCell(0, i, 1, 0);
  9786. builder.Write(hviv.CheckInDate);
  9787. builder.MoveToCell(0, i, 2, 0);
  9788. builder.Write(hviv.CheckOutDate);
  9789. builder.MoveToCell(0, i, 3, 0);
  9790. builder.Write(hviv.RoomType);
  9791. builder.MoveToCell(0, i, 4, 0);
  9792. builder.Write(hviv.ConfirmationNumber);
  9793. }
  9794. //删除多余行
  9795. int currRowIndex = vouchers.Count + 1;
  9796. int delRows = 21 - currRowIndex;
  9797. if (delRows > 0)
  9798. {
  9799. for (int i = 0; i < delRows; i++)
  9800. {
  9801. table.Rows.RemoveAt(currRowIndex);
  9802. //cultivateRowIndex++;
  9803. }
  9804. }
  9805. strFileName += "VOUCHER.docx";
  9806. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9807. doc.Save(fileDir);
  9808. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9809. return Ok(JsonView(true, "操作成功!", Url));
  9810. }
  9811. /// <summary>
  9812. /// 酒店预订
  9813. /// 生成VOUCHER 批量生成
  9814. /// New
  9815. /// </summary>
  9816. /// <param name="_dto"></param>
  9817. /// <returns></returns>
  9818. [HttpPost]
  9819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9820. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9821. {
  9822. #region 参数验证
  9823. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9824. if (_dto.PageId < 1) _dto.PageId = 28;
  9825. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9826. #region 团组操作权限验证 76 酒店预定模块
  9827. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9828. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9829. #endregion
  9830. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9831. #region 页面操作权限验证
  9832. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9833. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9834. #endregion
  9835. #endregion
  9836. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9837. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9838. .OrderBy(x => x.CheckInDate)
  9839. .ToListAsync();
  9840. //判断数据是否完整
  9841. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9842. string strFileName = "HotelStatement/";
  9843. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9844. if (dele != null)
  9845. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9846. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9847. for (int i = 0; i < hrDtas.Count; i++)
  9848. {
  9849. string guestNames = string.Empty;
  9850. List<int> guestIds = new List<int>();
  9851. var item = hrDtas[i];
  9852. //处理客户姓名
  9853. if (item.GuestName.Contains(","))
  9854. {
  9855. string[] guestIdArr = item.GuestName.Split(',');
  9856. foreach (var guestIdStr in guestIdArr)
  9857. if (int.TryParse(guestIdStr, out int guestId))
  9858. guestIds.Add(guestId);
  9859. }
  9860. else
  9861. {
  9862. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  9863. if (guestIdBool)
  9864. {
  9865. guestIds.Add(guestId);
  9866. }
  9867. //NaN
  9868. if (item.GuestName.Contains("NaN"))
  9869. {
  9870. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9871. }
  9872. }
  9873. if (guestIds.Count > 0)
  9874. {
  9875. guestIds = guestIds.Distinct().ToList();
  9876. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9877. if (guestDatas1.Count > 0)
  9878. {
  9879. guestNames = "";
  9880. foreach (var guest in guestDatas1)
  9881. {
  9882. string guestName = "";
  9883. if (guest.Sex == 0) guestName += @"MR.";
  9884. else if (guest.Sex == 1) guestName += @"MS.";
  9885. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9886. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9887. guestNames += @$"{guestName.Trim()}、";
  9888. }
  9889. if (guestNames.Length > 0)
  9890. {
  9891. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9892. }
  9893. }
  9894. }
  9895. //if (!string.IsNullOrEmpty(guestNames))
  9896. //{
  9897. hrDtas[i].GuestName = guestNames;
  9898. //}
  9899. }
  9900. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9901. Document doc = new Document();
  9902. DocumentBuilder builder = new DocumentBuilder(doc);
  9903. try
  9904. {
  9905. builder.MoveToDocumentStart();
  9906. foreach (var item in hrDtas)
  9907. {
  9908. //标题
  9909. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9910. builder.ParagraphFormat.LineSpacing = 1;
  9911. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9912. builder.ParagraphFormat.Style.Font.Size = 9;
  9913. builder.ParagraphFormat.Style.Font.Bold = true;
  9914. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9915. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9916. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9917. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9918. builder.ParagraphFormat.LineSpacing = 1;
  9919. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9920. builder.ParagraphFormat.Style.Font.Size = 9;
  9921. builder.ParagraphFormat.Style.Font.Bold = true;
  9922. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9923. builder.StartTable();
  9924. // 设置边框颜色
  9925. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9926. //设置边框样式
  9927. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9928. //表格
  9929. #region 第一行
  9930. builder.InsertCell();
  9931. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9932. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9933. //builder.CellFormat.AllowAutoFit = false;
  9934. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9935. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9936. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9937. builder.CellFormat.WrapText = true; //自动换行
  9938. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9939. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  9940. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9941. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9942. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9943. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9944. builder.Write("TOUR NO:");
  9945. builder.InsertCell();
  9946. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9947. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9948. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9949. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9950. builder.ParagraphFormat.Style.Font.Bold = false;
  9951. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9952. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9953. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9954. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9955. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9956. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9957. builder.Write($"{dele?.TourCode ?? "-"}");
  9958. builder.InsertCell();
  9959. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9960. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9961. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9962. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9963. builder.ParagraphFormat.Style.Font.Bold = false;
  9964. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9965. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9966. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9967. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9968. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9969. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9970. builder.Write($"CITY:");
  9971. builder.InsertCell();
  9972. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9973. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9974. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9975. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9976. builder.ParagraphFormat.Style.Font.Bold = false;
  9977. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9978. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9979. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9980. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9981. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9982. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9983. builder.Write($"{item.City}");
  9984. builder.EndRow();
  9985. #endregion
  9986. #region 第二行
  9987. builder.InsertCell();
  9988. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9989. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9990. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9991. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9992. builder.ParagraphFormat.Style.Font.Bold = false;
  9993. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9994. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9995. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9996. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9997. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9998. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9999. builder.Write("CONFIRMATION NO:");
  10000. builder.InsertCell();
  10001. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10002. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10003. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10004. builder.ParagraphFormat.Style.Font.Bold = false;
  10005. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10006. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10007. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10008. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10009. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10010. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10011. builder.CellFormat.VerticalMerge = CellMerge.None;
  10012. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10013. builder.Write($"{item.DetermineNo}");
  10014. builder.InsertCell();
  10015. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10016. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10017. builder.InsertCell();
  10018. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10019. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10020. builder.EndRow();
  10021. #endregion
  10022. #region 第三行
  10023. builder.InsertCell();
  10024. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10025. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10026. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10027. builder.ParagraphFormat.Style.Font.Bold = false;
  10028. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10029. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10030. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10031. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10032. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10033. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10034. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10035. builder.Write($"HOTEL NAME:");
  10036. builder.InsertCell();
  10037. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10038. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10039. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10040. builder.ParagraphFormat.Style.Font.Bold = false;
  10041. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10042. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10043. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10044. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10045. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10046. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10047. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10048. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10049. builder.Write($"{item.HotelName}");
  10050. builder.InsertCell();
  10051. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10052. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10053. builder.InsertCell();
  10054. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10055. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10056. builder.EndRow();
  10057. #endregion
  10058. #region 第四行
  10059. builder.InsertCell();
  10060. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10061. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10062. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10063. builder.ParagraphFormat.Style.Font.Bold = false;
  10064. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10065. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10066. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10067. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10068. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10069. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10070. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10071. builder.Write($"HOTEL ADDRESS:");
  10072. builder.InsertCell();
  10073. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10074. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10075. builder.ParagraphFormat.Style.Font.Size = 8;
  10076. builder.ParagraphFormat.Style.Font.Bold = false;
  10077. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10078. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10079. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10080. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10081. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10082. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10083. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10084. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10085. builder.Write($"{item.HotelAddress}");
  10086. builder.InsertCell();
  10087. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10088. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10089. builder.InsertCell();
  10090. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10091. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10092. builder.EndRow();
  10093. #endregion
  10094. #region 第五行
  10095. builder.InsertCell();
  10096. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10097. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10098. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10099. builder.ParagraphFormat.Style.Font.Bold = false;
  10100. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10101. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10102. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10103. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10104. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10105. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10106. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10107. builder.Write("TEL:");
  10108. builder.InsertCell();
  10109. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10110. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10111. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10112. builder.ParagraphFormat.Style.Font.Bold = false;
  10113. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10114. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10115. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10116. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10117. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10118. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10119. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10120. builder.Write($"{item.HotelTel}");
  10121. builder.InsertCell();
  10122. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10123. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10124. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10125. builder.ParagraphFormat.Style.Font.Bold = false;
  10126. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10127. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10128. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10129. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10130. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10131. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10132. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10133. builder.Write($"FAX:");
  10134. builder.InsertCell();
  10135. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10136. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10137. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10138. builder.ParagraphFormat.Style.Font.Bold = false;
  10139. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10140. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10141. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10142. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10143. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10144. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10145. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10146. builder.Write($"{item.HotelFax}");
  10147. builder.EndRow();
  10148. #endregion
  10149. #region 第六行
  10150. builder.InsertCell();
  10151. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10152. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10153. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10154. builder.ParagraphFormat.Style.Font.Bold = false;
  10155. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10156. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10157. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10158. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10159. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10160. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10161. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10162. builder.Write("CHECK IN:");
  10163. builder.InsertCell();
  10164. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10165. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10166. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10167. builder.ParagraphFormat.Style.Font.Bold = false;
  10168. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10169. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10170. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10171. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10172. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10173. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10174. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10175. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10176. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10177. builder.Write($"{checkInStr}");
  10178. builder.InsertCell();
  10179. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10180. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10181. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10182. builder.ParagraphFormat.Style.Font.Bold = false;
  10183. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10184. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10185. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10186. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10187. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10188. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10189. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10190. builder.Write($"CHECK OUT:");
  10191. builder.InsertCell();
  10192. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10193. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10194. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10195. builder.ParagraphFormat.Style.Font.Bold = false;
  10196. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10197. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10198. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10199. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10200. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10201. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10202. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10203. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10204. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10205. builder.Write($"{checkOutStr}");
  10206. builder.EndRow();
  10207. #endregion
  10208. #region 第七行
  10209. builder.InsertCell();
  10210. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10211. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10212. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10213. builder.ParagraphFormat.Style.Font.Bold = false;
  10214. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10215. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10216. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10217. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10218. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10219. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10220. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10221. builder.Write($"GUEST NAME:");
  10222. builder.InsertCell();
  10223. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10224. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10225. builder.ParagraphFormat.Style.Font.Size = 8;
  10226. builder.ParagraphFormat.Style.Font.Bold = false;
  10227. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10228. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10229. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10230. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10231. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10232. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10233. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10234. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10235. builder.Write($"{item.GuestName}");
  10236. builder.InsertCell();
  10237. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10238. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10239. builder.InsertCell();
  10240. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10241. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10242. builder.EndRow();
  10243. #endregion
  10244. #region 第八行
  10245. builder.InsertCell();
  10246. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10247. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10248. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10249. builder.ParagraphFormat.Style.Font.Bold = false;
  10250. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10251. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10252. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10253. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10254. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10255. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10256. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10257. builder.Write($"ROOM TYPE:");
  10258. builder.InsertCell();
  10259. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10260. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10261. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10262. builder.ParagraphFormat.Style.Font.Bold = false;
  10263. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10264. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10265. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10266. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10267. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10268. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10269. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10270. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10271. builder.Write($"{item.RoomExplanation}");
  10272. builder.InsertCell();
  10273. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10274. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10275. builder.InsertCell();
  10276. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10277. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10278. builder.EndRow();
  10279. #endregion
  10280. #region 第九行
  10281. builder.InsertCell();
  10282. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10283. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10284. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10285. builder.ParagraphFormat.Style.Font.Bold = false;
  10286. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10287. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10288. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10289. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10290. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10291. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10292. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10293. builder.Write($"NOTE:");
  10294. builder.InsertCell();
  10295. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10296. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10297. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10298. builder.ParagraphFormat.Style.Font.Bold = false;
  10299. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10300. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10301. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10302. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10303. 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.");
  10304. builder.InsertCell();
  10305. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10306. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10307. builder.InsertCell();
  10308. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10309. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10310. builder.EndRow();
  10311. #endregion
  10312. builder.EndTable();
  10313. //换行
  10314. builder.Writeln("");
  10315. builder.Writeln("");
  10316. }
  10317. #region 获取文档中的所有表格 设置文字自适应
  10318. // 获取文档中的所有表格。
  10319. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10320. {
  10321. // 遍历表格中的所有行。
  10322. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10323. {
  10324. foreach (Cell cell in row.Cells)
  10325. {
  10326. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10327. cellFormat.Width = 0;
  10328. }
  10329. }
  10330. }
  10331. #endregion
  10332. #region 设置页眉
  10333. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10334. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10335. if (System.IO.File.Exists(voucherHeaderPath))
  10336. {
  10337. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10338. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10339. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10340. Shape shape = builder.InsertImage(imageBytes);
  10341. // 调整图片位置
  10342. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10343. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10344. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10345. shape.Left = 0; // 将图片距离页面左边缘的距离
  10346. shape.Width = 81; // 设置图片宽度
  10347. shape.Height = 36; // 设置图片高度
  10348. }
  10349. //靠右
  10350. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10351. //// 设置页脚上下边距
  10352. //builder.PageSetup.HeaderDistance = 42;
  10353. // 添加页眉线
  10354. Aspose.Words.Border borderHeader = null;
  10355. try
  10356. {
  10357. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10358. }
  10359. catch (Exception e)
  10360. {
  10361. // TODO Auto-generated catch block
  10362. //e.printStackTrace();
  10363. }
  10364. borderHeader.Shadow = true;
  10365. borderHeader.DistanceFromText = 2;
  10366. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10367. #endregion
  10368. }
  10369. catch (Exception ex)
  10370. {
  10371. }
  10372. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10373. doc.Save(fileDir);
  10374. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10375. return Ok(JsonView(true, "操作成功!", Url));
  10376. }
  10377. /// <summary>
  10378. /// 酒店预订
  10379. /// 生成 预定成本 Excel
  10380. /// </summary>
  10381. /// <param name="_dto"></param>
  10382. /// <returns></returns>
  10383. [HttpPost]
  10384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10385. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10386. {
  10387. #region 参数验证
  10388. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10389. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10390. if (!vadalitorRes.IsValid)
  10391. {
  10392. var errors = new StringBuilder();
  10393. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10394. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10395. }
  10396. #region 团组操作权限验证 76 酒店预定模块
  10397. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10398. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10399. #endregion
  10400. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10401. #region 页面操作权限验证
  10402. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10403. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10404. #endregion
  10405. #endregion
  10406. decimal _rate = 1.00M;
  10407. string _currency = "";
  10408. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10409. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10410. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10411. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10412. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10413. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10414. {
  10415. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10416. }
  10417. _currency = _GroupCostParameter.Currency;
  10418. bool isIntType = int.TryParse(_currency, out int currId);
  10419. if (isIntType)
  10420. {
  10421. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10422. }
  10423. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10424. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10425. if (currInfo == null)
  10426. {
  10427. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10428. }
  10429. if (!_currency.ToUpper().Equals("CNY"))
  10430. {
  10431. _rate = _GroupCostParameter.Rate;
  10432. }
  10433. _rate = currInfo.Rate;
  10434. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10435. string strFileName = "HotelStatement/";
  10436. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10437. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10438. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10439. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10440. #region 数据处理
  10441. foreach (var item in hrDtas)
  10442. {
  10443. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10444. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10445. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10446. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10447. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10448. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10449. string singleRoomFeeStr = string.Empty,
  10450. doubleRoomFeeStr = string.Empty,
  10451. suiteRoomFeeStr = string.Empty,
  10452. otherRoomFeeStr = string.Empty,
  10453. payMoneyStr = string.Empty,
  10454. cardPriceStr = string.Empty;
  10455. if (roomCurr.Equals(_currency))
  10456. {
  10457. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10458. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10459. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10460. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10461. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10462. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10463. }
  10464. else
  10465. {
  10466. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10467. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10468. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10469. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10470. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10471. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10472. }
  10473. string breakfastPriceStr = string.Empty,
  10474. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10475. governmentRentStr = string.Empty,
  10476. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10477. cityTaxStrStr = string.Empty,
  10478. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10479. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10480. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10481. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10482. int payDId = roomInfo?.PayDId ?? 0;
  10483. pcfds.Add(new HotelReservations_PCFD_View()
  10484. {
  10485. City = item.City,
  10486. HotelName = item.HotelName,
  10487. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10488. // SingleRoomCount = item.SingleRoomCount,
  10489. SingleRoomPrice = singleRoomFeeStr,
  10490. // DoubleRoomCount = item.DoubleRoomCount,
  10491. DoubleRoomPrice = doubleRoomFeeStr,
  10492. //SuiteRoomCount = item.SuiteRoomCount,
  10493. SuiteRoomPrice = suiteRoomFeeStr,
  10494. OtherRoomPrice = otherRoomFeeStr,
  10495. //OtherRoomCount = item.OtherRoomCount,
  10496. BreakfastPrice = breakfastPriceStr,
  10497. GovernmentRent = governmentRentStr,
  10498. CityTax = cityTaxStrStr,
  10499. RoomExplanation = item.RoomExplanation,
  10500. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10501. PayTime = roomInfo?.ConsumptionDate,
  10502. BankNo = roomInfo?.BankNo,
  10503. PayMoney = payMoneyStr,
  10504. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10505. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10506. CardPrice = cardPriceStr,
  10507. Remark = ccpInfo.Remark
  10508. });
  10509. }
  10510. #endregion
  10511. //载入模板
  10512. WorkbookDesigner designer = new WorkbookDesigner();
  10513. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10514. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10515. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10516. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10517. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10518. designer.SetDataSource("Opertor", userInfo.CnName);
  10519. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10520. dt.TableName = "ViewMyHotelReservations";
  10521. designer.SetDataSource(dt);
  10522. designer.Process();
  10523. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10524. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10525. designer.Workbook.Save(serverPath);
  10526. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10527. #region 删除指定行
  10528. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10529. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10530. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10531. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10532. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10533. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10534. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10535. cssIndex = dt.Columns["CityTax"].Ordinal,
  10536. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10537. remarkIndex = dt.Columns["Remark"].Ordinal;
  10538. //删除指定列
  10539. foreach (DataRow item in dt.Rows)
  10540. {
  10541. string singleStr = item["SingleRoomPrice"].ToString();
  10542. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10543. if (containsDigitButNotZero1) singleDel = false;
  10544. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10545. string doubleStr = item["DoubleRoomPrice"].ToString();
  10546. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10547. if (containsDigitButNotZero2) doubleDel = false;
  10548. string suiteStr = item["SuiteRoomPrice"].ToString();
  10549. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10550. if (containsDigitButNotZero3) suiteDel = false;
  10551. string otherStr = item["OtherRoomPrice"].ToString();
  10552. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10553. if (containsDigitButNotZero4) otherDel = false;
  10554. string zcStr = item["BreakfastPrice"].ToString();
  10555. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10556. if (containsDigitButNotZero5) zcDel = false;
  10557. string dsStr = item["GovernmentRent"].ToString();
  10558. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10559. if (containsDigitButNotZero6) dsDel = false;
  10560. string cssStr = item["CityTax"].ToString();
  10561. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10562. if (containsDigitButNotZero7) cssDel = false;
  10563. string cpStr = item["ConsumptionPatterns"].ToString();
  10564. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10565. string remarkStr = item["Remark"].ToString();
  10566. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10567. }
  10568. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10569. DeleteColumn(serverPath, cpIndex, cpDel);
  10570. DeleteColumn(serverPath, dsIndex, dsDel);
  10571. DeleteColumn(serverPath, cssIndex, cssDel);
  10572. DeleteColumn(serverPath, zcIndex, zcDel);
  10573. DeleteColumn(serverPath, otherIndex, otherDel);
  10574. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10575. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10576. DeleteColumn(serverPath, singleIndex, singleDel);
  10577. #endregion
  10578. //只保留第一个表格
  10579. DeleteSheet(serverPath);
  10580. return Ok(JsonView(true, "操作成功", url = rst));
  10581. }
  10582. /// <summary>
  10583. /// 删除指定列
  10584. /// </summary>
  10585. /// <param name="file"></param>
  10586. /// <param name="columnIndex"></param>
  10587. /// <param name="isDel"></param>
  10588. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10589. {
  10590. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10591. //wb.Save(file);
  10592. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10593. if (sheet1 != null)
  10594. {
  10595. if (isDel)
  10596. {
  10597. Cells cells = sheet1.Cells;
  10598. cells.DeleteColumn(columnIndex);
  10599. }
  10600. }
  10601. wb.Save(file);
  10602. }
  10603. /// <summary>
  10604. /// 删除sheet
  10605. /// </summary>
  10606. /// <param name="file"></param>
  10607. /// <param name="sheetName"></param>
  10608. private void DeleteSheet(string file, string sheetName = "")
  10609. {
  10610. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10611. //wb.Save(file);
  10612. List<string> sheets = new List<string>();
  10613. foreach (var item in wb.Worksheets)
  10614. {
  10615. sheets.Add(item.Name);
  10616. }
  10617. if (sheets.Count > 0)
  10618. {
  10619. sheets.RemoveAt(0);//不删除第一个sheet
  10620. foreach (var item in sheets)
  10621. {
  10622. wb.Worksheets.RemoveAt(item);
  10623. }
  10624. }
  10625. wb.Save(file);
  10626. }
  10627. /// <summary>
  10628. /// 酒店预订
  10629. /// 确认单
  10630. /// </summary>
  10631. /// <param name="_dto"></param>
  10632. /// <returns></returns>
  10633. [HttpPost]
  10634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10635. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10636. {
  10637. try
  10638. {
  10639. #region 参数验证
  10640. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10641. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10642. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10643. #region 团组操作权限验证 76 酒店预定模块
  10644. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10645. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10646. #endregion
  10647. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10648. #region 页面操作权限验证
  10649. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10650. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10651. #endregion
  10652. #endregion
  10653. //团组信息
  10654. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10655. //酒店数据
  10656. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10657. if (listhoteldata.Count < 0)
  10658. {
  10659. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10660. }
  10661. //利datatable存储
  10662. DataTable dt = new DataTable();
  10663. dt.Columns.Add("CheckInDate", typeof(string));
  10664. dt.Columns.Add("City", typeof(string));
  10665. dt.Columns.Add("Hotel", typeof(string));
  10666. dt.Columns.Add("Room", typeof(string));
  10667. for (int i = 0; i < listhoteldata.Count; i++)
  10668. {
  10669. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10670. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10671. while (dayStart < dayEnd)
  10672. {
  10673. string temp = "";
  10674. DataRow row = dt.NewRow();
  10675. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10676. row["City"] = listhoteldata[i].City;
  10677. row["Hotel"] = listhoteldata[i].HotelName;
  10678. if (listhoteldata[i].SingleRoomCount > 0)
  10679. {
  10680. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10681. }
  10682. if (listhoteldata[i].DoubleRoomCount > 0)
  10683. {
  10684. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10685. }
  10686. if (listhoteldata[i].SuiteRoomCount > 0)
  10687. {
  10688. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10689. }
  10690. if (listhoteldata[i].OtherRoomCount > 0)
  10691. {
  10692. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10693. }
  10694. row["Room"] = temp;
  10695. dt.Rows.Add(row);
  10696. dayStart = dayStart.AddDays(1);
  10697. }
  10698. }
  10699. Dictionary<string, string> dic = new Dictionary<string, string>();
  10700. dic.Add("Dele", di.TeamName);
  10701. dic.Add("City", di.VisitCountry);
  10702. //模板路径
  10703. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10704. //载入模板
  10705. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10706. DocumentBuilder builder = new DocumentBuilder(doc);
  10707. foreach (var key in dic.Keys)
  10708. {
  10709. builder.MoveToBookmark(key);
  10710. builder.Write(dic[key]);
  10711. }
  10712. //获取word里所有表格
  10713. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10714. //获取所填表格的序数
  10715. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10716. var rowStart = tableOne.Rows[0]; //获取第1行
  10717. //循环赋值
  10718. for (int i = 0; i < dt.Rows.Count; i++)
  10719. {
  10720. builder.MoveToCell(0, i + 1, 0, 0);
  10721. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10722. builder.MoveToCell(0, i + 1, 1, 0);
  10723. builder.Write(dt.Rows[i]["City"].ToString());
  10724. builder.MoveToCell(0, i + 1, 2, 0);
  10725. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10726. builder.MoveToCell(0, i + 1, 3, 0);
  10727. builder.Write(dt.Rows[i]["Room"].ToString());
  10728. }
  10729. //删除多余行
  10730. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10731. {
  10732. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10733. }
  10734. string strFileName = di.TeamName + "酒店确认单.doc";
  10735. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10736. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10737. return Ok(JsonView(true, "成功", url));
  10738. }
  10739. catch (Exception ex)
  10740. {
  10741. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10742. }
  10743. }
  10744. #endregion
  10745. #region 团组状态
  10746. /// <summary>
  10747. /// 团组状态列表 Page
  10748. /// </summary>
  10749. /// <param name="dto">团组列表请求dto</param>
  10750. /// <returns></returns>
  10751. [HttpPost]
  10752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10753. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10754. {
  10755. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10756. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10757. {
  10758. string sqlWhere = string.Empty;
  10759. if (dto.IsSure == 0) //未完成
  10760. {
  10761. sqlWhere += string.Format(@" And IsSure = 0");
  10762. }
  10763. else if (dto.IsSure == 1) //已完成
  10764. {
  10765. sqlWhere += string.Format(@" And IsSure = 1");
  10766. }
  10767. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10768. {
  10769. string tj = dto.SearchCriteria;
  10770. 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}%')",
  10771. tj, tj, tj, tj, tj);
  10772. }
  10773. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10774. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10775. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10776. From (
  10777. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10778. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10779. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10780. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10781. From Grp_DelegationInfo gdi
  10782. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10783. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10784. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10785. Where gdi.IsDel = 0 {0}
  10786. ) temp ", sqlWhere);
  10787. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10788. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10789. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10790. }
  10791. else
  10792. {
  10793. return Ok(JsonView(false, "查询失败"));
  10794. }
  10795. }
  10796. /// <summary>
  10797. /// 团组状态
  10798. /// 设置操作完成
  10799. /// </summary>
  10800. /// <param name="dto">团组列表请求dto</param>
  10801. /// <returns></returns>
  10802. [HttpPost]
  10803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10804. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10805. {
  10806. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10807. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10808. {
  10809. Id = dto.Id,
  10810. IsSure = 1
  10811. };
  10812. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10813. .UpdateColumns(it => new { it.IsSure })
  10814. .WhereColumns(it => new { it.Id })
  10815. .ExecuteCommandAsync();
  10816. if (result > 0)
  10817. {
  10818. return Ok(JsonView(true, "操作完成!"));
  10819. }
  10820. return Ok(JsonView(false, "操作失败!"));
  10821. }
  10822. #endregion
  10823. #region 保险费用录入
  10824. /// <summary>
  10825. /// 根据团组Id查询保险费用列表
  10826. /// </summary>
  10827. /// <param name="dto"></param>
  10828. /// <returns></returns>
  10829. [HttpPost]
  10830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10831. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10832. {
  10833. try
  10834. {
  10835. Result groupData = await _customersRep.CustomersByDiId(dto);
  10836. if (groupData.Code != 0)
  10837. {
  10838. return Ok(JsonView(false, groupData.Msg));
  10839. }
  10840. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10841. }
  10842. catch (Exception ex)
  10843. {
  10844. return Ok(JsonView(false, ex.Message));
  10845. }
  10846. }
  10847. /// <summary>
  10848. /// 根据保险费用Id查询保险费用详细
  10849. /// </summary>
  10850. /// <param name="dto"></param>
  10851. /// <returns></returns>
  10852. [HttpPost]
  10853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10854. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10855. {
  10856. try
  10857. {
  10858. Result groupData = await _customersRep.CustomersById(dto);
  10859. if (groupData.Code != 0)
  10860. {
  10861. return Ok(JsonView(false, groupData.Msg));
  10862. }
  10863. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10864. }
  10865. catch (Exception ex)
  10866. {
  10867. return Ok(JsonView(false, ex.Message));
  10868. }
  10869. }
  10870. /// <summary>
  10871. /// 保险费用录入页面初始化绑定
  10872. /// </summary>
  10873. /// <param name="dto"></param>
  10874. /// <returns></returns>
  10875. [HttpPost]
  10876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10877. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10878. {
  10879. try
  10880. {
  10881. Result groupData = await _customersRep.CustomersInitialize(dto);
  10882. if (groupData.Code != 0)
  10883. {
  10884. return Ok(JsonView(false, groupData.Msg));
  10885. }
  10886. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10887. }
  10888. catch (Exception ex)
  10889. {
  10890. return Ok(JsonView(false, ex.Message));
  10891. }
  10892. }
  10893. /// <summary>
  10894. /// 保险费用操作(Status:1.新增,2.修改)
  10895. /// </summary>
  10896. /// <param name="dto"></param>
  10897. /// <returns></returns>
  10898. [HttpPost]
  10899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10900. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10901. {
  10902. Result groupData = await _customersRep.OpCustomers(dto);
  10903. if (groupData.Code != 0)
  10904. {
  10905. return Ok(JsonView(false, groupData.Msg));
  10906. }
  10907. #region 应用推送
  10908. try
  10909. {
  10910. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10911. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10912. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10913. }
  10914. catch (Exception ex)
  10915. {
  10916. }
  10917. #endregion
  10918. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10919. }
  10920. /// <summary>
  10921. /// 保险文件上传
  10922. /// </summary>
  10923. /// <param name="file"></param>
  10924. /// <returns></returns>
  10925. [HttpPost]
  10926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10927. public async Task<IActionResult> UploadCus(IFormFile file)
  10928. {
  10929. try
  10930. {
  10931. if (file != null)
  10932. {
  10933. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10934. //文件名称
  10935. string projectFileName = file.FileName;
  10936. //上传的文件的路径
  10937. string filePath = "";
  10938. if (!Directory.Exists(fileDir))
  10939. {
  10940. Directory.CreateDirectory(fileDir);
  10941. }
  10942. //上传的文件的路径
  10943. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10944. using (FileStream fs = System.IO.File.Create(filePath))
  10945. {
  10946. file.CopyTo(fs);
  10947. fs.Flush();
  10948. }
  10949. return Ok(JsonView(true, "上传成功!", projectFileName));
  10950. }
  10951. else
  10952. {
  10953. return Ok(JsonView(false, "上传失败!"));
  10954. }
  10955. }
  10956. catch (Exception ex)
  10957. {
  10958. return Ok(JsonView(false, "程序错误!"));
  10959. throw;
  10960. }
  10961. }
  10962. /// <summary>
  10963. /// 保险删除指定文件
  10964. /// </summary>
  10965. /// <param name="dto"></param>
  10966. /// <returns></returns>
  10967. [HttpPost]
  10968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10969. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10970. {
  10971. try
  10972. {
  10973. string filePath = "";
  10974. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10975. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10976. //int id = 0;
  10977. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10978. // 删除该文件
  10979. try
  10980. {
  10981. System.IO.File.Delete(filePath);
  10982. 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()
  10983. {
  10984. Attachment = "",
  10985. }).ExecuteCommandAsync();
  10986. if (result != 0)
  10987. {
  10988. return Ok(JsonView(true, "成功!"));
  10989. }
  10990. else
  10991. {
  10992. return Ok(JsonView(false, "失败!"));
  10993. }
  10994. }
  10995. catch (Exception)
  10996. {
  10997. 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()
  10998. {
  10999. Attachment = "",
  11000. }).ExecuteCommandAsync();
  11001. if (result != 0)
  11002. {
  11003. return Ok(JsonView(true, "成功!"));
  11004. }
  11005. else
  11006. {
  11007. return Ok(JsonView(false, "失败!"));
  11008. }
  11009. }
  11010. }
  11011. catch (Exception ex)
  11012. {
  11013. return Ok(JsonView(false, "程序错误!"));
  11014. throw;
  11015. }
  11016. }
  11017. /// <summary>
  11018. /// 保险费用操作(删除)
  11019. /// </summary>
  11020. /// <param name="dto"></param>
  11021. /// <returns></returns>
  11022. [HttpPost]
  11023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11024. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11025. {
  11026. try
  11027. {
  11028. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11029. if (!res)
  11030. {
  11031. return Ok(JsonView(false, "删除失败"));
  11032. }
  11033. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11034. {
  11035. IsDel = 1,
  11036. DeleteUserId = dto.DeleteUserId,
  11037. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11038. }).ExecuteCommandAsync();
  11039. return Ok(JsonView(true, "删除成功!"));
  11040. }
  11041. catch (Exception ex)
  11042. {
  11043. return Ok(JsonView(false, "程序错误!"));
  11044. throw;
  11045. }
  11046. }
  11047. #endregion
  11048. #region 接团客户名单 PageId 104
  11049. /// <summary>
  11050. /// 接团客户名单
  11051. /// 迁移数据(慎用!)
  11052. /// </summary>
  11053. /// <param name="dto"></param>
  11054. /// <returns></returns>
  11055. [HttpPost]
  11056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11057. public async Task<IActionResult> PostTourClientListChange()
  11058. {
  11059. try
  11060. {
  11061. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11062. //var groupClinetData1
  11063. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11064. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11065. int updateCount = 0;
  11066. if (oldOAClientList.Count > 0)
  11067. {
  11068. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11069. _sqlSugar.BeginTran();
  11070. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11071. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11072. foreach (var item in oldOAClientList)
  11073. {
  11074. int comId = 0;
  11075. string format = "yyyy-MM-dd HH:mm:ss";
  11076. string data11 = "1990-01-01 00:00";
  11077. var data1 = IsValidDate(item.OPdate, format);
  11078. if (data1) data11 = item.OPdate;
  11079. //客户公司验证
  11080. if (!string.IsNullOrEmpty(item.Company))
  11081. {
  11082. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11083. if (clientComInfo == null) // add
  11084. {
  11085. var addInfo = new Crm_CustomerCompany()
  11086. {
  11087. CompanyAbbreviation = "",
  11088. CompanyFullName = item.Company,
  11089. Address = "",
  11090. PostCodes = "",
  11091. LastedOpUserId = item.OPer,
  11092. LastedOpDt = Convert.ToDateTime(data11),
  11093. CreateUserId = item.OPer,
  11094. CreateTime = Convert.ToDateTime(data11),
  11095. IsDel = 0
  11096. };
  11097. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11098. if (comId1 > 0) comId = comId1;
  11099. }
  11100. else comId = clientComInfo.Id;
  11101. }
  11102. //客户人员验证
  11103. int clientId = 0;
  11104. string name = item.LastName + item.Name;
  11105. if (!string.IsNullOrEmpty(name))
  11106. {
  11107. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11108. if (clientInfo == null)
  11109. {
  11110. DateTime? dateTime = null;
  11111. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11112. if (isDt) dateTime = birthDayDt;
  11113. var addInfo1 = new Crm_DeleClient()
  11114. {
  11115. CrmCompanyId = comId,
  11116. DiId = -1,
  11117. LastName = item.LastName,
  11118. FirstName = item.Name,
  11119. OldName = "",
  11120. Pinyin = item.Pinyin,
  11121. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11122. Marriage = 0,
  11123. Phone = item.Phone,
  11124. Job = item.Job,
  11125. BirthDay = dateTime
  11126. };
  11127. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11128. if (clientId1 > 0) clientId = clientId1;
  11129. }
  11130. else clientId = clientInfo.Id;
  11131. }
  11132. if (clientId < 1)
  11133. {
  11134. continue;
  11135. }
  11136. int airType = 0;
  11137. if (item.AirType == "超经舱") airType = 459;
  11138. else if (item.AirType == "公务舱") airType = 458;
  11139. else if (item.AirType == "经济舱") airType = 460;
  11140. else if (item.AirType == "其他") airType = 565;
  11141. else if (item.AirType == "头等舱") airType = 457;
  11142. var _TourClientListEntity = new Grp_TourClientList()
  11143. {
  11144. DiId = item.Diid,
  11145. ClientId = clientId,
  11146. CreateUserId = item.OPer,
  11147. CreateTime = Convert.ToDateTime(data11),
  11148. Remark = item.Remark,
  11149. IsDel = item.Isdel,
  11150. ShippingSpaceTypeId = airType,
  11151. ShippingSpaceSpecialNeeds = item.AirRemark,
  11152. HotelSpecialNeeds = item.RoomType
  11153. };
  11154. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11155. if (_TourClientList > 0)
  11156. {
  11157. updateCount++;
  11158. }
  11159. }
  11160. _sqlSugar.CommitTran();
  11161. }
  11162. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11163. }
  11164. catch (Exception ex)
  11165. {
  11166. _sqlSugar.RollbackTran();
  11167. return Ok(JsonView(false, ex.Message));
  11168. }
  11169. return Ok(JsonView(true));
  11170. }
  11171. private bool IsValidDate(string dateString, string format)
  11172. {
  11173. DateTime dateValue;
  11174. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11175. return valid;
  11176. }
  11177. /// <summary>
  11178. /// 接团客户名单
  11179. /// 根据团组Id查询List
  11180. /// </summary>
  11181. /// <param name="dto"></param>
  11182. /// <returns></returns>
  11183. [HttpPost]
  11184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11185. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11186. {
  11187. #region 参数验证
  11188. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11189. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11190. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11191. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11192. #region 页面操作权限验证
  11193. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11194. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11195. #endregion
  11196. #endregion
  11197. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11198. if (viewData.Code != 0)
  11199. {
  11200. return Ok(JsonView(false, viewData.Msg));
  11201. }
  11202. return Ok(JsonView(viewData.Data));
  11203. }
  11204. /// <summary>
  11205. /// 接团客户名单
  11206. /// 基础数据 Init
  11207. /// </summary>
  11208. /// <param name="_dto"></param>
  11209. /// <returns></returns>
  11210. [HttpPost]
  11211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11212. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11213. {
  11214. #region 参数验证
  11215. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11216. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11217. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11218. #region 页面操作权限验证
  11219. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11220. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11221. #endregion
  11222. #endregion
  11223. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11224. }
  11225. /// <summary>
  11226. /// 接团客户名单
  11227. /// 根据 Id查询 Details
  11228. /// </summary>
  11229. /// <param name="_dto"></param>
  11230. /// <returns></returns>
  11231. [HttpPost]
  11232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11233. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11234. {
  11235. #region 参数验证
  11236. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11237. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11238. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11239. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11240. #region 页面操作权限验证
  11241. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11242. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11243. #endregion
  11244. #endregion
  11245. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11246. if (viewData.Code != 0)
  11247. {
  11248. return Ok(JsonView(false, viewData.Msg));
  11249. }
  11250. return Ok(JsonView(viewData.Data));
  11251. }
  11252. /// <summary>
  11253. /// 接团客户名单
  11254. /// Add Or Edit
  11255. /// </summary>
  11256. /// <param name="_dto"></param>
  11257. /// <returns></returns>
  11258. [HttpPost]
  11259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11260. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11261. {
  11262. #region 参数验证
  11263. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11264. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11265. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11266. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11267. #region 页面操作权限验证
  11268. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11269. if (_dto.Id == 0) //添加
  11270. {
  11271. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11272. }
  11273. else if (_dto.Id >= 0) //修改
  11274. {
  11275. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11276. }
  11277. #endregion
  11278. #endregion
  11279. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11280. if (viewData.Code != 0)
  11281. {
  11282. return Ok(JsonView(false, viewData.Msg));
  11283. }
  11284. return Ok(JsonView(true));
  11285. }
  11286. /// <summary>
  11287. /// 接团客户名单
  11288. /// AddMultiple(添加多个)
  11289. /// </summary>
  11290. /// <param name="_dto"></param>
  11291. /// <returns></returns>
  11292. [HttpPost]
  11293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11294. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11295. {
  11296. #region 参数验证
  11297. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11298. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11299. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11300. #region 页面操作权限验证
  11301. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11302. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11303. #endregion
  11304. #endregion
  11305. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11306. if (viewData.Code != 0)
  11307. {
  11308. return Ok(JsonView(false, viewData.Msg));
  11309. }
  11310. return Ok(JsonView(true));
  11311. }
  11312. /// <summary>
  11313. /// 接团客户名单
  11314. /// Del
  11315. /// </summary>
  11316. /// <param name="_dto"></param>
  11317. /// <returns></returns>
  11318. [HttpPost]
  11319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11320. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11321. {
  11322. #region 参数验证
  11323. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11324. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11325. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11326. #region 页面操作权限验证
  11327. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11328. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11329. #endregion
  11330. #endregion
  11331. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11332. if (viewData.Code != 0)
  11333. {
  11334. return Ok(JsonView(false, viewData.Msg));
  11335. }
  11336. return Ok(JsonView(true));
  11337. }
  11338. /// <summary>
  11339. /// 接团客户名单
  11340. /// 文件下载 客户名单
  11341. /// </summary>
  11342. /// <param name="_dto"></param>
  11343. /// <returns></returns>
  11344. [HttpPost]
  11345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11346. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11347. {
  11348. #region 参数验证
  11349. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11350. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11351. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11352. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11353. #region 页面操作权限验证
  11354. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11355. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11356. #endregion
  11357. #endregion
  11358. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11359. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11360. From Grp_TourClientList tcl
  11361. Left Join
  11362. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11363. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11364. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11365. From Crm_DeleClient dc
  11366. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11367. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11368. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11369. Where dc.IsDel = 0) temp
  11370. On temp.DcId =tcl.ClientId
  11371. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11372. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11373. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11374. //载入模板
  11375. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11376. if (_dto.Language == 1)
  11377. {
  11378. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11379. }
  11380. //载入模板
  11381. var doc = new Document(tempPath);
  11382. DocumentBuilder builder = new DocumentBuilder(doc);
  11383. //获取word里所有表格
  11384. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11385. //获取所填表格的序数
  11386. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11387. var rowStart = tableOne.Rows[0]; //获取第1行
  11388. if (_dto.Language == 0)
  11389. {
  11390. //循环赋值
  11391. for (int i = 0; i < DcList.Count; i++)
  11392. {
  11393. builder.MoveToCell(0, i + 1, 0, 0);
  11394. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11395. builder.MoveToCell(0, i + 1, 1, 0);
  11396. int sex = DcList[i].Sex;
  11397. string sexStr = string.Empty;
  11398. if (sex == 0) sexStr = "男";
  11399. else if (sex == 1) sexStr = "女";
  11400. else sexStr = "未设置";
  11401. builder.Write(sexStr);
  11402. builder.MoveToCell(0, i + 1, 2, 0);
  11403. string birthDay = DcList[i].BirthDay;
  11404. string birthDayStr = string.Empty;
  11405. if (!string.IsNullOrEmpty(birthDay))
  11406. {
  11407. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11408. }
  11409. builder.Write(birthDayStr);
  11410. builder.MoveToCell(0, i + 1, 3, 0);
  11411. string company = "";
  11412. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11413. {
  11414. company = DcList[i].CompanyFullName.ToString();
  11415. }
  11416. builder.Write(company);
  11417. builder.MoveToCell(0, i + 1, 4, 0);
  11418. builder.Write(DcList[i].Job);
  11419. }
  11420. }
  11421. else if (_dto.Language == 1)
  11422. {
  11423. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11424. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11425. List<string> transArrayStr = new List<string>();
  11426. string transStrRes1 = "";
  11427. for (int i = 0; i < DcList.Count; i++)
  11428. {
  11429. var dc = DcList[i];
  11430. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11431. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11432. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11433. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11434. else transStrRes1 += $"{str1}|";
  11435. }
  11436. //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";
  11437. string transStrRes = "";
  11438. if (transStrRes1.Length > 0)
  11439. {
  11440. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11441. }
  11442. //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
  11443. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11444. //List<string> transArray = new List<string> { };
  11445. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11446. if (transStrRes.Contains("|"))
  11447. {
  11448. string[] transArray1 = transStrRes.Split('|');
  11449. if (transArray1.Length > 0)
  11450. {
  11451. foreach (var item in transArray1)
  11452. {
  11453. if (item.Contains("&"))
  11454. {
  11455. string[] transArray2 = item.Split('&');
  11456. int index = 0;
  11457. string companyName = "", job = "";
  11458. if (transArray2.Length > 0)
  11459. {
  11460. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11461. if (1 < transArray2.Length) companyName = transArray2[1];
  11462. if (2 < transArray2.Length) job = transArray2[2];
  11463. }
  11464. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11465. }
  11466. }
  11467. }
  11468. }
  11469. //循环赋值
  11470. for (int i = 0; i < DcList.Count; i++)
  11471. {
  11472. string PYName = "";
  11473. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11474. {
  11475. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11476. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11477. PYName = PY_First + " " + PY_Last;
  11478. }
  11479. else
  11480. {
  11481. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11482. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11483. PYName = PY_First + " " + PY_Last;
  11484. }
  11485. builder.MoveToCell(0, i + 1, 0, 0);
  11486. builder.Write(PYName);
  11487. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11488. builder.MoveToCell(0, i + 1, 1, 0);
  11489. builder.Write(sex);
  11490. DateTime birthDt;
  11491. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11492. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11493. builder.MoveToCell(0, i + 1, 2, 0);
  11494. builder.Write(birthday);
  11495. string company = string.Empty, job = string.Empty;
  11496. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11497. if (dcTransInfo != null)
  11498. {
  11499. company = dcTransInfo.CompanyName;
  11500. job = dcTransInfo.Job;
  11501. }
  11502. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11503. {
  11504. //查询对照表
  11505. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11506. if (tempCec != null)
  11507. {
  11508. company = tempCec.enName;
  11509. }
  11510. //翻译
  11511. else
  11512. {
  11513. }
  11514. }
  11515. builder.MoveToCell(0, i + 1, 3, 0);
  11516. builder.Write(company);
  11517. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11518. {
  11519. //查询对照表
  11520. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11521. if (tempPec != null)
  11522. {
  11523. job = tempPec.enName;
  11524. }
  11525. //翻译
  11526. else
  11527. {
  11528. }
  11529. }
  11530. builder.MoveToCell(0, i + 1, 4, 0);
  11531. builder.Write(job);
  11532. }
  11533. }
  11534. //删除多余行
  11535. while (tableOne.Rows.Count > DcList.Count + 1)
  11536. {
  11537. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11538. }
  11539. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11540. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11541. doc.Save(fileDir);
  11542. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11543. return Ok(JsonView(true, "操作成功!", Url));
  11544. }
  11545. private class TranslateInfo
  11546. {
  11547. public int Index { get; set; }
  11548. public string CompanyName { get; set; }
  11549. public string Job { get; set; }
  11550. }
  11551. #endregion
  11552. #region 团组倒推表
  11553. /// <summary>
  11554. /// 倒推表基础数据
  11555. /// Init
  11556. /// </summary>
  11557. /// <param name="dto"></param>
  11558. /// <returns></returns>
  11559. [HttpPost]
  11560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11561. public async Task<IActionResult> PostInvertedListInit()
  11562. {
  11563. var viewData = await _invertedListRep._Init();
  11564. if (viewData.Code != 0)
  11565. {
  11566. return Ok(JsonView(false, viewData.Msg));
  11567. }
  11568. return Ok(JsonView(viewData.Data));
  11569. }
  11570. /// <summary>
  11571. /// 倒推表
  11572. /// Info
  11573. /// </summary>
  11574. /// <param name="dto"></param>
  11575. /// <returns></returns>
  11576. [HttpPost]
  11577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11578. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11579. {
  11580. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11581. if (viewData.Code != 0)
  11582. {
  11583. return Ok(JsonView(false, viewData.Msg));
  11584. }
  11585. return Ok(JsonView(viewData.Data));
  11586. }
  11587. /// <summary>
  11588. /// 倒推表
  11589. /// Create
  11590. /// </summary>
  11591. /// <param name="dto"></param>
  11592. /// <returns></returns>
  11593. [HttpPost]
  11594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11595. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11596. {
  11597. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11598. if (viewData.Code != 0)
  11599. {
  11600. return Ok(JsonView(false, viewData.Msg));
  11601. }
  11602. return Ok(JsonView(viewData.Data));
  11603. }
  11604. /// <summary>
  11605. /// 倒推表
  11606. /// Update
  11607. /// </summary>
  11608. /// <param name="dto"></param>
  11609. /// <returns></returns>
  11610. [HttpPost]
  11611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11612. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11613. {
  11614. var viewData = await _invertedListRep._Update(dto);
  11615. if (viewData.Code != 0)
  11616. {
  11617. return Ok(JsonView(false, viewData.Msg));
  11618. }
  11619. return Ok(JsonView(viewData.Data));
  11620. }
  11621. /// <summary>
  11622. /// 倒推表
  11623. /// File Download
  11624. /// </summary>
  11625. /// <param name="dto"></param>
  11626. /// <returns></returns>
  11627. [HttpPost]
  11628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11629. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11630. {
  11631. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11632. if (info2.Code != 0)
  11633. {
  11634. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11635. }
  11636. var info1 = info2.Data as InvertedListInfoView;
  11637. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11638. string teamName = "";
  11639. if (info != null) teamName = info.TeamName;
  11640. //载入模板
  11641. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11642. DocumentBuilder builder = new DocumentBuilder(doc);
  11643. //利用键值对存放数据
  11644. Dictionary<string, string> dic = new Dictionary<string, string>();
  11645. dic.Add("TeamName", teamName);
  11646. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11647. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11648. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11649. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11650. dic.Add("SQRemark", info1.ApprovalRemark);
  11651. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11652. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11653. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11654. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11655. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11656. dic.Add("QZRemark", info1.VisaInformationRemark);
  11657. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11658. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11659. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11660. dic.Add("CQRemark", info1.IssueVisaRemark);
  11661. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11662. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11663. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11664. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11665. #region 填充word模板书签内容
  11666. foreach (var key in dic.Keys)
  11667. {
  11668. builder.MoveToBookmark(key);
  11669. builder.Write(dic[key]);
  11670. }
  11671. #endregion
  11672. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11673. string fileName = $"{teamName}团出行准备流程表.doc";
  11674. string filePath = fileDir + $@"InvertedList/{fileName}";
  11675. doc.Save(filePath);
  11676. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11677. return Ok(JsonView(true, "操作成功!", Url));
  11678. }
  11679. #endregion
  11680. #region 三公签证费用(签证费、代办费)
  11681. /// <summary>
  11682. /// 三公签证费用(签证费、代办费)
  11683. /// List
  11684. /// </summary>
  11685. /// <returns></returns>
  11686. [HttpPost]
  11687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11688. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11689. {
  11690. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11691. if (_view.Code != 0)
  11692. {
  11693. return Ok(JsonView(false, _view.Msg));
  11694. }
  11695. return Ok(JsonView(true, "操作成功!", _view.Data));
  11696. }
  11697. /// <summary>
  11698. /// 三公签证费用(签证费、代办费)
  11699. /// Add Or Update
  11700. /// </summary>
  11701. /// <returns></returns>
  11702. [HttpPost]
  11703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11704. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11705. {
  11706. var _view = await _visaFeeInfoRep._Update(_dto);
  11707. if (_view.Code != 0)
  11708. {
  11709. return Ok(JsonView(false, _view.Msg));
  11710. }
  11711. return Ok(JsonView(true, _view.Msg));
  11712. }
  11713. #endregion
  11714. #region 酒店询价
  11715. /// <summary>
  11716. /// 酒店询价
  11717. /// Init
  11718. /// </summary>
  11719. /// <param name="dto"></param>
  11720. /// <returns></returns>
  11721. [HttpPost]
  11722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11723. public async Task<IActionResult> PostHotelInquiryInit()
  11724. {
  11725. var res = await _hotelInquiryRep._Init();
  11726. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11727. return Ok(JsonView(true, res.Msg, res.Data));
  11728. }
  11729. /// <summary>
  11730. /// 酒店询价
  11731. /// page Item
  11732. /// </summary>
  11733. /// <param name="_dto"></param>
  11734. /// <returns></returns>
  11735. [HttpPost]
  11736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11737. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11738. {
  11739. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11740. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11741. var view = res.Data as PageDataViewBase;
  11742. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11743. }
  11744. /// <summary>
  11745. /// 酒店询价
  11746. /// info
  11747. /// </summary>
  11748. /// <param name="_dto"></param>
  11749. /// <returns></returns>
  11750. [HttpPost]
  11751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11752. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11753. {
  11754. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11755. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11756. return Ok(JsonView(true, res.Msg, res.Data));
  11757. }
  11758. /// <summary>
  11759. /// 酒店询价
  11760. /// Add Or Edit
  11761. /// </summary>
  11762. /// <param name="_dto"></param>
  11763. /// <returns></returns>
  11764. [HttpPost]
  11765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11766. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11767. {
  11768. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11769. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11770. return Ok(JsonView(true, res.Msg, res.Data));
  11771. }
  11772. /// <summary>
  11773. /// 酒店询价
  11774. /// Del
  11775. /// </summary>
  11776. /// <param name="_dto"></param>
  11777. /// <returns></returns>
  11778. [HttpPost]
  11779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11780. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11781. {
  11782. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11783. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11784. return Ok(JsonView(true, res.Msg, res.Data));
  11785. }
  11786. #endregion
  11787. #region 下载匹配op行程单
  11788. /// <summary>
  11789. /// 匹配op行程单
  11790. /// Init
  11791. /// </summary>
  11792. /// <param name="dto">团组列表请求dto</param>
  11793. /// <returns></returns>
  11794. [HttpPost]
  11795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11796. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11797. {
  11798. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11799. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11800. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11801. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11802. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11803. .Where(it => it.IsDel == 0)
  11804. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11805. .OrderByDescending(it => it.CreateUserId)
  11806. .ToList();
  11807. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11808. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11809. var diids = groupInfos.Select(it => it.Id).ToList();
  11810. List<string> countrys = new List<string>();
  11811. foreach (var item in country)
  11812. {
  11813. var data = _groupRepository.FormartTeamName(item);
  11814. var dataArray = _groupRepository.GroupSplitCountry(data);
  11815. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11816. }
  11817. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11818. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11819. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11820. foreach (var item in areaItem)
  11821. {
  11822. string areaStr = item.Value;
  11823. if (!string.IsNullOrEmpty(areaStr))
  11824. {
  11825. string[] str1 = areaStr.Split("-");
  11826. if (str1.Length > 0)
  11827. {
  11828. areaArray.AddRange(str1);
  11829. }
  11830. }
  11831. }
  11832. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11833. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11834. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11835. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11836. .ToList();
  11837. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11838. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11839. .Where(it => countriesIds.Contains(it.Id))
  11840. .Select(it => new { it.Id, Name = it.Name_CN })
  11841. .ToList();
  11842. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11843. .Select(it => it.TeamName).ToList();
  11844. stopwatch.Stop();
  11845. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11846. }
  11847. ///// <summary>
  11848. ///// 匹配op行程单
  11849. ///// Init 查询区域数据
  11850. ///// </summary>
  11851. ///// <param name="dto">团组列表请求dto</param>
  11852. ///// <returns></returns>
  11853. //[HttpPost]
  11854. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11855. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11856. //{
  11857. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11858. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11859. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11860. // if (string.IsNullOrEmpty(countriesDataStr))
  11861. // {
  11862. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11863. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11864. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11865. // }
  11866. // else
  11867. // {
  11868. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11869. // }
  11870. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11871. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11872. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11873. // List<dynamic> childList = new List<dynamic>();
  11874. // int parentId = dto.CountriesId;
  11875. // if (provinceData.Count > 1)
  11876. // {
  11877. // foreach (var item1 in provinceData)
  11878. // {
  11879. // List<dynamic> childList1 = new List<dynamic>();
  11880. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11881. // foreach (var item2 in citiesData1)
  11882. // {
  11883. // List<dynamic> childList2 = new List<dynamic>();
  11884. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11885. // foreach (var item3 in countiesData1)
  11886. // {
  11887. // childList2.Add(new
  11888. // {
  11889. // id = item3.Id,
  11890. // parentId = item2.Id,
  11891. // level = "district",
  11892. // name = item3.Name_CN,
  11893. // });
  11894. // }
  11895. // childList1.Add(new
  11896. // {
  11897. // id = item2.Id,
  11898. // parentId = item1.Id,
  11899. // level = "city",
  11900. // name = item2.Name_CN,
  11901. // childList = childList2
  11902. // });
  11903. // }
  11904. // childList.Add(new
  11905. // {
  11906. // id = item1.Id,
  11907. // parentId = parentId,
  11908. // level = "province",
  11909. // name = item1.Name_CN,
  11910. // childList = childList1
  11911. // });
  11912. // }
  11913. // //城市
  11914. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11915. // foreach (var item2 in citiesData2)
  11916. // {
  11917. // List<dynamic> childList22 = new List<dynamic>();
  11918. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11919. // foreach (var item3 in countiesData1)
  11920. // {
  11921. // childList22.Add(new
  11922. // {
  11923. // id = item3.Id,
  11924. // parentId = item2.Id,
  11925. // level = "district",
  11926. // name = item3.Name_CN,
  11927. // });
  11928. // }
  11929. // childList.Add(new
  11930. // {
  11931. // id = item2.Id,
  11932. // parentId = parentId,
  11933. // level = "city",
  11934. // name = item2.Name_CN,
  11935. // childList = childList22
  11936. // });
  11937. // }
  11938. // }
  11939. // else
  11940. // {
  11941. // foreach (var item2 in citiesData)
  11942. // {
  11943. // string cname = item2.Name_CN;
  11944. // List<dynamic> childList1 = new List<dynamic>();
  11945. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11946. // foreach (var item3 in countiesData1)
  11947. // {
  11948. // childList1.Add(new
  11949. // {
  11950. // Id = item3.Id,
  11951. // parentId = item2.Id,
  11952. // level = "district",
  11953. // name = item3.Name_CN
  11954. // });
  11955. // }
  11956. // childList.Add(new
  11957. // {
  11958. // id = item2.Id,
  11959. // parentId = parentId,
  11960. // level = "city",
  11961. // name = item2.Name_CN,
  11962. // childList = childList1
  11963. // });
  11964. // }
  11965. // }
  11966. // stopwatch.Stop();
  11967. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11968. //}
  11969. /// <summary>
  11970. /// 匹配op行程单
  11971. /// 接团信息列表 Page
  11972. /// </summary>
  11973. /// <param name="dto">团组列表请求dto</param>
  11974. /// <returns></returns>
  11975. [HttpPost]
  11976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11977. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11978. {
  11979. var swatch = new Stopwatch();
  11980. swatch.Start();
  11981. #region 参数验证
  11982. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11983. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11984. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11985. #region 页面操作权限验证
  11986. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11987. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11988. #endregion
  11989. #endregion
  11990. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11991. {
  11992. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11993. string sqlWhere = "";
  11994. if (!string.IsNullOrEmpty(dto.Country))
  11995. {
  11996. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11997. }
  11998. if (!string.IsNullOrEmpty(dto.Area))
  11999. {
  12000. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12001. }
  12002. if (!string.IsNullOrEmpty(dto.TeamName))
  12003. {
  12004. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12005. }
  12006. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12007. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12008. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12009. swatch.Stop();
  12010. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12011. }
  12012. else
  12013. {
  12014. return Ok(JsonView(false, "查询失败"));
  12015. }
  12016. }
  12017. /// <summary>
  12018. /// 匹配op行程单
  12019. /// 行程单下载
  12020. /// </summary>
  12021. /// <param name="dto">团组列表请求dto</param>
  12022. /// <returns></returns>
  12023. [HttpPost]
  12024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12025. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12026. {
  12027. #region 参数验证
  12028. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12029. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12030. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12031. #region 页面操作权限验证
  12032. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12033. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12034. #endregion
  12035. #endregion
  12036. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12037. {
  12038. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12039. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12040. }
  12041. else
  12042. {
  12043. return Ok(JsonView(false, "下载失败!"));
  12044. }
  12045. }
  12046. #endregion
  12047. #region 国家信息 数据 注释
  12048. //[HttpPost]
  12049. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12050. //{
  12051. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12052. // foreach (var item in dto)
  12053. // {
  12054. // infos.Add(new Grp_GroupsTaskAssignment()
  12055. // {
  12056. // DIId = item,
  12057. // CTId = 82,
  12058. // UId = 248,
  12059. // IsEnable = 1,
  12060. // CreateUserId = 233,
  12061. // CreateTime = DateTime.Now,
  12062. // IsDel = 0
  12063. // });
  12064. // infos.Add(new Grp_GroupsTaskAssignment()
  12065. // {
  12066. // DIId = item,
  12067. // CTId = 82,
  12068. // UId = 286,
  12069. // IsEnable = 1,
  12070. // CreateUserId = 233,
  12071. // CreateTime = DateTime.Now,
  12072. // IsDel = 0
  12073. // });
  12074. // }
  12075. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12076. // return Ok("操作成功");
  12077. //}
  12078. //public class paramJsonDto
  12079. //{
  12080. // public List<CountriesInfo> str { get; set; }
  12081. //}
  12082. //[HttpPost]
  12083. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12084. //{
  12085. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12086. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12087. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12088. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12089. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12090. // _sqlSugar.BeginTran();
  12091. // int countitiesIndex = 0;
  12092. // foreach (var item in dto.str)
  12093. // {
  12094. // dynamic data = item.c;
  12095. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12096. // if (data != null)
  12097. // {
  12098. // countitiesIndex++;
  12099. // foreach (var item1 in data)
  12100. // {
  12101. // string cnname = item1.cn;
  12102. // string enname = item1.en;
  12103. // Sys_Cities provinceInfo = new Sys_Cities()
  12104. // {
  12105. // CountriesId = countriesId,
  12106. // Name_CN = cnname,
  12107. // Name_EN = enname,
  12108. // ParentId = 0,
  12109. // IsCapital = 1,
  12110. // CreateUserId = 208,
  12111. // CreateTime = DateTime.Now,
  12112. // IsDel = 0
  12113. // };
  12114. // if (item1.lv == "province") //省份
  12115. // {
  12116. // provinceInfo.Level = 1;
  12117. // int provinceId = 0;
  12118. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12119. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12120. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12121. // var data1 = item1.c;
  12122. // foreach (var item2 in data1)
  12123. // {
  12124. // if (item2.lv == "city")
  12125. // {
  12126. // string citycnname = item2.cn;
  12127. // string cityenname = item2.en;
  12128. // Sys_Cities cityInfo = new Sys_Cities()
  12129. // {
  12130. // CountriesId = countriesId,
  12131. // ParentId = provinceId,
  12132. // Level = 2,
  12133. // Name_CN = citycnname,
  12134. // Name_EN = cityenname,
  12135. // IsCapital = 1,
  12136. // CreateUserId = 208,
  12137. // CreateTime = DateTime.Now,
  12138. // IsDel = 0
  12139. // };
  12140. // if (item2.c != null)
  12141. // {
  12142. // int cityId = 0;
  12143. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12144. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12145. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12146. // foreach (var item3 in item2.c)
  12147. // {
  12148. // if (item3.lv == "district")
  12149. // {
  12150. // var districtInfo = new Sys_Cities()
  12151. // {
  12152. // CountriesId = countriesId,
  12153. // Name_CN = item3.cn,
  12154. // Name_EN = item3.en,
  12155. // Level = 3,
  12156. // ParentId = cityId,
  12157. // IsCapital = 1,
  12158. // CreateUserId = 208,
  12159. // CreateTime = DateTime.Now,
  12160. // IsDel = 0
  12161. // };
  12162. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12163. // //{
  12164. // districts.Add(districtInfo);
  12165. // //}
  12166. // }
  12167. // }
  12168. // }
  12169. // else
  12170. // {
  12171. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12172. // //{
  12173. // cities.Add(cityInfo);
  12174. // //}
  12175. // }
  12176. // }
  12177. // }
  12178. // }
  12179. // else if (item1.lv == "city")//城市
  12180. // {
  12181. // provinceInfo.Level = 2;
  12182. // if (item1.c != null)
  12183. // {
  12184. // int cityId = 0;
  12185. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12186. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12187. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12188. // foreach (var item3 in item1.c)
  12189. // {
  12190. // if (item3.lv == "district")
  12191. // {
  12192. // var districtInfo = new Sys_Cities()
  12193. // {
  12194. // CountriesId = countriesId,
  12195. // Name_CN = item3.cn,
  12196. // Name_EN = item3.en,
  12197. // Level = 3,
  12198. // ParentId = cityId,
  12199. // IsCapital = 1,
  12200. // CreateUserId = 208,
  12201. // CreateTime = DateTime.Now,
  12202. // IsDel = 0
  12203. // };
  12204. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12205. // //{
  12206. // districts.Add(districtInfo);
  12207. // //}
  12208. // }
  12209. // }
  12210. // }
  12211. // else
  12212. // {
  12213. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12214. // //{
  12215. // cities.Add(provinceInfo);
  12216. // //}
  12217. // }
  12218. // }
  12219. // }
  12220. // }
  12221. // }
  12222. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12223. // cities = cities.Distinct().ToList();
  12224. // districts = districts.Distinct().ToList();
  12225. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12226. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12227. // cities.AddRange(districts);
  12228. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12229. // //_sqlSugar.RollbackTran();
  12230. // _sqlSugar.CommitTran();
  12231. // return Ok(JsonView(false, "操作成功!"));
  12232. //}
  12233. //[HttpPost]
  12234. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12235. //{
  12236. // List<CountitiesInfo> infos = dto.MyProperty;
  12237. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12238. // _sqlSugar.BeginTran();
  12239. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12240. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12241. // foreach (var item in infos)
  12242. // {
  12243. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12244. // if (countryInfo != null)
  12245. // {
  12246. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12247. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12248. // if (cityInfo1 != null)
  12249. // {
  12250. // cityInfo1.IsCapital = 0;
  12251. // cityInfos.Add(cityInfo1);
  12252. // }
  12253. // }
  12254. // }
  12255. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12256. // .UpdateColumns(it => it.IsCapital)
  12257. // .WhereColumns(it => it.Id)
  12258. // .ExecuteCommand();
  12259. // //_sqlSugar.RollbackTran();
  12260. // _sqlSugar.CommitTran();
  12261. // return Ok(JsonView(false, "操作成功!"));
  12262. //}
  12263. //public class CounrtiesDto
  12264. //{
  12265. // public List<CountitiesInfo> MyProperty { get; set; }
  12266. //}
  12267. //public class CountitiesInfo
  12268. //{
  12269. // /// <summary>
  12270. // /// 圣约翰
  12271. // /// </summary>
  12272. // public string capital_name_chinese { get; set; }
  12273. // /// <summary>
  12274. // ///
  12275. // /// </summary>
  12276. // public string capital_name { get; set; }
  12277. // /// <summary>
  12278. // ///
  12279. // /// </summary>
  12280. // public string country_type { get; set; }
  12281. // /// <summary>
  12282. // /// 安提瓜和巴布达
  12283. // /// </summary>
  12284. // public string country_name_chinese { get; set; }
  12285. // /// <summary>
  12286. // /// 安提瓜和巴布达
  12287. // /// </summary>
  12288. // public string country_name_chinese_short { get; set; }
  12289. // /// <summary>
  12290. // /// 安提瓜和巴布达
  12291. // /// </summary>
  12292. // public string country_name_chinese_UN { get; set; }
  12293. // /// <summary>
  12294. // ///
  12295. // /// </summary>
  12296. // public string country_name_english_abbreviation { get; set; }
  12297. // /// <summary>
  12298. // ///
  12299. // /// </summary>
  12300. // public string country_name_english_formal { get; set; }
  12301. // /// <summary>
  12302. // ///
  12303. // /// </summary>
  12304. // public string country_name_english_UN { get; set; }
  12305. // /// <summary>
  12306. // ///
  12307. // /// </summary>
  12308. // public string continent_name { get; set; }
  12309. // /// <summary>
  12310. // ///
  12311. // /// </summary>
  12312. // public string subregion_name { get; set; }
  12313. // /// <summary>
  12314. // ///
  12315. // /// </summary>
  12316. // public string country_code2 { get; set; }
  12317. // /// <summary>
  12318. // ///
  12319. // /// </summary>
  12320. // public string country_code3 { get; set; }
  12321. // /// <summary>
  12322. // ///
  12323. // /// </summary>
  12324. // public string phone_code { get; set; }
  12325. //}
  12326. //public class CountriesInfo : BasicInfo
  12327. //{
  12328. // public List<CitiesInfo> c { get; set; }
  12329. //}
  12330. //public class CitiesInfo : BasicInfo
  12331. //{
  12332. // public List<AreaInfo> c { get; set; }
  12333. //}
  12334. //public class AreaInfo : BasicInfo
  12335. //{
  12336. // public List<AreaInfo> c { get; set; }
  12337. //}
  12338. //public class BasicInfo
  12339. //{
  12340. // public string code { get; set; }
  12341. // public string cn { get; set; }
  12342. // public string lv { get; set; }
  12343. // public string en { get; set; }
  12344. //}
  12345. #endregion
  12346. #region 查看邀请方
  12347. /// <summary>
  12348. /// 查看邀请方
  12349. /// 邀请方信息 Init
  12350. /// </summary>
  12351. /// <param name="dto"></param>
  12352. /// <returns></returns>
  12353. [HttpPost]
  12354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12355. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12356. {
  12357. string sqlWhere = string.Empty;
  12358. if (!string.IsNullOrEmpty(dto.Search))
  12359. {
  12360. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12361. }
  12362. string sql = string.Format($@"Select
  12363. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12364. Id,
  12365. UnitName
  12366. From Res_InvitationOfficialActivityData
  12367. Where IsDel = 0
  12368. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12369. RefAsync<int> total = 0;
  12370. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12371. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12372. }
  12373. /// <summary>
  12374. /// 查看邀请方
  12375. /// 国家信息 Init
  12376. /// </summary>
  12377. /// <param name="dto"></param>
  12378. /// <returns></returns>
  12379. [HttpPost]
  12380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12381. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12382. {
  12383. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12384. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12385. var diids = groupInfos.Select(it => it.Id).ToList();
  12386. List<string> countrys = new List<string>();
  12387. foreach (var item in country)
  12388. {
  12389. var data = _groupRepository.FormartTeamName(item);
  12390. var dataArray = _groupRepository.GroupSplitCountry(data);
  12391. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12392. }
  12393. countrys = countrys.Distinct().ToList();
  12394. for (int i = 0; i < countrys.Count; i++)
  12395. {
  12396. string item = countrys[i];
  12397. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12398. {
  12399. countrys.Remove(item);
  12400. i--;
  12401. }
  12402. }
  12403. RefAsync<int> total = 0;
  12404. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12405. .Where(it => countrys.Contains(it.Name_CN))
  12406. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12407. .Select(it => new { id = it.Id, name = it.Name_CN })
  12408. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12409. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12410. }
  12411. /// <summary>
  12412. /// 查看邀请方
  12413. /// 城市信息 Init
  12414. /// </summary>
  12415. /// <param name="dto"></param>
  12416. /// <returns></returns>
  12417. [HttpPost]
  12418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12419. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12420. {
  12421. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12422. RefAsync<int> total = 0;
  12423. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12424. .Where(it => it.CountriesId == dto.CountiesId)
  12425. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12426. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12427. .Select(it => new { id = it.Id, name = it.Name_CN })
  12428. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12429. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12430. }
  12431. /// <summary>
  12432. /// 查看邀请方
  12433. /// 团组名称 Init
  12434. /// </summary>
  12435. /// <param name="dto"></param>
  12436. /// <returns></returns>
  12437. [HttpPost]
  12438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12439. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12440. {
  12441. var watch = new Stopwatch();
  12442. watch.Start();
  12443. RefAsync<int> total = 0;
  12444. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12445. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12446. .Where((oa, di) => oa.IsDel == 0)
  12447. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12448. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12449. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12450. .Distinct()
  12451. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12452. watch.Stop();
  12453. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12454. }
  12455. /// <summary>
  12456. /// 查看邀请方
  12457. /// 团组 & 邀请方信息
  12458. /// </summary>
  12459. /// <param name="dto"></param>
  12460. /// <returns></returns>
  12461. [HttpPost]
  12462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12463. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12464. {
  12465. var watch = new Stopwatch();
  12466. watch.Start();
  12467. RefAsync<int> total = 0;
  12468. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12469. .AS("Grp_DelegationInfo")
  12470. .Includes(x => x.InvitingInfos)
  12471. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12472. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12473. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12474. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12475. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12476. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12477. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12478. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12479. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12480. infos.ForEach(x =>
  12481. {
  12482. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12483. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12484. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12485. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12486. });
  12487. watch.Stop();
  12488. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12489. }
  12490. #endregion
  12491. #region 报批行程
  12492. /// <summary>
  12493. /// 报批行程初始化
  12494. /// </summary>
  12495. /// <param name="dto"></param>
  12496. /// <returns></returns>
  12497. [HttpPost]
  12498. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12499. {
  12500. const int chiNumber = 5;
  12501. var jw = JsonView(false);
  12502. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12503. var group = groupList.First();
  12504. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12505. group = groupList.First(x => x.Id == diid);
  12506. if (group == null)
  12507. {
  12508. jw.Msg = "暂无团组!";
  12509. return Ok(jw);
  12510. }
  12511. var data = new
  12512. {
  12513. groupList = groupList.Select(x => new
  12514. {
  12515. x.TeamName,
  12516. x.Id
  12517. }),
  12518. content = new ArrayList(),
  12519. groupInfo = new
  12520. {
  12521. group.VisitDays,
  12522. group.TourCode,
  12523. group.VisitPNumber,
  12524. group.TeamName,
  12525. group.Id,
  12526. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12527. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12528. },
  12529. };
  12530. var resultArr = new ArrayList();
  12531. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12532. if (content.Count == 0)
  12533. {
  12534. var stay = "-";
  12535. var cityPath = "-";
  12536. //添加城市路径以及住宿地
  12537. //黑屏代码数据
  12538. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12539. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12540. {
  12541. jw = JsonView(true, "黑屏代码有误!", data);
  12542. return Ok(jw);
  12543. }
  12544. foreach (DataRow row in dtBlack.Rows)
  12545. {
  12546. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12547. {
  12548. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12549. return Ok(jw);
  12550. }
  12551. }
  12552. //黑屏代码获取时间区间
  12553. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12554. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12555. _sqlSugar.BeginTran();
  12556. for (int i = 0; i < timeArr.Count; i++)
  12557. {
  12558. stay = "-";
  12559. cityPath = "-";
  12560. DateTime NewData = DateTime.Parse(timeArr[i]);
  12561. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12562. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12563. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12564. if (tbSelect.Length > 0)
  12565. {
  12566. List<string> threeCodeStr = new List<string>();
  12567. foreach (var item in tbSelect)
  12568. {
  12569. var threeCode = item["Three"].ToString() ?? "";
  12570. if (threeCode.Length == 6)
  12571. {
  12572. var start = threeCode.Substring(0, 3);
  12573. var end = threeCode.Substring(3, 3);
  12574. if (threeCodeStr.Count == 0)
  12575. {
  12576. threeCodeStr.Add(start);
  12577. threeCodeStr.Add(end);
  12578. }
  12579. else
  12580. {
  12581. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12582. {
  12583. threeCodeStr.Add(end);
  12584. }
  12585. else
  12586. {
  12587. threeCodeStr.Add(start);
  12588. threeCodeStr.Add(end);
  12589. }
  12590. }
  12591. }
  12592. }
  12593. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12594. var last = threeCodeStr.Last();
  12595. foreach (var item in threeCodeStr)
  12596. {
  12597. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12598. if (item.Equals(last))
  12599. {
  12600. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12601. }
  12602. }
  12603. cityPath = cityPath.Trim('-');
  12604. }
  12605. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12606. appro.Diid = diid ?? -1;
  12607. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12608. appro.Id = thisId;
  12609. appro.CreateUserId = dto.UserId;
  12610. appro.CreateTime = DateTime.Now;
  12611. content.Add(appro);
  12612. }
  12613. _sqlSugar.CommitTran();
  12614. }
  12615. foreach (var x in content)
  12616. {
  12617. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12618. if (chiList.Count < chiNumber)
  12619. {
  12620. for (int i = chiList.Count; i < chiNumber; i++)
  12621. {
  12622. chiList.Add(new Grp_ApprovalTravelDetails());
  12623. }
  12624. }
  12625. resultArr.Add(new
  12626. {
  12627. x.Id,
  12628. x.Date,
  12629. x.Diid,
  12630. chiList = chiList.Select(x1 => new
  12631. {
  12632. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12633. x1.Details,
  12634. x1.ParentId,
  12635. x1.Id
  12636. })
  12637. });
  12638. }
  12639. data = data with
  12640. {
  12641. content = resultArr,
  12642. };
  12643. jw = JsonView(true, "获取成功!", data);
  12644. return Ok(jw);
  12645. }
  12646. /// <summary>
  12647. /// 报批行程删除
  12648. /// </summary>
  12649. /// <param name="dto"></param>
  12650. /// <returns></returns>
  12651. [HttpPost]
  12652. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12653. {
  12654. var jw = JsonView(false);
  12655. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12656. if (group == null)
  12657. {
  12658. jw.Msg = "团组参数有误!";
  12659. return Ok(jw);
  12660. }
  12661. try
  12662. {
  12663. _sqlSugar.BeginTran();
  12664. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12665. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12666. {
  12667. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12668. DeleteUserId = dto.uesrId,
  12669. IsDel = 1
  12670. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12671. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12672. {
  12673. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12674. DeleteUserId = dto.uesrId,
  12675. IsDel = 1
  12676. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12677. _sqlSugar.CommitTran();
  12678. jw = JsonView(true, "删除成功");
  12679. }
  12680. catch (Exception ex)
  12681. {
  12682. jw = JsonView(false, ex.Message);
  12683. }
  12684. return Ok(jw);
  12685. }
  12686. /// <summary>
  12687. /// 报批行程保存
  12688. /// </summary>
  12689. /// <param name="dto"></param>
  12690. /// <returns></returns>
  12691. [HttpPost]
  12692. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12693. {
  12694. var jw = JsonView(false);
  12695. var Find = dto.Arr.Find(x => x.id == 0);
  12696. if (Find != null)
  12697. {
  12698. jw.Msg = "生成的ID为0!";
  12699. return Ok(jw);
  12700. }
  12701. foreach (var item in dto.Arr)
  12702. {
  12703. foreach (var chi in item.chiList)
  12704. {
  12705. if (chi.parentId == 0)
  12706. {
  12707. chi.parentId = item.id;
  12708. }
  12709. }
  12710. }
  12711. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12712. _sqlSugar.BeginTran();
  12713. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12714. {
  12715. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12716. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12717. {
  12718. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12719. DeleteUserId = dto.UserId,
  12720. IsDel = 1
  12721. }).ExecuteCommand();
  12722. }
  12723. try
  12724. {
  12725. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12726. {
  12727. CreateTime = DateTime.Now,
  12728. CreateUserId = dto.UserId,
  12729. Details = x.details,
  12730. ParentId = x.parentId,
  12731. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12732. Remark = "",
  12733. IsDel = 0
  12734. }).ToList()).ExecuteCommand();
  12735. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12736. {
  12737. Id = x.id,
  12738. Details = x.details,
  12739. ParentId = x.parentId,
  12740. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12741. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12742. {
  12743. Details = x.Details,
  12744. ParentId = x.ParentId,
  12745. Time = x.Time
  12746. }).ExecuteCommand();
  12747. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12748. {
  12749. Id = x.id,
  12750. Date = x.date,
  12751. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12752. {
  12753. Date = x.Date
  12754. }).ExecuteCommand();
  12755. _sqlSugar.CommitTran();
  12756. jw = JsonView(true, "保存成功!");
  12757. }
  12758. catch (Exception ex)
  12759. {
  12760. _sqlSugar.RollbackTran();
  12761. jw = JsonView(false, "保存失败!" + ex.Message);
  12762. }
  12763. return Ok(jw);
  12764. }
  12765. /// <summary>
  12766. /// 报批行程生成
  12767. /// </summary>
  12768. /// <param name="dto"></param>
  12769. /// <returns></returns>
  12770. [HttpPost]
  12771. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12772. {
  12773. var jw = JsonView(false);
  12774. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12775. if (group == null)
  12776. {
  12777. jw.Msg = "暂无该团组!";
  12778. return Ok(jw);
  12779. }
  12780. //黑屏代码数据
  12781. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12782. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12783. {
  12784. jw.Msg = "黑屏代码有误!";
  12785. return Ok(jw);
  12786. }
  12787. foreach (DataRow row in dtBlack.Rows)
  12788. {
  12789. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12790. {
  12791. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12792. return Ok(jw);
  12793. }
  12794. }
  12795. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12796. var resultArr = new ArrayList();
  12797. if (officialActivitiesArr.Count == 0)
  12798. {
  12799. jw.Msg = "暂无公务出访信息!";
  12800. return Ok(jw);
  12801. }
  12802. try
  12803. {
  12804. _sqlSugar.BeginTran();
  12805. DeleteApprovalJourney(new
  12806. Domain.Dtos.Groups.DeleteApprovalJourney
  12807. {
  12808. Diid = dto.Diid,
  12809. uesrId = dto.Userid
  12810. });
  12811. var stay = "-";
  12812. var cityPath = "-";
  12813. //添加城市路径以及住宿地
  12814. //黑屏代码获取时间区间
  12815. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12816. var empty = "【未收入该三字码!请机票同事录入】";
  12817. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12818. for (int i = 0; i < timeArr.Count; i++)
  12819. {
  12820. stay = "-";
  12821. cityPath = "-";
  12822. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12823. DateTime NewData = DateTime.Parse(timeArr[i]);
  12824. 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();
  12825. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12826. if (tbSelect.Length > 0)
  12827. {
  12828. List<string> threeCodeStr = new List<string>();
  12829. bool isTrade = false;
  12830. string trip = string.Empty;
  12831. var rowLast = tbSelect.Last();
  12832. var rowFirst = tbSelect.First();
  12833. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12834. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12835. var takeOffTime = DateTime.Parse(timeArr[i]);
  12836. var fallToTime = DateTime.Parse(timeArr[i]);
  12837. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12838. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12839. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12840. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12841. foreach (var item in tbSelect)
  12842. {
  12843. var start = string.Empty;
  12844. var end = string.Empty;
  12845. var threeCode = item["Three"].ToString() ?? "";
  12846. if (threeCode.Length == 6)
  12847. {
  12848. start = threeCode.Substring(0, 3);
  12849. end = threeCode.Substring(3, 3);
  12850. if (threeCodeStr.Count == 0)
  12851. {
  12852. threeCodeStr.Add(start);
  12853. threeCodeStr.Add(end);
  12854. }
  12855. else
  12856. {
  12857. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12858. {
  12859. threeCodeStr.Add(end);
  12860. }
  12861. else
  12862. {
  12863. threeCodeStr.Add(start);
  12864. threeCodeStr.Add(end);
  12865. }
  12866. }
  12867. }
  12868. //处理机票信息
  12869. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12870. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12871. if (start_Object == null)
  12872. {
  12873. start_Object = new Res_ThreeCode()
  12874. {
  12875. AirPort = empty,
  12876. AirPort_En = empty,
  12877. City = empty,
  12878. Country = empty,
  12879. Four = empty,
  12880. Three = empty,
  12881. };
  12882. }
  12883. if (end_Object == null)
  12884. {
  12885. end_Object = new Res_ThreeCode()
  12886. {
  12887. AirPort = empty,
  12888. AirPort_En = empty,
  12889. City = empty,
  12890. Country = empty,
  12891. Four = empty,
  12892. Three = empty,
  12893. };
  12894. }
  12895. //机型判断
  12896. string airModel = item["AirModel"].ToString();
  12897. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12898. string flightTime = item["FlightTime"].ToString();
  12899. if (flightTime!.Contains(":"))
  12900. {
  12901. flightTime = flightTime.Replace(":", "小时");
  12902. flightTime += "分钟";
  12903. }
  12904. if (flightTime.Contains("H"))
  12905. {
  12906. flightTime = flightTime.Replace("H", "小时");
  12907. }
  12908. if (flightTime.Contains("M"))
  12909. {
  12910. flightTime = flightTime.Replace("M", "分钟");
  12911. }
  12912. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12913. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12914. {
  12915. flightTime = flightDataTime.Hour > 0
  12916. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12917. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12918. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12919. }
  12920. //航班号
  12921. string flightcode = item["Fliagtcode"].ToString();
  12922. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12923. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12924. if (aircompany == null)
  12925. {
  12926. aircompany = new Res_AirCompany
  12927. {
  12928. CnName = hsEmpty,
  12929. EnName = hsEmpty,
  12930. ShortCode = hsEmpty,
  12931. };
  12932. }
  12933. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12934. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12935. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12936. if (isTrade)
  12937. {
  12938. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12939. }
  12940. else
  12941. {
  12942. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12943. }
  12944. }
  12945. chiarr.Add(new Grp_ApprovalTravelDetails
  12946. {
  12947. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12948. CreateTime = DateTime.Now,
  12949. CreateUserId = dto.Userid,
  12950. ParentId = 0,
  12951. Details = trip
  12952. });
  12953. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12954. var last = threeCodeStr.Last();
  12955. foreach (var item in threeCodeStr)
  12956. {
  12957. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12958. if (item.Equals(last))
  12959. {
  12960. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12961. }
  12962. }
  12963. cityPath = cityPath.Trim('-');
  12964. }
  12965. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12966. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12967. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12968. appro.Diid = dto.Diid;
  12969. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12970. appro.Id = thisId;
  12971. appro.CreateUserId = dto.Userid;
  12972. appro.CreateTime = DateTime.Now;
  12973. foreach (var item in gwinfo)
  12974. {
  12975. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12976. chi.Details = "拜访" + item.Client;
  12977. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12978. {
  12979. chi.Details += "," + item.ReqSample;
  12980. }
  12981. chi.ParentId = thisId;
  12982. chi.Time = item.Time;
  12983. chiarr.Add(chi);
  12984. }
  12985. if (chiarr.Count < 5)
  12986. {
  12987. for (int j = chiarr.Count; j < 5; j++)
  12988. {
  12989. chiarr.Add(new
  12990. Grp_ApprovalTravelDetails());
  12991. }
  12992. }
  12993. resultArr.Add(new
  12994. {
  12995. appro.Id,
  12996. appro.Date,
  12997. appro.Diid,
  12998. chiList = chiarr.Select(x1 => new
  12999. {
  13000. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13001. x1.Details,
  13002. x1.ParentId,
  13003. x1.Id
  13004. })
  13005. });
  13006. }
  13007. _sqlSugar.CommitTran();
  13008. jw = JsonView(true, "生成成功!", resultArr);
  13009. }
  13010. catch (Exception ex)
  13011. {
  13012. jw.Code = 400;
  13013. jw.Msg = "生成失败!" + ex.Message;
  13014. }
  13015. return Ok(jw);
  13016. }
  13017. /// <summary>
  13018. /// 报批行程word导出
  13019. /// </summary>
  13020. /// <param name="dto"></param>
  13021. /// <returns></returns>
  13022. [HttpPost]
  13023. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13024. {
  13025. var jw = JsonView(false);
  13026. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13027. if (group == null)
  13028. {
  13029. jw.Msg = "暂无该团组!";
  13030. return Ok(jw);
  13031. }
  13032. //模板路径
  13033. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13034. //载入模板
  13035. Document doc = new Document(tempPath);
  13036. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13037. //获取所填表格的序数
  13038. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13039. Aspose.Words.Tables.Row titleRowClone = null;
  13040. Aspose.Words.Tables.Row CenterRowClone = null;
  13041. int index = 0;
  13042. int indexChi = 0;
  13043. int SetIndex = 0;
  13044. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13045. //获取数据,放到datatable
  13046. foreach (var item in ApprovalTravelArr)
  13047. {
  13048. if (index > 0)
  13049. {
  13050. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13051. tableOne.AppendChild(titleRowClone);
  13052. }
  13053. var textTime = item.Date;
  13054. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13055. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13056. SetIndex++;
  13057. if (ChiRep.Count > 0)
  13058. {
  13059. foreach (var itemChi in ChiRep)
  13060. {
  13061. var txtTime = itemChi.Time;
  13062. var txtDetail = itemChi.Details;
  13063. if (indexChi > 0)
  13064. {
  13065. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13066. tableOne.AppendChild(CenterRowClone);
  13067. }
  13068. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13069. {
  13070. SetCells(tableOne, doc, SetIndex, 0, "");
  13071. SetCells(tableOne, doc, SetIndex, 1, "");
  13072. indexChi++;
  13073. SetIndex++;
  13074. break;
  13075. }
  13076. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13077. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13078. indexChi++;
  13079. SetIndex++;
  13080. }
  13081. }
  13082. else
  13083. {
  13084. if (indexChi > 0)
  13085. {
  13086. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13087. tableOne.AppendChild(CenterRowClone);
  13088. }
  13089. SetCells(tableOne, doc, SetIndex, 0, "");
  13090. SetCells(tableOne, doc, SetIndex, 1, "");
  13091. indexChi++;
  13092. SetIndex++;
  13093. }
  13094. index++;
  13095. }
  13096. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13097. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13098. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13099. jw.Code = 200;
  13100. jw.Msg = "";
  13101. return Ok(jw);
  13102. }
  13103. private string intToString(int numberVal)
  13104. {
  13105. string numberval = numberVal.ToString();
  13106. Dictionary<char, string> Number = new Dictionary<char, string>();
  13107. Number.Add('1', "一");
  13108. Number.Add('2', "二");
  13109. Number.Add('3', "三");
  13110. Number.Add('4', "四");
  13111. Number.Add('5', "五");
  13112. Number.Add('6', "六");
  13113. Number.Add('7', "七");
  13114. Number.Add('8', "八");
  13115. Number.Add('9', "九");
  13116. string stringNumberVal = string.Empty;
  13117. for (int i = 0; i < numberval.Length; i++)
  13118. {
  13119. if (i == 0)
  13120. {
  13121. stringNumberVal += Number[numberval[i]];
  13122. }
  13123. else if (i >= 1)
  13124. {
  13125. if (numberval[i] == '0')
  13126. {
  13127. stringNumberVal = "十";
  13128. }
  13129. else
  13130. {
  13131. stringNumberVal += "十" + Number[numberval[i]];
  13132. }
  13133. }
  13134. }
  13135. return stringNumberVal;
  13136. }
  13137. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13138. {
  13139. //获取table中的某个单元格,从0开始
  13140. Cell lshCell = table.Rows[rows].Cells[cells];
  13141. //将单元格中段落移除
  13142. foreach (Node item in lshCell.Paragraphs)
  13143. {
  13144. lshCell.Paragraphs.Remove(item);
  13145. }
  13146. if (val.Contains("\r\n"))
  13147. {
  13148. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13149. foreach (var item in spArr)
  13150. {
  13151. //新建一个段落
  13152. Paragraph p = new Paragraph(doc);
  13153. var r = new Run(doc, item);
  13154. //把设置的值赋给之前新建的段落
  13155. p.AppendChild(r);
  13156. //将此段落加到单元格内
  13157. lshCell.AppendChild(p);
  13158. }
  13159. }
  13160. else
  13161. {
  13162. //新建一个段落
  13163. Paragraph p = new Paragraph(doc);
  13164. var r = new Run(doc, val);
  13165. //把设置的值赋给之前新建的段落
  13166. p.AppendChild(r);
  13167. //将此段落加到单元格内
  13168. lshCell.AppendChild(p);
  13169. }
  13170. }
  13171. [HttpPost]
  13172. public async Task<IActionResult> ServerHttp(string paramStr)
  13173. {
  13174. paramStr = paramStr.TrimEnd('\'');
  13175. paramStr = paramStr.TrimStart('\'');
  13176. JsonView jw = JsonView(false);
  13177. JObject param = JObject.Parse(paramStr);
  13178. if (!param.ContainsKey("url"))
  13179. {
  13180. jw.Msg = "url null";
  13181. return Ok(jw);
  13182. }
  13183. string url = param["url"]!.ToString();
  13184. var methon = "get";
  13185. Dictionary<string, string> headValues = null;
  13186. string bodyStr = string.Empty;
  13187. if (param.ContainsKey("methon"))
  13188. {
  13189. methon = param["methon"]!.ToString().ToLower();
  13190. }
  13191. if (param.ContainsKey("header"))
  13192. {
  13193. var header = param["header"]!.ToString();
  13194. JObject headerJobject = JObject.Parse(header);
  13195. headValues = new Dictionary<string, string>();
  13196. foreach (JProperty item in headerJobject.Properties())
  13197. {
  13198. var value = item.Value.ToString();
  13199. var head = item.Path;
  13200. headValues.Add(head, value);
  13201. }
  13202. }
  13203. HttpClient client = new HttpClient();
  13204. string responseString = string.Empty;
  13205. StringContent content = null;
  13206. if (headValues != null)
  13207. {
  13208. foreach (var item in headValues.Keys)
  13209. {
  13210. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13211. {
  13212. if (param.ContainsKey("body"))
  13213. {
  13214. bodyStr = param["body"]!.ToString();
  13215. }
  13216. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13217. }
  13218. else
  13219. {
  13220. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13221. }
  13222. }
  13223. }
  13224. try
  13225. {
  13226. if (methon == "get")
  13227. {
  13228. responseString = await client.GetStringAsync(url);
  13229. }
  13230. else if (methon == "post")
  13231. {
  13232. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13233. {
  13234. Content = content
  13235. };
  13236. var response = await client.SendAsync(request);
  13237. try
  13238. {
  13239. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13240. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13241. {
  13242. using (StreamReader reader = new StreamReader(gzipStream))
  13243. {
  13244. responseString = await reader.ReadToEndAsync();
  13245. }
  13246. }
  13247. }
  13248. catch (Exception)
  13249. {
  13250. responseString = await response.Content.ReadAsStringAsync();
  13251. }
  13252. }
  13253. else
  13254. {
  13255. responseString = "methon error";
  13256. }
  13257. jw = JsonView(true, "success", responseString);
  13258. }
  13259. catch (Exception ex)
  13260. {
  13261. jw.Msg = "error " + ex.Message;
  13262. jw.Data = ex.StackTrace;
  13263. }
  13264. finally
  13265. {
  13266. client.Dispose();
  13267. }
  13268. return Ok(jw);
  13269. }
  13270. #endregion
  13271. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13272. /// <summary>
  13273. /// 团组接待意见调查 - 信息管理
  13274. /// 基础数据(团组)
  13275. /// </summary>
  13276. /// <param name="dto"></param>
  13277. /// <returns></returns>
  13278. [HttpGet]
  13279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13280. public async Task<IActionResult> OpinionaireInit()
  13281. {
  13282. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13283. .Select(x => new
  13284. {
  13285. x.Id,
  13286. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13287. })
  13288. .OrderByDescending(x => x.Id)
  13289. .ToListAsync();
  13290. return Ok(JsonView(groupData, groupData.Count));
  13291. }
  13292. /// <summary>
  13293. /// 团组接待意见调查 - 信息管理
  13294. /// 列表
  13295. /// </summary>
  13296. /// <param name="groupId"></param>
  13297. /// <returns></returns>
  13298. [HttpGet("{groupId}")]
  13299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13300. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13301. {
  13302. if (groupId < 1) Ok(JsonView(false,"请传入有效的diId"));
  13303. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13304. //.LeftJoin<Sys_Users>((x,u) => x.CreateUserId == u.Id)
  13305. //.Select((x, u) => new
  13306. //{
  13307. // x.Id,
  13308. // x.TourGuideName,
  13309. // x.CityName,
  13310. // CreateUserName = u.CnName,
  13311. // x.CreateTime
  13312. //})
  13313. .Select(x => new
  13314. {
  13315. x.Id,
  13316. x.TourGuideName,
  13317. x.CityName,
  13318. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13319. x.CreateTime
  13320. })
  13321. .OrderBy(x => x.Id)
  13322. .ToListAsync();
  13323. return Ok(JsonView(data));
  13324. }
  13325. /// <summary>
  13326. /// 团组接待意见调查 - 信息管理
  13327. /// 保存
  13328. /// </summary>
  13329. /// <param name="dto"></param>
  13330. /// <returns></returns>
  13331. [HttpPost]
  13332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13333. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  13334. {
  13335. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13336. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13337. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13338. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  13339. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  13340. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  13341. _opinionaireRep.BeginTran();
  13342. if (addData != null && addData.Count > 0)
  13343. {
  13344. foreach (var item in addData)
  13345. {
  13346. item.CreateUserId = currUserInfo.UserId;
  13347. item.DiId = dto.DiId;
  13348. }
  13349. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  13350. }
  13351. if (updData != null && updData.Count > 0)
  13352. {
  13353. var upd = await _opinionaireRep._sqlSugar
  13354. .Updateable(updData)
  13355. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  13356. .WhereColumns(x =>new{ x.Id})
  13357. .ExecuteCommandAsync();
  13358. }
  13359. _opinionaireRep.CommitTran();
  13360. return Ok(JsonView("操作成功!"));
  13361. }
  13362. /// <summary>
  13363. /// 团组接待意见调查 - 信息管理
  13364. /// 删除
  13365. /// </summary>
  13366. /// <param name="id"></param>
  13367. /// <returns></returns>
  13368. [HttpDelete("{id}")]
  13369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13370. public async Task<IActionResult> OpinionaireManageDel(int id)
  13371. {
  13372. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13373. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13374. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  13375. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  13376. if (!del) return Ok(JsonView("操作失败!"));
  13377. return Ok(JsonView("操作成功!"));
  13378. }
  13379. #endregion
  13380. // /// <summary>
  13381. // ///
  13382. // /// </summary>
  13383. // /// <param name="_dto"></param>
  13384. // /// <returns></returns>
  13385. // [HttpPost]
  13386. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13387. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13388. // {
  13389. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13390. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13391. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13392. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13393. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13394. // dic_psg.Add("客人", 974);
  13395. // dic_psg.Add("司机", 975);
  13396. // dic_psg.Add("导游", 976);
  13397. // dic_psg.Add("公司内部人员", 977);
  13398. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13399. // foreach (var item in list_visa)
  13400. // {
  13401. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13402. // temp.Id = item.Id;
  13403. // temp.DIId = item.DIId;
  13404. // temp.VisaClient = item.VisaClient;
  13405. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13406. // temp.VisaCurrency = item.VisaCurrency;
  13407. // temp.IsThird = item.IsThird;
  13408. // if (dic_psg.ContainsKey(item.PassengerType))
  13409. // {
  13410. // temp.PassengerType = dic_psg[item.PassengerType];
  13411. // }
  13412. // else {
  13413. // temp.PassengerType = -1;
  13414. // }
  13415. // temp.VisaNumber = item.VisaNumber;
  13416. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13417. // temp.CreateUserId = item.Operators;
  13418. // DateTime dt_ct;
  13419. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13420. // if (b_ct)
  13421. // {
  13422. // temp.CreateTime = dt_ct;
  13423. // }
  13424. // else
  13425. // {
  13426. // temp.CreateTime = DateTime.Now;
  13427. // }
  13428. // temp.DeleteTime = "";
  13429. // temp.DeleteUserId = 0;
  13430. // temp.Remark = item.Remark;
  13431. // if (string.IsNullOrEmpty(temp.Remark)) {
  13432. // temp.Remark = "";
  13433. // }
  13434. // temp.IsDel = item.IsDel;
  13435. // temp.VisaDescription = item.VisaAttachment;
  13436. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13437. //([Id]
  13438. // ,[DIId]
  13439. // ,[VisaClient]
  13440. // ,[VisaPrice]
  13441. // ,[VisaCurrency]
  13442. // ,[IsThird]
  13443. // ,[PassengerType]
  13444. // ,[VisaNumber]
  13445. // ,[VisaFreeNumber]
  13446. // ,[CreateUserId]
  13447. // ,[CreateTime]
  13448. // ,[DeleteTime]
  13449. // ,[DeleteUserId]
  13450. // ,[Remark]
  13451. // ,[IsDel]
  13452. // ,[visaDescription])
  13453. // VALUES
  13454. // ({0},{1},'{2}',{3},{4}
  13455. //,{5},{6},{7},{8},{9}
  13456. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13457. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13458. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13459. //);
  13460. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13461. // }
  13462. // return Ok(JsonView(true, "操作成功!"));
  13463. // }
  13464. /// <summary>
  13465. /// 123132123
  13466. /// </summary>
  13467. /// <param name="_dto"></param>
  13468. /// <returns></returns>
  13469. [HttpPost]
  13470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13471. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13472. {
  13473. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13474. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13475. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13476. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13477. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13478. dicDetail.Add(789, 1034);
  13479. dicDetail.Add(790, 1035);
  13480. dicDetail.Add(791, 1036);
  13481. dicDetail.Add(792, 1037);
  13482. dicDetail.Add(793, 1038);
  13483. dicDetail.Add(794, 1039);
  13484. dicDetail.Add(795, 1040);
  13485. dicDetail.Add(796, 1041);
  13486. dicDetail.Add(797, 1042);
  13487. dicDetail.Add(798, 1043);
  13488. dicDetail.Add(801, 1044);
  13489. dicDetail.Add(802, 1045);
  13490. dicDetail.Add(803, 1046);
  13491. Dictionary<int, int> dic = new Dictionary<int, int>();
  13492. dic.Add(806, 1027);
  13493. dic.Add(807, 1028);
  13494. dic.Add(808, 1029);
  13495. dic.Add(809, 1030);
  13496. dic.Add(810, 1031);
  13497. dic.Add(811, 1032);
  13498. dic.Add(812, 1033);
  13499. foreach (var item in list_visa)
  13500. {
  13501. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13502. temp.Coefficient = item.coefficient;
  13503. DateTime dtCrt;
  13504. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13505. if (b1)
  13506. {
  13507. temp.CreateTime = dtCrt;
  13508. }
  13509. else
  13510. {
  13511. temp.CreateTime = DateTime.Now;
  13512. }
  13513. temp.CreateUserId = item.Operators;
  13514. temp.DeleteTime = "";
  13515. temp.DeleteUserId = 0;
  13516. temp.DiId = int.Parse(item.DIID);
  13517. temp.FilePath = item.FilePath;
  13518. temp.IsDel = item.IsDel;
  13519. temp.Price = item.Price;
  13520. temp.PriceCount = 1;
  13521. temp.PriceCurrency = item.Currency;
  13522. int detailId = 0;
  13523. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13524. {
  13525. detailId = dicDetail[item.PriceTypeDetail];
  13526. }
  13527. temp.PriceDetailType = detailId;
  13528. temp.PriceDt = DateTime.Now;
  13529. temp.PriceName = item.PriceName;
  13530. temp.PriceSum = item.Price;
  13531. int tid = 0;
  13532. if (dic.ContainsKey(item.PriceType))
  13533. {
  13534. tid = dic[item.PriceType];
  13535. }
  13536. temp.PriceType = tid;
  13537. temp.Remark = item.Remark;
  13538. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13539. }
  13540. return Ok(JsonView(true, "操作成功!"));
  13541. }
  13542. }
  13543. }