GroupsController.cs 770 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using EyeSoft.Collections.Generic;
  7. using EyeSoft.IO;
  8. using Microsoft.AspNetCore.SignalR;
  9. using MySqlX.XDevAPI.Relational;
  10. using NPOI.HSSF.UserModel;
  11. using NPOI.SS.Format;
  12. using NPOI.SS.Formula.Functions;
  13. using NPOI.SS.UserModel;
  14. using NPOI.SS.Util;
  15. using NPOI.XSSF.UserModel;
  16. using OASystem.API.OAMethodLib;
  17. using OASystem.API.OAMethodLib.APNs;
  18. using OASystem.API.OAMethodLib.File;
  19. using OASystem.API.OAMethodLib.Hub.HubClients;
  20. using OASystem.API.OAMethodLib.Hub.Hubs;
  21. using OASystem.API.OAMethodLib.JuHeAPI;
  22. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Domain.ViewModels.Statistics;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using OfficeOpenXml;
  36. using Org.BouncyCastle.Asn1.Ocsp;
  37. using Quartz.Util;
  38. using SqlSugar;
  39. using SqlSugar.Extensions;
  40. using System.Collections;
  41. using System.Data;
  42. using System.Data.OleDb;
  43. using System.Diagnostics;
  44. using System.Globalization;
  45. using System.IO;
  46. using System.IO.Compression;
  47. using System.Net.Http;
  48. using System.Reflection.PortableExecutable;
  49. using System.Security.Cryptography;
  50. using Ubiety.Dns.Core;
  51. using static NPOI.POIFS.Crypt.CryptoFunctions;
  52. using static OASystem.API.OAMethodLib.JWTHelper;
  53. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  54. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  55. using Bookmark = Aspose.Words.Bookmark;
  56. using Cell = Aspose.Words.Tables.Cell;
  57. using Table = Aspose.Words.Tables.Table;
  58. namespace OASystem.API.Controllers
  59. {
  60. /// <summary>
  61. /// 团组相关
  62. /// </summary>
  63. //[Authorize]
  64. [Route("api/[controller]/[action]")]
  65. public class GroupsController : ControllerBase
  66. {
  67. private readonly ILogger<GroupsController> _logger;
  68. private readonly GrpScheduleRepository _grpScheduleRep;
  69. private readonly IMapper _mapper;
  70. private readonly DelegationInfoRepository _groupRepository;
  71. private readonly TaskAssignmentRepository _taskAssignmentRep;
  72. private readonly AirTicketResRepository _airTicketResRep;
  73. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  74. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  75. private readonly DelegationEnDataRepository _delegationEnDataRep;
  76. private readonly DelegationVisaRepository _delegationVisaRep;
  77. private readonly VisaPriceRepository _visaPriceRep;
  78. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  79. private readonly HotelPriceRepository _hotelPriceRep;
  80. private readonly CustomersRepository _customersRep;
  81. private readonly MessageRepository _message;
  82. private readonly SqlSugarClient _sqlSugar;
  83. private readonly TourClientListRepository _tourClientListRep;
  84. private readonly TeamRateRepository _teamRateRep;
  85. #region 成本相关
  86. private readonly CheckBoxsRepository _checkBoxs;
  87. private readonly GroupCostRepository _GroupCostRepository;
  88. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  89. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  90. #endregion
  91. private readonly SetDataRepository _setDataRep;
  92. private string url;
  93. private string path;
  94. private readonly EnterExitCostRepository _enterExitCostRep;
  95. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  96. private readonly UsersRepository _usersRep;
  97. private readonly IJuHeApiService _juHeApi;
  98. private readonly InvertedListRepository _invertedListRep;
  99. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  100. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  101. private readonly ThreeCodeRepository _threeCodeRepository;
  102. private readonly HotelInquiryRepository _hotelInquiryRep;
  103. private readonly FeeAuditRepository _feeAuditRep;
  104. private readonly VisaCommissionRepository _visaCommissionRep;
  105. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  106. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  107. public GroupsController(
  108. ILogger<GroupsController> logger,
  109. IMapper mapper,
  110. IHubContext<ChatHub, IChatClient> hubContext,
  111. SqlSugarClient sqlSugar,
  112. GrpScheduleRepository grpScheduleRep,
  113. DelegationInfoRepository groupRepository,
  114. TaskAssignmentRepository taskAssignmentRep,
  115. AirTicketResRepository airTicketResRep,
  116. DecreasePaymentsRepository decreasePaymentsRep,
  117. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  118. DelegationEnDataRepository delegationEnDataRep,
  119. EnterExitCostRepository enterExitCostRep,
  120. DelegationVisaRepository delegationVisaRep,
  121. MessageRepository message,
  122. VisaPriceRepository visaPriceRep,
  123. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  124. CheckBoxsRepository checkBoxs,
  125. GroupCostRepository GroupCostRepository,
  126. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  127. GroupCostParameterRepository GroupCostParameterRepository,
  128. HotelPriceRepository hotelPriceRep,
  129. CustomersRepository customersRep,
  130. SetDataRepository setDataRep,
  131. TourClientListRepository tourClientListRep,
  132. TeamRateRepository teamRateRep,
  133. UsersRepository usersRep, IJuHeApiService juHeApi,
  134. InvertedListRepository invertedListRep,
  135. VisaFeeInfoRepository visaFeeInfoRep,
  136. TicketBlackCodeRepository ticketBlackCodeRep,
  137. HotelInquiryRepository hotelInquiryRep,
  138. ThreeCodeRepository threeCodeRepository,
  139. FeeAuditRepository feeAuditRep,
  140. VisaCommissionRepository visaCommissionRep,
  141. ForeignReceivablesRepository ffrRep,
  142. OpinionaireRepository opinionaireRep
  143. )
  144. {
  145. _logger = logger;
  146. _mapper = mapper;
  147. _grpScheduleRep = grpScheduleRep;
  148. _groupRepository = groupRepository;
  149. _taskAssignmentRep = taskAssignmentRep;
  150. _airTicketResRep = airTicketResRep;
  151. _sqlSugar = sqlSugar;
  152. url = AppSettingsHelper.Get("ExcelBaseUrl");
  153. path = AppSettingsHelper.Get("ExcelBasePath");
  154. if (!System.IO.Directory.Exists(path))
  155. {
  156. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  157. }
  158. _decreasePaymentsRep = decreasePaymentsRep;
  159. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  160. _delegationEnDataRep = delegationEnDataRep;
  161. _enterExitCostRep = enterExitCostRep;
  162. _delegationVisaRep = delegationVisaRep;
  163. _message = message;
  164. _visaPriceRep = visaPriceRep;
  165. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  166. _checkBoxs = checkBoxs;
  167. _GroupCostRepository = GroupCostRepository;
  168. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  169. _GroupCostParameterRepository = GroupCostParameterRepository;
  170. _hotelPriceRep = hotelPriceRep;
  171. _customersRep = customersRep;
  172. _setDataRep = setDataRep;
  173. _tourClientListRep = tourClientListRep;
  174. _teamRateRep = teamRateRep;
  175. _hubContext = hubContext;
  176. _usersRep = usersRep;
  177. _juHeApi = juHeApi;
  178. _invertedListRep = invertedListRep;
  179. _visaFeeInfoRep = visaFeeInfoRep;
  180. _ticketBlackCodeRep = ticketBlackCodeRep;
  181. _hotelInquiryRep = hotelInquiryRep;
  182. _threeCodeRepository = threeCodeRepository;
  183. _feeAuditRep = feeAuditRep;
  184. _visaCommissionRep = visaCommissionRep;
  185. _ffrRep = ffrRep;
  186. _opinionaireRep = opinionaireRep;
  187. }
  188. #region 流程管控
  189. /// <summary>
  190. /// 获取团组流程管控信息
  191. /// </summary>
  192. /// <param name="paras">参数Json字符串</param>
  193. /// <returns></returns>
  194. [HttpPost]
  195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  196. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  197. {
  198. if (string.IsNullOrEmpty(_jsonDto.Paras))
  199. {
  200. return Ok(JsonView(false, "参数为空"));
  201. }
  202. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  203. if (_ScheduleDto != null)
  204. {
  205. if (_ScheduleDto.SearchType == 2)//获取列表
  206. {
  207. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  208. return Ok(JsonView(_grpScheduleViewList));
  209. }
  210. else//获取对象
  211. {
  212. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  213. if (_grpScheduleView != null)
  214. {
  215. return Ok(JsonView(_grpScheduleView));
  216. }
  217. }
  218. }
  219. else
  220. {
  221. return Ok(JsonView(false, "参数反序列化失败"));
  222. }
  223. return Ok(JsonView(false, "暂无数据!"));
  224. }
  225. /// <summary>
  226. /// 修改团组流程管控详细表数据
  227. /// </summary>
  228. /// <param name="paras"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  232. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  233. {
  234. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  235. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  236. .SetColumns(it => it.Duty == _detail.Duty)
  237. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  238. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  239. .SetColumns(it => it.JobContent == _detail.JobContent)
  240. .SetColumns(it => it.Remark == _detail.Remark)
  241. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  242. .Where(s => s.Id == dto.Id)
  243. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  244. .ExecuteCommandAsync();
  245. if (result > 0)
  246. {
  247. return Ok(JsonView(true, "保存成功!"));
  248. }
  249. return Ok(JsonView(false, "保存失败!"));
  250. }
  251. /// <summary>
  252. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  253. /// </summary>
  254. /// <param name="dto"></param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  259. {
  260. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  261. _detail.IsDel = 1;
  262. _detail.DeleteUserId = dto.Duty;
  263. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  264. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  265. .SetColumns(it => it.IsDel == _detail.IsDel)
  266. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  267. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  268. .Where(it => it.Id == dto.Id)
  269. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  270. //.WhereColumns(s => s.Id == dto.Id)
  271. .ExecuteCommandAsync();
  272. if (result > 0)
  273. {
  274. return Ok(JsonView(true, "删除成功!"));
  275. }
  276. return Ok(JsonView(false, "删除失败!"));
  277. }
  278. /// <summary>
  279. /// 增加团组流程管控详细表数据
  280. /// </summary>
  281. /// <param name="dto"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  285. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  286. {
  287. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  288. if (DateTime.Now < _detail.ExpectBeginDt)
  289. {
  290. _detail.StepStatus = 0;
  291. }
  292. else
  293. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  294. _detail.StepStatus = 1;
  295. }
  296. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  297. if (result > 0)
  298. {
  299. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  300. return Ok(JsonView(true, "添加成功!", _result));
  301. }
  302. return Ok(JsonView(false, "添加失败!"));
  303. }
  304. #endregion
  305. #region 团组基本信息
  306. /// <summary>
  307. /// 接团信息列表
  308. /// </summary>
  309. /// <param name="dto">团组列表请求dto</param>
  310. /// <returns></returns>
  311. [HttpPost]
  312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  313. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  314. {
  315. var groupData = await _groupRepository.GetGroupList(dto);
  316. if (groupData.Code != 0)
  317. {
  318. return Ok(JsonView(false, groupData.Msg));
  319. }
  320. return Ok(JsonView(groupData.Data));
  321. }
  322. /// <summary>
  323. /// 分页查询团组列表
  324. /// </summary>
  325. /// <param name="dto"></param>
  326. /// <returns></returns>
  327. [HttpPost]
  328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  329. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  330. {
  331. var watch = new Stopwatch();
  332. watch.Start();
  333. RefAsync<int> total = 0;
  334. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  335. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  336. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  337. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  338. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  339. .Distinct()
  340. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  341. watch.Stop();
  342. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  343. }
  344. /// <summary>
  345. /// 接团信息列表 Page
  346. /// </summary>
  347. /// <param name="dto">团组列表请求dto</param>
  348. /// <returns></returns>
  349. [HttpPost]
  350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  351. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  352. {
  353. #region 参数验证
  354. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  355. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  356. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  357. #region 页面操作权限验证
  358. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  359. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  360. #endregion
  361. #endregion
  362. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  363. {
  364. string sqlWhere = string.Empty;
  365. if (dto.IsSure == 0) //未完成
  366. {
  367. sqlWhere += string.Format(@" And IsSure = 0");
  368. }
  369. else if (dto.IsSure == 1) //已完成
  370. {
  371. sqlWhere += string.Format(@" And IsSure = 1");
  372. }
  373. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  374. {
  375. string tj = dto.SearchCriteria;
  376. 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}%')",
  377. tj, tj, tj, tj, tj);
  378. }
  379. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  380. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  381. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  382. JietuanOperator,IsSure,CreateTime,IsBid
  383. From (
  384. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  385. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  386. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  387. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  388. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  389. From Grp_DelegationInfo gdi
  390. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  391. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  392. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  393. Where gdi.IsDel = 0 {0}
  394. ) temp", sqlWhere);
  395. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  396. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  397. #region 处理所属部门
  398. /*
  399. * 1.sq 和 gyy 等显示 市场部
  400. * 2.王鸽和主管及张总还有管理员号统一国交部
  401. * 2-1. 4 管理员 ,21 张海麟
  402. */
  403. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  404. List<int> userIds1 = new List<int>() { 4, 21 };
  405. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  406. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  407. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  408. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  409. .ToList();
  410. foreach (var item in _DelegationList)
  411. {
  412. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  413. }
  414. #endregion
  415. var _view = new
  416. {
  417. PageFuncAuth = pageFunAuthView,
  418. Data = _DelegationList
  419. };
  420. return Ok(JsonView(true, "查询成功!", _view, total));
  421. }
  422. else
  423. {
  424. return Ok(JsonView(false, "查询失败"));
  425. }
  426. }
  427. /// <summary>
  428. /// 团组列表
  429. /// </summary>
  430. /// <returns></returns>
  431. [HttpPost]
  432. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  433. {
  434. #region 参数验证
  435. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  436. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  437. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  438. #region 页面操作权限验证
  439. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  440. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  441. #endregion
  442. #endregion
  443. if (dto.PortType != 1 && dto.PortType != 2)
  444. {
  445. return Ok(JsonView(false, "查询失败!"));
  446. }
  447. string orderbyStr = "order by gdi.CreateTime Desc";
  448. string sqlWhere = string.Empty;
  449. if (dto.IsSure == 0) //未完成
  450. {
  451. sqlWhere += string.Format(@" And IsSure = 0");
  452. }
  453. else if (dto.IsSure == 1) //已完成
  454. {
  455. sqlWhere += string.Format(@" And IsSure = 1");
  456. }
  457. //团组类型
  458. if (dto.TeamDid > 0)
  459. {
  460. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  461. }
  462. //团组名称
  463. if (!string.IsNullOrEmpty(dto.TeamName))
  464. {
  465. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  466. }
  467. //客户名称
  468. if (!string.IsNullOrEmpty(dto.ClientName))
  469. {
  470. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  471. }
  472. //客户单位
  473. if (!string.IsNullOrEmpty(dto.ClientUnit))
  474. {
  475. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  476. }
  477. //出访时间
  478. if (!string.IsNullOrEmpty(dto.visitDataTime))
  479. {
  480. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  481. orderbyStr = "order by gdi.VisitDate";
  482. }
  483. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  484. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  485. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  486. JietuanOperator,IsSure,CreateTime
  487. From (
  488. Select row_number() over({0}) as Row_Number,
  489. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  490. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  491. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  492. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  493. From Grp_DelegationInfo gdi
  494. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  495. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  496. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  497. Where gdi.IsDel = 0 {1}
  498. ) temp ", orderbyStr, sqlWhere);
  499. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  500. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  501. #region 处理所属部门
  502. /*
  503. * 1.sq 和 gyy 等显示 市场部
  504. * 2.王鸽和主管及张总还有管理员号统一国交部
  505. * 2-1. 4 管理员 ,21 张海麟
  506. */
  507. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  508. List<int> userIds1 = new List<int>() { 4, 21 };
  509. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  510. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  511. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  512. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  513. .ToList();
  514. foreach (var item in _DelegationList)
  515. {
  516. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  517. }
  518. #endregion
  519. var _view = new
  520. {
  521. PageFuncAuth = pageFunAuthView,
  522. Data = _DelegationList
  523. };
  524. return Ok(JsonView(true, "查询成功!", _view, total));
  525. }
  526. /// <summary>
  527. /// 接团信息详情
  528. /// </summary>
  529. /// <param name="dto">团组info请求dto</param>
  530. /// <returns></returns>
  531. [HttpPost]
  532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  533. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  534. {
  535. var groupData = await _groupRepository.GetGroupInfo(dto);
  536. if (groupData.Code != 0)
  537. {
  538. return Ok(JsonView(false, groupData.Msg));
  539. }
  540. return Ok(JsonView(groupData.Data));
  541. }
  542. /// <summary>
  543. /// 接团信息 编辑添加
  544. /// 基础信息数据源
  545. /// </summary>
  546. /// <param name="dto"></param>
  547. /// <returns></returns>
  548. [HttpPost]
  549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  550. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  551. {
  552. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  553. if (groupData.Code != 0)
  554. {
  555. return Ok(JsonView(false, groupData.Msg));
  556. }
  557. return Ok(JsonView(groupData.Data));
  558. }
  559. /// <summary>
  560. /// 接团信息 操作(增改)
  561. /// </summary>
  562. /// <param name="dto"></param>
  563. /// <returns></returns>
  564. [HttpPost]
  565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  566. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  567. {
  568. try
  569. {
  570. decimal ffrPrice = 0.00M;
  571. DateTime? visitDt = null;
  572. if (dto.Status == 2)
  573. {
  574. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  575. if (groupInfo != null)
  576. {
  577. ffrPrice = groupInfo.PaymentMoney;
  578. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  579. }
  580. }
  581. var groupData = await _groupRepository.GroupOperation(dto);
  582. if (groupData.Code != 0)
  583. {
  584. return Ok(JsonView(false, groupData.Msg));
  585. }
  586. int diId = 0;
  587. //添加时 默认加入团组汇率
  588. if (dto.Status == 1) //添加
  589. {
  590. diId = groupData.Data;
  591. //添加默认币种
  592. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  593. //默认分配权限
  594. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  595. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  596. var _managerIds = new List<int>() { 22, 32, 21 };
  597. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  598. if (userIds.Count > 0)
  599. {
  600. userIds.Add(208);
  601. //创建团组管控
  602. GroupStepForDelegation.CreateWorkStep(diId);
  603. //发送消息
  604. string groupName = dto.TeamName;
  605. string createGroupUser = string.Empty;
  606. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  607. if (userInfo != null) createGroupUser = userInfo.CnName;
  608. string title = $"系统通知";
  609. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  610. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  611. }
  612. //默认创建倒推表
  613. await _invertedListRep._Create(dto.UserId, diId);
  614. }
  615. else if (dto.Status == 2)
  616. {
  617. diId = dto.Id;
  618. }
  619. #region 签证人员团组时间通知
  620. #region 计算出访起止时间
  621. var startTime = new DateTime();
  622. var endTime = new DateTime();
  623. if (DateTime.TryParse(dto.VisitDate, out startTime))
  624. {
  625. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  626. }
  627. #endregion
  628. if (diId > 0)
  629. {
  630. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  631. }
  632. #endregion
  633. #region 团组操作默认添加/修改收款账单
  634. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  635. {
  636. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  637. .Where(x => x.IsDel == 0 &&
  638. x.Diid == diId &&
  639. x.Remark.Equals("预付款")
  640. )
  641. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  642. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  643. .FirstAsync();
  644. ffrInfo = new Fin_ForeignReceivables()
  645. {
  646. Diid = diId,
  647. PriceName = dto.ClientUnit,
  648. Price = dto.PaymentMoney,
  649. Count = 1,
  650. Unit = $"元",
  651. ItemSumPrice = dto.PaymentMoney,
  652. Rate = 1.0000M,
  653. Currency = 836,
  654. AddingWay = 0,
  655. CreateUserId = dto.UserId,
  656. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  657. Remark = $"预付款"
  658. };
  659. if (ffrInfo == null) //Add
  660. {
  661. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  662. }
  663. else //修改
  664. {
  665. await _sqlSugar.Updateable(ffrInfo)
  666. .UpdateColumns(x => new
  667. {
  668. x.PriceName,
  669. x.Price,
  670. x.ItemSumPrice,
  671. x.CreateTime,
  672. x.CreateUserId
  673. })
  674. .WhereColumns(x => x.Id)
  675. .ExecuteCommandAsync();
  676. }
  677. }
  678. #endregion
  679. return Ok(JsonView(true, "操作成功!", diId));
  680. }
  681. catch (Exception ex)
  682. {
  683. Logs("[response]" + JsonConvert.SerializeObject(dto));
  684. Logs(ex.Message);
  685. return Ok(JsonView(false, ex.Message));
  686. }
  687. }
  688. /// <summary>
  689. /// 接团流程操作(增改)
  690. /// 安卓端使用 建团时添加客户名单
  691. /// </summary>
  692. /// <param name="dto"></param>
  693. /// <returns></returns>
  694. [HttpPost]
  695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  696. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  697. {
  698. try
  699. {
  700. #region 参数验证
  701. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  702. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  703. #region 页面操作权限验证
  704. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  705. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  706. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  707. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  708. #endregion
  709. #endregion
  710. _sqlSugar.BeginTran();
  711. decimal ffrPrice = 0.00M;
  712. DateTime? visitDt = null;
  713. if (dto.Status == 2)
  714. {
  715. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  716. if (groupInfo != null)
  717. {
  718. ffrPrice = groupInfo.PaymentMoney;
  719. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  720. }
  721. }
  722. var _dto = new GroupOperationDto();
  723. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  724. var groupData = await _groupRepository.GroupOperation(_dto);
  725. if (groupData.Code != 0)
  726. {
  727. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  728. }
  729. int diId = 0;
  730. //添加时 默认加入团组汇率
  731. if (dto.Status == 1) //添加
  732. {
  733. diId = groupData.Data;
  734. //添加默认币种
  735. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  736. //默认分配权限
  737. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  738. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  739. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  740. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  741. if (userIds.Count > 0)
  742. {
  743. userIds.Add(208);
  744. //创建团组管控
  745. GroupStepForDelegation.CreateWorkStep(diId);
  746. //发送消息
  747. string groupName = dto.TeamName;
  748. string createGroupUser = string.Empty;
  749. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  750. if (userInfo != null) createGroupUser = userInfo.CnName;
  751. string title = $"系统通知";
  752. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  753. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  754. }
  755. #region 应用推送
  756. try
  757. {
  758. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  759. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  760. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  761. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  762. {
  763. List<string> userList = new List<string>() { users.QiyeChatUserId };
  764. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  765. }
  766. }
  767. catch (Exception ex)
  768. {
  769. }
  770. #endregion
  771. //默认创建倒推表
  772. await _invertedListRep._Create(dto.UserId, diId);
  773. }
  774. if (dto.Status == 2)
  775. {
  776. diId = dto.Id;
  777. if (diId == 0)
  778. {
  779. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  780. }
  781. }
  782. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  783. if (viewData.Code != 0)
  784. {
  785. _sqlSugar.RollbackTran();
  786. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  787. }
  788. #region 团组操作默认添加/修改收款账单
  789. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  790. {
  791. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  792. .Where(x => x.IsDel == 0 &&
  793. x.Diid == diId &&
  794. x.Remark.Equals("预付款")
  795. )
  796. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  797. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  798. .FirstAsync();
  799. ffrInfo = new Fin_ForeignReceivables()
  800. {
  801. Diid = diId,
  802. PriceName = dto.ClientUnit,
  803. Price = dto.PaymentMoney,
  804. Count = 1,
  805. Unit = $"元",
  806. ItemSumPrice = dto.PaymentMoney,
  807. Rate = 1.0000M,
  808. Currency = 836,
  809. AddingWay = 0,
  810. CreateUserId = dto.UserId,
  811. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  812. Remark = $"预付款"
  813. };
  814. if (ffrInfo == null) //Add
  815. {
  816. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  817. }
  818. else //修改
  819. {
  820. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  821. .UpdateColumns(x => new
  822. {
  823. x.PriceName,
  824. x.Price,
  825. x.ItemSumPrice,
  826. x.CreateTime,
  827. x.CreateUserId
  828. })
  829. .WhereColumns(x => x.Id)
  830. .ExecuteCommandAsync();
  831. }
  832. }
  833. #endregion
  834. #region 签证人员团组时间通知
  835. #region 计算出访起止时间
  836. var startTime = new DateTime();
  837. var endTime = new DateTime();
  838. if (DateTime.TryParse(dto.VisitDate, out startTime))
  839. {
  840. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  841. }
  842. #endregion
  843. if (diId > 0)
  844. {
  845. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  846. }
  847. #endregion
  848. _sqlSugar.CommitTran();
  849. return Ok(JsonView(true, "添加成功"));
  850. }
  851. catch (Exception ex)
  852. {
  853. _sqlSugar.RollbackTran();
  854. return Ok(JsonView(false, ex.Message));
  855. }
  856. }
  857. /// <summary>
  858. /// 接团信息 操作(删除)
  859. /// </summary>
  860. /// <param name="dto"></param>
  861. /// <returns></returns>
  862. [HttpPost]
  863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  864. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  865. {
  866. try
  867. {
  868. var groupData = await _groupRepository.GroupDel(dto);
  869. if (groupData.Code != 0)
  870. {
  871. return Ok(JsonView(false, groupData.Msg));
  872. }
  873. return Ok(JsonView(true));
  874. }
  875. catch (Exception ex)
  876. {
  877. Logs("[response]" + JsonConvert.SerializeObject(dto));
  878. Logs(ex.Message);
  879. return Ok(JsonView(false, ex.Message));
  880. }
  881. }
  882. /// <summary>
  883. /// 获取团组销售报价号
  884. /// 团组添加时 使用
  885. /// </summary>
  886. /// <returns></returns>
  887. [HttpPost]
  888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  889. public async Task<IActionResult> GetGroupSalesQuoteNo()
  890. {
  891. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  892. if (groupData.Code != 0)
  893. {
  894. return Ok(JsonView(false, groupData.Msg));
  895. }
  896. object salesQuoteNo = new
  897. {
  898. SalesQuoteNo = groupData.Data
  899. };
  900. return Ok(JsonView(salesQuoteNo));
  901. }
  902. /// <summary>
  903. /// 设置确认出团
  904. /// </summary>
  905. /// <param name="dto"></param>
  906. /// <returns></returns>
  907. [HttpPost]
  908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  909. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  910. {
  911. var groupData = await _groupRepository.ConfirmationGroup(dto);
  912. if (groupData.Code != 0)
  913. {
  914. return Ok(JsonView(false, groupData.Msg));
  915. }
  916. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  917. #region OA消息推送
  918. try
  919. {
  920. string groupName = groupInfo.TeamName;
  921. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  922. List<int> userIds = new List<int>();
  923. listUser.ForEach(s => userIds.Add(s.Id));
  924. string title = $"系统通知";
  925. string content = $"团组[{groupName}]已确认出团!";
  926. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  927. }
  928. catch (Exception ex)
  929. {
  930. }
  931. #endregion
  932. #region 应用推送
  933. try
  934. {
  935. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  936. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  937. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  938. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  939. {
  940. List<string> userList = new List<string>() { users.QiyeChatUserId };
  941. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  942. }
  943. }
  944. catch (Exception ex)
  945. {
  946. }
  947. #endregion
  948. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  949. return Ok(JsonView(true, "操作成功!", groupData.Data));
  950. }
  951. /// <summary>
  952. /// 获取团组名称data And 签证国别Data
  953. /// </summary>
  954. /// <param name="dto"></param>
  955. /// <returns></returns>
  956. [HttpPost]
  957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  958. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  959. {
  960. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  961. if (groupData.Code != 0)
  962. {
  963. return Ok(JsonView(false, groupData.Msg));
  964. }
  965. return Ok(JsonView(groupData.Data));
  966. }
  967. /// <summary>
  968. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  969. /// </summary>
  970. /// <returns></returns>
  971. [HttpPost]
  972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  973. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  974. {
  975. try
  976. {
  977. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, groupData.Msg));
  981. }
  982. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  983. }
  984. catch (Exception ex)
  985. {
  986. return Ok(JsonView(false, "程序错误!"));
  987. throw;
  988. }
  989. }
  990. /// <summary>
  991. /// 团组清单 Excel
  992. /// </summary>
  993. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  994. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  995. /// <returns></returns>
  996. [HttpGet]
  997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  998. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  999. {
  1000. DateTime _beginDt, _endDt;
  1001. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1002. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1003. if (!beginBool && !endBool)
  1004. {
  1005. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1006. }
  1007. string sql = string.Format(@"
  1008. SELECT
  1009. ROW_NUMBER,
  1010. Id,
  1011. SalesQuoteNo,
  1012. TourCode,
  1013. TeamTypeId,
  1014. TeamType,
  1015. TeamLevId,
  1016. TeamLev,
  1017. TeamName,
  1018. ClientName,
  1019. ClientUnit,
  1020. VisitDate,
  1021. VisitDays,
  1022. VisitPNumber,
  1023. JietuanOperatorId,
  1024. JietuanOperator,
  1025. IsSure,
  1026. CreateTime,
  1027. IsBid
  1028. FROM
  1029. (
  1030. SELECT
  1031. ROW_NUMBER() OVER(
  1032. ORDER BY
  1033. gdi.CreateTime Desc
  1034. ) AS ROW_NUMBER,
  1035. gdi.Id,
  1036. SalesQuoteNo,
  1037. TourCode,
  1038. ssd.Id TeamTypeId,
  1039. ssd.Name TeamType,
  1040. ssd1.Id TeamLevId,
  1041. ssd1.Name TeamLev,
  1042. TeamName,
  1043. ClientName,
  1044. ClientUnit,
  1045. VisitDate,
  1046. VisitDays,
  1047. VisitPNumber,
  1048. JietuanOperator JietuanOperatorId,
  1049. su.CnName JietuanOperator,
  1050. IsSure,
  1051. gdi.CreateTime,
  1052. gdi.IsBid
  1053. FROM
  1054. Grp_DelegationInfo gdi
  1055. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1056. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1057. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1058. WHERE
  1059. gdi.IsDel = 0
  1060. AND gdi.IsBid = 0
  1061. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1062. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1063. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1064. #region 处理所属部门
  1065. /*
  1066. * 1.sq 和 gyy 等显示 市场部
  1067. * 2.王鸽和主管及张总还有管理员号统一国交部
  1068. * 2-1. 4 管理员 ,21 张海麟
  1069. */
  1070. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1071. List<int> userIds1 = new List<int>() { 4, 21 };
  1072. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1073. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1074. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1075. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1076. .ToListAsync();
  1077. foreach (var item in groupList)
  1078. {
  1079. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1080. }
  1081. #endregion
  1082. #region Excel
  1083. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1084. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1085. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1086. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1087. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1088. //载入模板
  1089. WorkbookDesigner designer = new WorkbookDesigner();
  1090. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1091. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1092. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1093. dt.TableName = "GroupList";
  1094. designer.SetDataSource(dt);
  1095. designer.Process();
  1096. if (!Directory.Exists(savePath))
  1097. {
  1098. Directory.CreateDirectory(savePath);
  1099. }
  1100. string serverPath = $"{savePath}{fileName}";
  1101. designer.Workbook.Save(serverPath);
  1102. string rst = $"{servicePath}{ftpPath}{fileName}";
  1103. #endregion
  1104. return Ok(JsonView(true, "操作成功!", rst));
  1105. }
  1106. #endregion
  1107. #region 团组&签证
  1108. /// <summary>
  1109. /// 根据团组Id获取签证客户信息List
  1110. /// </summary>
  1111. /// <param name="dto">请求dto</param>
  1112. /// <returns></returns>
  1113. [HttpPost]
  1114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1115. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1116. {
  1117. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1118. if (groupData.Code != 0)
  1119. {
  1120. return Ok(JsonView(false, groupData.Msg));
  1121. }
  1122. return Ok(JsonView(groupData.Data));
  1123. }
  1124. /// <summary>
  1125. /// IOS获取团组签证拍照上传进度01(团组列表)
  1126. /// </summary>
  1127. /// <param name="dto">请求dto</param>
  1128. /// <returns></returns>
  1129. [HttpPost]
  1130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1131. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1132. {
  1133. if (dto == null)
  1134. {
  1135. return Ok(JsonView(false, "参数为空"));
  1136. }
  1137. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1138. return Ok(JsonView(visaList));
  1139. }
  1140. /// <summary>
  1141. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1142. /// </summary>
  1143. /// <returns></returns>
  1144. [HttpPost]
  1145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1146. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1147. {
  1148. if (dto == null)
  1149. {
  1150. return Ok(JsonView(false, "请求错误:"));
  1151. }
  1152. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1153. return Ok(JsonView(list));
  1154. }
  1155. /// <summary>
  1156. /// IOS获取团组签证拍照上传进度03(相册)
  1157. /// </summary>
  1158. /// <returns></returns>
  1159. [HttpPost]
  1160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1161. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1162. {
  1163. if (dto == null)
  1164. {
  1165. return Ok(JsonView(false, "请求错误:"));
  1166. }
  1167. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1168. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1169. list.ForEach(s => s.url = url);
  1170. return Ok(JsonView(list));
  1171. }
  1172. /// <summary>
  1173. /// IOS获取团组签证拍照上传进度04(图片上传)
  1174. /// </summary>
  1175. /// <param name="dto"></param>
  1176. /// <returns></returns>
  1177. [HttpPost]
  1178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1179. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1180. {
  1181. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1182. //if (!string.IsNullOrEmpty(result))
  1183. //{
  1184. //}
  1185. //else {
  1186. // return Ok(JsonView(false, "上传失败"));
  1187. //}
  1188. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1189. int sucNum = 0;
  1190. try
  1191. {
  1192. foreach (var item in dto.base64DataList)
  1193. {
  1194. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1195. string result = decodeBase64ToImage(item, imageName);
  1196. if (!string.IsNullOrEmpty(result))
  1197. {
  1198. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1199. pic.CreateUserId = dto.CreateUserId;
  1200. pic.PicName = imageName;
  1201. pic.PicPath = result;
  1202. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1203. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1204. if (insertResult > 0)
  1205. {
  1206. sucNum++;
  1207. }
  1208. }
  1209. }
  1210. }
  1211. catch (Exception ex)
  1212. {
  1213. return Ok(JsonView(false, ex.Message));
  1214. }
  1215. string msg = string.Format(@"成功上传{0}张", sucNum);
  1216. return Ok(JsonView(true, msg));
  1217. }
  1218. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1219. {
  1220. string filename = "";//声明一个string类型的相对路径
  1221. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1222. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1223. try//会有异常抛出,try,catch一下
  1224. {
  1225. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1226. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1227. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1228. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1229. //文件名称
  1230. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1231. //上传的文件的路径
  1232. string filePath = "";
  1233. if (!Directory.Exists(fileDir))
  1234. {
  1235. Directory.CreateDirectory(fileDir);
  1236. }
  1237. //上传的文件的路径
  1238. filePath = fileDir + filename;
  1239. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1240. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1241. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1242. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1243. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1244. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1245. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1246. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1247. bitmap.Dispose();
  1248. }
  1249. catch (Exception e)
  1250. {
  1251. string massage = e.Message;
  1252. Logs("IOS图片上传Error:" + massage);
  1253. //filename = e.Message;
  1254. }
  1255. return filename;//返回相对路径
  1256. }
  1257. /// <summary>
  1258. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1259. /// </summary>
  1260. /// <param name="dto"></param>
  1261. /// <returns></returns>
  1262. [HttpPost]
  1263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1264. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1265. {
  1266. if (dto == null)
  1267. {
  1268. return Ok(JsonView(false, "请求错误:"));
  1269. }
  1270. string msg = "参数错误";
  1271. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1272. {
  1273. try
  1274. {
  1275. //_delegationVisaRep.BeginTran();
  1276. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1277. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1278. .Where(s => s.Id == dto.visaProgressCustomerId)
  1279. .ExecuteCommandAsync();
  1280. if (updCount > 0 && dto.publishCode == 1)
  1281. {
  1282. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1283. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1284. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1285. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1286. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1287. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1288. if (groupData == null)
  1289. {
  1290. _delegationVisaRep.RollbackTran();
  1291. }
  1292. string title = string.Format(@"[签证进度更新]");
  1293. string content = string.Format(@"测试文本");
  1294. bool rst = await _message.AddMsg(new MessageDto()
  1295. {
  1296. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1297. IssuerId = dto.publisher,
  1298. Title = title,
  1299. Content = content,
  1300. ReleaseTime = DateTime.Now,
  1301. UIdList = new List<int> {
  1302. 234
  1303. }
  1304. });
  1305. if (rst)
  1306. {
  1307. return Ok(JsonView(true, "发送通知成功"));
  1308. }
  1309. }
  1310. //_delegationVisaRep.CommitTran();
  1311. }
  1312. catch (Exception)
  1313. {
  1314. //_delegationVisaRep.RollbackTran();
  1315. }
  1316. }
  1317. return Ok(JsonView(true, msg));
  1318. }
  1319. #endregion
  1320. #region 团组任务分配
  1321. /// <summary>
  1322. /// 团组任务分配初始化
  1323. /// </summary>
  1324. /// <param name="dto"></param>
  1325. /// <returns></returns>
  1326. [HttpPost]
  1327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1328. public async Task<IActionResult> GetTaskAssignmen()
  1329. {
  1330. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1331. if (groupData.Code != 0)
  1332. {
  1333. return Ok(JsonView(false, groupData.Msg));
  1334. }
  1335. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1336. }
  1337. /// <summary>
  1338. /// 团组任务分配查询
  1339. /// </summary>
  1340. /// <param name="dto"></param>
  1341. /// <returns></returns>
  1342. [HttpPost]
  1343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1344. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1345. {
  1346. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1347. if (groupData.Code != 0)
  1348. {
  1349. return Ok(JsonView(false, groupData.Msg));
  1350. }
  1351. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1352. }
  1353. /// <summary>
  1354. /// 团组任务分配操作
  1355. /// </summary>
  1356. /// <param name="dto"></param>
  1357. /// <returns></returns>
  1358. [HttpPost]
  1359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1360. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1361. {
  1362. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1363. if (groupData.Code != 0)
  1364. {
  1365. return Ok(JsonView(false, groupData.Msg));
  1366. }
  1367. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1368. }
  1369. /// <summary>
  1370. /// 团组任务分配
  1371. /// 批量分配
  1372. /// 查询团组
  1373. /// </summary>
  1374. /// <param name="dto"></param>
  1375. /// <returns></returns>
  1376. [HttpPost]
  1377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1378. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1379. {
  1380. //参数验证
  1381. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1382. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1383. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1384. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1385. }
  1386. /// <summary>
  1387. /// 团组任务分配
  1388. /// 批量分配
  1389. /// </summary>
  1390. /// <param name="dto"></param>
  1391. /// <returns></returns>
  1392. [HttpPost]
  1393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1394. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1395. {
  1396. //参数验证
  1397. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1398. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1399. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1400. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1401. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1402. }
  1403. #endregion
  1404. #region 团组费用审核
  1405. /// <summary>
  1406. /// 费用审核
  1407. /// 团组列表 Page
  1408. /// </summary>
  1409. /// <param name="_dto">团组列表请求dto</param>
  1410. /// <returns></returns>
  1411. [HttpPost]
  1412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1413. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1414. {
  1415. #region 参数验证
  1416. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1417. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1419. #region 页面操作权限验证
  1420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1421. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1422. #endregion
  1423. #endregion
  1424. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1425. {
  1426. string sqlWhere = string.Empty;
  1427. if (_dto.IsSure == 0) //未完成
  1428. {
  1429. sqlWhere += string.Format(@" And IsSure = 0");
  1430. }
  1431. else if (_dto.IsSure == 1) //已完成
  1432. {
  1433. sqlWhere += string.Format(@" And IsSure = 1");
  1434. }
  1435. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1436. {
  1437. string tj = _dto.SearchCriteria;
  1438. 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}%')",
  1439. tj, tj, tj, tj, tj);
  1440. }
  1441. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1442. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1443. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1444. From (
  1445. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1446. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1447. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1448. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1449. From Grp_DelegationInfo gdi
  1450. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1451. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1452. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1453. Where gdi.IsDel = 0 {0}
  1454. ) temp ", sqlWhere);
  1455. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1456. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1457. var _view = new
  1458. {
  1459. PageFuncAuth = pageFunAuthView,
  1460. Data = _DelegationList
  1461. };
  1462. return Ok(JsonView(true, "查询成功!", _view, total));
  1463. }
  1464. else
  1465. {
  1466. return Ok(JsonView(false, "查询失败"));
  1467. }
  1468. }
  1469. /// <summary>
  1470. /// 获取团组费用审核
  1471. /// </summary>
  1472. /// <param name="paras">参数Json字符串</param>
  1473. /// <returns></returns>
  1474. [HttpPost]
  1475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1476. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1477. {
  1478. try
  1479. {
  1480. #region 参数验证
  1481. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1482. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1483. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1484. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1485. #region 页面操作权限验证
  1486. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1487. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1488. #endregion
  1489. #endregion
  1490. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1491. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1492. #region 费用清单
  1493. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1494. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1495. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1496. List<Grp_CreditCardPayment> entityList = _groupRepository
  1497. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1498. .Where(exp.ToExpression())
  1499. .ToList();
  1500. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1501. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1502. /*
  1503. * 76://酒店预订
  1504. */
  1505. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1506. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1507. .ToListAsync();
  1508. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1509. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1510. .ToListAsync();
  1511. /*
  1512. * 79://车/导游地接
  1513. */
  1514. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1515. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1516. .ToListAsync();
  1517. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1518. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1519. .ToListAsync();
  1520. /*
  1521. * 80: //签证
  1522. */
  1523. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1524. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1525. .ToListAsync();
  1526. /*
  1527. *81: //邀请/公务活动
  1528. */
  1529. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1530. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1531. .ToListAsync();
  1532. /*
  1533. * 82: //团组客户保险
  1534. */
  1535. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1536. /*
  1537. * Lable = 85 机票预订
  1538. */
  1539. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1540. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1541. .ToListAsync();
  1542. /*
  1543. * 85 机票预定
  1544. */
  1545. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1546. /*
  1547. * 98 其他款项
  1548. */
  1549. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1550. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1551. .ToListAsync();
  1552. /*
  1553. * 285:收款退还
  1554. */
  1555. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1556. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1557. .ToListAsync();
  1558. /*
  1559. * 1015: //超支费用
  1560. */
  1561. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1562. /*
  1563. * 币种信息
  1564. */
  1565. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1566. /*
  1567. * 车/导游地接 费用类型
  1568. */
  1569. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1570. /*
  1571. * 车/导游地接 费用类型
  1572. */
  1573. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1574. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1575. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1576. /*
  1577. * 用户信息
  1578. */
  1579. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1580. /*
  1581. * 费用模块
  1582. */
  1583. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1584. string priceModule = string.Empty;
  1585. if (sdPriceName != null)
  1586. {
  1587. priceModule = sdPriceName.Name;
  1588. }
  1589. /*
  1590. * 成本信息
  1591. */
  1592. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1593. decimal _groupRate = 0.0000M;
  1594. string _groupCurrencyCode = "-";
  1595. if (groupCost != null)
  1596. {
  1597. _groupRate = groupCost.Rate;
  1598. if (int.TryParse(groupCost.Currency, out int _currency))
  1599. {
  1600. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1601. }
  1602. else _groupCurrencyCode = groupCost.Currency;
  1603. }
  1604. string costContentSql = $"Select * From Grp_GroupCost";
  1605. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1606. //处理日期为空的天数
  1607. for (int i = 0; i < groupCostDetails.Count; i++)
  1608. if (i != 0)
  1609. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1610. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1611. /*
  1612. * 处理详情数据
  1613. */
  1614. foreach (var entity in entityList)
  1615. {
  1616. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1617. _detail.Id = entity.Id;
  1618. _detail.PriceName = priceModule;
  1619. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1620. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1621. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1622. //处理金额
  1623. if (entity.CTable == 1015)
  1624. {
  1625. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1626. if (czInfo != null)
  1627. {
  1628. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1629. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1630. }
  1631. }
  1632. /*
  1633. * 应付款金额
  1634. */
  1635. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1636. string PaymentCurrency_WaitPay = "Unknown";
  1637. string hotelCurrncyCode = "Unknown";
  1638. string hotelCurrncyName = "Unknown";
  1639. if (sdPaymentCurrency_WaitPay != null)
  1640. {
  1641. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1642. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1643. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1644. if (hotelCurrncyCode.Equals("CNY"))
  1645. {
  1646. entity.DayRate = 1.0000M;
  1647. }
  1648. }
  1649. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1650. /*
  1651. * 此次付款金额
  1652. */
  1653. decimal CurrPayStr = 0.00M,
  1654. OriginalCurrPay = 0.00M;
  1655. if (entity.PayPercentage == 0)
  1656. {
  1657. if (entity.PayThenMoney != 0)
  1658. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1659. }
  1660. else
  1661. {
  1662. if (entity.PayMoney != 0)
  1663. {
  1664. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1665. }
  1666. }
  1667. if (_dto.Label == 79)
  1668. {
  1669. string original = string.Empty;
  1670. if (hotelCurrncyCode.Equals("CNY"))
  1671. {
  1672. OriginalCurrPay = CurrPayStr;
  1673. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1674. }
  1675. else
  1676. {
  1677. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1678. //760 EUR(7600.00 CNY)
  1679. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1680. }
  1681. }
  1682. else
  1683. {
  1684. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1685. }
  1686. /*
  1687. * 剩余尾款
  1688. */
  1689. decimal BalanceStr = 0;
  1690. if (CurrPayStr != 0)
  1691. {
  1692. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1693. BalanceStr = 0;
  1694. else
  1695. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1696. }
  1697. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1698. /*
  1699. * Bus名称
  1700. */
  1701. _detail.BusName = "待增加";
  1702. /*
  1703. *费用所属
  1704. */
  1705. switch (entity.CTable)
  1706. {
  1707. case 76://酒店预订
  1708. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1709. if (hotelReservations != null)
  1710. {
  1711. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1712. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1713. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1714. string roomFeeStr = "", roomFeestr1 = "";
  1715. //是否比较房型价格
  1716. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1717. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1718. roomFeeStr += $"<br/>";
  1719. if (hotelReservations.SingleRoomPrice > 0)
  1720. {
  1721. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1722. __isSingle = true;
  1723. }
  1724. if (hotelReservations.DoubleRoomPrice > 0)
  1725. {
  1726. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1727. __isDouble = true;
  1728. }
  1729. if (hotelReservations.SuiteRoomPrice > 0)
  1730. {
  1731. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1732. __isSuite = true;
  1733. }
  1734. if (hotelReservations.OtherRoomPrice > 0)
  1735. {
  1736. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1737. __isOther = true;
  1738. }
  1739. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1740. else roomFeeStr += " 0.00 * 0";
  1741. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1742. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1743. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1744. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1745. /*
  1746. * 费用类型
  1747. * 1:房费
  1748. * 2:早餐
  1749. * 3:地税
  1750. * 4:城市税
  1751. * </summary>
  1752. */
  1753. //地税
  1754. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1755. if (governmentRentData != null)
  1756. {
  1757. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1758. governmentRentFee = governmentRentData.Price;
  1759. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1760. if (governmentRentCurrData != null)
  1761. {
  1762. governmentRentCode = governmentRentCurrData.Name;
  1763. governmentRentName = $"({governmentRentCurrData.Remark})";
  1764. }
  1765. }
  1766. //城市税
  1767. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1768. if (cityTaxData != null)
  1769. {
  1770. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1771. cityTaxFee = cityTaxData.Price;
  1772. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1773. if (cityTaxCurrData != null)
  1774. {
  1775. cityTaxCode = cityTaxCurrData.Name;
  1776. cityTaxName = $"({cityTaxCurrData.Remark})";
  1777. }
  1778. }
  1779. //酒店早餐
  1780. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1781. if (breakfastData != null)
  1782. {
  1783. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1784. breakfastFee = breakfastData.Price;
  1785. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1786. if (breakfastCurrData != null)
  1787. {
  1788. breakfastCode = breakfastCurrData.Name;
  1789. breakfastName = $"({breakfastCurrData.Remark})";
  1790. }
  1791. }
  1792. //房间费用
  1793. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1794. if (roomData != null)
  1795. {
  1796. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1797. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1798. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1799. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1800. roomFee = roomData.Price;
  1801. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1802. if (roomCurrData != null)
  1803. {
  1804. roomCode = roomCurrData.Name;
  1805. roomName = $"({roomCurrData.Remark})";
  1806. }
  1807. }
  1808. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1809. string hotelCostStr = "";
  1810. decimal hotelCsotTotal = 0.00M;
  1811. if (groupCost != null)
  1812. {
  1813. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1814. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1815. }
  1816. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1817. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1818. string hotelCost_day = "";
  1819. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1820. foreach (var item in hotelCostDetails1)
  1821. {
  1822. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1823. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1824. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1825. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1826. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1827. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1828. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1829. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1830. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1831. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1832. hotelCost_day += @$"<br/>";
  1833. }
  1834. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1835. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1836. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1837. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1838. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1839. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1840. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1841. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1842. $"房间说明: {hotelReservations.Remark} <br/>" +
  1843. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1844. $"{hotelBreakfastStr}" +
  1845. $"{hotelGovernmentRentStr}" +
  1846. $"{hotelCityTaxStr}";
  1847. _detail.PriceNameContent = hotelReservations.HotelName;
  1848. }
  1849. break;
  1850. case 79://车/导游地接
  1851. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1852. if (touristGuideGroundReservations != null)
  1853. {
  1854. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1855. {
  1856. _detail.BusName = touristGuideGroundReservations.BusName;
  1857. }
  1858. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1859. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1860. //if (isInt)
  1861. //{
  1862. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1863. // if (cityInfo != null)
  1864. // {
  1865. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1866. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1867. // if (carFeeItem != null)
  1868. // {
  1869. // nameContent += $@"({carFeeItem.Name})";
  1870. // }
  1871. // _detail.PriceNameContent = nameContent;
  1872. // }
  1873. //}
  1874. //else
  1875. //{
  1876. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1877. //}
  1878. var touristGuideGroundReservationsContents =
  1879. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1880. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1881. foreach (var item in touristGuideGroundReservationsContents)
  1882. {
  1883. string typeName = "Unknown";
  1884. string carCurrencyCode = "Unknown";
  1885. string carCurrencyName = "Unknown";
  1886. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1887. if (carTypeData != null) typeName = carTypeData.Name;
  1888. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1889. if (currencyData != null)
  1890. {
  1891. carCurrencyCode = currencyData.Name;
  1892. carCurrencyName = currencyData.Remark;
  1893. }
  1894. //op、成本 币种是否一致
  1895. bool IsCurrencyAgreement = false;
  1896. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1897. string opCostStr = string.Empty;
  1898. decimal opCostTypePrice = 0.00M;
  1899. #region 处理成本各项费用
  1900. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1901. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1902. if (opCost.Count > 0)
  1903. {
  1904. switch (item.SId)
  1905. {
  1906. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1907. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1908. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1909. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1910. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1911. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1912. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1913. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1914. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1915. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1916. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1917. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1918. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1919. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1920. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1921. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1922. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1923. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1924. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1925. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1926. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1927. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1928. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1929. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1930. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1931. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1932. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1933. }
  1934. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1935. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1936. }
  1937. #endregion
  1938. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1939. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1940. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1941. $"{opTypeStr} {opCostStr}<br/>" +
  1942. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1943. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1944. }
  1945. _detail.PriceMsgContent = priceMsg;
  1946. }
  1947. break;
  1948. case 80: //签证
  1949. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1950. if (visaInfo != null)
  1951. {
  1952. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1953. _detail.PriceNameContent = visaInfo.VisaDescription;
  1954. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1955. }
  1956. break;
  1957. case 81: //邀请/公务活动
  1958. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1959. if (_ioa != null)
  1960. {
  1961. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1962. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1963. sendCurrName = "Unknown", //快递费用币种 Name
  1964. sendCurrCode = "Unknown", //快递费用币种 Code
  1965. eventsCurrName = "Unknown", //公务活动费币种 Name
  1966. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1967. translateCurrName = "Unknown", //公务翻译费 Name
  1968. translateCurrCode = "Unknown"; //公务翻译费 Code
  1969. #region 处理费用币种
  1970. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1971. if (inviteCurrData != null)
  1972. {
  1973. inviteCurrName = inviteCurrData.Remark;
  1974. inviteCurrCode = inviteCurrData.Name;
  1975. }
  1976. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1977. if (sendCurrData != null)
  1978. {
  1979. sendCurrName = sendCurrData.Remark;
  1980. sendCurrCode = sendCurrData.Name;
  1981. }
  1982. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1983. if (eventsCurrData != null)
  1984. {
  1985. eventsCurrName = eventsCurrData.Remark;
  1986. eventsCurrCode = eventsCurrData.Name;
  1987. }
  1988. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1989. if (translateCurrData != null)
  1990. {
  1991. translateCurrName = translateCurrData.Remark;
  1992. translateCurrCode = translateCurrData.Name;
  1993. }
  1994. #endregion
  1995. _detail.PriceNameContent = _ioa.InviterArea;
  1996. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1997. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1998. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1999. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2000. $@"备注:" + _ioa.Remark + "<br/>";
  2001. }
  2002. break;
  2003. case 82: //团组客户保险
  2004. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2005. if (customers != null)
  2006. {
  2007. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2008. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2009. }
  2010. break;
  2011. case 85: //机票预订
  2012. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2013. if (jpRes != null)
  2014. {
  2015. string FlightsDescription = jpRes.FlightsDescription;
  2016. string PriceDescription = jpRes.PriceDescription;
  2017. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2018. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2019. }
  2020. break;
  2021. case 98://其他款项
  2022. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2023. if (gdpRes != null)
  2024. {
  2025. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2026. _detail.PriceNameContent = gdpRes.PriceName;
  2027. }
  2028. break;
  2029. case 285://收款退还
  2030. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2031. if (refundAndOtherMoney != null)
  2032. {
  2033. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2034. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2035. }
  2036. break;
  2037. case 751://酒店早餐
  2038. break;
  2039. case 1015://超支费用
  2040. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2041. if (groupExtraCost != null)
  2042. {
  2043. _detail.PriceNameContent = groupExtraCost.PriceName;
  2044. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2045. }
  2046. break;
  2047. default:
  2048. break;
  2049. }
  2050. /*
  2051. * 申请人
  2052. */
  2053. string operatorName = " - ";
  2054. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2055. if (_opUser != null)
  2056. {
  2057. operatorName = _opUser.CnName;
  2058. }
  2059. _detail.OperatorName = operatorName;
  2060. /*
  2061. * 审核人
  2062. */
  2063. string auditOperatorName = "Unknown";
  2064. if (entity.AuditGMOperate == 0)
  2065. auditOperatorName = " - ";
  2066. else if (entity.AuditGMOperate == 4)
  2067. auditOperatorName = "自动审核";
  2068. else
  2069. {
  2070. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2071. if (_adUser != null)
  2072. {
  2073. auditOperatorName = _adUser.CnName;
  2074. }
  2075. }
  2076. _detail.AuditOperatorName = auditOperatorName;
  2077. /*
  2078. * 超预算比例
  2079. */
  2080. string overBudgetStr = "";
  2081. if (entity.ExceedBudget == -1)
  2082. overBudgetStr = sdPriceName.Name + "尚无预算";
  2083. else if (entity.ExceedBudget == 0)
  2084. {
  2085. if (entity.CTable == 76 || entity.CTable == 79)
  2086. {
  2087. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2088. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2089. }
  2090. else
  2091. {
  2092. overBudgetStr = "未超预算";
  2093. }
  2094. }
  2095. else
  2096. overBudgetStr = entity.ExceedBudget.ToString("P");
  2097. _detail.OverBudget = overBudgetStr;
  2098. /*
  2099. * 已审核金额
  2100. */
  2101. decimal auditFee = 0.00M;
  2102. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2103. /*
  2104. * 费用总计
  2105. */
  2106. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2107. {
  2108. CurrencyId = entity.PaymentCurrency,
  2109. CurrencyName = PaymentCurrency_WaitPay,
  2110. AmountPayable = entity.PayMoney,
  2111. ThisPayment = OriginalCurrPay,
  2112. BalancePayment = BalanceStr,
  2113. AuditedFunds = auditFee
  2114. });
  2115. _detail.IsAuditGM = entity.IsAuditGM;
  2116. detailList.Add(_detail);
  2117. }
  2118. #endregion
  2119. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2120. /*
  2121. * 下方描述处理
  2122. */
  2123. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2124. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2125. if (ccpCurrencyPrice != null)
  2126. {
  2127. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2128. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2129. }
  2130. else
  2131. {
  2132. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2133. }
  2134. string amountPayableStr = string.Format(@"应付款总金额: ");
  2135. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2136. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2137. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2138. foreach (var item in nonDuplicat)
  2139. {
  2140. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2141. if (strs.Count > 0)
  2142. {
  2143. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2144. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2145. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2146. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2147. //单独处理此次付款金额
  2148. if (item.CurrencyId == 836) //人民币
  2149. {
  2150. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2151. }
  2152. else
  2153. {
  2154. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2155. }
  2156. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2157. //单独处理已审核费用
  2158. if (item.CurrencyId == 836) //人民币
  2159. {
  2160. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2161. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2162. }
  2163. else
  2164. {
  2165. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2166. }
  2167. }
  2168. }
  2169. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2170. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2171. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2172. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2173. var _view1 = new
  2174. {
  2175. PageFuncAuth = pageFunAuthView,
  2176. Data = _view
  2177. };
  2178. return Ok(JsonView(_view1));
  2179. }
  2180. catch (Exception ex)
  2181. {
  2182. return Ok(JsonView(false, ex.Message));
  2183. }
  2184. }
  2185. /// <summary>
  2186. /// 费用审核
  2187. /// 修改团组费用审核状态
  2188. /// </summary>
  2189. /// <param name="_dto">参数Json字符串</param>
  2190. /// <returns></returns>
  2191. [HttpPost]
  2192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2193. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2194. {
  2195. #region 参数验证
  2196. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2197. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2198. #endregion
  2199. #region 页面操作权限验证
  2200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2201. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2202. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2203. #endregion
  2204. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2205. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2206. DateTime dtNow = DateTime.Now;
  2207. _groupRepository.BeginTran();
  2208. int rst = 0;
  2209. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2210. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2211. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2212. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2213. List<dynamic> msgDatas = new List<dynamic>();
  2214. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2215. foreach (var item in idList)
  2216. {
  2217. int CreditId = int.Parse(item);
  2218. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2219. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2220. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2221. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2222. .Where(s => s.Id == CreditId)
  2223. .ExecuteCommandAsync();
  2224. if (result < 1)
  2225. {
  2226. rst = -1;
  2227. _groupRepository.RollbackTran();
  2228. return Ok(JsonView(false, "操作失败并回滚!"));
  2229. }
  2230. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2231. if (creditData != null)
  2232. {
  2233. #region 应用通知配置
  2234. try
  2235. {
  2236. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2237. }
  2238. catch (Exception ex)
  2239. {
  2240. }
  2241. #endregion
  2242. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2243. string groupNameStr = string.Empty;
  2244. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2245. if (groupData != null) groupNameStr = groupData.TeamName;
  2246. string creditTypeStr = string.Empty;
  2247. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2248. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2249. string creditCurrency = string.Empty;
  2250. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2251. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2252. if (creditCurrency.Equals("CNY"))
  2253. {
  2254. creditData.DayRate = 1.0000M;
  2255. }
  2256. if (creditData.PayPercentage == 0.00M)
  2257. {
  2258. creditData.PayPercentage = 100M;
  2259. }
  2260. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2261. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2262. string msgContent = "";
  2263. if (creditCurrency.Equals("CNY"))
  2264. {
  2265. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2266. }
  2267. else
  2268. {
  2269. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2270. }
  2271. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2272. }
  2273. }
  2274. if (rst == 0)
  2275. {
  2276. _groupRepository.CommitTran();
  2277. foreach (var item in msgDatas)
  2278. {
  2279. //发送消息
  2280. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2281. }
  2282. #region 应用推送
  2283. try
  2284. {
  2285. foreach (var ccpId in dic_ccp_user.Keys)
  2286. {
  2287. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2288. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2289. }
  2290. }
  2291. catch (Exception)
  2292. {
  2293. }
  2294. #endregion
  2295. return Ok(JsonView(true, "操作成功!"));
  2296. }
  2297. return Ok(JsonView(false, "操作失败!"));
  2298. }
  2299. #endregion
  2300. #region 机票费用录入
  2301. /// <summary>
  2302. /// 机票录入当前登录人可操作团组
  2303. /// </summary>
  2304. /// <param name="dto"></param>
  2305. /// <returns></returns>
  2306. [HttpPost]
  2307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2308. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2309. {
  2310. try
  2311. {
  2312. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2313. if (groupData.Code != 0)
  2314. {
  2315. return Ok(JsonView(false, groupData.Msg));
  2316. }
  2317. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2318. }
  2319. catch (Exception ex)
  2320. {
  2321. return Ok(JsonView(false, "程序错误!"));
  2322. throw;
  2323. }
  2324. }
  2325. /// <summary>
  2326. /// 机票费用录入列表
  2327. /// </summary>
  2328. /// <param name="dto"></param>
  2329. /// <returns></returns>
  2330. [HttpPost]
  2331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2332. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2333. {
  2334. try
  2335. {
  2336. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2337. if (groupData.Code != 0)
  2338. {
  2339. return Ok(JsonView(false, groupData.Msg));
  2340. }
  2341. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2342. }
  2343. catch (Exception ex)
  2344. {
  2345. return Ok(JsonView(false, ex.Message));
  2346. throw;
  2347. }
  2348. }
  2349. /// <summary>
  2350. /// 根据id查询费用录入信息
  2351. /// </summary>
  2352. /// <param name="dto"></param>
  2353. /// <returns></returns>
  2354. [HttpPost]
  2355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2356. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2357. {
  2358. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2359. if (groupData.Code != 0)
  2360. {
  2361. return Ok(JsonView(false, groupData.Msg));
  2362. }
  2363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2364. }
  2365. /// <summary>
  2366. /// 机票费用录入操作(Status:1.新增,2.修改)
  2367. /// </summary>
  2368. /// <param name="dto"></param>
  2369. /// <returns></returns>
  2370. [HttpPost]
  2371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2372. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2373. {
  2374. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2375. if (groupData.Code != 0)
  2376. {
  2377. return Ok(JsonView(false, groupData.Msg));
  2378. }
  2379. #region 应用推送
  2380. try
  2381. {
  2382. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2383. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2384. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2385. //2024-10-21 新增LZ UID
  2386. var userIds = new List<int>() { 21 };
  2387. string title = $"系统通知";
  2388. string content = "";
  2389. var diId = dto.AirTicketResOpData.DiId;
  2390. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2391. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2392. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2393. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2394. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2395. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content);
  2396. }
  2397. catch (Exception ex)
  2398. {
  2399. }
  2400. #endregion
  2401. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2402. }
  2403. /// <summary>
  2404. /// 根据舱位类型查询接团客户名单信息
  2405. /// </summary>
  2406. /// <param name="dto"></param>
  2407. /// <returns></returns>
  2408. [HttpPost]
  2409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2410. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2411. {
  2412. try
  2413. {
  2414. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2415. if (crm_Groups.Count != 0)
  2416. {
  2417. List<dynamic> Customer = new List<dynamic>();
  2418. foreach (var item in crm_Groups)
  2419. {
  2420. var data = new
  2421. {
  2422. Id = item.Id,
  2423. Pinyin = item.Pinyin,
  2424. Name = item.LastName + item.FirstName
  2425. };
  2426. Customer.Add(data);
  2427. }
  2428. return Ok(JsonView(true, "查询成功!", Customer));
  2429. }
  2430. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2431. }
  2432. catch (Exception ex)
  2433. {
  2434. return Ok(JsonView(false, "程序错误!"));
  2435. throw;
  2436. }
  2437. }
  2438. /// <summary>
  2439. /// 根据团号获取客户信息
  2440. /// </summary>
  2441. /// <param name="dto"></param>
  2442. /// <returns></returns>
  2443. [HttpPost]
  2444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2445. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2446. {
  2447. var jw = JsonView(false);
  2448. if (dto.DIID < 1)
  2449. {
  2450. jw.Msg += "请输入正确的diid";
  2451. return Ok(jw);
  2452. }
  2453. var arr = getSimplClientList(dto.DIID);
  2454. jw = JsonView(true, "获取成功!", arr);
  2455. return Ok(jw);
  2456. }
  2457. private List<SimplClientInfo> getSimplClientList(int diId)
  2458. {
  2459. 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);
  2460. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2461. return arr;
  2462. }
  2463. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2464. {
  2465. string result = origin;
  2466. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2467. {
  2468. string[] temparr = origin.Split(',');
  2469. string fistrStr = temparr[0];
  2470. int count = temparr.Count();
  2471. int tempId;
  2472. bool success = int.TryParse(fistrStr, out tempId);
  2473. if (success)
  2474. {
  2475. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2476. if (tempInfo != null)
  2477. {
  2478. if (count > 1)
  2479. {
  2480. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2481. }
  2482. else
  2483. {
  2484. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2485. }
  2486. }
  2487. }
  2488. }
  2489. return result;
  2490. }
  2491. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2492. {
  2493. string result = origin;
  2494. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2495. {
  2496. string[] temparr = origin.Split(',');
  2497. result = "";
  2498. foreach (var item in temparr)
  2499. {
  2500. int tempId;
  2501. bool success = int.TryParse(item, out tempId);
  2502. if (success)
  2503. {
  2504. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2505. if (tempInfo != null)
  2506. {
  2507. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2508. }
  2509. }
  2510. }
  2511. }
  2512. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2513. return result;
  2514. }
  2515. /// <summary>
  2516. /// 机票费用录入,删除
  2517. /// </summary>
  2518. /// <param name="dto"></param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2523. {
  2524. try
  2525. {
  2526. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2527. if (res)
  2528. {
  2529. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2530. {
  2531. IsDel = 1,
  2532. DeleteUserId = dto.DeleteUserId,
  2533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2534. }).ExecuteCommandAsync();
  2535. return Ok(JsonView(true, "删除成功!"));
  2536. }
  2537. return Ok(JsonView(false, "删除失败!"));
  2538. }
  2539. catch (Exception ex)
  2540. {
  2541. return Ok(JsonView(false, "程序错误!"));
  2542. throw;
  2543. }
  2544. }
  2545. /// <summary>
  2546. /// 导出机票录入报表
  2547. /// </summary>
  2548. /// <param name="dto"></param>
  2549. /// <returns></returns>
  2550. [HttpPost]
  2551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2552. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2553. {
  2554. try
  2555. {
  2556. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2557. if (groupData.Code != 0)
  2558. {
  2559. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2560. }
  2561. else
  2562. {
  2563. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2564. if (AirTicketReservations.Count != 0)
  2565. {
  2566. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2567. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2568. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2569. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2570. WorkbookDesigner designer = new WorkbookDesigner();
  2571. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2572. decimal countCost = 0;
  2573. foreach (var item in AirTicketReservations)
  2574. {
  2575. #region 处理客人姓名
  2576. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2577. item.ClientName = clientNames;
  2578. #endregion
  2579. if (item.BankType == "其他")
  2580. {
  2581. item.BankNo = "--";
  2582. }
  2583. else
  2584. {
  2585. if (!string.IsNullOrEmpty(item.BankType))
  2586. {
  2587. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2588. }
  2589. }
  2590. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2591. item.Price = System.Decimal.Round(item.Price, 2);
  2592. countCost += Convert.ToDecimal(item.Price);
  2593. }
  2594. designer.SetDataSource("Export", AirTicketReservations);
  2595. designer.SetDataSource("ExportDiCode", diCode);
  2596. designer.SetDataSource("ExportDiName", diName);
  2597. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2598. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2599. designer.Process();
  2600. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2601. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2602. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2603. return Ok(JsonView(true, "成功", url = rst));
  2604. }
  2605. else
  2606. {
  2607. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2608. }
  2609. }
  2610. }
  2611. catch (Exception ex)
  2612. {
  2613. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2614. throw;
  2615. }
  2616. }
  2617. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2618. /// <summary>
  2619. /// 行程单导出
  2620. /// </summary>
  2621. /// <param name="dto"></param>
  2622. /// <returns></returns>
  2623. [HttpPost]
  2624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2625. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2626. {
  2627. try
  2628. {
  2629. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2630. if (groupData.Code != 0)
  2631. {
  2632. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2633. }
  2634. else
  2635. {
  2636. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2637. if (dto.Language == "CN")
  2638. {
  2639. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2640. DocumentBuilder builder = new DocumentBuilder(doc);
  2641. int tableIndex = 0;//表格索引
  2642. //得到文档中的第一个表格
  2643. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2644. foreach (var item in _AirTicketReservations)
  2645. {
  2646. #region 处理固定数据
  2647. string[] FlightsCode = item.FlightsCode.Split('/');
  2648. if (FlightsCode.Length != 0)
  2649. {
  2650. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2651. if (_AirCompany != null)
  2652. {
  2653. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2654. }
  2655. else
  2656. {
  2657. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2658. }
  2659. }
  2660. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2661. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2662. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2663. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2664. string name = "";
  2665. foreach (string clientName in nameArray)
  2666. {
  2667. if (!name.Contains(clientName))
  2668. {
  2669. name += clientName + ",";
  2670. }
  2671. }
  2672. if (!string.IsNullOrWhiteSpace(name))
  2673. {
  2674. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2675. }
  2676. else
  2677. {
  2678. table.Range.Bookmarks["ClientName"].Text = "--";
  2679. }
  2680. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2681. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2682. table.Range.Bookmarks["JointTicket"].Text = "--";
  2683. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2684. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2685. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2686. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2687. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2688. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2689. #endregion
  2690. #region 循环数据处理
  2691. List<AirInfo> airs = new List<AirInfo>();
  2692. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2693. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2694. for (int i = 0; i < FlightsCode.Length; i++)
  2695. {
  2696. AirInfo air = new AirInfo();
  2697. string[] tempstr = DayArray[i]
  2698. .Replace("\r\n", string.Empty)
  2699. .Replace("\\r\\n", string.Empty)
  2700. .TrimStart().TrimEnd()
  2701. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2702. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2703. string starCity = "";
  2704. if (star_Three != null)
  2705. {
  2706. starCity = star_Three.AirPort;
  2707. }
  2708. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2709. string EndCity = "";
  2710. if (End_Three != null)
  2711. {
  2712. EndCity = End_Three.AirPort;
  2713. }
  2714. air.Destination = starCity + "/" + EndCity;
  2715. air.Flight = FlightsCode[i];
  2716. air.SeatingClass = item.CTypeName;
  2717. string dateTime = tempstr[2];
  2718. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2719. air.FlightDate = DateTemp;
  2720. air.DepartureTime = tempstr[5];
  2721. air.LandingTime = tempstr[6];
  2722. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2723. air.TicketStatus = "--";
  2724. air.Luggage = "--";
  2725. air.DepartureTerminal = "--";
  2726. air.LandingTerminal = "--";
  2727. airs.Add(air);
  2728. }
  2729. int row = 13;
  2730. for (int i = 0; i < airs.Count; i++)
  2731. {
  2732. if (airs.Count > 2)
  2733. {
  2734. for (int j = 0; j < airs.Count - 2; j++)
  2735. {
  2736. var CopyRow = table.Rows[12].Clone(true);
  2737. table.Rows.Add(CopyRow);
  2738. }
  2739. }
  2740. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2741. int index = 0;
  2742. foreach (PropertyInfo property in properties)
  2743. {
  2744. string value = property.GetValue(airs[i]).ToString();
  2745. Cell ishcel0 = table.Rows[row].Cells[index];
  2746. Paragraph p = new Paragraph(doc);
  2747. string s = value;
  2748. p.AppendChild(new Run(doc, s));
  2749. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2750. ishcel0.AppendChild(p);
  2751. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2752. index++;
  2753. }
  2754. row++;
  2755. }
  2756. #endregion
  2757. Paragraph lastParagraph = new Paragraph(doc);
  2758. //第一个表格末尾加段落
  2759. table.ParentNode.InsertAfter(lastParagraph, table);
  2760. //复制第一个表格
  2761. Table cloneTable = (Table)table.Clone(true);
  2762. //在文档末尾段落后面加入复制的表格
  2763. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2764. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2765. {
  2766. int rownewsIndex = 13;
  2767. for (int i = 0; i < 2; i++)
  2768. {
  2769. var CopyRow = table.Rows[12].Clone(true);
  2770. table.Rows.RemoveAt(13);
  2771. table.Rows.Add(CopyRow);
  2772. rownewsIndex++;
  2773. }
  2774. }
  2775. else
  2776. {
  2777. table.Rows.RemoveAt(12);
  2778. }
  2779. cloneTable.Rows.RemoveAt(12);
  2780. }
  2781. if (_AirTicketReservations.Count != 0)
  2782. {
  2783. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2784. if (FlightsCode.Length != 0)
  2785. {
  2786. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2787. if (_AirCompany != null)
  2788. {
  2789. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2790. }
  2791. else
  2792. {
  2793. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2794. }
  2795. }
  2796. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2797. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2798. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2799. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2800. string name = "";
  2801. foreach (string clientName in nameArray)
  2802. {
  2803. if (!name.Contains(clientName))
  2804. {
  2805. name += clientName + ",";
  2806. }
  2807. }
  2808. if (!string.IsNullOrWhiteSpace(name))
  2809. {
  2810. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2811. }
  2812. else
  2813. {
  2814. table.Range.Bookmarks["ClientName"].Text = "--";
  2815. }
  2816. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2817. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2818. table.Range.Bookmarks["JointTicket"].Text = "--";
  2819. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2820. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2821. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2822. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2823. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2824. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2825. }
  2826. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2827. //保存合并后的文档
  2828. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2829. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2830. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2831. return Ok(JsonView(true, "成功!", rst));
  2832. }
  2833. else
  2834. {
  2835. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2836. DocumentBuilder builder = new DocumentBuilder(doc);
  2837. int tableIndex = 0;//表格索引
  2838. //得到文档中的第一个表格
  2839. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2840. List<string> texts = new List<string>();
  2841. foreach (var item in _AirTicketReservations)
  2842. {
  2843. string[] FlightsCode = item.FlightsCode.Split('/');
  2844. if (FlightsCode.Length != 0)
  2845. {
  2846. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2847. if (_AirCompany != null)
  2848. {
  2849. if (!transDic.ContainsKey(_AirCompany.CnName))
  2850. {
  2851. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2852. }
  2853. }
  2854. else
  2855. {
  2856. if (!transDic.ContainsKey("--"))
  2857. {
  2858. transDic.Add("--", "--");
  2859. }
  2860. }
  2861. }
  2862. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2863. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2864. string name = "";
  2865. foreach (string clientName in nameArray)
  2866. {
  2867. name += clientName + ",";
  2868. }
  2869. if (!texts.Contains(name))
  2870. {
  2871. texts.Add(name);
  2872. }
  2873. List<AirInfo> airs = new List<AirInfo>();
  2874. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2875. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2876. for (int i = 0; i < FlightsCode.Length; i++)
  2877. {
  2878. AirInfo air = new AirInfo();
  2879. string[] tempstr = DayArray[i]
  2880. .Replace("\r\n", string.Empty)
  2881. .Replace("\\r\\n", string.Empty)
  2882. .TrimStart().TrimEnd()
  2883. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2884. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2885. if (star_Three != null)
  2886. {
  2887. if (!transDic.ContainsKey(star_Three.AirPort))
  2888. {
  2889. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2890. }
  2891. }
  2892. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2893. if (End_Three != null)
  2894. {
  2895. if (!transDic.ContainsKey(End_Three.AirPort))
  2896. {
  2897. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2898. }
  2899. }
  2900. if (!texts.Contains(item.CTypeName))
  2901. {
  2902. texts.Add(item.CTypeName);
  2903. }
  2904. }
  2905. }
  2906. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2907. if (transData.Count > 0)
  2908. {
  2909. foreach (TranslateResult item in transData)
  2910. {
  2911. if (!transDic.ContainsKey(item.Query))
  2912. {
  2913. transDic.Add(item.Query, item.Translation);
  2914. }
  2915. }
  2916. }
  2917. foreach (var item in _AirTicketReservations)
  2918. {
  2919. #region 处理固定数据
  2920. string[] FlightsCode = item.FlightsCode.Split('/');
  2921. if (FlightsCode.Length != 0)
  2922. {
  2923. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2924. if (_AirCompany != null)
  2925. {
  2926. string str = "--";
  2927. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2928. if (!string.IsNullOrEmpty(translateResult))
  2929. {
  2930. str = translateResult;
  2931. str = _airTicketResRep.Processing(str);
  2932. }
  2933. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2934. }
  2935. else
  2936. {
  2937. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2938. }
  2939. }
  2940. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2941. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2942. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2943. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2944. string names = "";
  2945. foreach (string clientName in nameArray)
  2946. {
  2947. names += clientName + ",";
  2948. }
  2949. if (!string.IsNullOrWhiteSpace(names))
  2950. {
  2951. string str = "--";
  2952. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2953. if (!string.IsNullOrEmpty(translateResult))
  2954. {
  2955. str = translateResult;
  2956. str = _airTicketResRep.Processing(str);
  2957. }
  2958. table.Range.Bookmarks["ClientName"].Text = str;
  2959. }
  2960. else
  2961. {
  2962. table.Range.Bookmarks["ClientName"].Text = "--";
  2963. }
  2964. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2965. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2966. table.Range.Bookmarks["JointTicket"].Text = "--";
  2967. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2968. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2969. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2970. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2971. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2972. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2973. #endregion
  2974. #region 循环数据处理
  2975. List<AirInfo> airs = new List<AirInfo>();
  2976. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2977. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2978. for (int i = 0; i < FlightsCode.Length; i++)
  2979. {
  2980. AirInfo air = new AirInfo();
  2981. string[] tempstr = DayArray[i]
  2982. .Replace("\r\n", string.Empty)
  2983. .Replace("\\r\\n", string.Empty)
  2984. .TrimStart().TrimEnd()
  2985. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2986. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2987. string starCity = "";
  2988. if (star_Three != null)
  2989. {
  2990. string str2 = "--";
  2991. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2992. if (!string.IsNullOrEmpty(translateResult2))
  2993. {
  2994. str2 = translateResult2;
  2995. str2 = _airTicketResRep.Processing(str2);
  2996. }
  2997. starCity = str2;
  2998. }
  2999. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3000. string EndCity = "";
  3001. if (End_Three != null)
  3002. {
  3003. string str1 = "--";
  3004. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3005. if (!string.IsNullOrEmpty(translateResult1))
  3006. {
  3007. str1 = translateResult1;
  3008. str1 = _airTicketResRep.Processing(str1);
  3009. }
  3010. EndCity = str1;
  3011. }
  3012. air.Destination = starCity + "/" + EndCity;
  3013. air.Flight = FlightsCode[i];
  3014. string str = "--";
  3015. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3016. if (!string.IsNullOrEmpty(translateResult))
  3017. {
  3018. str = translateResult;
  3019. str = _airTicketResRep.Processing(str);
  3020. }
  3021. air.SeatingClass = str;
  3022. string dateTime = tempstr[2];
  3023. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3024. air.FlightDate = DateTemp;
  3025. air.DepartureTime = tempstr[5];
  3026. air.LandingTime = tempstr[6];
  3027. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3028. air.TicketStatus = "--";
  3029. air.Luggage = "--";
  3030. air.DepartureTerminal = "--";
  3031. air.LandingTerminal = "--";
  3032. airs.Add(air);
  3033. }
  3034. int row = 13;
  3035. for (int i = 0; i < airs.Count; i++)
  3036. {
  3037. if (airs.Count > 2)
  3038. {
  3039. for (int j = 0; j < airs.Count - 2; j++)
  3040. {
  3041. var CopyRow = table.Rows[12].Clone(true);
  3042. table.Rows.Add(CopyRow);
  3043. }
  3044. }
  3045. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3046. int index = 0;
  3047. foreach (PropertyInfo property in properties)
  3048. {
  3049. string value = property.GetValue(airs[i]).ToString();
  3050. Cell ishcel0 = table.Rows[row].Cells[index];
  3051. Paragraph p = new Paragraph(doc);
  3052. string s = value;
  3053. p.AppendChild(new Run(doc, s));
  3054. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3055. ishcel0.AppendChild(p);
  3056. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3057. //ishcel0.CellFormat.VerticalAlignment=
  3058. index++;
  3059. }
  3060. row++;
  3061. }
  3062. #endregion
  3063. Paragraph lastParagraph = new Paragraph(doc);
  3064. //第一个表格末尾加段落
  3065. table.ParentNode.InsertAfter(lastParagraph, table);
  3066. //复制第一个表格
  3067. Table cloneTable = (Table)table.Clone(true);
  3068. //在文档末尾段落后面加入复制的表格
  3069. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3070. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3071. {
  3072. int rownewsIndex = 13;
  3073. for (int i = 0; i < 2; i++)
  3074. {
  3075. var CopyRow = table.Rows[12].Clone(true);
  3076. table.Rows.RemoveAt(13);
  3077. table.Rows.Add(CopyRow);
  3078. rownewsIndex++;
  3079. }
  3080. }
  3081. else
  3082. {
  3083. table.Rows.RemoveAt(12);
  3084. }
  3085. cloneTable.Rows.RemoveAt(12);
  3086. }
  3087. if (_AirTicketReservations.Count != 0)
  3088. {
  3089. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3090. if (FlightsCode.Length != 0)
  3091. {
  3092. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3093. if (_AirCompany != null)
  3094. {
  3095. string str = "--";
  3096. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3097. if (!string.IsNullOrEmpty(translateResult))
  3098. {
  3099. str = translateResult;
  3100. str = _airTicketResRep.Processing(str);
  3101. }
  3102. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3103. }
  3104. else
  3105. {
  3106. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3107. }
  3108. }
  3109. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3110. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3111. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3112. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3113. string names = "";
  3114. foreach (string clientName in nameArray)
  3115. {
  3116. names += clientName + ",";
  3117. }
  3118. if (!string.IsNullOrWhiteSpace(names))
  3119. {
  3120. string str = "--";
  3121. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3122. if (!string.IsNullOrEmpty(translateResult))
  3123. {
  3124. str = translateResult;
  3125. str = _airTicketResRep.Processing(str);
  3126. }
  3127. table.Range.Bookmarks["ClientName"].Text = str;
  3128. }
  3129. else
  3130. {
  3131. table.Range.Bookmarks["ClientName"].Text = "--";
  3132. }
  3133. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3134. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3135. table.Range.Bookmarks["JointTicket"].Text = "--";
  3136. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3137. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3138. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3139. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3140. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3141. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3142. }
  3143. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3144. //保存合并后的文档
  3145. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3146. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3147. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3148. return Ok(JsonView(true, "成功!", rst));
  3149. }
  3150. }
  3151. }
  3152. catch (Exception ex)
  3153. {
  3154. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3155. throw;
  3156. }
  3157. }
  3158. #endregion
  3159. #region 团组增减款项 --> 其他款项
  3160. /// <summary>
  3161. /// 团组增减款项下拉框绑定
  3162. /// </summary>
  3163. /// <param name="dto"></param>
  3164. /// <returns></returns>
  3165. [HttpPost]
  3166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3167. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3168. {
  3169. #region 参数验证
  3170. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3171. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3172. #endregion
  3173. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3174. }
  3175. /// <summary>
  3176. /// 根据团组Id查询团组增减款项
  3177. /// </summary>
  3178. /// <param name="dto"></param>
  3179. /// <returns></returns>
  3180. [HttpPost]
  3181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3182. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3183. {
  3184. #region 参数验证
  3185. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3186. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3187. #endregion
  3188. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3189. }
  3190. /// <summary>
  3191. /// 团组增减款项操作(Status:1.新增,2.修改)
  3192. /// </summary>
  3193. /// <param name="dto"></param>
  3194. /// <returns></returns>
  3195. [HttpPost]
  3196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3197. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3198. {
  3199. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3200. if (groupData.Code != 200)
  3201. {
  3202. return Ok(JsonView(false, groupData.Msg));
  3203. }
  3204. #region 应用推送
  3205. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3206. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3207. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3208. //自动审核
  3209. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3210. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3211. //2024-10-21 新增LZ UID
  3212. var userIds = new List<int>() { 21 };
  3213. string title = $"系统通知";
  3214. string content = "";
  3215. var diId = dto.DiId;
  3216. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3217. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3218. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3219. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3220. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3221. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3222. #endregion
  3223. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3224. }
  3225. /// <summary>
  3226. /// 团组增减款项操作 删除
  3227. /// </summary>
  3228. /// <param name="dto"></param>
  3229. /// <returns></returns>
  3230. [HttpPost]
  3231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3232. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3233. {
  3234. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3235. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3236. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3237. if (res.Code == 0)
  3238. {
  3239. return Ok(JsonView(true, "删除成功!"));
  3240. }
  3241. return Ok(JsonView(false, "删除失败!"));
  3242. }
  3243. /// <summary>
  3244. /// 根据团组增减款项Id查询
  3245. /// </summary>
  3246. /// <param name="dto"></param>
  3247. /// <returns></returns>
  3248. [HttpPost]
  3249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3250. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3251. {
  3252. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3253. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3254. }
  3255. /// <summary>
  3256. /// 查询供应商名称
  3257. /// </summary>
  3258. /// <param name="dto"></param>
  3259. /// <returns></returns>
  3260. [HttpPost]
  3261. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3262. {
  3263. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3264. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3265. ?? new List<Grp_DecreasePayments>();
  3266. dbResult = dbResult.Distinct(new
  3267. ProductComparer()).ToList();
  3268. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3269. {
  3270. x.Id,
  3271. x.SupplierAddress,
  3272. x.SupplierArea,
  3273. x.SupplierContact,
  3274. x.SupplierContactNumber,
  3275. x.SupplierEmail,
  3276. x.SupplierName,
  3277. x.SupplierSocialAccount,
  3278. x.SupplierTypeId,
  3279. }).ToList());
  3280. return Ok(jw);
  3281. }
  3282. /// <summary>
  3283. /// 团组增减款项 OTA匹配
  3284. /// </summary>
  3285. /// <param name="file"></param>
  3286. /// <returns></returns>
  3287. [HttpPost]
  3288. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3289. {
  3290. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3291. string fileName = file.FileName;
  3292. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3293. {
  3294. return Ok(JsonView(false, "请上传Excel文件!"));
  3295. }
  3296. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3297. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3298. if (!Directory.Exists(path))
  3299. {
  3300. Directory.CreateDirectory(path);
  3301. }
  3302. var filePath = @$"{path}/{fileName}";
  3303. //保存文件
  3304. using (FileStream fs = System.IO.File.Create(filePath))
  3305. {
  3306. file.CopyTo(fs);
  3307. fs.Flush();
  3308. }
  3309. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3310. //读取ExcelFile
  3311. DataTable dt = ConvertExcelToDataTable(filePath);
  3312. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3313. dt.TableName = "TB";
  3314. //修改table列名
  3315. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3316. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3317. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3318. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3319. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3320. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3321. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3322. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3323. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3324. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3325. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3326. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3327. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3328. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3329. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3330. var otaOrderNos = new List<string>();
  3331. foreach (DataRow item in dt.Rows)
  3332. {
  3333. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3334. }
  3335. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3336. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3337. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3338. .Select((dp, di) => new
  3339. {
  3340. dp.PriceName,
  3341. dp.OTAOrderNo,
  3342. dp.FeeTotal,
  3343. di.TeamName,
  3344. })
  3345. .ToListAsync();
  3346. foreach (DataRow item in dt.Rows)
  3347. {
  3348. var otaOrderNo = item["OTAOrderNo"].ToString();
  3349. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3350. if (oaData == null) continue;
  3351. item["GroupName"] = oaData.TeamName;
  3352. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3353. }
  3354. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3355. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3356. List<DataTable> datas = new List<DataTable>();
  3357. datas.Add(dt);
  3358. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3359. return Ok(JsonView(true, "操作成功", new { url = url }));
  3360. }
  3361. #region
  3362. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3363. {
  3364. // 创建Workbook对象
  3365. Workbook workbook = new Workbook(excelFilePath);
  3366. // 获取第一个工作表
  3367. Worksheet worksheet = workbook.Worksheets[0];
  3368. // 将工作表转换为DataTable
  3369. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3370. return dataTable;
  3371. }
  3372. #endregion
  3373. #endregion
  3374. #region 文件上传、删除
  3375. /// <summary>
  3376. /// region 文件上传 可以带参数
  3377. /// </summary>
  3378. /// <param name="file"></param>
  3379. /// <returns></returns>
  3380. [HttpPost]
  3381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3382. public async Task<IActionResult> UploadProject(IFormFile file)
  3383. {
  3384. //var TypeName = Request.Headers["TypeName"].ToString();
  3385. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3386. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3387. ////文件名称
  3388. //string projectFileName = file.FileName;
  3389. ////上传的文件的路径
  3390. //string filePath = $"{fileDir}/{projectFileName}";
  3391. //if (TypeName == "A")//A代表团组增减款项
  3392. //{
  3393. // filePath = fileDir + $@"\团组增减款项相关文件";
  3394. // if (!Directory.Exists(filePath))
  3395. // {
  3396. // Directory.CreateDirectory(filePath);
  3397. // }
  3398. // //上传的文件的路径
  3399. // filePath += $@"\{projectFileName}";
  3400. //}
  3401. //else if (TypeName == "B")//B代表商邀相关文件
  3402. //{
  3403. // //上传的文件的路径
  3404. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3405. // if (!Directory.Exists(filePath))
  3406. // {
  3407. // Directory.CreateDirectory(filePath);
  3408. // }
  3409. // //上传的文件的路径
  3410. // filePath = $@"\{projectFileName}";
  3411. //}
  3412. //try
  3413. //{
  3414. // using (FileStream fs = System.IO.File.Create(filePath))
  3415. // {
  3416. // file.CopyTo(fs);
  3417. // fs.Flush();
  3418. // }
  3419. //}
  3420. //catch (Exception ex)
  3421. //{
  3422. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3423. //}
  3424. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3425. try
  3426. {
  3427. var TypeName = Request.Headers["TypeName"].ToString();
  3428. if (file != null)
  3429. {
  3430. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3431. //文件名称
  3432. string projectFileName = file.FileName;
  3433. //上传的文件的路径
  3434. string filePath = $"{fileDir}/{projectFileName}";
  3435. if (TypeName == "A")//A代表团组增减款项
  3436. {
  3437. if (!Directory.Exists(fileDir))
  3438. {
  3439. Directory.CreateDirectory(fileDir);
  3440. }
  3441. //上传的文件的路径
  3442. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3443. }
  3444. else if (TypeName == "B")//B代表商邀相关文件
  3445. {
  3446. if (!Directory.Exists(fileDir))
  3447. {
  3448. Directory.CreateDirectory(fileDir);
  3449. }
  3450. //上传的文件的路径
  3451. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3452. }
  3453. using (FileStream fs = System.IO.File.Create(filePath))
  3454. {
  3455. file.CopyTo(fs);
  3456. fs.Flush();
  3457. }
  3458. return Ok(JsonView(true, "上传成功!", projectFileName));
  3459. }
  3460. else
  3461. {
  3462. return Ok(JsonView(false, "上传失败!"));
  3463. }
  3464. }
  3465. catch (Exception ex)
  3466. {
  3467. return Ok(JsonView(false, "程序错误!"));
  3468. }
  3469. }
  3470. /// <summary>
  3471. /// 删除指定文件
  3472. /// </summary>
  3473. /// <param name="dto"></param>
  3474. /// <returns></returns>
  3475. [HttpPost]
  3476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3477. public async Task<IActionResult> DelFile(DelFileDto dto)
  3478. {
  3479. try
  3480. {
  3481. var TypeName = Request.Headers["TypeName"].ToString();
  3482. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3483. string filePath = "";
  3484. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3485. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3486. int id = 0;
  3487. if (TypeName == "A")
  3488. {
  3489. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3490. // 删除该文件
  3491. System.IO.File.Delete(filePath);
  3492. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3493. .Where(a => a.Id == dto.Id)
  3494. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3495. .ExecuteCommandAsync();
  3496. }
  3497. else if (TypeName == "B")
  3498. {
  3499. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3500. // 删除该文件
  3501. System.IO.File.Delete(filePath);
  3502. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3503. if (info != null)
  3504. {
  3505. string[] files = new string[] { };
  3506. if (!string.IsNullOrEmpty(info.Attachment))
  3507. {
  3508. try
  3509. {
  3510. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3511. }
  3512. catch (Exception)
  3513. {
  3514. files = new List<string>() { info.Attachment }.ToArray();
  3515. }
  3516. }
  3517. if (files.Length > 0)
  3518. {
  3519. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3520. string filePath2 = string.Empty;
  3521. if (files1.Length > 0)
  3522. {
  3523. filePath2 = JsonConvert.SerializeObject(files1);
  3524. }
  3525. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3526. .Where(a => a.Id == dto.Id)
  3527. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3528. .ExecuteCommandAsync();
  3529. }
  3530. }
  3531. }
  3532. if (id != 0)
  3533. {
  3534. return Ok(JsonView(true, "成功!"));
  3535. }
  3536. else
  3537. {
  3538. return Ok(JsonView(false, "失败!"));
  3539. }
  3540. }
  3541. catch (Exception ex)
  3542. {
  3543. return Ok(JsonView(false, "程序错误!"));
  3544. throw;
  3545. }
  3546. }
  3547. /// <summary>
  3548. /// 文件上传多个文件 可以带参数
  3549. /// </summary>
  3550. /// <param name="file"></param>
  3551. /// <returns></returns>
  3552. [HttpPost]
  3553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3554. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3555. {
  3556. try
  3557. {
  3558. var TypeName = Request.Headers["TypeName"].ToString();
  3559. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3560. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3561. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3562. var filePahts = new List<string>();
  3563. foreach (var file in files)
  3564. {
  3565. //文件名称
  3566. string projectFileName = file.FileName;
  3567. //上传的文件的路径
  3568. string filePath = $"{fileDir}/{projectFileName}";
  3569. if (TypeName == "A")//A代表团组增减款项
  3570. {
  3571. if (!Directory.Exists(fileDir))
  3572. {
  3573. Directory.CreateDirectory(fileDir);
  3574. }
  3575. //上传的文件的路径
  3576. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3577. }
  3578. else if (TypeName == "B")//B代表商邀相关文件
  3579. {
  3580. if (!Directory.Exists(fileDir))
  3581. {
  3582. Directory.CreateDirectory(fileDir);
  3583. }
  3584. //上传的文件的路径
  3585. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3586. }
  3587. using (FileStream fs = System.IO.File.Create(filePath))
  3588. {
  3589. file.CopyTo(fs);
  3590. fs.Flush();
  3591. }
  3592. filePahts.Add(projectFileName);
  3593. }
  3594. return Ok(JsonView(true, "上传成功!", filePahts));
  3595. }
  3596. catch (Exception ex)
  3597. {
  3598. return Ok(JsonView(false, "程序错误!"));
  3599. }
  3600. }
  3601. #endregion
  3602. #region 商邀费用录入
  3603. /// <summary>
  3604. /// 根据团组Id查询商邀费用列表
  3605. /// </summary>
  3606. /// <param name="dto"></param>
  3607. /// <returns></returns>
  3608. [HttpPost]
  3609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3610. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3611. {
  3612. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3613. if (groupData.Code != 0)
  3614. {
  3615. return Ok(JsonView(false, groupData.Msg));
  3616. }
  3617. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3618. }
  3619. /// <summary>
  3620. /// 商邀费用列表
  3621. /// 下载文件
  3622. /// </summary>
  3623. /// <param name="dto"></param>
  3624. /// <returns></returns>
  3625. [HttpGet("{id}")]
  3626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3627. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3628. {
  3629. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3630. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3631. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3632. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3633. var filePaths = new List<string>();
  3634. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3635. try
  3636. {
  3637. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3638. }
  3639. catch (Exception ex)
  3640. {
  3641. filePaths.Add(info.Attachment);
  3642. }
  3643. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3644. for (int i = 0; i < filePaths.Count; i++)
  3645. {
  3646. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3647. }
  3648. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3649. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3650. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3651. {
  3652. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3653. {
  3654. foreach (string filePath in filePaths)
  3655. {
  3656. if (System.IO.File.Exists(filePath))
  3657. {
  3658. // 获取文件名
  3659. string fileName = Path.GetFileName(filePath);
  3660. // 将文件添加到ZIP归档中
  3661. zipArchive.CreateEntryFromFile(filePath, fileName);
  3662. }
  3663. }
  3664. }
  3665. }
  3666. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3667. }
  3668. /// <summary>
  3669. /// 商邀费用 Info Page 基础数据源
  3670. /// </summary>
  3671. /// <param name="dto"></param>
  3672. /// <returns></returns>
  3673. [HttpPost]
  3674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3675. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3676. {
  3677. try
  3678. {
  3679. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3680. if (groupData.Code != 0)
  3681. {
  3682. return Ok(JsonView(false, groupData.Msg));
  3683. }
  3684. return Ok(JsonView(true, "操作成功", groupData.Data));
  3685. }
  3686. catch (Exception ex)
  3687. {
  3688. return Ok(JsonView(false, ex.Message));
  3689. throw;
  3690. }
  3691. }
  3692. /// <summary>
  3693. /// 根据商邀费用ID查询C表和商邀费用数据
  3694. /// </summary>
  3695. /// <param name="dto"></param>
  3696. /// <returns></returns>
  3697. [HttpPost]
  3698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3699. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3700. {
  3701. try
  3702. {
  3703. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3704. if (groupData.Code != 0)
  3705. {
  3706. return Ok(JsonView(false, groupData.Msg));
  3707. }
  3708. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3709. }
  3710. catch (Exception ex)
  3711. {
  3712. return Ok(JsonView(false, ex.Message));
  3713. throw;
  3714. }
  3715. }
  3716. /// <summary>
  3717. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3718. /// </summary>
  3719. /// <param name="dto"></param>
  3720. /// <returns></returns>
  3721. [HttpPost]
  3722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3723. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3724. {
  3725. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3726. if (groupData.Code != 0)
  3727. {
  3728. return Ok(JsonView(false, groupData.Msg));
  3729. }
  3730. #region 应用推送
  3731. try
  3732. {
  3733. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3734. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3735. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3736. //2024-10-21 新增LZ UID
  3737. var userIds = new List<int>() { 21 };
  3738. string title = $"系统通知";
  3739. string content = "";
  3740. var diId = dto.DiId;
  3741. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3742. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3743. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3744. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3745. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3746. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content);
  3747. }
  3748. catch (Exception ex)
  3749. {
  3750. }
  3751. #endregion
  3752. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3753. }
  3754. /// <summary>
  3755. /// 商邀删除
  3756. /// </summary>
  3757. /// <param name="dto"></param>
  3758. /// <returns></returns>
  3759. [HttpPost]
  3760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3761. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3762. {
  3763. try
  3764. {
  3765. _sqlSugar.BeginTran();
  3766. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3767. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3768. {
  3769. IsDel = 1,
  3770. DeleteUserId = dto.DeleteUserId,
  3771. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3772. })
  3773. .Where(it => it.Id == dto.Id)
  3774. .ExecuteCommand();
  3775. if (res1 > 0)
  3776. {
  3777. int _diId = 0;
  3778. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3779. if (_ioaInfo != null)
  3780. {
  3781. _diId = _ioaInfo.DiId;
  3782. }
  3783. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3784. .SetColumns(a => new Grp_CreditCardPayment()
  3785. {
  3786. IsDel = 1,
  3787. DeleteUserId = dto.DeleteUserId,
  3788. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3789. })
  3790. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3791. .ExecuteCommand();
  3792. if (res2 > 0)
  3793. {
  3794. _sqlSugar.CommitTran();
  3795. return Ok(JsonView(true, "删除成功!"));
  3796. }
  3797. }
  3798. _sqlSugar.RollbackTran();
  3799. return Ok(JsonView(false, "删除失败"));
  3800. }
  3801. catch (Exception ex)
  3802. {
  3803. _sqlSugar.RollbackTran();
  3804. return Ok(JsonView(false, ex.Message));
  3805. }
  3806. }
  3807. /// <summary>
  3808. /// 团组模块文件上传
  3809. /// </summary>
  3810. /// <param name="dto"></param>
  3811. /// <returns></returns>
  3812. [HttpPost]
  3813. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3814. {
  3815. var jw = JsonView(false);
  3816. long M = 1024 * 1024;
  3817. if (dto.Files == null || dto.Files.Count == 0)
  3818. {
  3819. jw.Msg = "无文件信息!";
  3820. return Ok(jw);
  3821. }
  3822. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3823. {
  3824. jw.Msg = "文件大小超过20M!";
  3825. return Ok(jw);
  3826. }
  3827. //var nameSp = dto.File.FileName.Split(".");
  3828. //if (nameSp.Length < 2)
  3829. //{
  3830. // jw.Msg = "拓展名称有误!";
  3831. // return Ok(jw);
  3832. //}
  3833. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3834. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3835. //{
  3836. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3837. // return Ok(jw);
  3838. //}
  3839. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3840. if (Ctable == null)
  3841. {
  3842. jw.Msg = "Ctable指向有误!";
  3843. return Ok(jw);
  3844. }
  3845. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3846. if (groupInfo == null)
  3847. {
  3848. jw.Msg = "团组信息不存在!";
  3849. return Ok(jw);
  3850. }
  3851. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3852. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3853. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3854. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3855. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3856. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3857. try
  3858. {
  3859. if (!Directory.Exists(fileBase))
  3860. {
  3861. Directory.CreateDirectory(fileBase);
  3862. }
  3863. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3864. foreach (var fileStream in dto.Files)
  3865. {
  3866. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3867. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3868. {
  3869. Cid = dto.Cid,
  3870. CreateTime = DateTime.Now,
  3871. CreateUserId = dto.Userid,
  3872. Ctable = dto.Ctable,
  3873. Diid = dto.Diid,
  3874. IsDel = 0,
  3875. FilePath = saveFilePath,
  3876. FileName = fileStream.FileName
  3877. };
  3878. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3879. {
  3880. fileStream.CopyTo(fs);
  3881. fs.Flush();
  3882. }
  3883. saveArr.Add(file);
  3884. }
  3885. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3886. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3887. jw = JsonView(true, "保存成功!", new
  3888. {
  3889. count = addResult,
  3890. filesName = saveArr.Select(x => x.FileName)
  3891. });
  3892. }
  3893. catch (Exception ex)
  3894. {
  3895. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3896. {
  3897. count = 0,
  3898. filesName = new string[0],
  3899. });
  3900. }
  3901. return Ok(jw);
  3902. }
  3903. /// <summary>
  3904. /// 查询各模块已保存文件
  3905. /// </summary>
  3906. /// <param name="dto"></param>
  3907. /// <returns></returns>
  3908. [HttpPost]
  3909. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3910. {
  3911. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3912. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3913. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3914. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3915. {
  3916. expression = Expressionable.Create<Grp_GroupModelFile>()
  3917. .And(x => visaIds.Contains(x.CreateUserId));
  3918. }
  3919. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3920. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3921. .Where(expression.ToExpression())
  3922. .ToList();
  3923. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3924. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3925. {
  3926. x.FileName,
  3927. x.Id,
  3928. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3929. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3930. })));
  3931. }
  3932. /// <summary>
  3933. /// 下载该团组下的所有文件
  3934. /// </summary>
  3935. /// <param name="dto"></param>
  3936. /// <returns></returns>
  3937. [HttpPost]
  3938. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3939. {
  3940. var jw = JsonView(false);
  3941. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3942. if (groupInfo == null)
  3943. {
  3944. jw.Msg = "团组信息不存在!";
  3945. return Ok(jw);
  3946. }
  3947. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3948. var isModule = Convert.ToBoolean(dto.isModule);
  3949. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3950. IOOperatorHelper io = new IOOperatorHelper();
  3951. if (isModule)
  3952. {
  3953. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3954. foreach (var moduleArr in moduleGroup)
  3955. {
  3956. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3957. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3958. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3959. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3960. foreach (var item in moduleArr)
  3961. {
  3962. if (System.IO.File.Exists(item.FilePath))
  3963. {
  3964. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3965. {
  3966. byte[] bytes = new byte[fileStream.Length];
  3967. fileStream.Read(bytes, 0, bytes.Length);
  3968. fileStream.Close();
  3969. Stream stream = new MemoryStream(bytes);
  3970. chiZips.Add(item.FileName, stream);
  3971. }
  3972. }
  3973. }
  3974. if (chiZips.Count > 0)
  3975. {
  3976. var byts = io.ConvertZipStream(chiZips);
  3977. Stream stream = new MemoryStream(byts);
  3978. Zips.Add(key.Name + "_.zip", stream);
  3979. }
  3980. }
  3981. }
  3982. else
  3983. {
  3984. foreach (var item in dbQuery)
  3985. {
  3986. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3987. {
  3988. byte[] bytes = new byte[fileStream.Length];
  3989. fileStream.Read(bytes, 0, bytes.Length);
  3990. fileStream.Close();
  3991. Stream stream = new MemoryStream(bytes);
  3992. while (Zips.Keys.Contains(item.FileName))
  3993. {
  3994. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3995. }
  3996. Zips.Add(item.FileName, stream);
  3997. }
  3998. }
  3999. }
  4000. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4001. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4002. if (Zips.Count > 0)
  4003. {
  4004. var byts = io.ConvertZipStream(Zips);
  4005. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4006. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4007. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4008. }
  4009. else
  4010. {
  4011. jw.Msg = "暂无生成文件!";
  4012. }
  4013. return Ok(jw);
  4014. }
  4015. /// <summary>
  4016. /// 下载该团组下此模块的所有文件
  4017. /// </summary>
  4018. /// <param name="dto"></param>
  4019. /// <returns></returns>
  4020. [HttpPost]
  4021. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4022. {
  4023. var jw = JsonView(false);
  4024. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4025. if (groupInfo == null)
  4026. {
  4027. jw.Msg = "团组信息不存在!";
  4028. return Ok(jw);
  4029. }
  4030. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4031. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4032. && x.IsDel == 0);
  4033. if (key == null)
  4034. {
  4035. jw.Msg = "Ctable指向错误!";
  4036. return Ok(jw);
  4037. }
  4038. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4039. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4040. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4041. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4042. IOOperatorHelper io = new IOOperatorHelper();
  4043. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4044. foreach (var item in dbQuery)
  4045. {
  4046. if (System.IO.File.Exists(item.FilePath))
  4047. {
  4048. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4049. {
  4050. byte[] bytes = new byte[fileStream.Length];
  4051. fileStream.Read(bytes, 0, bytes.Length);
  4052. fileStream.Close();
  4053. Stream stream = new MemoryStream(bytes);
  4054. while (Zips.Keys.Contains(item.FileName))
  4055. {
  4056. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4057. }
  4058. Zips.Add(item.FileName, stream);
  4059. }
  4060. }
  4061. }
  4062. if (Zips.Count > 0)
  4063. {
  4064. var byts = io.ConvertZipStream(Zips);
  4065. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4066. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4067. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4068. }
  4069. else
  4070. {
  4071. jw.Msg = "暂无生成文件!";
  4072. }
  4073. return Ok(jw);
  4074. }
  4075. /// <summary>
  4076. /// 删除该团组下的指定文件
  4077. /// </summary>
  4078. /// <param name="dto"></param>
  4079. /// <returns></returns>
  4080. [HttpPost]
  4081. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4082. {
  4083. var jw = JsonView(false);
  4084. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4085. if (sing == null)
  4086. {
  4087. jw.Msg = "暂无";
  4088. return Ok(jw);
  4089. }
  4090. if (System.IO.File.Exists(sing.FilePath))
  4091. {
  4092. try
  4093. {
  4094. System.IO.File.Delete(sing.FilePath);
  4095. }
  4096. catch (Exception ex)
  4097. {
  4098. jw.Msg = "删除失败!" + ex.Message;
  4099. return Ok(jw);
  4100. }
  4101. }
  4102. sing.IsDel = 1;
  4103. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4104. sing.DeleteUserId = dto.UserId;
  4105. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4106. jw = JsonView(true, "删除成功!");
  4107. return Ok(jw);
  4108. }
  4109. #endregion
  4110. #region 团组英文资料
  4111. /// <summary>
  4112. /// 查询团组英文所有资料
  4113. /// </summary>
  4114. /// <param name="dto"></param>
  4115. /// <returns></returns>
  4116. [HttpPost]
  4117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4118. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4119. {
  4120. try
  4121. {
  4122. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4123. if (groupData.Code != 0)
  4124. {
  4125. return Ok(JsonView(false, groupData.Msg));
  4126. }
  4127. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4128. }
  4129. catch (Exception ex)
  4130. {
  4131. return Ok(JsonView(false, "程序错误!"));
  4132. throw;
  4133. }
  4134. }
  4135. /// <summary>
  4136. /// 团组英文资料操作(Status:1.新增,2.修改)
  4137. /// </summary>
  4138. /// <param name="dto"></param>
  4139. /// <returns></returns>
  4140. [HttpPost]
  4141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4142. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4143. {
  4144. try
  4145. {
  4146. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4147. if (groupData.Code != 0)
  4148. {
  4149. return Ok(JsonView(false, groupData.Msg));
  4150. }
  4151. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4152. }
  4153. catch (Exception ex)
  4154. {
  4155. return Ok(JsonView(false, "程序错误!"));
  4156. throw;
  4157. }
  4158. }
  4159. /// <summary>
  4160. /// 团组英文资料Id查询数据
  4161. /// </summary>
  4162. /// <param name="dto"></param>
  4163. /// <returns></returns>
  4164. [HttpPost]
  4165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4166. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4167. {
  4168. try
  4169. {
  4170. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4171. if (_DelegationEnData != null)
  4172. {
  4173. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4174. }
  4175. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4176. }
  4177. catch (Exception ex)
  4178. {
  4179. return Ok(JsonView(false, "程序错误!"));
  4180. throw;
  4181. }
  4182. }
  4183. /// <summary>
  4184. /// 团组英文资料删除
  4185. /// </summary>
  4186. /// <param name="dto"></param>
  4187. /// <returns></returns>
  4188. [HttpPost]
  4189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4190. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4191. {
  4192. try
  4193. {
  4194. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4195. if (!res)
  4196. {
  4197. return Ok(JsonView(false, "删除失败"));
  4198. }
  4199. return Ok(JsonView(true, "删除成功!"));
  4200. }
  4201. catch (Exception ex)
  4202. {
  4203. return Ok(JsonView(false, "程序错误!"));
  4204. throw;
  4205. }
  4206. }
  4207. #endregion
  4208. #region 导出邀请函
  4209. /// <summary>
  4210. /// 导出邀请函页面初始化
  4211. /// </summary>
  4212. /// <param name="dto"></param>
  4213. /// <returns></returns>
  4214. [HttpPost]
  4215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4216. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4217. {
  4218. try
  4219. {
  4220. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4221. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4222. if (dto.DiId == 0)
  4223. {
  4224. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4225. }
  4226. else
  4227. {
  4228. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4229. }
  4230. return Ok(JsonView(true, "查询成功!", new
  4231. {
  4232. deleClient = crm_Deles,
  4233. delegations = grp_Delegations
  4234. }));
  4235. }
  4236. catch (Exception ex)
  4237. {
  4238. return Ok(JsonView(false, "程序错误!"));
  4239. throw;
  4240. }
  4241. }
  4242. /// <summary>
  4243. /// 导出邀请函
  4244. /// </summary>
  4245. /// <param name="dto"></param>
  4246. /// <returns></returns>
  4247. [HttpPost]
  4248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4249. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4250. {
  4251. #region 参数验证
  4252. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4253. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4254. #endregion
  4255. try
  4256. {
  4257. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4258. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4259. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4260. From Grp_TourClientList tcl
  4261. Left Join
  4262. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4263. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4264. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4265. From Crm_DeleClient dc
  4266. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4267. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4268. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4269. Where dc.IsDel = 0) temp
  4270. On temp.DcId =tcl.ClientId
  4271. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4272. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4273. List<string> texts = new List<string>();
  4274. if (datas.Count != 0)
  4275. {
  4276. foreach (TourClientListDetailsView item in datas)
  4277. {
  4278. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4279. {
  4280. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4281. }
  4282. else
  4283. {
  4284. string name = item.LastName + item.FirstName;
  4285. texts.Add(name);
  4286. }
  4287. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4288. {
  4289. if (!transDic.ContainsKey(item.Job))
  4290. {
  4291. texts.Add(item.Job);
  4292. }
  4293. }
  4294. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4295. {
  4296. texts.Add(item.CompanyFullName);
  4297. }
  4298. }
  4299. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4300. if (transData.Count > 0)
  4301. {
  4302. foreach (TranslateResult item in transData)
  4303. {
  4304. if (!transDic.ContainsKey(item.Query))
  4305. {
  4306. transDic.Add(item.Query, item.Translation);
  4307. }
  4308. }
  4309. }
  4310. List<GuestList> list = new List<GuestList>();
  4311. foreach (TourClientListDetailsView dele in datas)
  4312. {
  4313. GuestList guestList = new GuestList();
  4314. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4315. {
  4316. guestList.Name = dele.Pinyin;
  4317. }
  4318. else
  4319. {
  4320. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4321. guestList.Name = Name;
  4322. }
  4323. if (dele.Sex == 0)
  4324. {
  4325. guestList.Sex = "Male";
  4326. }
  4327. else if (dele.Sex == 1)
  4328. {
  4329. guestList.Sex = "Female";
  4330. }
  4331. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4332. if (!string.IsNullOrEmpty(dele.Job))
  4333. {
  4334. guestList.Job = dele.Job;
  4335. }
  4336. list.Add(guestList);
  4337. }
  4338. //载入模板
  4339. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4340. DocumentBuilder builder = new DocumentBuilder(doc);
  4341. //获取word里所有表格
  4342. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4343. //获取所填表格的序数
  4344. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4345. var rowStart = tableOne.Rows[0]; //获取第1行
  4346. //循环赋值
  4347. for (int i = 0; i < list.Count; i++)
  4348. {
  4349. builder.MoveToCell(0, i + 1, 0, 0);
  4350. builder.Write(list[i].Name.ToString());
  4351. builder.MoveToCell(0, i + 1, 1, 0);
  4352. builder.Write(list[i].Sex.ToString());
  4353. builder.MoveToCell(0, i + 1, 2, 0);
  4354. builder.Write(list[i].DOB.ToString());
  4355. builder.MoveToCell(0, i + 1, 3, 0);
  4356. builder.Write(list[i].Job.ToString());
  4357. }
  4358. //删除多余行
  4359. while (tableOne.Rows.Count > list.Count + 1)
  4360. {
  4361. tableOne.Rows.RemoveAt(list.Count + 1);
  4362. }
  4363. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4364. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4365. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4366. doc.Save(filePath);
  4367. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4368. return Ok(JsonView(true, "操作成功!", Url));
  4369. }
  4370. else
  4371. {
  4372. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4373. }
  4374. }
  4375. catch (Exception ex)
  4376. {
  4377. return Ok(JsonView(false, ex.Message));
  4378. throw;
  4379. }
  4380. }
  4381. #endregion
  4382. #region 团组经理模块 出入境费用
  4383. ///// <summary>
  4384. ///// 团组模块 - 出入境费用
  4385. ///// </summary>
  4386. ///// <returns></returns>
  4387. //[HttpPost]
  4388. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4389. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4390. //{
  4391. // try
  4392. // {
  4393. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4394. // if (data.Code != 0)
  4395. // {
  4396. // return Ok(JsonView(false, data.Msg));
  4397. // }
  4398. // return Ok(JsonView(true, "查询成功!"));
  4399. // }
  4400. // catch (Exception ex)
  4401. // {
  4402. // return Ok(JsonView(false, ex.Message));
  4403. // throw;
  4404. // }
  4405. //}
  4406. /// <summary>
  4407. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4408. /// </summary>
  4409. /// <returns></returns>
  4410. [HttpPost]
  4411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4412. public async Task<IActionResult> SetDayAndCostAreaChange()
  4413. {
  4414. try
  4415. {
  4416. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4417. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4418. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4419. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4420. foreach (var item in unite) //处理交集数据
  4421. {
  4422. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4423. }
  4424. foreach (var item in merge) //处理差集数据
  4425. {
  4426. int nationalTravelFeeId = 0;
  4427. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4428. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4429. else
  4430. {
  4431. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4432. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4433. }
  4434. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4435. }
  4436. //只更新dayAndCost 的 nationalTravelFeeId;
  4437. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4438. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4439. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4440. }
  4441. catch (Exception ex)
  4442. {
  4443. return Ok(JsonView(false, ex.Message));
  4444. throw;
  4445. }
  4446. }
  4447. /// <summary>
  4448. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4449. /// </summary>
  4450. /// <returns></returns>
  4451. [HttpPost]
  4452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4453. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4454. {
  4455. try
  4456. {
  4457. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4458. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4459. //SetDataInfoView
  4460. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4461. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4462. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4463. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4464. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4465. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4466. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4467. //默认币种显示
  4468. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4469. {
  4470. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4471. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4472. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4473. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4474. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4475. };
  4476. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4477. if (_currencyRate.Count > 0)
  4478. {
  4479. foreach (var item in _currencyInfos)
  4480. {
  4481. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4482. if (rateInfo != null)
  4483. {
  4484. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4485. rate1 *= 1.035M;
  4486. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4487. }
  4488. }
  4489. }
  4490. return Ok(JsonView(true, "查询成功!", new
  4491. {
  4492. GroupNameData = groupNameData.Data,
  4493. CurrencyData = _CurrencyData,
  4494. WordTypeData = _WordTypeData,
  4495. ExcelTypeData = _ExcelTypeData,
  4496. CurrencyInit = _currencyInfos
  4497. }));
  4498. }
  4499. catch (Exception ex)
  4500. {
  4501. return Ok(JsonView(false, ex.Message));
  4502. throw;
  4503. }
  4504. }
  4505. /// <summary>
  4506. /// 团组模块 - 出入境费用
  4507. /// 实时汇率 tips
  4508. /// 签证费用 tips
  4509. /// </summary>
  4510. /// <returns></returns>
  4511. [HttpPost]
  4512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4513. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4514. {
  4515. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4516. //默认币种显示
  4517. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4518. {
  4519. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4520. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4521. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4522. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4523. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4524. };
  4525. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4526. List<dynamic> reteInfos = new List<dynamic>();
  4527. if (_currencyRate.Count > 0)
  4528. {
  4529. foreach (var item in _currencyInfos)
  4530. {
  4531. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4532. if (rateInfo != null)
  4533. {
  4534. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4535. decimal rate1 = item.Rate;
  4536. rate1 *= 1.03M;
  4537. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4538. reteInfos.Add(new
  4539. {
  4540. currCode = item.CurrencyCode,
  4541. currName = item.CurrencyName,
  4542. rate = rate2,
  4543. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4544. });
  4545. }
  4546. }
  4547. }
  4548. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4549. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4550. return Ok(JsonView(true, "查询成功!", new
  4551. {
  4552. //GroupNameData = groupNameData.Data,
  4553. visaData = visaData.Data,
  4554. airData = airData.Data,
  4555. reteInfos = reteInfos
  4556. }));
  4557. }
  4558. /// <summary>
  4559. /// 团组模块 - 出入境费用 - Info
  4560. /// </summary>
  4561. /// <returns></returns>
  4562. [HttpPost]
  4563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4564. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4565. {
  4566. try
  4567. {
  4568. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4569. if (data.Code != 0)
  4570. {
  4571. return Ok(JsonView(false, data.Msg));
  4572. }
  4573. return Ok(JsonView(true, "查询成功!", data.Data));
  4574. }
  4575. catch (Exception ex)
  4576. {
  4577. return Ok(JsonView(false, ex.Message));
  4578. }
  4579. }
  4580. /// <summary>
  4581. /// 团组模块 - 出入境费用 - Add And Update
  4582. /// </summary>
  4583. /// <returns></returns>
  4584. [HttpPost]
  4585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4586. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4587. {
  4588. try
  4589. {
  4590. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4591. if (dto.DayOtherPriceData.Any())
  4592. {
  4593. var inserList = dto.DayOtherPriceData
  4594. .Where(x => x.Id == 0)
  4595. .Select(x => new Grp_DayOtherPrice
  4596. {
  4597. Cost = x.Cost,
  4598. Id = x.Id,
  4599. CreateTime = DateTime.Now,
  4600. CreateUserId = dto.UserId,
  4601. Currency = x.Currency,
  4602. Diid = x.Diid,
  4603. Index = x.Index,
  4604. IsDel = 0,
  4605. SetDataId = x.SetDataId,
  4606. SubTotal = x.SubTotal
  4607. })
  4608. .ToList();
  4609. var updateList = dto.DayOtherPriceData
  4610. .Where(x => x.Id != 0)
  4611. .Select(x => new Grp_DayOtherPrice
  4612. {
  4613. Cost = x.Cost,
  4614. Id = x.Id,
  4615. CreateTime = DateTime.Now,
  4616. CreateUserId = dto.UserId,
  4617. Currency = x.Currency,
  4618. Diid = x.Diid,
  4619. Index = x.Index,
  4620. IsDel = 0,
  4621. SetDataId = x.SetDataId,
  4622. SubTotal = x.SubTotal,
  4623. })
  4624. .ToList();
  4625. //添加
  4626. _sqlSugar.BeginTran();
  4627. if (inserList.Any())
  4628. {
  4629. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4630. }
  4631. if (updateList.Any())
  4632. {
  4633. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4634. }
  4635. _sqlSugar.CommitTran();
  4636. }
  4637. if (data.Code != 0)
  4638. {
  4639. return Ok(JsonView(false, data.Msg));
  4640. }
  4641. //生成默认文件pdf并且通知人员
  4642. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4643. {
  4644. DiId = dto.DiId,
  4645. ExportType = 1,
  4646. SubTypeId = 1005
  4647. }, "pdf");
  4648. //发送通知
  4649. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4650. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4651. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4652. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4653. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4654. //汇率信息记录
  4655. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4656. return Ok(JsonView(true, data.Msg, data.Data));
  4657. }
  4658. catch (Exception ex)
  4659. {
  4660. return Ok(JsonView(false, ex.Message));
  4661. }
  4662. }
  4663. /// <summary>
  4664. /// 团组模块 - 出入境费用 - Confirm 费用
  4665. /// </summary>
  4666. /// <returns></returns>
  4667. [HttpPost]
  4668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4669. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4670. {
  4671. //TODO:测试完毕需把对应的用户ID更改
  4672. //1、数据表添加字段
  4673. //2、更改字段接口()
  4674. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4675. //3、确认成功 给财务发送消息
  4676. if (_view.Code == 200)
  4677. {
  4678. if (dto.Type == 1)
  4679. {
  4680. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4681. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4682. }
  4683. }
  4684. return Ok(_view);
  4685. }
  4686. /// <summary>
  4687. /// 团组模块 - 出入境费用 - File downlaod
  4688. /// </summary>
  4689. /// <param name="dto"></param>
  4690. /// <returns></returns>
  4691. [HttpPost]
  4692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4693. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4694. {
  4695. try
  4696. {
  4697. if (dto.DiId < 1)
  4698. {
  4699. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4700. }
  4701. if (dto.ExportType < 1)
  4702. {
  4703. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4704. }
  4705. if (dto.SubTypeId < 1)
  4706. {
  4707. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4708. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4709. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4710. 3 团组成员名单 1 团组成员名单", ""));
  4711. }
  4712. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4713. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4714. if (_EnterExitCosts == null)
  4715. {
  4716. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4717. }
  4718. //数据源
  4719. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4720. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4721. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4722. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4723. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4724. .LeftJoin<Sys_SetData>((x,a)=> a.IsDel == 0 && a.Id == x.SetDataId)
  4725. .LeftJoin<Sys_SetData>((x, a, b) => a.IsDel == 0 && a.Id == x.Currency)
  4726. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4727. .Select((x, a, b) => new
  4728. {
  4729. x.Index,
  4730. itemName = a.Name,
  4731. CurrencyStr = b.Name,
  4732. x.Cost,
  4733. x.SubTotal,
  4734. })
  4735. .OrderBy((x) => x.Index)
  4736. .ToList();
  4737. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4738. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4739. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4740. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4741. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4742. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4743. .Select((tcl, dc, cc) => new
  4744. {
  4745. Name = dc.LastName + dc.FirstName,
  4746. Sex = dc.Sex,
  4747. Birthday = dc.BirthDay,
  4748. Company = cc.CompanyFullName,
  4749. Job = dc.Job
  4750. })
  4751. .ToList();
  4752. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4753. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4754. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4755. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4756. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4757. if (dto.ExportType == 1) //明细表
  4758. {
  4759. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4760. {
  4761. //获取模板
  4762. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4763. //载入模板
  4764. Document doc = new Document(tempPath);
  4765. DocumentBuilder builder = new DocumentBuilder(doc);
  4766. //利用键值对存放数据
  4767. Dictionary<string, string> dic = new Dictionary<string, string>();
  4768. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4769. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4770. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4771. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4772. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal);
  4773. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4774. //境内费用(其他费用)
  4775. if (_EnterExitCosts.ChoiceOne == 1)
  4776. {
  4777. string row1_1 = "";
  4778. if (_EnterExitCosts.Visa > 0)
  4779. {
  4780. //insidePayTotal += _EnterExitCosts.Visa;
  4781. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4782. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4783. {
  4784. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4785. }
  4786. }
  4787. string row1_2 = "";
  4788. if (_EnterExitCosts.YiMiao > 0)
  4789. {
  4790. //insidePayTotal += _EnterExitCosts.YiMiao;
  4791. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4792. }
  4793. if (_EnterExitCosts.HeSuan > 0)
  4794. {
  4795. //insidePayTotal += _EnterExitCosts.HeSuan;
  4796. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4797. }
  4798. if (_EnterExitCosts.Service > 0)
  4799. {
  4800. //insidePayTotal += _EnterExitCosts.Service;
  4801. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4802. }
  4803. string row1_3 = "";
  4804. if (_EnterExitCosts.Safe > 0)
  4805. {
  4806. //insidePayTotal += _EnterExitCosts.Safe;
  4807. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4808. }
  4809. if (_EnterExitCosts.Ticket > 0)
  4810. {
  4811. //insidePayTotal += _EnterExitCosts.Ticket;
  4812. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4813. }
  4814. string row1 = "";
  4815. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4816. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4817. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4818. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4819. dic.Add("Row1Str", row1);
  4820. }
  4821. string airTotalStr = string.Empty,
  4822. airPriceStr = string.Empty;
  4823. //经济舱
  4824. if (_EnterExitCosts.SumJJC == 1)
  4825. {
  4826. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4827. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4828. }
  4829. //公务舱
  4830. if (_EnterExitCosts.SumGWC == 1)
  4831. {
  4832. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4833. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4834. }
  4835. //头等舱
  4836. if (_EnterExitCosts.SumTDC == 1)
  4837. {
  4838. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4839. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4840. }
  4841. dic.Add("AirTotalStr", airTotalStr);
  4842. dic.Add("AirPriceStr", airPriceStr);
  4843. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4844. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4845. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4846. int table1Row = 0,
  4847. table2Row = 0,
  4848. table3Row = 0,
  4849. table4Row = 0,
  4850. table5Row = 0;
  4851. //住宿费
  4852. if (_EnterExitCosts.ChoiceThree == 1)
  4853. {
  4854. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4855. table1Row = dac1.Count;
  4856. #region 填充word表格内容
  4857. for (int i = 0; i < dac1.Count; i++)
  4858. {
  4859. Grp_DayAndCost dac = dac1[i];
  4860. if (dac == null) continue;
  4861. builder.MoveToCell(0, i, 0, 0);
  4862. builder.Write("第" + dac.Days.ToString() + "晚:");
  4863. builder.MoveToCell(0, i, 1, 0);
  4864. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4865. //builder.Write(dac.Place == null ? "" : dac.Place);
  4866. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4867. builder.MoveToCell(0, i, 2, 0);
  4868. builder.Write("费用标准:");
  4869. string curr = "";
  4870. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4871. if (currData != null)
  4872. {
  4873. curr = currData.Name;
  4874. }
  4875. builder.MoveToCell(0, i, 3, 0);
  4876. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4877. builder.MoveToCell(0, i, 4, 0);
  4878. builder.Write("费用小计:");
  4879. builder.MoveToCell(0, i, 5, 0);
  4880. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4881. }
  4882. #endregion
  4883. }
  4884. else dic.Add("SubZS", "0.00");
  4885. //删除多余行
  4886. while (table1.Rows.Count > table1Row)
  4887. {
  4888. table1.Rows.RemoveAt(table1Row);
  4889. }
  4890. //伙食费
  4891. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4892. if (_EnterExitCosts.ChoiceFour == 1)
  4893. {
  4894. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4895. table2Row = dac2.Count;
  4896. #region 填充word表格内容
  4897. for (int i = 0; i < dac2.Count; i++)
  4898. {
  4899. Grp_DayAndCost dac = dac2[i];
  4900. if (dac == null) continue;
  4901. builder.MoveToCell(1, i, 0, 0);
  4902. builder.Write("第" + dac.Days.ToString() + "天:");
  4903. builder.MoveToCell(1, i, 1, 0);
  4904. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4905. builder.MoveToCell(1, i, 2, 0);
  4906. builder.Write("费用标准:");
  4907. string curr = "";
  4908. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4909. if (currData != null)
  4910. {
  4911. curr = currData.Name;
  4912. }
  4913. builder.MoveToCell(1, i, 3, 0);
  4914. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4915. builder.MoveToCell(1, i, 4, 0);
  4916. builder.Write("费用小计:");
  4917. builder.MoveToCell(1, i, 5, 0);
  4918. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4919. }
  4920. #endregion
  4921. }
  4922. else dic.Add("SubHS", "0.00");
  4923. //删除多余行
  4924. while (table2.Rows.Count > table2Row)
  4925. {
  4926. table2.Rows.RemoveAt(table2Row);
  4927. }
  4928. //公杂费
  4929. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4930. if (_EnterExitCosts.ChoiceFive == 1)
  4931. {
  4932. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4933. table3Row = dac3.Count;
  4934. #region 填充word表格内容
  4935. for (int i = 0; i < dac3.Count; i++)
  4936. {
  4937. Grp_DayAndCost dac = dac3[i];
  4938. if (dac == null) continue;
  4939. builder.MoveToCell(2, i, 0, 0);
  4940. builder.Write("第" + dac.Days.ToString() + "天:");
  4941. builder.MoveToCell(2, i, 1, 0);
  4942. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4943. builder.MoveToCell(2, i, 2, 0);
  4944. builder.Write("费用标准:");
  4945. string curr = "";
  4946. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4947. if (currData != null)
  4948. {
  4949. curr = currData.Name;
  4950. }
  4951. builder.MoveToCell(2, i, 3, 0);
  4952. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4953. builder.MoveToCell(2, i, 4, 0);
  4954. builder.Write("费用小计:");
  4955. builder.MoveToCell(2, i, 5, 0);
  4956. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4957. }
  4958. //删除多余行
  4959. while (table3.Rows.Count > table3Row)
  4960. {
  4961. table3.Rows.RemoveAt(table3Row);
  4962. }
  4963. #endregion
  4964. }
  4965. else dic.Add("SubGZF", "0.00");
  4966. //删除多余行
  4967. while (table3.Rows.Count > table3Row)
  4968. {
  4969. table3.Rows.RemoveAt(table3Row);
  4970. }
  4971. //培训费
  4972. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4973. if (_EnterExitCosts.ChoiceSix == 1)
  4974. {
  4975. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4976. dic.Add("SubPX", pxStr);
  4977. table4Row = dac4.Count;
  4978. #region 填充word表格内容
  4979. for (int i = 0; i < dac4.Count; i++)
  4980. {
  4981. Grp_DayAndCost dac = dac4[i];
  4982. if (dac == null) continue;
  4983. builder.MoveToCell(3, i, 0, 0);
  4984. builder.Write("第" + dac.Days.ToString() + "天:");
  4985. builder.MoveToCell(3, i, 1, 0);
  4986. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4987. builder.MoveToCell(3, i, 2, 0);
  4988. builder.Write("费用标准:");
  4989. string curr = "";
  4990. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4991. if (currData != null)
  4992. {
  4993. curr = currData.Name;
  4994. }
  4995. builder.MoveToCell(3, i, 3, 0);
  4996. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4997. builder.MoveToCell(3, i, 4, 0);
  4998. builder.Write("费用小计:");
  4999. builder.MoveToCell(3, i, 5, 0);
  5000. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5001. }
  5002. #endregion
  5003. }
  5004. //else dic.Add("SubPX","0.00");
  5005. //删除多余行
  5006. while (table4.Rows.Count > table4Row)
  5007. {
  5008. table4.Rows.RemoveAt(table4Row);
  5009. }
  5010. //其他费用
  5011. Aspose.Words.Tables.Table table5 = allTables[3] as Aspose.Words.Tables.Table;
  5012. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5013. {
  5014. dic.Add("SubQT", otherPriceTotal.ToString("#0.00"));
  5015. table5Row = table5.Count;
  5016. #region 填充word表格内容
  5017. for (int i = 0; i < dac5.Count; i++)
  5018. {
  5019. var dac = dac5[i];
  5020. if (dac == null) continue;
  5021. builder.MoveToCell(3, i, 0, 0);
  5022. builder.Write("第" + dac.Index.ToString() + "项:");
  5023. builder.MoveToCell(3, i, 1, 0);
  5024. builder.Write(dac.itemName);
  5025. builder.MoveToCell(3, i, 2, 0);
  5026. builder.Write("费用标准:");
  5027. builder.MoveToCell(3, i, 3, 0);
  5028. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5029. builder.MoveToCell(3, i, 4, 0);
  5030. builder.Write("费用小计:");
  5031. builder.MoveToCell(3, i, 5, 0);
  5032. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5033. }
  5034. #endregion
  5035. }
  5036. else dic.Add("SubQT", "0.00");
  5037. //删除多余行
  5038. while (table5.Rows.Count > table5Row)
  5039. {
  5040. table5.Rows.RemoveAt(table5Row);
  5041. }
  5042. //加上其他费用
  5043. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5044. decimal subJJC = 0.00M,
  5045. subGWC = 0.00M,
  5046. subTDC = 0.00M;
  5047. //经济舱
  5048. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5049. //公务舱
  5050. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5051. //头等舱
  5052. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5053. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5054. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5055. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5056. #region 填充word模板书签内容
  5057. foreach (var key in dic.Keys)
  5058. {
  5059. builder.MoveToBookmark(key);
  5060. builder.Write(dic[key]);
  5061. }
  5062. #endregion
  5063. //文件名
  5064. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5065. AsposeHelper.removewatermark_v2180();
  5066. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5067. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5068. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5069. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5070. }
  5071. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5072. {
  5073. //获取模板
  5074. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5075. //载入模板
  5076. Document doc = new Document(tempPath);
  5077. DocumentBuilder builder = new DocumentBuilder(doc);
  5078. Dictionary<string, string> dic = new Dictionary<string, string>();
  5079. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5080. {
  5081. List<string> list = new List<string>();
  5082. try
  5083. {
  5084. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5085. foreach (var item in spilitArr)
  5086. {
  5087. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5088. var depCode = spDotandEmpty[2].Substring(0, 3);
  5089. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5090. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5091. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5092. list.Add(depName);
  5093. list.Add(arrName);
  5094. }
  5095. list = list.Distinct().ToList();
  5096. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5097. }
  5098. catch (Exception)
  5099. {
  5100. dic.Add("ReturnCode", "行程录入不正确!");
  5101. }
  5102. }
  5103. else
  5104. {
  5105. dic.Add("ReturnCode", "未录入行程!");
  5106. }
  5107. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5108. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5109. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5110. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5111. {
  5112. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5113. dic.Add("Day", sp.Days.ToString());
  5114. }
  5115. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5116. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5117. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5118. //dic.Add("Names", Names);
  5119. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5120. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5121. decimal dac1totalPrice = 0.00M;
  5122. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5123. foreach (var dac in dac1)
  5124. {
  5125. if (dac.SubTotal == 0.00M)
  5126. {
  5127. continue;
  5128. }
  5129. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5130. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5131. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5132. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5133. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5134. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5135. builder.Write(currency);//币种
  5136. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5137. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5138. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5139. builder.Write("");//人数
  5140. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5141. builder.Write("");//天数
  5142. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5143. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5144. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5145. decimal rate = 0.00M;
  5146. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5147. builder.Write(rate.ToString("#0.0000"));//汇率
  5148. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5149. decimal rbmPrice = dac.SubTotal;
  5150. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5151. accommodationStartIndex++;
  5152. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5153. }
  5154. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5155. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5156. {
  5157. table1.Rows.RemoveAt(i - 1);
  5158. foodandotherStartIndex--;
  5159. }
  5160. if (dac2.Count == dac3.Count)//国家 币种 金额
  5161. {
  5162. for (int i = 0; i < dac2.Count; i++)
  5163. {
  5164. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5165. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5166. }
  5167. }
  5168. decimal dac2totalPrice = 0.00M;
  5169. foreach (var dac in dac2)
  5170. {
  5171. if (dac.SubTotal == 0)
  5172. {
  5173. continue;
  5174. }
  5175. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5176. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5177. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5178. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5179. builder.Write(currency);//币种
  5180. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5181. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5182. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5183. builder.Write("");//人数
  5184. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5185. builder.Write("");//天数
  5186. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5187. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5188. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5189. decimal rate = 0.00M;
  5190. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5191. builder.Write(rate.ToString("#0.0000"));//汇率
  5192. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5193. decimal rbmPrice = dac.SubTotal;
  5194. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5195. foodandotherStartIndex++;
  5196. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5197. }
  5198. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5199. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5200. {
  5201. table1.Rows.RemoveAt(i - 1);
  5202. }
  5203. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5204. string otherFeeStr = "";
  5205. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5206. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5207. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5208. if (otherFeeStr.Length > 0)
  5209. {
  5210. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5211. otherFeeStr = $"({otherFeeStr})";
  5212. dic.Add("OtherFeeStr", otherFeeStr);
  5213. }
  5214. //总计
  5215. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5216. //国际旅费
  5217. string outsideAir = string.Empty;
  5218. string allPriceAir = string.Empty;
  5219. if (_EnterExitCosts.SumJJC == 1)
  5220. {
  5221. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5222. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5223. }
  5224. if (_EnterExitCosts.SumGWC == 1)
  5225. {
  5226. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5227. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5228. }
  5229. if (_EnterExitCosts.SumTDC == 1)
  5230. {
  5231. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5232. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5233. }
  5234. dic.Add("InTravelPrice", $"({outsideAir})");
  5235. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5236. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5237. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5238. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5239. foreach (var key in dic.Keys)
  5240. {
  5241. builder.MoveToBookmark(key);
  5242. builder.Write(dic[key]);
  5243. }
  5244. //模板文件名
  5245. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5246. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5247. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5248. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5249. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5250. }
  5251. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5252. {
  5253. //获取模板
  5254. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5255. //载入模板
  5256. WorkbookDesigner designer = new WorkbookDesigner();
  5257. designer.Workbook = new Workbook(tempPath);
  5258. Dictionary<string, string> dic = new Dictionary<string, string>();
  5259. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5260. {
  5261. List<string> list = new List<string>();
  5262. try
  5263. {
  5264. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5265. foreach (var item in spilitArr)
  5266. {
  5267. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5268. var depCode = spDotandEmpty[2].Substring(0, 3);
  5269. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5270. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5271. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5272. list.Add(depName);
  5273. list.Add(arrName);
  5274. }
  5275. list = list.Distinct().ToList();
  5276. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5277. }
  5278. catch (Exception)
  5279. {
  5280. dic.Add("ReturnCode", "行程录入不正确!");
  5281. }
  5282. }
  5283. else
  5284. {
  5285. dic.Add("ReturnCode", "未录入行程!");
  5286. }
  5287. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5288. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5289. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5290. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5291. {
  5292. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5293. dic.Add("Day", sp.Days.ToString());
  5294. }
  5295. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5296. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5297. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5298. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5299. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5300. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5301. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5302. designer.SetDataSource("Name", Names);
  5303. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5304. designer.SetDataSource("Day", dic["Day"] + "天");
  5305. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5306. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5307. int startIndex = 10;
  5308. const int startIndexcopy = 10;
  5309. if (dac2.Count == dac3.Count)//国家 币种 金额
  5310. {
  5311. for (int i = 0; i < dac2.Count; i++)
  5312. {
  5313. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5314. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5315. }
  5316. }
  5317. DataTable dtdac1 = new DataTable();
  5318. List<string> place = new List<string>();
  5319. dtdac1.Columns.AddRange(new DataColumn[] {
  5320. new DataColumn(){ ColumnName = "city"},
  5321. new DataColumn(){ ColumnName = "curr"},
  5322. new DataColumn(){ ColumnName = "criterion"},
  5323. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5324. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5325. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5326. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5327. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5328. });
  5329. DataTable dtdac2 = new DataTable();
  5330. dtdac2.Columns.AddRange(new DataColumn[] {
  5331. new DataColumn(){ ColumnName = "city"},
  5332. new DataColumn(){ ColumnName = "curr"},
  5333. new DataColumn(){ ColumnName = "criterion"},
  5334. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5335. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5336. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5337. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5338. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5339. });
  5340. dtdac1.TableName = "tb1";
  5341. dtdac2.TableName = "tb2";
  5342. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5343. foreach (var item in dac1)
  5344. {
  5345. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5346. if (place.Contains(item.Place))
  5347. {
  5348. continue;
  5349. }
  5350. DataRow row = dtdac1.NewRow();
  5351. row["city"] = item.Place;
  5352. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5353. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5354. row["curr"] = currency;
  5355. row["rate"] = rate.ToString("#0.0000");
  5356. row["criterion"] = item.Cost.ToString("#0.00");
  5357. row["number"] = 1;
  5358. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5359. //row["costRMB"] = rbmPrice;
  5360. dtdac1.Rows.Add(row);
  5361. place.Add(item.Place);
  5362. }
  5363. place = new List<string>();
  5364. foreach (var item in dac2)
  5365. {
  5366. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5367. if (place.Contains(item.Place))
  5368. {
  5369. continue;
  5370. }
  5371. DataRow row = dtdac2.NewRow();
  5372. row["city"] = item.Place;
  5373. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5374. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5375. row["curr"] = currency;
  5376. row["rate"] = rate.ToString("#0.0000");
  5377. row["criterion"] = item.Cost.ToString("#0.00");
  5378. row["number"] = 1;
  5379. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5380. //row["cost"] = item.SubTotal;
  5381. //row["costRMB"] = rbmPrice;
  5382. dtdac2.Rows.Add(row);
  5383. place.Add(item.Place);
  5384. //dac2totalPrice += rbmPrice;
  5385. }
  5386. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5387. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5388. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5389. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5390. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5391. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5392. string cell4Str1 = string.Empty;
  5393. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5394. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5395. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5396. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5397. string cellStr = $" 5.其他费用(";
  5398. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5399. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5400. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5401. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5402. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5403. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5404. if (cellStr.Length > 8)
  5405. {
  5406. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5407. }
  5408. cellStr += ")";
  5409. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5410. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5411. decimal pxFee = dac4.Sum(it => it.Cost);
  5412. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5413. string celllastStr1 = "";
  5414. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5415. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5416. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5417. celllastStr1 += $",国际旅费 元";
  5418. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5419. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5420. designer.SetDataSource("cell4Str", cell4Str);
  5421. designer.SetDataSource("cellStr", cellStr);
  5422. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5423. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5424. designer.SetDataSource("celllastStr", celllastStr);
  5425. Workbook wb = designer.Workbook;
  5426. var sheet = wb.Worksheets[0];
  5427. //绑定datatable数据集
  5428. designer.SetDataSource(dtdac1);
  5429. designer.SetDataSource(dtdac2);
  5430. designer.Process();
  5431. var rowStart = dtdac1.Rows.Count;
  5432. while (rowStart > 0)
  5433. {
  5434. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5435. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5436. startIndex++;
  5437. rowStart--;
  5438. }
  5439. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5440. startIndex += 1; //总计行
  5441. rowStart = dtdac2.Rows.Count;
  5442. while (rowStart > 0)
  5443. {
  5444. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5445. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5446. startIndex++;
  5447. rowStart--;
  5448. }
  5449. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5450. wb.CalculateFormula(true);
  5451. //模板文件名
  5452. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5453. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5454. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5455. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5456. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5457. }
  5458. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5459. {
  5460. //获取模板
  5461. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5462. //载入模板
  5463. Document doc = new Document(tempPath);
  5464. DocumentBuilder builder = new DocumentBuilder(doc);
  5465. Dictionary<string, string> dic = new Dictionary<string, string>();
  5466. dic.Add("GroupName", _DelegationInfo.TeamName);
  5467. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5468. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5469. string missionLeaderJob = "";//负责人job
  5470. int groupNumber = 0; //团人数
  5471. if (DeleClientList.Count > 0)
  5472. {
  5473. missionLeader = DeleClientList[0]?.Name ?? "";
  5474. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5475. }
  5476. dic.Add("MissionLeader", missionLeader); //团负责人
  5477. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5478. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5479. #region MyRegion
  5480. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5481. //{
  5482. // List<string> list = new List<string>();
  5483. // try
  5484. // {
  5485. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5486. // foreach (var item in spilitArr)
  5487. // {
  5488. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5489. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5490. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5491. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5492. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5493. // list.Add(depName);
  5494. // list.Add(arrName);
  5495. // }
  5496. // list = list.Distinct().ToList();
  5497. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5498. // }
  5499. // catch (Exception)
  5500. // {
  5501. // dic.Add("ReturnCode", "行程录入不正确!");
  5502. // }
  5503. //}
  5504. //else
  5505. //{
  5506. // dic.Add("ReturnCode", "未录入行程!");
  5507. //}
  5508. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5509. dic.Add("ReturnCode", string.Join("、", countrys));
  5510. #endregion
  5511. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5512. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5513. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5514. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5515. //{
  5516. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5517. // dic.Add("Day", sp.Days.ToString());
  5518. //}
  5519. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5520. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5521. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5522. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5523. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5524. //培训人员名单
  5525. int cultivateRowIndex = 7;
  5526. foreach (var item in DeleClientList)
  5527. {
  5528. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5529. builder.Write(item.Name);
  5530. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5531. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5532. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5533. string birthDay = "";
  5534. if (item.Birthday != null)
  5535. {
  5536. DateTime dt = Convert.ToDateTime(item.Birthday);
  5537. birthDay = $"{dt.Year}.{dt.Month}";
  5538. }
  5539. builder.Write(birthDay);
  5540. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5541. builder.Write(item.Company);
  5542. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5543. builder.Write(item.Job);
  5544. cultivateRowIndex++;
  5545. }
  5546. //删除多余行
  5547. //cultivateRowIndex -= 2;
  5548. int delRows = 10 + 7 - cultivateRowIndex;
  5549. if (delRows > 0)
  5550. {
  5551. for (int i = 0; i < delRows; i++)
  5552. {
  5553. table1.Rows.RemoveAt(cultivateRowIndex);
  5554. //cultivateRowIndex++;
  5555. }
  5556. }
  5557. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5558. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5559. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5560. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5561. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5562. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5563. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5564. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5565. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5566. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5567. //其他费用
  5568. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5569. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5570. //其他费用合计
  5571. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5572. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5573. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5574. //公务舱合计
  5575. //国际旅费
  5576. string outsideJJ = "";
  5577. string allPriceJJ = "";
  5578. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5579. {
  5580. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5581. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5582. }
  5583. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5584. {
  5585. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5586. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5587. }
  5588. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5589. {
  5590. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5591. dic.Add("AirFeeTotal", airFeeTotalStr);
  5592. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5593. dic.Add("FeeTotal", feeTotalStr);
  5594. }
  5595. foreach (var key in dic.Keys)
  5596. {
  5597. builder.MoveToBookmark(key);
  5598. builder.Write(dic[key]);
  5599. }
  5600. //模板文件名
  5601. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5602. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5603. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5604. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5605. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5606. }
  5607. }
  5608. else if (dto.ExportType == 2) //表格
  5609. {
  5610. //利用键值对存放数据
  5611. Dictionary<string, string> dic = new Dictionary<string, string>();
  5612. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5613. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5614. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5615. dic.Add("Day", sp.Days.ToString());
  5616. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5617. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5618. {
  5619. //获取模板
  5620. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5621. //载入模板
  5622. Document doc = new Document(tempPath);
  5623. DocumentBuilder builder = new DocumentBuilder(doc);
  5624. dic.Add("TeamName", _DelegationInfo.TeamName);
  5625. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5626. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5627. string missionLeaderName = "",
  5628. missionLeaderJob = "";
  5629. if (DeleClientList.Count > 0)
  5630. {
  5631. missionLeaderName = DeleClientList[0].Name;
  5632. missionLeaderJob = DeleClientList[0].Job;
  5633. }
  5634. dic.Add("MissionLeaderName", missionLeaderName);
  5635. dic.Add("MissionLeaderJob", missionLeaderJob);
  5636. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5637. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5638. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5639. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5640. int rowCount = 10;//总人数行
  5641. int startRowIndex = 7; //起始行
  5642. for (int i = 0; i < DeleClientList.Count; i++)
  5643. {
  5644. builder.MoveToCell(0, startRowIndex, 0, 0);
  5645. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5646. builder.MoveToCell(0, startRowIndex, 1, 0);
  5647. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5648. builder.Write(sex);//性别
  5649. builder.MoveToCell(0, startRowIndex, 2, 0);
  5650. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5651. builder.MoveToCell(0, startRowIndex, 3, 0);
  5652. builder.Write(DeleClientList[i].Company);//工作单位
  5653. builder.MoveToCell(0, startRowIndex, 4, 0);
  5654. builder.Write(DeleClientList[i].Job);//职务及级别
  5655. builder.MoveToCell(0, startRowIndex, 5, 0);
  5656. builder.Write("");//人员属性
  5657. builder.MoveToCell(0, startRowIndex, 6, 0);
  5658. builder.Write("");//上次出国时间
  5659. startRowIndex++;
  5660. }
  5661. int nullRow = rowCount - DeleClientList.Count;//空行
  5662. for (int i = 0; i < nullRow; i++)
  5663. {
  5664. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5665. }
  5666. foreach (var key in dic.Keys)
  5667. {
  5668. builder.MoveToBookmark(key);
  5669. builder.Write(dic[key]);
  5670. }
  5671. //模板文件名
  5672. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5673. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5674. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5675. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5676. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5677. }
  5678. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5679. {
  5680. //获取模板
  5681. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5682. //载入模板
  5683. Document doc = new Document(tempPath);
  5684. DocumentBuilder builder = new DocumentBuilder(doc);
  5685. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5686. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5687. dic.Add("Names", Names);
  5688. int accommodationRows = 12, foodandotherRows = 12;
  5689. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5690. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5691. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5692. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5693. int accommodationStartIndex = 6;
  5694. decimal dac1totalPrice = 0.00M;
  5695. foreach (var dac in dac1)
  5696. {
  5697. if (dac.SubTotal == 0)
  5698. {
  5699. continue;
  5700. }
  5701. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5702. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5703. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5704. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5705. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5706. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5707. builder.Write(currency);//币种
  5708. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5709. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5710. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5711. builder.Write("");//人数
  5712. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5713. builder.Write("");//天数
  5714. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5715. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5716. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5717. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5718. builder.Write(rate.ToString("#0.0000"));//汇率
  5719. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5720. decimal rbmPrice = rate * dac.SubTotal;
  5721. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5722. accommodationStartIndex++;
  5723. dac1totalPrice += rbmPrice;
  5724. }
  5725. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5726. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5727. builder.Write("小计");
  5728. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5729. builder.Write(dac1totalPrice.ToString("#0.00"));
  5730. accommodationStartIndex++;
  5731. int nullRow = accommodationRows - dac1.Count;
  5732. //删除空行
  5733. //if (nullRow > 0)
  5734. //{
  5735. // int rowIndex = accommodationStartIndex;
  5736. // for (int i = 0; i < nullRow; i++)
  5737. // {
  5738. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5739. // row.Remove();
  5740. // rowIndex++;
  5741. // }
  5742. //}
  5743. if (dac2.Count == dac3.Count)//国家 币种 金额
  5744. {
  5745. for (int i = 0; i < dac2.Count; i++)
  5746. {
  5747. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5748. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5749. }
  5750. }
  5751. int foodandotherStartIndex = 19;//
  5752. decimal dac2totalPrice = 0.00M;
  5753. foreach (var dac in dac2)
  5754. {
  5755. if (dac.SubTotal == 0)
  5756. {
  5757. continue;
  5758. }
  5759. //foodandotherStartIndex = 12;
  5760. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5761. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5762. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5763. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5764. builder.Write(currency);//币种
  5765. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5766. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5767. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5768. builder.Write("");//人数
  5769. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5770. builder.Write("");//天数
  5771. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5772. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5773. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5774. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5775. builder.Write(rate.ToString("#0.0000"));//汇率
  5776. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5777. decimal rbmPrice = rate * dac.SubTotal;
  5778. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5779. foodandotherStartIndex++;
  5780. dac2totalPrice += rbmPrice;
  5781. }
  5782. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5783. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5784. //删除空行
  5785. //if (dac2.Count < foodandotherRows)
  5786. //{
  5787. // while (table2.Rows.Count > dac2.Count)
  5788. // {
  5789. // table2.Rows.RemoveAt(dac2.Count);
  5790. // }
  5791. //}
  5792. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5793. string otherFeeStr = "";
  5794. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5795. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5796. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5797. if (otherFeeStr.Length > 0)
  5798. {
  5799. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5800. otherFeeStr = $"({otherFeeStr})";
  5801. dic.Add("OtherFeeStr", otherFeeStr);
  5802. }
  5803. foreach (var key in dic.Keys)
  5804. {
  5805. builder.MoveToBookmark(key);
  5806. builder.Write(dic[key]);
  5807. }
  5808. //模板文件名
  5809. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5810. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5811. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5812. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5813. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5814. }
  5815. }
  5816. else if (dto.ExportType == 3)
  5817. {
  5818. if (dto.SubTypeId == 1) //团组成员名单
  5819. {
  5820. if (DeleClientList.Count < 1)
  5821. {
  5822. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5823. }
  5824. //获取模板
  5825. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5826. //载入模板
  5827. Document doc = new Document(tempPath);
  5828. DocumentBuilder builder = new DocumentBuilder(doc);
  5829. //获取word里所有表格
  5830. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5831. //获取所填表格的序数
  5832. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5833. var rowStart = tableOne.Rows[0]; //获取第1行
  5834. //循环赋值
  5835. for (int i = 0; i < DeleClientList.Count; i++)
  5836. {
  5837. builder.MoveToCell(0, i + 1, 0, 0);
  5838. builder.Write(DeleClientList[i].Name);
  5839. builder.MoveToCell(0, i + 1, 1, 0);
  5840. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5841. builder.Write(sex);
  5842. builder.MoveToCell(0, i + 1, 2, 0);
  5843. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5844. builder.MoveToCell(0, i + 1, 3, 0);
  5845. builder.Write(DeleClientList[i].Company);
  5846. builder.MoveToCell(0, i + 1, 4, 0);
  5847. builder.Write(DeleClientList[i].Job);
  5848. }
  5849. //删除多余行
  5850. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5851. {
  5852. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5853. }
  5854. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5855. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5856. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5857. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5858. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5859. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5860. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5861. }
  5862. }
  5863. return Ok(JsonView(400, "操作失败!", ""));
  5864. }
  5865. catch (Exception ex)
  5866. {
  5867. return Ok(JsonView(400, ex.Message, ""));
  5868. }
  5869. }
  5870. /// <summary>
  5871. /// 获取三公费用标准city
  5872. /// </summary>
  5873. /// <param name="placeData"></param>
  5874. /// <param name="nationalTravelFeeId"></param>
  5875. /// <returns></returns>
  5876. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5877. {
  5878. string _city = string.Empty;
  5879. if (placeData.Count < 1) return _city;
  5880. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5881. if (data == null) return _city;
  5882. string country = data.Country;
  5883. string city = data.City;
  5884. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5885. else _city = city;
  5886. return _city;
  5887. }
  5888. /// <summary>
  5889. /// 团组模块 - 出入境费用 - 明细表导出
  5890. /// </summary>
  5891. /// <returns></returns>
  5892. [HttpPost]
  5893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5894. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5895. {
  5896. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5897. if (data.Code != 0)
  5898. {
  5899. return Ok(JsonView(false, data.Msg));
  5900. }
  5901. return Ok(JsonView(true, data.Msg, data.Data));
  5902. }
  5903. /// <summary>
  5904. /// 团组模块 - 出入境费用 - 一键清空
  5905. /// </summary>
  5906. /// <returns></returns>
  5907. [HttpPost]
  5908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5909. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5910. {
  5911. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5912. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5913. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5914. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5915. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5916. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5917. .SetColumns(x => new Grp_DayOtherPrice
  5918. {
  5919. IsDel = 1,
  5920. DeleteUserId = dto.UserId,
  5921. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5922. })
  5923. .ExecuteCommandAsync();
  5924. if (_view.Code == 0)
  5925. {
  5926. return Ok(JsonView(true, "操作成功"));
  5927. }
  5928. return Ok(JsonView(false, "操作失败"));
  5929. }
  5930. /// <summary>
  5931. /// 团组模块 - 出入境费用 - 子项删除
  5932. /// </summary>
  5933. /// <returns></returns>
  5934. [HttpPost]
  5935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5936. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5937. {
  5938. try
  5939. {
  5940. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5941. if (data.Code != 0)
  5942. {
  5943. return Ok(JsonView(false, data.Msg));
  5944. }
  5945. return Ok(JsonView(true, "操作成功!", data.Data));
  5946. }
  5947. catch (Exception ex)
  5948. {
  5949. return Ok(JsonView(false, ex.Message));
  5950. }
  5951. }
  5952. /// <summary>
  5953. /// 删除三公其他费用
  5954. /// </summary>
  5955. /// <param name="dto"></param>
  5956. /// <returns></returns>
  5957. [HttpPost]
  5958. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5959. {
  5960. var jw = JsonView(false,"删除失败!");
  5961. var data = new Grp_DayOtherPrice()
  5962. {
  5963. Id = dto.Id,
  5964. IsDel = 1,
  5965. DeleteUserId = dto.DeleteUserId,
  5966. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  5967. };
  5968. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  5969. if (del > 0)
  5970. {
  5971. jw.Code = 200;
  5972. jw.Msg = "删除成功!";
  5973. }
  5974. return Ok(jw);
  5975. }
  5976. /// <summary>
  5977. /// 团组模块 - 出入境国家费用标准 List
  5978. /// </summary>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5982. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5983. {
  5984. try
  5985. {
  5986. Stopwatch sw = new Stopwatch();
  5987. sw.Start();
  5988. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5989. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5990. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5991. Where gntf.Isdel = 0");
  5992. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5993. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5994. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5995. //foreach (var item in nationalTravel)
  5996. //{
  5997. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5998. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5999. // if (otherData != null)
  6000. // {
  6001. // cityData.Remove(otherData);
  6002. // cityData.Add(otherData);
  6003. // }
  6004. // nationalTravelFeeData1.Add(new
  6005. // {
  6006. // Country = item.Country,
  6007. // CityData = cityData
  6008. // });
  6009. //}
  6010. sw.Stop();
  6011. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6012. }
  6013. catch (Exception ex)
  6014. {
  6015. return Ok(JsonView(false, ex.Message));
  6016. throw;
  6017. }
  6018. }
  6019. /// <summary>
  6020. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6021. /// </summary>
  6022. /// <returns></returns>
  6023. [HttpPost]
  6024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6025. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6026. {
  6027. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6028. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6029. List<string> countryData = new List<string>();
  6030. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6031. countryData = countryData.Distinct().ToList();
  6032. List<dynamic> dataSource = new List<dynamic>();
  6033. foreach (var item in countryData)
  6034. {
  6035. List<string> cityData1 = new List<string>();
  6036. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6037. var countryData2 = new
  6038. {
  6039. CountryName = item,
  6040. CityData = cityData1
  6041. };
  6042. dataSource.Add(countryData2);
  6043. }
  6044. return Ok(JsonView(true, "查询成功!", dataSource));
  6045. }
  6046. /// <summary>
  6047. /// 团组模块 - 出入境国家费用标准 Page List
  6048. /// </summary>
  6049. /// <returns></returns>
  6050. [HttpPost]
  6051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6052. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6053. {
  6054. int portId = dto.PortType;
  6055. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6056. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6057. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6058. string whereSql = string.Empty;
  6059. if (!string.IsNullOrEmpty(dto.Country))
  6060. {
  6061. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6062. }
  6063. if (!string.IsNullOrEmpty(dto.City))
  6064. {
  6065. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6066. }
  6067. string pageSql = string.Format(@"Select * From (
  6068. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6069. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6070. From Grp_NationalTravelFee gntf
  6071. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6072. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6073. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6074. RefAsync<int> total = 0;
  6075. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6076. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6077. }
  6078. /// <summary>
  6079. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6080. /// </summary>
  6081. /// <returns></returns>
  6082. [HttpPost]
  6083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6084. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6085. {
  6086. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6087. int portId = dto.PortType;
  6088. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6089. string whereSql = string.Empty;
  6090. if (!string.IsNullOrEmpty(dto.Country))
  6091. {
  6092. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6093. }
  6094. if (!string.IsNullOrEmpty(dto.City))
  6095. {
  6096. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6097. }
  6098. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6099. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6100. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6101. From Grp_NationalTravelFee gntf
  6102. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6103. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6104. Where gntf.Isdel = 0 {0} ", whereSql);
  6105. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6106. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6107. }
  6108. /// <summary>
  6109. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6110. /// </summary>
  6111. /// <returns></returns>
  6112. [HttpPost]
  6113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6114. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6115. {
  6116. try
  6117. {
  6118. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6119. if (data.Code != 0)
  6120. {
  6121. return Ok(JsonView(false, data.Msg));
  6122. }
  6123. return Ok(JsonView(true, "操作成功!", data.Data));
  6124. }
  6125. catch (Exception ex)
  6126. {
  6127. return Ok(JsonView(false, ex.Message));
  6128. }
  6129. }
  6130. /// <summary>
  6131. /// 团组模块 - 出入境国家费用标准 - Del
  6132. /// </summary>
  6133. /// <returns></returns>
  6134. [HttpPost]
  6135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6136. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6137. {
  6138. try
  6139. {
  6140. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6141. {
  6142. Id = dto.Id,
  6143. DeleteUserId = dto.DeleteUserId,
  6144. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6145. IsDel = 1
  6146. };
  6147. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6148. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6149. .WhereColumns(it => new { it.Id })
  6150. .ExecuteCommandAsync();
  6151. if (delStatus <= 0)
  6152. {
  6153. return Ok(JsonView(false, "删除失败!"));
  6154. }
  6155. return Ok(JsonView(true, "操作成功!"));
  6156. }
  6157. catch (Exception ex)
  6158. {
  6159. return Ok(JsonView(false, ex.Message));
  6160. }
  6161. }
  6162. /// <summary>
  6163. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6164. /// 注:Get 请求Headers 加 Token
  6165. /// </summary>
  6166. /// <param name="groupId"></param>
  6167. /// <returns></returns>
  6168. [HttpGet("{groupId}")]
  6169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6170. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6171. {
  6172. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6173. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6174. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6175. data.ForEach(x =>
  6176. {
  6177. x.CreateUserId = _currUserInfo.UserId;
  6178. });
  6179. if (data.Count > 0)
  6180. {
  6181. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6182. if (add > 0)
  6183. {
  6184. return Ok(JsonView(true, "操作成功!"));
  6185. }
  6186. }
  6187. return Ok(JsonView(false, "未操作!"));
  6188. }
  6189. #endregion
  6190. #region 签证费用录入
  6191. /// <summary>
  6192. /// 根据diid查询签证费用列表
  6193. /// </summary>
  6194. /// <param name="dto"></param>
  6195. /// <returns></returns>
  6196. [HttpPost]
  6197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6198. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6199. {
  6200. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6201. if (groupData.Code != 0)
  6202. {
  6203. return Ok(JsonView(false, groupData.Msg));
  6204. }
  6205. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6206. }
  6207. /// <summary>
  6208. /// 根据签证费用Id查询单条数据及c表数据
  6209. /// </summary>
  6210. /// <param name="dto"></param>
  6211. /// <returns></returns>
  6212. [HttpPost]
  6213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6214. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6215. {
  6216. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6217. if (groupData.Code != 0)
  6218. {
  6219. return Ok(JsonView(false, groupData.Msg));
  6220. }
  6221. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6222. }
  6223. /// <summary>
  6224. /// 签证费用删除
  6225. /// </summary>
  6226. /// <param name="dto"></param>
  6227. /// <returns></returns>
  6228. [HttpPost]
  6229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6230. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6231. {
  6232. _sqlSugar.BeginTran();
  6233. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6234. if (!res)
  6235. {
  6236. _sqlSugar.RollbackTran();
  6237. return Ok(JsonView(false, "删除失败"));
  6238. }
  6239. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6240. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6241. .SetColumns(a => new Grp_CreditCardPayment()
  6242. {
  6243. IsDel = 1,
  6244. DeleteUserId = dto.DeleteUserId,
  6245. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6246. })
  6247. .ExecuteCommand();
  6248. if (resSub < 1)
  6249. {
  6250. _sqlSugar.RollbackTran();
  6251. return Ok(JsonView(false, "删除失败"));
  6252. }
  6253. _sqlSugar.CommitTran();
  6254. return Ok(JsonView(true, "删除成功!"));
  6255. }
  6256. /// <summary>
  6257. /// 签证费用录入下拉框初始化
  6258. /// </summary>
  6259. /// <returns></returns>
  6260. [HttpPost]
  6261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6262. public async Task<IActionResult> VisaPriceAddSelect()
  6263. {
  6264. //支付方式
  6265. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6266. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6267. //币种
  6268. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6269. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6270. //乘客类型
  6271. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6272. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6273. //卡类型
  6274. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6275. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6276. //代办费类型
  6277. var agencyFeeTypeData = new List<dynamic>() {
  6278. new { id = 0 , Text = "未选择" },
  6279. new { id = 1 , Text = "小公务" },
  6280. new { id = 2 , Text = "大公务" },
  6281. };
  6282. //签证费用标准国家Data
  6283. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  6284. var data = new
  6285. {
  6286. Payment = _Payment,
  6287. CurrencyList = _CurrencyList,
  6288. PassengerType = _PassengerType,
  6289. BankCard = _BankCard,
  6290. AgencyFeeType = agencyFeeTypeData,
  6291. CountryFeeData = visaCountryFeeData
  6292. };
  6293. return Ok(JsonView(true, "查询成功!", data));
  6294. }
  6295. /// <summary>
  6296. /// 签证费用录入操作(Status:1.新增,2.修改)
  6297. /// </summary>
  6298. /// <param name="dto"></param>
  6299. /// <returns></returns>
  6300. [HttpPost]
  6301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6302. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6303. {
  6304. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6305. if (groupData.Code != 0)
  6306. {
  6307. return Ok(JsonView(false, groupData.Msg));
  6308. }
  6309. #region 应用推送
  6310. try
  6311. {
  6312. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6313. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6314. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6315. //2024-10-21 新增LZ UID
  6316. var userIds = new List<int>() { 21 };
  6317. string title = $"系统通知";
  6318. string content = "";
  6319. var diId = dto.DiId;
  6320. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6321. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6322. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6323. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6324. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6325. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content);
  6326. }
  6327. catch (Exception ex)
  6328. {
  6329. }
  6330. #endregion
  6331. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6332. }
  6333. #endregion
  6334. #region 签证提成录入
  6335. /// <summary>
  6336. /// 签证提成录入
  6337. /// 基础数据
  6338. /// </summary>
  6339. /// <param name="_dto"></param>
  6340. /// <returns></returns>
  6341. [HttpGet]
  6342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6343. public async Task<IActionResult> VisaCommissionInit()
  6344. {
  6345. return Ok(await _visaCommissionRep.Init());
  6346. }
  6347. /// <summary>
  6348. /// 签证提成录入
  6349. /// Item
  6350. /// </summary>
  6351. /// <param name="_dto"></param>
  6352. /// <returns></returns>
  6353. [HttpPost]
  6354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6355. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6356. {
  6357. var validator = new VisaCommissionItemDtoValidator();
  6358. var validatorRes = await validator.ValidateAsync(_dto);
  6359. if (!validatorRes.IsValid)
  6360. {
  6361. StringBuilder sb = new StringBuilder();
  6362. foreach (var item in validatorRes.Errors)
  6363. {
  6364. sb.AppendLine(item.ErrorMessage);
  6365. }
  6366. return Ok(JsonView(false, sb.ToString()));
  6367. }
  6368. return Ok(await _visaCommissionRep.Item(_dto));
  6369. }
  6370. /// <summary>
  6371. /// 签证提成录入
  6372. /// Save
  6373. /// </summary>
  6374. /// <param name="_dto"></param>
  6375. /// <returns></returns>
  6376. [HttpPost]
  6377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6378. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6379. {
  6380. //参数验证
  6381. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6382. foreach (var item in _dto.Items)
  6383. {
  6384. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6385. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6386. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6387. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6388. }
  6389. return Ok(await _visaCommissionRep.Save(_dto));
  6390. }
  6391. /// <summary>
  6392. /// 签证提成录入
  6393. /// Create
  6394. /// </summary>
  6395. /// <param name="_dto"></param>
  6396. /// <returns></returns>
  6397. [HttpPost]
  6398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6399. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6400. {
  6401. var validator = new VisaCommissionCreateDtoValidator();
  6402. var validatorRes = await validator.ValidateAsync(_dto);
  6403. if (!validatorRes.IsValid)
  6404. {
  6405. StringBuilder sb = new StringBuilder();
  6406. foreach (var item in validatorRes.Errors)
  6407. {
  6408. sb.AppendLine(item.ErrorMessage);
  6409. }
  6410. return Ok(JsonView(false, sb.ToString()));
  6411. }
  6412. return Ok(await _visaCommissionRep.Create(_dto));
  6413. }
  6414. /// <summary>
  6415. /// 签证提成录入
  6416. /// Put(编辑)
  6417. /// </summary>
  6418. /// <param name="id"></param>
  6419. /// <param name="_dto"></param>
  6420. /// <returns></returns>
  6421. [HttpPut]
  6422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6423. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6424. {
  6425. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6426. var validator = new VisaCommissionCreateDtoValidator();
  6427. var validatorRes = await validator.ValidateAsync(_dto);
  6428. if (!validatorRes.IsValid)
  6429. {
  6430. StringBuilder sb = new StringBuilder();
  6431. foreach (var item in validatorRes.Errors)
  6432. {
  6433. sb.AppendLine(item.ErrorMessage);
  6434. }
  6435. return Ok(JsonView(false, sb.ToString()));
  6436. }
  6437. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6438. }
  6439. /// <summary>
  6440. /// 签证提成录入
  6441. /// Del
  6442. /// </summary>
  6443. /// <param name="id"></param>
  6444. /// <param name="currUserId"></param>
  6445. /// <returns></returns>
  6446. [HttpPost]
  6447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6448. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6449. {
  6450. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6451. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6452. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6453. }
  6454. #endregion
  6455. #region op费用录入
  6456. /// <summary>
  6457. /// 根据diid查询op费用列表
  6458. /// </summary>
  6459. /// <param name="dto"></param>
  6460. /// <returns></returns>
  6461. [HttpPost]
  6462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6463. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6464. {
  6465. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6466. if (groupData.Code != 0)
  6467. {
  6468. return Ok(JsonView(false, groupData.Msg));
  6469. }
  6470. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6471. }
  6472. /// <summary>
  6473. /// 根据op费用Id查询单条数据及c表数据
  6474. /// </summary>
  6475. /// <param name="dto"></param>
  6476. /// <returns></returns>
  6477. [HttpPost]
  6478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6479. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6480. {
  6481. try
  6482. {
  6483. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6484. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6485. var data = new
  6486. {
  6487. CarTouristGuideGround = _groupData,
  6488. CreditCardPayment = _creditCardPayment
  6489. };
  6490. return Ok(JsonView(true, "查询成功!", data));
  6491. }
  6492. catch (Exception ex)
  6493. {
  6494. return Ok(JsonView(false, "程序错误!"));
  6495. }
  6496. }
  6497. /// <summary>
  6498. /// op费用删除
  6499. /// </summary>
  6500. /// <param name="dto"></param>
  6501. /// <returns></returns>
  6502. [HttpPost]
  6503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6504. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6505. {
  6506. try
  6507. {
  6508. _sqlSugar.BeginTran();
  6509. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6510. if (!res)
  6511. {
  6512. return Ok(JsonView(false, "删除失败"));
  6513. }
  6514. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6515. {
  6516. IsDel = 1,
  6517. DeleteUserId = dto.DeleteUserId,
  6518. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6519. }).ExecuteCommandAsync();
  6520. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6521. {
  6522. IsDel = 1,
  6523. DeleteUserId = dto.DeleteUserId,
  6524. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6525. }).ExecuteCommandAsync();
  6526. #region 删除超支相关数据
  6527. //删除导入的超支数据
  6528. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6529. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6530. {
  6531. IsDel = 1,
  6532. DeleteUserId = dto.DeleteUserId,
  6533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6534. }).ExecuteCommand();
  6535. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6536. {
  6537. IsDel = 1,
  6538. DeleteUserId = dto.DeleteUserId,
  6539. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6540. }).ExecuteCommand();
  6541. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6542. {
  6543. IsDel = 1,
  6544. DeleteUserId = dto.DeleteUserId,
  6545. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6546. }).ExecuteCommand();
  6547. #endregion
  6548. _sqlSugar.CommitTran();
  6549. return Ok(JsonView(true, "删除成功!"));
  6550. }
  6551. catch (Exception ex)
  6552. {
  6553. _sqlSugar.RollbackTran();
  6554. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6555. }
  6556. }
  6557. /// <summary>
  6558. /// op费用录入操作(Status:1.新增,2.修改)
  6559. /// </summary>
  6560. /// <param name="dto"></param>
  6561. /// <returns></returns>
  6562. [HttpPost]
  6563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6564. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6565. {
  6566. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6567. if (groupData.Code != 0)
  6568. {
  6569. return Ok(JsonView(false, groupData.Msg));
  6570. }
  6571. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6572. }
  6573. /// <summary>
  6574. /// 填写费用详细页面初始化绑定
  6575. /// </summary>
  6576. /// <param name="dto"></param>
  6577. /// <returns></returns>
  6578. [HttpPost]
  6579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6580. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6581. {
  6582. try
  6583. {
  6584. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6585. if (groupData.Code != 0)
  6586. {
  6587. return Ok(JsonView(false, groupData.Msg));
  6588. }
  6589. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6590. }
  6591. catch (Exception ex)
  6592. {
  6593. return Ok(JsonView(false, ex.Message));
  6594. }
  6595. }
  6596. /// <summary>
  6597. /// 根据op费用Id查询详细数据
  6598. /// </summary>
  6599. /// <param name="dto"></param>
  6600. /// <returns></returns>
  6601. [HttpPost]
  6602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6603. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6604. {
  6605. try
  6606. {
  6607. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6608. if (groupData.Code != 0)
  6609. {
  6610. return Ok(JsonView(false, groupData.Msg));
  6611. }
  6612. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6613. }
  6614. catch (Exception ex)
  6615. {
  6616. return Ok(JsonView(false, ex.Message));
  6617. }
  6618. }
  6619. /// <summary>
  6620. /// OP费用录入填写详情
  6621. /// </summary>
  6622. /// <param name="dto"></param>
  6623. /// <returns></returns>
  6624. [HttpPost]
  6625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6626. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6627. {
  6628. try
  6629. {
  6630. #region 参数校验
  6631. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6632. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6633. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6634. #endregion
  6635. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6636. if (groupData.Code != 0)
  6637. {
  6638. return Ok(JsonView(false, groupData.Msg));
  6639. }
  6640. //自动审核
  6641. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6642. #region 应用推送
  6643. try
  6644. {
  6645. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6646. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6647. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6648. //2024-10-21 新增LZ UID
  6649. var userIds = new List<int>() { 21 };
  6650. string title = $"系统通知";
  6651. var diId = dto.DiId;
  6652. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6653. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6654. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6655. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6656. await APNsTools.iOS_PushNotifications1("051", "OP费用审核", "", content);
  6657. }
  6658. catch (Exception ex)
  6659. {
  6660. }
  6661. #endregion
  6662. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6663. }
  6664. catch (Exception ex)
  6665. {
  6666. return Ok(JsonView(false, ex.Message));
  6667. }
  6668. }
  6669. /// <summary>
  6670. /// 获取三公详细所有城市
  6671. /// </summary>
  6672. /// <returns></returns>
  6673. [HttpGet]
  6674. public IActionResult OpCarCityResult()
  6675. {
  6676. var jw = JsonView(false);
  6677. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6678. {
  6679. x.Id,
  6680. x.Country,
  6681. x.City,
  6682. }).ToList();
  6683. if (data.Count > 0)
  6684. {
  6685. jw = JsonView(true, "获取成功!", data);
  6686. }
  6687. else
  6688. {
  6689. jw.Msg = "城市数据为空!";
  6690. jw.Data = new string[0];
  6691. }
  6692. return Ok(jw);
  6693. }
  6694. /// <summary>
  6695. /// 导出地接费用明细
  6696. /// </summary>
  6697. /// <param name="dto"></param>
  6698. /// <returns></returns>
  6699. [HttpPost]
  6700. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6701. {
  6702. var jw = JsonView(false);
  6703. if (dto.Diid < 1)
  6704. {
  6705. jw.Msg = "请输入正确的diid!";
  6706. return Ok(jw);
  6707. }
  6708. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6709. if (group == null)
  6710. {
  6711. jw.Msg = "未找到团组信息!";
  6712. return Ok(jw);
  6713. }
  6714. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6715. if (localGuideArr.Count == 0)
  6716. {
  6717. jw.Msg = "该团组暂无地接信息!";
  6718. return Ok(jw);
  6719. }
  6720. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6721. var overspendSoure = new Dictionary<int, int>
  6722. {
  6723. { 91, 982 }, //车
  6724. { 92 , 1059} ,//导游
  6725. { 994 , 1073}, //翻译
  6726. { 988 , 1074 }, //早餐
  6727. { 93 , 1075 }, //午餐
  6728. { 989 , 1076 }, //晚餐
  6729. };
  6730. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6731. foreach (var groupArr in localGroup)
  6732. {
  6733. var keyValue = groupArr.Key;
  6734. if (int.TryParse(keyValue, out int cityid))
  6735. {
  6736. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6737. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6738. }
  6739. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6740. foreach (var item in groupArr)
  6741. {
  6742. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6743. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6744. new Grp_CarTouristGuideGroundReservationsContentExtend
  6745. {
  6746. Count = a.Count,
  6747. CreateTime = a.CreateTime,
  6748. CreateUserId = a.CreateUserId,
  6749. CTGGRId = a.CTGGRId,
  6750. Currency = a.Currency,
  6751. DatePrice = a.DatePrice,
  6752. DeleteTime = a.DeleteTime,
  6753. DeleteUserId = a.DeleteUserId,
  6754. DiId = a.DiId,
  6755. Id = a.Id,
  6756. IsDel = a.IsDel,
  6757. Price = a.Price,
  6758. PriceContent = a.PriceContent,
  6759. Remark = a.Remark,
  6760. SId = a.SId,
  6761. SidName = b.Name,
  6762. Units = a.Units,
  6763. }
  6764. ).ToList();
  6765. if (content.Count > 0)
  6766. {
  6767. contentArr.Add(content);
  6768. }
  6769. }
  6770. //open excel
  6771. //set excel
  6772. //save excel
  6773. try
  6774. {
  6775. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6776. IWorkbook workbook;
  6777. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6778. {
  6779. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6780. }
  6781. else
  6782. {
  6783. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6784. }
  6785. ISheet sheet = workbook.GetSheetAt(0);
  6786. var rowStartIndex = 2;
  6787. var clounmCount = 10;
  6788. var initStyleRow = sheet.GetRow(2);
  6789. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6790. //var overspendArrDetail =
  6791. var existsId = new List<CarCompare>();
  6792. var lastElem = arr.Last();
  6793. var thisSid = -1;
  6794. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6795. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6796. {
  6797. Name = "未知币种!",
  6798. Remark = "未知币种!",
  6799. };
  6800. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6801. Action cloneRowFn = () =>
  6802. {
  6803. rowStartIndex++;
  6804. var cloneRow = sheet.CreateRow(rowStartIndex);
  6805. // 复制样式
  6806. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6807. {
  6808. ICell sourceCell = initStyleRow.GetCell(i);
  6809. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6810. // 确保单元格存在样式
  6811. if (sourceCell.CellStyle != null)
  6812. {
  6813. targetCell.CellStyle = sourceCell.CellStyle;
  6814. }
  6815. }
  6816. };
  6817. var mergeRow = () =>
  6818. {
  6819. for (int i = 2; i < sheet.LastRowNum; i++)
  6820. {
  6821. var row = sheet.GetRow(i);
  6822. var cellFirst = row.GetCell(0);
  6823. var thisIndex = i + 1;
  6824. while (thisIndex < sheet.LastRowNum)
  6825. {
  6826. var nextRow = sheet.GetRow(thisIndex);
  6827. var nextCellFirst = nextRow.GetCell(0);
  6828. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6829. {
  6830. thisIndex++;
  6831. }
  6832. else
  6833. {
  6834. break;
  6835. }
  6836. }
  6837. thisIndex--;
  6838. if (thisIndex != i)
  6839. {
  6840. //合并row
  6841. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6842. i, // 起始行索引(0-based)
  6843. thisIndex, // 结束行索引(0-based)
  6844. 0, // 起始列索引(0-based)
  6845. 0 // 结束列索引(0-based)
  6846. );
  6847. sheet.AddMergedRegion(cellRangeAddress);
  6848. i = thisIndex;
  6849. }
  6850. }
  6851. };
  6852. var chaoshiNumber = 0;
  6853. var totalNumber = 0.00M;
  6854. string lastStr = "";
  6855. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6856. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6857. {
  6858. b.IsAuditGM,
  6859. x.Id,
  6860. x.Area,
  6861. b.PayPercentage,
  6862. b.PayMoney,
  6863. }).ToList();
  6864. string yesPayment = "", noPayment = "";
  6865. foreach (var item in queryCarArrByCityAndDiid)
  6866. {
  6867. if (item.IsAuditGM == 1)
  6868. {
  6869. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6870. }
  6871. else
  6872. {
  6873. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6874. }
  6875. }
  6876. lastStr = yesPayment + noPayment;
  6877. foreach (var item in arr)
  6878. {
  6879. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6880. {
  6881. if (thisSid != item.SId)
  6882. {
  6883. if (thisSid == -1)
  6884. {
  6885. thisSid = item.SId;
  6886. }
  6887. else
  6888. {
  6889. //合并小计行
  6890. //创建合并区域的实例
  6891. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6892. rowStartIndex, // 起始行索引(0-based)
  6893. rowStartIndex, // 结束行索引(0-based)
  6894. 0, // 起始列索引(0-based)
  6895. 3 // 结束列索引(0-based)
  6896. );
  6897. sheet.AddMergedRegion(cellRangeAddress);
  6898. var CellStyle = workbook.CreateCellStyle();
  6899. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6900. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6901. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6902. for (int i = 0; i <= clounmCount; i++)
  6903. {
  6904. if (i > 6)
  6905. {
  6906. var CellStyle1 = workbook.CreateCellStyle();
  6907. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6908. IFont Font = workbook.CreateFont(); // 创建字体
  6909. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6910. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6911. CellStyle1.SetFont(Font);
  6912. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6913. }
  6914. else
  6915. {
  6916. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6917. }
  6918. }
  6919. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6920. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6921. //超时合计
  6922. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6923. //超时数
  6924. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6925. //超时合计费用
  6926. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6927. thisSid = item.SId;
  6928. cloneRowFn();
  6929. chaoshiNumber = 0;
  6930. totalNumber = 0;
  6931. }
  6932. }
  6933. IRow row = sheet.GetRow(rowStartIndex);
  6934. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6935. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6936. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6937. if (isOpenOverspendSoure)
  6938. {
  6939. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6940. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6941. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6942. }
  6943. for (int i = 0; i <= clounmCount; i++)
  6944. {
  6945. var cell = row.GetCell(i);
  6946. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6947. if (cell == null)
  6948. {
  6949. cell = row.CreateCell(i);
  6950. }
  6951. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6952. fontRed.CloneStyleFrom(cell.CellStyle);
  6953. IFont Font = workbook.CreateFont(); // 创建字体
  6954. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6955. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6956. fontRed.SetFont(Font);
  6957. byte[] rgb = new byte[3] { 255, 242, 204 };
  6958. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6959. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6960. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6961. if (workbook is XSSFWorkbook)
  6962. {
  6963. BackgroundColor255_242_204.FillForegroundColor = 0;
  6964. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6965. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6966. }
  6967. else
  6968. {
  6969. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6970. }
  6971. if (i == 1 || i > 6)
  6972. {
  6973. if (i > 6)
  6974. {
  6975. fontRed.FillForegroundColor = 0;
  6976. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6977. fontRed.FillPattern = FillPattern.SolidForeground;
  6978. }
  6979. cell.CellStyle = fontRed;
  6980. }
  6981. if (i > 2 && i < 7)
  6982. {
  6983. cell.CellStyle = BackgroundColor255_242_204;
  6984. }
  6985. cell.SetCellValue(setCellValue); //写入单元格
  6986. }
  6987. if (overspendSoure.ContainsKey(thisSid))
  6988. {
  6989. var overspendId = overspendSoure[thisSid];
  6990. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6991. }
  6992. cloneRowFn();
  6993. existsId.Add(new CarCompare
  6994. {
  6995. DataPrice = item.DatePrice.ObjToDate(),
  6996. Sid = item.SId
  6997. });
  6998. }
  6999. if (item.Equals(lastElem))
  7000. {
  7001. //合并小计行
  7002. //创建合并区域的实例
  7003. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7004. rowStartIndex, // 起始行索引(0-based)
  7005. rowStartIndex, // 结束行索引(0-based)
  7006. 0, // 起始列索引(0-based)
  7007. 3 // 结束列索引(0-based)
  7008. );
  7009. sheet.AddMergedRegion(cellRangeAddress);
  7010. var CellStyle = workbook.CreateCellStyle();
  7011. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7012. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7013. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7014. for (int i = 0; i <= clounmCount; i++)
  7015. {
  7016. if (i > 6)
  7017. {
  7018. var CellStyle1 = workbook.CreateCellStyle();
  7019. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7020. IFont Font = workbook.CreateFont(); // 创建字体
  7021. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7022. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7023. CellStyle1.SetFont(Font);
  7024. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7025. }
  7026. else
  7027. {
  7028. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7029. }
  7030. }
  7031. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7032. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7033. //超时合计
  7034. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7035. //超时数
  7036. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7037. //超时合计费用
  7038. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7039. cloneRowFn();
  7040. // 创建合并区域的实例
  7041. cellRangeAddress = new CellRangeAddress(
  7042. rowStartIndex, // 起始行索引(0-based)
  7043. rowStartIndex, // 结束行索引(0-based)
  7044. 0, // 起始列索引(0-based)
  7045. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  7046. );
  7047. // 添加合并区域
  7048. sheet.AddMergedRegion(cellRangeAddress);
  7049. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  7050. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  7051. }
  7052. }
  7053. mergeRow();
  7054. // 保存修改后的Excel文件到新文件
  7055. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  7056. // new FileStream(newFilePath, FileMode.CreateNew)
  7057. using (var stream = new MemoryStream())
  7058. {
  7059. workbook.Write(stream, true);
  7060. stream.Flush();
  7061. stream.Seek(0, SeekOrigin.Begin);
  7062. MemoryStream memoryStream = new MemoryStream();
  7063. stream.CopyTo(memoryStream);
  7064. memoryStream.Seek(0, SeekOrigin.Begin);
  7065. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  7066. }
  7067. workbook.Close();
  7068. workbook.Dispose();
  7069. }
  7070. catch (Exception ex)
  7071. {
  7072. jw.Msg = "出现异常!" + ex.Message;
  7073. return Ok(jw);
  7074. }
  7075. }
  7076. if (Zips.Count > 0)
  7077. {
  7078. IOOperatorHelper io = new IOOperatorHelper();
  7079. var byts = io.ConvertZipStream(Zips);
  7080. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  7081. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  7082. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  7083. }
  7084. else
  7085. {
  7086. jw.Msg = "暂无生成文件!";
  7087. }
  7088. return Ok(jw);
  7089. }
  7090. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  7091. {
  7092. string outStr = string.Empty;
  7093. switch (i)
  7094. {
  7095. case 0:
  7096. outStr = arr[0].SidName;
  7097. break;
  7098. case 1:
  7099. outStr = arr[0].DataPriceStr;
  7100. break;
  7101. case 2:
  7102. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  7103. break;
  7104. case 4:
  7105. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  7106. break;
  7107. case 7:
  7108. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7109. {
  7110. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  7111. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  7112. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  7113. }
  7114. break;
  7115. case 8:
  7116. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7117. {
  7118. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  7119. }
  7120. break;
  7121. case 9:
  7122. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7123. {
  7124. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  7125. }
  7126. break;
  7127. case 10:
  7128. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7129. {
  7130. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  7131. }
  7132. break;
  7133. }
  7134. return outStr;
  7135. }
  7136. #region OP行程单
  7137. /// <summary>
  7138. /// OP行程单初始化
  7139. /// </summary>
  7140. /// <param name="dto"></param>
  7141. /// <returns></returns>
  7142. [HttpPost]
  7143. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7144. {
  7145. var jw = JsonView(false);
  7146. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7147. var group = groupList.First();
  7148. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7149. if (group == null)
  7150. {
  7151. jw.Msg = "暂无团组!";
  7152. return Ok(jw);
  7153. }
  7154. group = groupList.Find(x => x.Id == diid);
  7155. if (group == null)
  7156. {
  7157. jw.Msg = "请输入正确的团组ID!";
  7158. return Ok(jw);
  7159. }
  7160. string city = string.Empty;
  7161. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7162. if (blackCode.Count > 0)
  7163. {
  7164. var black = blackCode.First();
  7165. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7166. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7167. if (blackSp.Length > 0)
  7168. {
  7169. try
  7170. {
  7171. var cityArrCode = new List<string>(20);
  7172. foreach (var item in blackSp)
  7173. {
  7174. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7175. var IndexSelect = itemSp[2];
  7176. var cityArrCodeLength = cityArrCode.Count - 1;
  7177. var startCity = IndexSelect.Substring(0, 3);
  7178. if (cityArrCodeLength > 0)
  7179. {
  7180. var arrEndCity = cityArrCode[cityArrCodeLength];
  7181. if (arrEndCity != startCity)
  7182. {
  7183. cityArrCode.Add(startCity.ToUpper());
  7184. }
  7185. }
  7186. else
  7187. {
  7188. cityArrCode.Add(startCity.ToUpper());
  7189. }
  7190. var endCity = IndexSelect.Substring(3, 3);
  7191. cityArrCode.Add(endCity.ToUpper());
  7192. }
  7193. var cityThree = string.Empty;
  7194. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7195. cityThree = cityThree.TrimEnd(',');
  7196. if (string.IsNullOrWhiteSpace(cityThree))
  7197. {
  7198. throw new
  7199. Exception("error");
  7200. }
  7201. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7202. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7203. foreach (var item in cityArrCode)
  7204. {
  7205. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7206. if (find != null)
  7207. {
  7208. city += find.City + "/";
  7209. }
  7210. else
  7211. {
  7212. city += item + "三字码未收入/";
  7213. }
  7214. }
  7215. city = city.TrimEnd('/');
  7216. }
  7217. catch (Exception e)
  7218. {
  7219. city = "黑屏代码格式不正确!";
  7220. }
  7221. }
  7222. }
  7223. else
  7224. {
  7225. city = "未录入黑屏代码";
  7226. }
  7227. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7228. {
  7229. Date = x.Date,
  7230. Days = x.Days,
  7231. Diffgroup = x.Diffgroup,
  7232. Diid = x.Diid,
  7233. Traffic_First = x.Traffic_First,
  7234. Traffic_Second = x.Traffic_Second,
  7235. Trip = x.Trip,
  7236. WeekDay = x.WeekDay,
  7237. Id = x.Id
  7238. }).ToList();
  7239. jw.Data = new
  7240. {
  7241. groupList = groupList.Select(x => new
  7242. {
  7243. x.Id,
  7244. x.TeamName,
  7245. x.TourCode
  7246. }).ToList(),
  7247. groupInfo = new
  7248. {
  7249. group.VisitDays,
  7250. group.TourCode,
  7251. group.VisitPNumber,
  7252. group.TeamName,
  7253. city
  7254. },
  7255. OpTravelList
  7256. };
  7257. jw.Code = 200;
  7258. jw.Msg = "操作成功!";
  7259. return Ok(jw);
  7260. }
  7261. /// <summary>
  7262. /// 删除团组行程单
  7263. /// </summary>
  7264. /// <returns></returns>
  7265. [HttpPost]
  7266. public IActionResult DelTravel(DelOpTravelDto dto)
  7267. {
  7268. var jw = JsonView(false);
  7269. if (dto.UserId <= 0 || dto.Diid <= 0)
  7270. {
  7271. jw.Msg = "请输入正确的参数!";
  7272. return Ok(jw);
  7273. }
  7274. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7275. .SetColumns(x => new Grp_TravelList
  7276. {
  7277. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7278. DeleteUserId = dto.UserId,
  7279. IsDel = 1,
  7280. }).ExecuteCommand();
  7281. jw = JsonView(true);
  7282. return Ok(jw);
  7283. }
  7284. /// <summary>
  7285. /// 行程单保存
  7286. /// </summary>
  7287. /// <returns></returns>
  7288. [HttpPost]
  7289. public IActionResult TravelSave(TravelSaveDto dto)
  7290. {
  7291. var jw = JsonView(false);
  7292. if (dto.Arr.Count > 0)
  7293. {
  7294. try
  7295. {
  7296. _sqlSugar.BeginTran();
  7297. foreach (var item in dto.Arr)
  7298. {
  7299. if (item.Id == 0)
  7300. {
  7301. throw new Exception("请传入正确的Id");
  7302. }
  7303. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7304. .SetColumns(x => new Grp_TravelList
  7305. {
  7306. Trip = item.Trip
  7307. }).ExecuteCommand();
  7308. }
  7309. _sqlSugar.CommitTran();
  7310. jw = JsonView(true);
  7311. }
  7312. catch (Exception ex)
  7313. {
  7314. _sqlSugar.RollbackTran();
  7315. jw.Msg = "程序异常!" + ex.Message;
  7316. }
  7317. }
  7318. else
  7319. {
  7320. jw.Msg = "请传入正确的参数!";
  7321. }
  7322. return Ok(jw);
  7323. }
  7324. /// <summary>
  7325. /// 导出行程单
  7326. /// </summary>
  7327. /// <param name="dto"></param>
  7328. /// <returns></returns>
  7329. [HttpPost]
  7330. public IActionResult ExportTravel(ExportTravelDto dto)
  7331. {
  7332. var jw = JsonView(false);
  7333. jw.Data = "";
  7334. int diid = 0;
  7335. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7336. if (Find == null)
  7337. {
  7338. jw.Msg = "请选择正确的团组!";
  7339. return Ok(jw);
  7340. }
  7341. else
  7342. {
  7343. diid = Find.Id;
  7344. }
  7345. //数据源
  7346. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7347. DataTable dtBlack = null;
  7348. try
  7349. {
  7350. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7351. }
  7352. catch (Exception)
  7353. {
  7354. jw.Msg = "机票黑屏代码有误!";
  7355. return Ok(jw);
  7356. }
  7357. string CityStr = string.Empty;
  7358. if (dtBlack.Rows.Count == 0)
  7359. {
  7360. jw.Msg = "机票黑屏代码有误!";
  7361. return Ok(jw);
  7362. }
  7363. else
  7364. {
  7365. foreach (DataRow row in dtBlack.Rows)
  7366. {
  7367. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7368. {
  7369. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7370. return Ok(jw);
  7371. }
  7372. }
  7373. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7374. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7375. }
  7376. //创建数据源Table
  7377. DataTable dtSource = new DataTable();
  7378. dtSource.Columns.Add("Days", typeof(string));
  7379. dtSource.Columns.Add("Date", typeof(string));
  7380. dtSource.Columns.Add("Week", typeof(string));
  7381. dtSource.Columns.Add("Traffic", typeof(string));
  7382. dtSource.Columns.Add("Trip", typeof(string));
  7383. //获取数据,放到datatable
  7384. foreach (var item in _travelList)
  7385. {
  7386. DataRow dr = dtSource.NewRow();
  7387. dr["Days"] = item.Days;
  7388. dr["Date"] = item.Date;
  7389. dr["Week"] = item.WeekDay;
  7390. dr["Traffic"] = item.Traffic_First
  7391. + "\r\n"
  7392. + item.Traffic_Second;
  7393. dr["Trip"] = item.Trip;
  7394. dtSource.Rows.Add(dr);
  7395. }
  7396. Dictionary<string, string> dic = new Dictionary<string, string>();
  7397. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7398. dic.Add("City", CityStr);
  7399. dic.Add("Days", Find.VisitDays.ToString());
  7400. dic.Add("DeleCode", Find.TourCode);
  7401. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7402. //模板路径
  7403. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7404. //载入模板
  7405. Document doc = null;
  7406. DocumentBuilder builder = null;
  7407. try
  7408. {
  7409. //载入模板
  7410. doc = new Document(tempPath);
  7411. builder = new DocumentBuilder(doc);
  7412. }
  7413. catch (Exception)
  7414. {
  7415. jw.Msg = "模板位置不存在!";
  7416. return Ok(jw);
  7417. }
  7418. foreach (var key in dic.Keys)
  7419. {
  7420. Bookmark bookmark = doc.Range.Bookmarks[key];
  7421. if (bookmark != null)
  7422. {
  7423. builder.MoveToBookmark(key);
  7424. builder.Write(dic[key]);
  7425. }
  7426. }
  7427. //获取word里所有表格
  7428. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7429. //获取所填表格的序数
  7430. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7431. try
  7432. {
  7433. //循环赋值
  7434. for (int i = 0; i < dtSource.Rows.Count; i++)
  7435. {
  7436. builder.MoveToCell(0, i + 1, 0, 0);
  7437. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7438. builder.MoveToCell(0, i + 1, 1, 0);
  7439. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7440. builder.MoveToCell(0, i + 1, 2, 0);
  7441. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7442. var trip = dtSource.Rows[i]["Trip"].ToString();
  7443. builder.MoveToCell(0, i + 1, 3, 0);
  7444. builder.Write(trip);
  7445. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7446. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7447. // 获取特定索引的段落
  7448. Paragraph paragraph = (Paragraph)paragraphs[0];
  7449. Run run = paragraph.Runs[0];
  7450. Aspose.Words.Font font = run.Font;
  7451. font.Name = "黑体";
  7452. //设置双休红色
  7453. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7454. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7455. paragraph = (Paragraph)paragraphs[1];
  7456. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7457. {
  7458. run = paragraph.Runs[0];
  7459. font = run.Font;
  7460. font.Color = Color.Red;
  7461. }
  7462. }
  7463. }
  7464. catch (Exception ex)
  7465. {
  7466. }
  7467. //删除多余行
  7468. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7469. {
  7470. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7471. }
  7472. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7473. if (!Directory.Exists(savePath))
  7474. {
  7475. try
  7476. {
  7477. Directory.CreateDirectory(savePath);
  7478. }
  7479. catch
  7480. {
  7481. }
  7482. }
  7483. string path = savePath + Find.TeamName + "出访日程";
  7484. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7485. try
  7486. {
  7487. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7488. string postfix = ".docx";
  7489. if (dto.IsPDF == 1)
  7490. {
  7491. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7492. postfix = ".pdf";
  7493. }
  7494. doc.Save(path + postfix, saveFormat);
  7495. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7496. }
  7497. catch (Exception)
  7498. {
  7499. jw = JsonView(false);
  7500. }
  7501. return Ok(jw);
  7502. }
  7503. /// <summary>
  7504. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7505. /// </summary>
  7506. /// <param name="num"></param>
  7507. /// <returns></returns>
  7508. string GetNum(string num)
  7509. {
  7510. string str = "";
  7511. switch (num)
  7512. {
  7513. case "1":
  7514. str = "一";
  7515. break;
  7516. case "2":
  7517. str = "二";
  7518. break;
  7519. case "3":
  7520. str = "三";
  7521. break;
  7522. case "4":
  7523. str = "四";
  7524. break;
  7525. case "5":
  7526. str = "五";
  7527. break;
  7528. case "6":
  7529. str = "六";
  7530. break;
  7531. case "7":
  7532. str = "七";
  7533. break;
  7534. case "8":
  7535. str = "八";
  7536. break;
  7537. case "9":
  7538. str = "九";
  7539. break;
  7540. case "10":
  7541. str = "十";
  7542. break;
  7543. case "11":
  7544. str = "十一";
  7545. break;
  7546. case "12":
  7547. str = "十二";
  7548. break;
  7549. case "一":
  7550. str = "1";
  7551. break;
  7552. case "二":
  7553. str = "2";
  7554. break;
  7555. case "三":
  7556. str = "3";
  7557. break;
  7558. case "四":
  7559. str = "4";
  7560. break;
  7561. case "五":
  7562. str = "5";
  7563. break;
  7564. case "六":
  7565. str = "6";
  7566. break;
  7567. case "七":
  7568. str = "7";
  7569. break;
  7570. case "八":
  7571. str = "8";
  7572. break;
  7573. case "九":
  7574. str = "9";
  7575. break;
  7576. case "十":
  7577. str = "10";
  7578. break;
  7579. case "十一":
  7580. str = "11";
  7581. break;
  7582. case "十二":
  7583. str = "12";
  7584. break;
  7585. }
  7586. return str;
  7587. }
  7588. #endregion
  7589. #endregion
  7590. #region 团组成本
  7591. /// <summary>
  7592. /// 团组成本数据初始化
  7593. /// </summary>
  7594. /// <param name="dto"></param>
  7595. /// <returns></returns>
  7596. [HttpPost]
  7597. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7598. {
  7599. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7600. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7601. WHEN COUNT(*) >= 0 THEN 'True'
  7602. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7603. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7604. ").ToList(); //团组列表
  7605. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7606. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7607. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7608. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7609. if (groupinfoValue != null)
  7610. {
  7611. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7612. var spArr = new string[1] { countryArr };
  7613. if (countryArr.Contains("|"))
  7614. {
  7615. spArr = countryArr.Split("|");
  7616. }
  7617. else if (countryArr.Contains("、"))
  7618. {
  7619. spArr = countryArr.Split("、");
  7620. }
  7621. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7622. {
  7623. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7624. if (dbQueryCountry != null)
  7625. {
  7626. visaCountryInfoArr.Add(dbQueryCountry);
  7627. }
  7628. }
  7629. }
  7630. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7631. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7632. var create = _GroupCostRepository.
  7633. CreateGroupCostByBlackCode(dto.Diid);
  7634. if (groupCost.Count == 0 && create.Code == 0)
  7635. {
  7636. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7637. }
  7638. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7639. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7640. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7641. groupCostMap = groupCostMap.Select(x =>
  7642. {
  7643. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7644. {
  7645. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7646. }
  7647. return x;
  7648. }).ToList();
  7649. //GroupCostParameter.Add(new
  7650. // Grp_GroupCostParameter());
  7651. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7652. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7653. return Ok(JsonView(new
  7654. {
  7655. groupList,
  7656. groupInfo,
  7657. groupChecks,
  7658. groupCost = groupCostMap,
  7659. hotelNumber,
  7660. GroupCostParameter = GroupCostParameterMap,
  7661. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7662. {
  7663. x.VisaCountry,
  7664. x.VisaPrice,
  7665. x.Id,
  7666. }).ToList(),
  7667. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7668. blackCodeIsTrue = create.Code == 0 ? true : false,
  7669. hotelIsTrue = hotelIsTrue,
  7670. }));
  7671. }
  7672. /// <summary>
  7673. /// 团组成本信息保存
  7674. /// </summary>
  7675. /// <param name="dto"></param>
  7676. /// <returns></returns>
  7677. [HttpPost]
  7678. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7679. {
  7680. if (dto.Diid <= 0 || dto.Userid <= 0)
  7681. {
  7682. return Ok(JsonView(false));
  7683. }
  7684. JsonView jw = null;
  7685. bool isTrue = false;
  7686. #region 复制团组成本
  7687. //if (dto.Diid == 2581)
  7688. //{
  7689. // dto.Diid = 2599;
  7690. // dto.CheckBoxs.ForEach(x =>
  7691. // {
  7692. // x.Diid = 2599;
  7693. // });
  7694. // dto.GroupCosts.ForEach(x =>
  7695. // {
  7696. // x.Diid = 2599;
  7697. // });
  7698. // dto.CostTypeHotelNumbers.ForEach(x =>
  7699. // {
  7700. // x.Diid = 2599;
  7701. // });
  7702. // dto.GroupCostParameters.ForEach(x =>
  7703. // {
  7704. // x.DiId = 2599;
  7705. // });
  7706. //}
  7707. #endregion
  7708. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7709. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7710. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7711. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7712. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7713. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7714. try
  7715. {
  7716. _sqlSugar.BeginTran();
  7717. isTrue = await _GroupCostRepository.
  7718. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7719. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7720. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7721. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7722. _sqlSugar.CommitTran();
  7723. jw = JsonView(true, "保存成功!", isTrue);
  7724. }
  7725. catch (Exception)
  7726. {
  7727. _sqlSugar.RollbackTran();
  7728. jw = JsonView(false);
  7729. }
  7730. return Ok(jw);
  7731. }
  7732. /// <summary>
  7733. /// 司兼导数据
  7734. /// </summary>
  7735. /// <param name="dto"></param>
  7736. /// <returns></returns>
  7737. [HttpPost]
  7738. public IActionResult GetCarGuides(CarGuidesDto dto)
  7739. {
  7740. JsonView jw = null;
  7741. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7742. jw = JsonView(true, "获取成功!", Data);
  7743. return Ok(jw);
  7744. }
  7745. /// <summary>
  7746. /// 导游数据
  7747. /// </summary>
  7748. /// <param name="dto"></param>
  7749. /// <returns></returns>
  7750. [HttpPost]
  7751. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7752. {
  7753. JsonView jw = null;
  7754. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7755. // 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
  7756. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7757. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7758. jw = JsonView(true, "获取成功!", Data);
  7759. return Ok(jw);
  7760. }
  7761. /// <summary>
  7762. /// 成本车数据
  7763. /// </summary>
  7764. /// <param name="dto"></param>
  7765. /// <returns></returns>
  7766. [HttpPost]
  7767. public IActionResult GetCarInfo(CarGuidesDto dto)
  7768. {
  7769. JsonView jw = null;
  7770. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7771. jw = JsonView(true, "获取成功!", Data);
  7772. return Ok(jw);
  7773. }
  7774. /// <summary>
  7775. /// 景点数据
  7776. /// </summary>
  7777. /// <param name="dto"></param>
  7778. /// <returns></returns>
  7779. [HttpPost]
  7780. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7781. {
  7782. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7783. return Ok(JsonView(true, "获取成功!", Data));
  7784. }
  7785. /// <summary>
  7786. /// 成本通知
  7787. /// </summary>
  7788. /// <param name="dto"></param>
  7789. /// <returns></returns>
  7790. [HttpPost]
  7791. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7792. {
  7793. if (dto.Diid < 0)
  7794. {
  7795. return Ok(JsonView(false));
  7796. }
  7797. JsonView jw = null;
  7798. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7799. if (GroupCostParameter != null)
  7800. {
  7801. int IsShare = 0;
  7802. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7803. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7804. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7805. string msg = string.Empty;
  7806. if (isTrue)
  7807. {
  7808. if (IsShare == 0)
  7809. {
  7810. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7811. }
  7812. else
  7813. {
  7814. #region 企微通知对应岗位用户
  7815. try
  7816. {
  7817. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7818. }
  7819. catch (Exception ex)
  7820. {
  7821. }
  7822. #endregion
  7823. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7824. }
  7825. jw = JsonView(isTrue, msg, new { IsShare });
  7826. }
  7827. else
  7828. {
  7829. msg = "修改失败!";
  7830. jw = JsonView(isTrue, msg);
  7831. }
  7832. }
  7833. else
  7834. {
  7835. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7836. }
  7837. return Ok(jw);
  7838. }
  7839. /// <summary>
  7840. /// 导出报价单
  7841. /// </summary>
  7842. /// <param name="dto"></param>
  7843. /// <returns></returns>
  7844. [HttpPost]
  7845. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7846. {
  7847. if (dto.Diid == 0)
  7848. {
  7849. return Ok(JsonView(false, "请传递团组id"));
  7850. }
  7851. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7852. if (deleInfo.Code != 0)
  7853. {
  7854. return Ok(JsonView(false, "团组信息查询失败!"));
  7855. }
  7856. var di = deleInfo.Data as DelegationInfoWebView;
  7857. if (di != null)
  7858. {
  7859. di.TeamName = di.TeamName.Replace("|", "、");
  7860. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7861. //文件名
  7862. string strFileName = di.TeamName + "-收款账单.doc";
  7863. //获取模板
  7864. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7865. //载入模板
  7866. Document doc = new Document(tmppath);
  7867. decimal TotalPrice = 0.00M;
  7868. string itemStr = string.Empty;
  7869. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7870. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7871. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7872. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7873. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7874. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7875. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7876. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7877. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7878. foreach (var cost in groupCostType)
  7879. {
  7880. var List = cost.ToList();
  7881. if (cost.Key == "A")
  7882. {
  7883. foreach (var ListItem in List)
  7884. {
  7885. if (ListItem.number > 0)
  7886. {
  7887. if (ListItem.code.Contains("TBR"))
  7888. {
  7889. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7890. }
  7891. else
  7892. {
  7893. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7894. }
  7895. TotalPrice += (ListItem.number * ListItem.price);
  7896. }
  7897. }
  7898. }
  7899. else
  7900. {
  7901. itemStr = itemStr.Insert(0, "A段\r\n");
  7902. itemStr += "B段\r\n";
  7903. foreach (var ListItem in List)
  7904. {
  7905. if (ListItem.number > 0)
  7906. {
  7907. if (ListItem.code.Contains("TBR"))
  7908. {
  7909. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7910. }
  7911. else
  7912. {
  7913. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7914. }
  7915. TotalPrice += (ListItem.number * ListItem.price);
  7916. }
  7917. }
  7918. }
  7919. }
  7920. #region 替换Word模板书签内容
  7921. Dictionary<string, string> marks = new Dictionary<string, string>();
  7922. marks.Add("To", di.ClientUnit);//付款方
  7923. marks.Add("ToTel", di.TellPhone);//付款方电话
  7924. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7925. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7926. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7927. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7928. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7929. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7930. marks.Add("PayItemContent", itemStr);//详细信息
  7931. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7932. #endregion
  7933. ////注
  7934. //if (doc.Range.Bookmarks["Attention"] != null)
  7935. //{
  7936. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7937. // mark.Text = frList[0].Attention;
  7938. //}
  7939. foreach (var item in marks.Keys)
  7940. {
  7941. if (doc.Range.Bookmarks[item] != null)
  7942. {
  7943. Bookmark mark = doc.Range.Bookmarks[item];
  7944. mark.Text = marks[item];
  7945. }
  7946. }
  7947. byte[] bytes = null;
  7948. using (MemoryStream stream = new MemoryStream())
  7949. {
  7950. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7951. bytes = stream.ToArray();
  7952. }
  7953. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7954. return Ok(JsonView(true, "", new
  7955. {
  7956. Data = bytes,
  7957. strFileName,
  7958. }));
  7959. }
  7960. else
  7961. {
  7962. return Ok(JsonView(false, "团组信息不存在!"));
  7963. }
  7964. }
  7965. /// <summary>
  7966. /// 导出团组成本
  7967. /// </summary>
  7968. /// <param name="dto"></param>
  7969. /// <returns></returns>
  7970. [HttpPost]
  7971. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7972. {
  7973. var jw = JsonView(false);
  7974. if (dto.Diid == 0)
  7975. {
  7976. return Ok(JsonView(false, "请传递团组id"));
  7977. }
  7978. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7979. if (deleInfo.Code != 0)
  7980. {
  7981. return Ok(JsonView(false, "团组信息查询失败!"));
  7982. }
  7983. var di = deleInfo.Data as DelegationInfoWebView;
  7984. if (di == null)
  7985. {
  7986. return Ok(JsonView(false, "团组信息查询失败!"));
  7987. }
  7988. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7989. WorkbookDesigner designer = new WorkbookDesigner();
  7990. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7991. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7992. for (int i = 0; i < List_GC.Count; i++)
  7993. {
  7994. GroupCost_Excel gc = new GroupCost_Excel();
  7995. gc.Id = List_GC[i].Id;
  7996. gc.Diid = List_GC[i].Diid.ToString();
  7997. gc.DAY = List_GC[i].DAY;
  7998. string week = "";
  7999. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  8000. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  8001. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  8002. gc.ITIN = List_GC[i].ITIN;
  8003. gc.CarType = List_GC[i].CarType;
  8004. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  8005. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  8006. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  8007. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  8008. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  8009. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  8010. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  8011. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  8012. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  8013. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  8014. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  8015. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  8016. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8017. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8018. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  8019. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  8020. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  8021. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  8022. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  8023. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  8024. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  8025. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  8026. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  8027. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  8028. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  8029. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  8030. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  8031. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  8032. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  8033. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  8034. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  8035. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  8036. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  8037. List_GC1.Add(gc);
  8038. }
  8039. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  8040. dt.TableName = "TB";
  8041. //报表标题等不用dt的值
  8042. designer.SetDataSource("TeamName", dto.title.TeamName);
  8043. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  8044. designer.SetDataSource("Tax", dto.title.Tax);
  8045. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  8046. designer.SetDataSource("Currency", dto.title.Currency);
  8047. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  8048. designer.SetDataSource("Rate", dto.title.Rate);
  8049. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  8050. var Aparams = hotels.Find(x => x.Type == "Default");
  8051. if (Aparams == null)
  8052. {
  8053. return Ok(jw);
  8054. }
  8055. //酒店数量
  8056. var txtSGRNumber = Aparams.SGR.ToString();
  8057. var txtTBRNumber = Aparams.TBR.ToString();
  8058. var txtJSESNumber = Aparams.JSES.ToString();
  8059. var txtSUITENumbe = Aparams.SUITE.ToString();
  8060. if (dto.costType == "B")
  8061. {
  8062. Aparams = hotels.Find(x => x.Type == "A");
  8063. var Bparams = hotels.Find(x => x.Type == "B");
  8064. if (Aparams == null || Bparams == null)
  8065. {
  8066. return Ok(jw);
  8067. }
  8068. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  8069. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  8070. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  8071. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  8072. }
  8073. designer.SetDataSource("SGRNumber", txtSGRNumber);
  8074. designer.SetDataSource("TBRNumber", txtTBRNumber);
  8075. designer.SetDataSource("JSESNumber", txtJSESNumber);
  8076. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  8077. var ws = designer.Workbook.Worksheets[0];
  8078. int Row = List_GC.Count;
  8079. int startIndex = 11;
  8080. int HideRows = 0;
  8081. List<int> hideRowsList = new List<int>();
  8082. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  8083. #region A段left数据
  8084. var left = dto.leftInfo.Find(x => x.Type == "A");
  8085. if (left == null)
  8086. {
  8087. return Ok(jw);
  8088. }
  8089. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  8090. if (leftBindData != null)
  8091. {
  8092. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  8093. designer.SetDataSource("VisaRS", leftBindData.rs);
  8094. designer.SetDataSource("VisaXS", leftBindData.xs);
  8095. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8096. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8097. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8098. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8099. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8100. }
  8101. else
  8102. {
  8103. hideRowsList.Add(Row + startIndex + HideRows);
  8104. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8105. }
  8106. HideRows += 2;
  8107. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  8108. if (leftBindData != null)
  8109. {
  8110. designer.SetDataSource("BXDRCB", leftBindData.cb);
  8111. designer.SetDataSource("BXRS", leftBindData.rs);
  8112. designer.SetDataSource("BXXS", leftBindData.xs);
  8113. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8114. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8115. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8116. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8117. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8118. }
  8119. else
  8120. {
  8121. hideRowsList.Add(Row + startIndex + HideRows);
  8122. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8123. }
  8124. HideRows += 2;
  8125. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8126. if (leftBindData != null)
  8127. {
  8128. designer.SetDataSource("HSDRCB", leftBindData.cb);
  8129. designer.SetDataSource("HSRS", leftBindData.rs);
  8130. designer.SetDataSource("HSXS", leftBindData.xs);
  8131. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8132. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8133. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8134. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8135. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8136. }
  8137. else
  8138. {
  8139. hideRowsList.Add(Row + startIndex + HideRows);
  8140. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8141. }
  8142. HideRows += 2;
  8143. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8144. if (leftBindData != null)
  8145. {
  8146. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8147. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8148. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8149. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8150. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8151. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8152. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8153. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8154. }
  8155. else
  8156. {
  8157. hideRowsList.Add(Row + startIndex + HideRows);
  8158. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8159. }
  8160. HideRows += 2;
  8161. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8162. if (leftBindData != null)
  8163. {
  8164. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8165. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8166. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8167. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8168. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8169. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8170. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8171. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8172. }
  8173. else
  8174. {
  8175. hideRowsList.Add(Row + startIndex + HideRows);
  8176. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8177. }
  8178. HideRows += 2;
  8179. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8180. if (leftBindData != null)
  8181. {
  8182. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8183. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8184. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8185. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8186. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8187. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8188. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8189. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8190. }
  8191. else
  8192. {
  8193. hideRowsList.Add(Row + startIndex + HideRows);
  8194. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8195. }
  8196. HideRows += 2;
  8197. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8198. if (leftBindData != null)
  8199. {
  8200. ////TBR
  8201. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8202. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8203. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8204. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8205. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8206. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8207. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8208. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8209. }
  8210. else
  8211. {
  8212. hideRowsList.Add(Row + startIndex + HideRows);
  8213. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8214. }
  8215. HideRows += 2;
  8216. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8217. if (leftBindData != null)
  8218. {
  8219. ////SGR
  8220. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8221. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8222. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8223. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8224. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8225. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8226. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8227. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8228. }
  8229. else
  8230. {
  8231. hideRowsList.Add(Row + startIndex + HideRows);
  8232. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8233. }
  8234. HideRows += 2;
  8235. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8236. if (leftBindData != null)
  8237. {
  8238. ////JS/ES
  8239. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8240. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8241. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8242. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8243. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8244. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8245. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8246. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8247. }
  8248. else
  8249. {
  8250. hideRowsList.Add(Row + startIndex + HideRows);
  8251. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8252. }
  8253. HideRows += 2;
  8254. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8255. if (leftBindData != null)
  8256. {
  8257. ////SUITE
  8258. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8259. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8260. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8261. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8262. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8263. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8264. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8265. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8266. }
  8267. else
  8268. {
  8269. hideRowsList.Add(Row + startIndex + HideRows);
  8270. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8271. }
  8272. HideRows += 2;
  8273. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8274. if (leftBindData != null)
  8275. {
  8276. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8277. designer.SetDataSource("DJRS", leftBindData.rs);
  8278. designer.SetDataSource("DJXS", leftBindData.xs);
  8279. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8280. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8281. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8282. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8283. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8284. }
  8285. else
  8286. {
  8287. hideRowsList.Add(Row + startIndex + HideRows);
  8288. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8289. }
  8290. HideRows += 2;
  8291. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8292. if (leftBindData != null)
  8293. {
  8294. designer.SetDataSource("HCPCB", leftBindData.cb);
  8295. designer.SetDataSource("HCPRS", leftBindData.rs);
  8296. designer.SetDataSource("HCPXS", leftBindData.xs);
  8297. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8298. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8299. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8300. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8301. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8302. }
  8303. else
  8304. {
  8305. hideRowsList.Add(Row + startIndex + HideRows);
  8306. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8307. }
  8308. HideRows += 2;
  8309. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8310. if (leftBindData != null)
  8311. {
  8312. designer.SetDataSource("CPCB", leftBindData.cb);
  8313. designer.SetDataSource("CPRS", leftBindData.rs);
  8314. designer.SetDataSource("CPXS", leftBindData.xs);
  8315. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8316. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8317. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8318. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8319. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8320. }
  8321. else
  8322. {
  8323. hideRowsList.Add(Row + startIndex + HideRows);
  8324. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8325. }
  8326. HideRows += 2;
  8327. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8328. if (leftBindData != null)
  8329. {
  8330. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8331. designer.SetDataSource("GWRS", leftBindData.rs);
  8332. designer.SetDataSource("GWXS", leftBindData.xs);
  8333. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8334. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8335. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8336. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8337. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8338. }
  8339. else
  8340. {
  8341. hideRowsList.Add(Row + startIndex + HideRows);
  8342. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8343. }
  8344. HideRows += 2;
  8345. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8346. if (leftBindData != null)
  8347. {
  8348. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8349. designer.SetDataSource("LYJRS", leftBindData.rs);
  8350. designer.SetDataSource("LYJXS", leftBindData.xs);
  8351. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8352. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8353. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8354. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8355. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8356. }
  8357. else
  8358. {
  8359. hideRowsList.Add(Row + startIndex + HideRows);
  8360. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8361. }
  8362. #endregion
  8363. #region A段Right信息
  8364. var right = dto.rightInfo.Find(x => x.Type == "A");
  8365. if (right == null)
  8366. {
  8367. return Ok(jw);
  8368. }
  8369. HideRows += 4;
  8370. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8371. if (rightBindData != null)
  8372. {
  8373. //经济舱 + 双人间 TBR
  8374. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8375. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8376. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8377. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8378. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8379. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8380. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8381. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8382. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8383. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8384. }
  8385. else
  8386. {
  8387. hideRowsList.Add(Row + startIndex + HideRows);
  8388. }
  8389. HideRows += 2;
  8390. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8391. if (rightBindData != null)
  8392. {
  8393. //经济舱 + 单人间 SGR
  8394. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8395. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8396. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8397. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8398. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8399. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8400. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8401. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8402. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8403. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8404. }
  8405. else
  8406. {
  8407. hideRowsList.Add(Row + startIndex + HideRows);
  8408. }
  8409. HideRows += 2;
  8410. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8411. if (rightBindData != null)
  8412. {
  8413. //公务舱 + 单人间 SGR
  8414. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8415. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8416. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8417. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8418. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8419. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8420. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8421. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8422. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8423. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8424. }
  8425. else
  8426. {
  8427. hideRowsList.Add(Row + startIndex + HideRows);
  8428. }
  8429. HideRows += 2;
  8430. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8431. if (rightBindData != null)
  8432. {
  8433. //公务舱 + 小套房 JSES
  8434. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8435. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8436. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8437. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8438. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8439. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8440. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8441. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8442. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8443. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8444. }
  8445. else
  8446. {
  8447. hideRowsList.Add(Row + startIndex + HideRows);
  8448. }
  8449. HideRows += 2;
  8450. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8451. if (rightBindData != null)
  8452. {
  8453. //公务舱 + 小套房 JSES
  8454. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8455. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8456. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8457. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8458. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8459. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8460. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8461. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8462. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8463. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8464. }
  8465. else
  8466. {
  8467. hideRowsList.Add(Row + startIndex + HideRows);
  8468. }
  8469. HideRows += 2;
  8470. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8471. if (rightBindData != null)
  8472. {
  8473. //经济舱 + 大套房
  8474. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8475. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8476. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8477. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8478. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8479. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8480. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8481. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8482. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8483. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8484. }
  8485. else
  8486. {
  8487. hideRowsList.Add(Row + startIndex + HideRows);
  8488. }
  8489. HideRows += 2;
  8490. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8491. if (rightBindData != null)
  8492. {
  8493. //头等舱 + 小套房 JSES
  8494. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8495. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8496. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8497. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8498. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8499. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8500. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8501. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8502. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8503. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8504. }
  8505. else
  8506. {
  8507. hideRowsList.Add(Row + startIndex + HideRows);
  8508. }
  8509. HideRows += 2;
  8510. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8511. if (rightBindData != null)
  8512. {
  8513. //头等舱 + 大套房
  8514. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8515. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8516. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8517. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8518. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8519. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8520. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8521. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8522. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8523. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8524. }
  8525. else
  8526. {
  8527. hideRowsList.Add(Row + startIndex + HideRows);
  8528. }
  8529. #endregion
  8530. #region B段标题清空
  8531. designer.SetDataSource("CostBDRCB", "");
  8532. designer.SetDataSource("CostBRS", "");
  8533. designer.SetDataSource("CostBXS", "");
  8534. designer.SetDataSource("CostBZCB", "");
  8535. designer.SetDataSource("CostBDRBJ", "");
  8536. designer.SetDataSource("CostBZBJ", "");
  8537. designer.SetDataSource("CostBDRLR", "");
  8538. designer.SetDataSource("CostBZLR", "");
  8539. designer.SetDataSource("CostBDRCBOM", "");
  8540. designer.SetDataSource("CostBRSOM", "");
  8541. designer.SetDataSource("CostBZCBOM", "");
  8542. designer.SetDataSource("CostBDRBJOM", "");
  8543. designer.SetDataSource("CostBZBJOM", "");
  8544. designer.SetDataSource("CostBDRLROM", "");
  8545. designer.SetDataSource("CostBZLROM", "");
  8546. #endregion
  8547. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8548. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8549. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8550. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8551. designer.SetDataSource("DJName", "地接(CNY)");
  8552. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8553. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8554. designer.SetDataSource("GWName", "公务(CNY)");
  8555. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8556. designer.SetDataSource("LYJName", "零用金(CNY)");
  8557. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8558. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8559. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8560. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8561. designer.SetDataSource("BXName", "保险(CNY)");
  8562. designer.SetDataSource("VisaName", "签证(CNY)");
  8563. #region B段基本数据
  8564. if (dto.costType == "B")
  8565. {
  8566. left = dto.leftInfo.Find(x => x.Type == "B");
  8567. if (left == null)
  8568. {
  8569. return Ok(jw);
  8570. }
  8571. #region B段left数据
  8572. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8573. if (leftBindData != null)
  8574. {
  8575. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8576. designer.SetDataSource("BHSRS", leftBindData.rs);
  8577. designer.SetDataSource("BHSXS", leftBindData.xs);
  8578. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8579. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8580. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8581. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8582. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8583. }
  8584. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8585. if (leftBindData != null)
  8586. {
  8587. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8588. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8589. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8590. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8591. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8592. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8593. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8594. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8595. }
  8596. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8597. if (leftBindData != null)
  8598. {
  8599. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8600. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8601. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8602. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8603. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8604. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8605. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8606. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8607. }
  8608. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8609. if (leftBindData != null)
  8610. {
  8611. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8612. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8613. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8614. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8615. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8616. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8617. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8618. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8619. }
  8620. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8621. if (leftBindData != null)
  8622. {
  8623. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8624. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8625. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8626. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8627. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8628. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8629. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8630. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8631. }
  8632. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8633. if (leftBindData != null)
  8634. {
  8635. designer.SetDataSource("BCPCB", leftBindData.cb);
  8636. designer.SetDataSource("BCPRS", leftBindData.rs);
  8637. designer.SetDataSource("BCPXS", leftBindData.xs);
  8638. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8639. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8640. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8641. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8642. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8643. }
  8644. //TBR
  8645. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8646. if (leftBindData != null)
  8647. {
  8648. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8649. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8650. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8651. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8652. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8653. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8654. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8655. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8656. }
  8657. //SGR
  8658. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8659. if (leftBindData != null)
  8660. {
  8661. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8662. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8663. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8664. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8665. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8666. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8667. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8668. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8669. }
  8670. //JS/ES
  8671. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8672. if (leftBindData != null)
  8673. {
  8674. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8675. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8676. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8677. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8678. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8679. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8680. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8681. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8682. }
  8683. //SUITE
  8684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8685. if (leftBindData != null)
  8686. {
  8687. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8688. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8689. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8690. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8691. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8692. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8693. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8694. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8695. }
  8696. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8697. if (leftBindData != null)
  8698. {
  8699. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8700. designer.SetDataSource("BDJRS", leftBindData.rs);
  8701. designer.SetDataSource("BDJXS", leftBindData.xs);
  8702. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8703. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8704. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8705. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8706. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8707. }
  8708. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8709. if (leftBindData != null)
  8710. {
  8711. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8712. designer.SetDataSource("BGWRS", leftBindData.rs);
  8713. designer.SetDataSource("BGWXS", leftBindData.xs);
  8714. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8715. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8716. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8717. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8718. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8719. }
  8720. #region 优化方案
  8721. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8722. //excelBind.Add("零用金", new {
  8723. //cb="",
  8724. //rs="",
  8725. //xs ="",
  8726. //zcb = "",
  8727. //});
  8728. #endregion
  8729. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8730. if (leftBindData != null)
  8731. {
  8732. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8733. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8734. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8735. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8736. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8737. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8738. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8739. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8740. }
  8741. #endregion
  8742. #region B段Right信息
  8743. right = dto.rightInfo.Find(x => x.Type == "B");
  8744. if (right == null)
  8745. {
  8746. return Ok(jw);
  8747. }
  8748. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8749. if (rightBindData != null)
  8750. {
  8751. //经济舱 + 双人间 TBR
  8752. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8753. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8754. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8755. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8756. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8757. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8758. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8759. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8760. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8761. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8762. }
  8763. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8764. if (rightBindData != null)
  8765. {
  8766. //经济舱 + 单人间 SGR
  8767. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8768. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8769. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8770. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8771. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8772. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8773. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8774. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8775. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8776. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8777. }
  8778. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8779. if (rightBindData != null)
  8780. {
  8781. //公务舱 + 单人间 SGR
  8782. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8783. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8784. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8785. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8786. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8787. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8788. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8789. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8790. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8791. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8792. }
  8793. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8794. if (rightBindData != null)
  8795. {
  8796. //公务舱 + 小套房 JSES
  8797. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8798. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8799. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8800. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8801. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8802. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8803. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8804. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8805. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8806. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8807. }
  8808. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8809. if (rightBindData != null)
  8810. {
  8811. //公务舱 + 小套房 JSES
  8812. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8813. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8814. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8815. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8816. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8817. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8818. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8819. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8820. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8821. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8822. }
  8823. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8824. if (rightBindData != null)
  8825. {
  8826. //经济舱 + 大套房
  8827. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8828. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8829. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8830. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8831. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8832. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8833. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8834. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8835. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8836. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8837. }
  8838. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8839. if (rightBindData != null)
  8840. {
  8841. //头等舱 + 小套房 JSES
  8842. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8843. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8844. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8845. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8846. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8847. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8848. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8849. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8850. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8851. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8852. }
  8853. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8854. if (rightBindData != null)
  8855. {
  8856. //头等舱 + 大套房
  8857. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8858. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8859. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8860. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8861. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8862. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8863. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8864. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8865. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8866. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8867. }
  8868. #endregion
  8869. #region 标题
  8870. designer.SetDataSource("CostBDRCB", "单人成本");
  8871. designer.SetDataSource("CostBRS", "人数");
  8872. designer.SetDataSource("CostBXS", "系数");
  8873. designer.SetDataSource("CostBZCB", "总成本");
  8874. designer.SetDataSource("CostBDRBJ", "单人报价");
  8875. designer.SetDataSource("CostBZBJ", "总报价");
  8876. designer.SetDataSource("CostBDRLR", "单人利润");
  8877. designer.SetDataSource("CostBZLR", "总利润");
  8878. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8879. designer.SetDataSource("CostBRSOM", "人数");
  8880. designer.SetDataSource("CostBZCBOM", "总成本");
  8881. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8882. designer.SetDataSource("CostBZBJOM", "总报价");
  8883. designer.SetDataSource("CostBDRLROM", "单人利润");
  8884. designer.SetDataSource("CostBZLROM", "总利润");
  8885. #endregion
  8886. }
  8887. #endregion
  8888. designer.SetDataSource("TzZCB2", TzZCB2);
  8889. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8890. designer.SetDataSource("TzZLR2", TzZLR2);
  8891. string[] dataSourceKeys = new string[]
  8892. {
  8893. "VF",
  8894. "TGS",
  8895. "TGOF",
  8896. "TGM",
  8897. "TGA",
  8898. "TGTF",
  8899. "TGEF",
  8900. "CFM",
  8901. "CFOF",
  8902. "B",
  8903. "L",
  8904. "D",
  8905. "TBR",
  8906. "SGR",
  8907. "JSES",
  8908. "Suite",
  8909. "TV",
  8910. "1L",
  8911. "IF",
  8912. "EF",
  8913. "BRF",
  8914. "TE",
  8915. "TGT",
  8916. "DRVT",
  8917. "PC",
  8918. "TLF",
  8919. "ECT"
  8920. };
  8921. foreach (var item in dataSourceKeys)
  8922. {
  8923. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8924. if (find != null)
  8925. {
  8926. designer.SetDataSource(item, find.text);
  8927. }
  8928. else
  8929. {
  8930. designer.SetDataSource(item, 0);
  8931. }
  8932. }
  8933. designer.SetDataSource(dt);
  8934. //根据数据源处理生成报表内容
  8935. designer.Process();
  8936. designer.Workbook.Worksheets[0].Name = "清单";
  8937. Worksheet sheet = designer.Workbook.Worksheets[0];
  8938. foreach (var Rowindex in hideRowsList)
  8939. {
  8940. ws.Cells.HideRows(Rowindex, 2);
  8941. }
  8942. byte[] bytes = null;
  8943. string strFileName = di.TeamName + "-团组-成本.xls";
  8944. using (MemoryStream stream = new MemoryStream())
  8945. {
  8946. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8947. bytes = stream.ToArray();
  8948. }
  8949. return Ok(JsonView(true, "", new
  8950. {
  8951. Data = bytes,
  8952. strFileName,
  8953. }));
  8954. }
  8955. /// <summary>
  8956. /// 导出客户报表
  8957. /// </summary>
  8958. /// <returns></returns>
  8959. [HttpPost]
  8960. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8961. {
  8962. var jw = JsonView(false);
  8963. if (dto.Diid == 0)
  8964. {
  8965. return Ok(JsonView(false, "请传递团组id"));
  8966. }
  8967. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8968. if (deleInfo.Code != 0)
  8969. {
  8970. return Ok(JsonView(false, "团组信息查询失败!"));
  8971. }
  8972. var di = deleInfo.Data as DelegationInfoWebView;
  8973. if (di == null)
  8974. {
  8975. return Ok(JsonView(false, "团组信息查询失败!"));
  8976. }
  8977. //文件名
  8978. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8979. //获取模板
  8980. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8981. //载入模板
  8982. Document doc = new Document(tmppath);
  8983. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8984. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8985. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8986. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8987. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8988. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8989. if (AParameter == null)
  8990. {
  8991. return Ok(JsonView(false, "系数不存在!"));
  8992. }
  8993. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8994. , TzAirDesc, TzZCost;
  8995. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8996. = TzAirDesc = TzZCost = string.Empty;
  8997. TzNumber = AParameter.CostTypenumber.ToString();
  8998. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8999. CarGuides1 = dto.CarGuides1;
  9000. Meal = dto.Meal;
  9001. SubsidizedMeals = dto.SubsidizedMeals;
  9002. NightRepair = dto.NightRepair;
  9003. AttractionsTickets = dto.AttractionsTickets;
  9004. MiscellaneousFees = dto.MiscellaneousFees;
  9005. ATip = dto.ATip;
  9006. TzHotelDesc = "";
  9007. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  9008. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  9009. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  9010. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  9011. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  9012. TzAirDesc = "";
  9013. TzZCost = dto.TzZCost;
  9014. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  9015. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  9016. var index = 1;
  9017. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  9018. foreach (var item in TzHotelDescArr)
  9019. {
  9020. if (AinfoArr != null)
  9021. {
  9022. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9023. if (Ainfo != null)
  9024. {
  9025. if (int.Parse(Ainfo.rs) <= 0)
  9026. {
  9027. continue;
  9028. }
  9029. var hotelText = string.Empty;
  9030. switch (item)
  9031. {
  9032. case "SGR":
  9033. hotelText = "单人间";
  9034. break;
  9035. case "JSES":
  9036. hotelText = "小套房";
  9037. break;
  9038. case "SUITE":
  9039. hotelText = "套房";
  9040. break;
  9041. case "TBR":
  9042. hotelText = "双人间";
  9043. break;
  9044. }
  9045. if (item != "TBR")
  9046. {
  9047. 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";
  9048. }
  9049. else
  9050. {
  9051. 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";
  9052. }
  9053. index++;
  9054. }
  9055. }
  9056. }
  9057. index = 1;
  9058. foreach (var item in TzAirDescArr)
  9059. {
  9060. if (AinfoArr != null)
  9061. {
  9062. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9063. if (Ainfo != null)
  9064. {
  9065. if (int.Parse(Ainfo.rs) <= 0)
  9066. {
  9067. continue;
  9068. }
  9069. 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";
  9070. index++;
  9071. }
  9072. }
  9073. }
  9074. if (dto.costType == "B")
  9075. {
  9076. if (BParameter == null)
  9077. {
  9078. return Ok(JsonView(false, "B段系数不存在!"));
  9079. }
  9080. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  9081. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  9082. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  9083. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  9084. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  9085. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  9086. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  9087. foreach (var item in TzHotelDescArr)
  9088. {
  9089. if (AinfoArr != null)
  9090. {
  9091. TzHotelDesc += "B段信息 \r\n";
  9092. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9093. if (Ainfo != null)
  9094. {
  9095. if (int.Parse(Ainfo.rs) <= 0)
  9096. {
  9097. continue;
  9098. }
  9099. var hotelText = string.Empty;
  9100. switch (item)
  9101. {
  9102. case "SGR":
  9103. hotelText = "单人间";
  9104. break;
  9105. case "JSES":
  9106. hotelText = "小套房";
  9107. break;
  9108. case "SUITE":
  9109. hotelText = "套房";
  9110. break;
  9111. case "TBR":
  9112. hotelText = "双人间";
  9113. break;
  9114. }
  9115. if (item != "TBR")
  9116. {
  9117. 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";
  9118. }
  9119. else
  9120. {
  9121. 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";
  9122. }
  9123. index++;
  9124. }
  9125. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  9126. }
  9127. }
  9128. index = 1;
  9129. foreach (var item in TzAirDescArr)
  9130. {
  9131. if (AinfoArr != null)
  9132. {
  9133. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9134. if (Ainfo != null)
  9135. {
  9136. if (int.Parse(Ainfo.rs) <= 0)
  9137. {
  9138. continue;
  9139. }
  9140. 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";
  9141. index++;
  9142. }
  9143. }
  9144. }
  9145. }
  9146. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9147. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9148. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9149. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9150. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9151. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9152. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9153. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9154. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9155. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9156. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9157. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9158. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9159. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9160. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9161. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9162. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9163. DickeyValue.Add("TzZCost", TzZCost);
  9164. foreach (var key in DickeyValue.Keys)
  9165. {
  9166. if (doc.Range.Bookmarks[key] != null)
  9167. {
  9168. Bookmark mark = doc.Range.Bookmarks[key];
  9169. mark.Text = DickeyValue[key];
  9170. }
  9171. }
  9172. byte[] bytes = null;
  9173. string strFileName = di.TeamName + "-客户报价.doc";
  9174. using (MemoryStream stream = new MemoryStream())
  9175. {
  9176. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9177. bytes = stream.ToArray();
  9178. }
  9179. return Ok(JsonView(true, "", new
  9180. {
  9181. Data = bytes,
  9182. strFileName,
  9183. }));
  9184. }
  9185. /// <summary>
  9186. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9187. /// </summary>
  9188. /// <param name="dto"></param>
  9189. /// <returns></returns>
  9190. [HttpPost]
  9191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9192. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9193. {
  9194. try
  9195. {
  9196. #region 参数验证
  9197. if (dto.DiId < 0)
  9198. {
  9199. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9200. }
  9201. List<int> cTableIds = new List<int>() {
  9202. 76 ,//酒店预订
  9203. 77 ,//行程
  9204. 79 ,//车/导游地接
  9205. 80 ,//签证
  9206. 81 ,//邀请/公务活
  9207. 82 ,//团组客户保险
  9208. 85 ,//机票预订
  9209. 98 ,//其他款项
  9210. 285 ,//收款退还
  9211. 751 ,//酒店早餐
  9212. 1015 // 超支费用
  9213. };
  9214. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9215. {
  9216. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9217. }
  9218. #endregion
  9219. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9220. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9221. if (_GroupCostParameters.Count <= 0)
  9222. {
  9223. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9224. }
  9225. if (_GroupCostParameters[0].IsShare == 0)
  9226. {
  9227. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9228. }
  9229. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9230. //处理date为空问题
  9231. if (_GroupCosts.Count > 0)
  9232. {
  9233. for (int i = 0; i < _GroupCosts.Count; i++)
  9234. {
  9235. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9236. {
  9237. if (i > 0)
  9238. {
  9239. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9240. }
  9241. }
  9242. }
  9243. }
  9244. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9245. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9246. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9247. string currCode = "";
  9248. #region currCode 验证
  9249. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9250. if (isInt)
  9251. {
  9252. var currData = currDatas.Find(it => it.Id == intCurrency);
  9253. if (currData != null)
  9254. {
  9255. currCode = currData.Name;
  9256. }
  9257. }
  9258. else
  9259. {
  9260. currCode = _GroupCostParameters[0].Currency.Trim();
  9261. }
  9262. #endregion
  9263. //op,酒店单段模式存储
  9264. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9265. {
  9266. CurrencyCode = currCode,
  9267. Rate = _GroupCostParameters[0].Rate,
  9268. CostType = _GroupCostParameters[0].CostType,
  9269. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9270. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9271. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9272. };
  9273. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9274. if (_GroupCostParameters.Count == 2)
  9275. {
  9276. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9277. }
  9278. foreach (var item in _GroupCostParameters)
  9279. {
  9280. decimal _rate = 1;
  9281. decimal _rate1 = item.Rate;
  9282. decimal _scale = 1;
  9283. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9284. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9285. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9286. //if (userInfo != null)
  9287. //{
  9288. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9289. // {
  9290. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9291. // {
  9292. // _scale = 1.00M;
  9293. // }
  9294. // }
  9295. //}
  9296. #endregion
  9297. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9298. {
  9299. CurrencyCode = currCode,
  9300. Rate = _rate1,
  9301. CostType = item.CostType,
  9302. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9303. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9304. CostTypeNumber = item.CostTypenumber
  9305. };
  9306. if (_GroupCostParameters.Count > 1)
  9307. {
  9308. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9309. }
  9310. else
  9311. {
  9312. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9313. }
  9314. if (dto.CTable == 79)//
  9315. {
  9316. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9317. modulePromptInfo.TotalCost = item.DJCB;
  9318. }
  9319. List<string> costTypes = new List<string>() { "A", "B" };
  9320. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9321. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9322. if (_GroupCostsDuplicates.Count() == 1)
  9323. {
  9324. _GroupCostsTypeData = _GroupCosts;
  9325. }
  9326. else
  9327. {
  9328. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9329. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9330. }
  9331. /*
  9332. * 76 酒店预订
  9333. * 77 行程
  9334. * 79 车/导游地接
  9335. * 80 签证
  9336. * 81 邀请/公务活动
  9337. * 82 团组客户保险
  9338. * 85 机票预订
  9339. * 98 其他款项
  9340. * 285 收款退还
  9341. * 751 酒店早餐
  9342. * 1015 超支费用
  9343. */
  9344. switch (dto.CTable)
  9345. {
  9346. case 76: // 酒店预订
  9347. _ModuleSubPromptInfo.AddRange(
  9348. _GroupCostsTypeData.Select(it => new
  9349. {
  9350. it.DAY,
  9351. it.Date,
  9352. it.ACCON,
  9353. it.ITIN,
  9354. it.SGR,
  9355. it.TBR,
  9356. it.JS_ES,
  9357. it.Suite
  9358. })
  9359. );
  9360. break;
  9361. case 79: // 车/导游地接
  9362. _ModuleSubPromptInfo.AddRange(
  9363. _GroupCostsTypeData.Select(it => new
  9364. {
  9365. Date = it.Date, //日期
  9366. CarFee = it.CarCost * _rate * _scale, //车费用
  9367. CarType = it.CarType, //车型
  9368. DriverFee = it.CFS * _rate * _scale, //司机工资
  9369. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9370. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9371. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9372. GuideFee = it.TGS * _rate * _scale, //导游费用
  9373. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9374. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9375. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9376. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9377. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9378. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9379. Breakfast = it.B * _rate * _scale, //早餐费
  9380. Lunch = it.L * _rate * _scale, //午餐费
  9381. Dinner = it.D * _rate * _scale, //晚餐费
  9382. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9383. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9384. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9385. TicketFee = it.EF * _rate * _scale, //门票费
  9386. TicketRemark = it.EFR, //门票费描述
  9387. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9388. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9389. SpentCash = it.PC * _rate * _scale, //零用金
  9390. LeadersFee = it.TLF * _rate * _scale, //领队费
  9391. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9392. })
  9393. );
  9394. break;
  9395. case 85: // 机票
  9396. List<dynamic> datas = new List<dynamic>();
  9397. datas.Add(
  9398. new
  9399. {
  9400. AirType = "经济舱",
  9401. AirNum = item.JJCRS,
  9402. AirDRCB = item.JJCCB,
  9403. AirZCB = (item.JJCRS * item.JJCCB)
  9404. }
  9405. );
  9406. datas.Add(
  9407. new
  9408. {
  9409. AirType = "公务舱",
  9410. AirNum = item.GWCRS,
  9411. AirDRCB = item.GWCCB,
  9412. AirZCB = (item.GWCRS * item.GWCCB)
  9413. }
  9414. );
  9415. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9416. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9417. modulePromptInfo.Data = new
  9418. {
  9419. airFeeData = datas,
  9420. airInitData = initDatas
  9421. };
  9422. _ModulePromptInfos.Add(modulePromptInfo);
  9423. break;
  9424. default:
  9425. break;
  9426. }
  9427. }
  9428. if (dto.CTable != 85)
  9429. {
  9430. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9431. _ModulePromptInfos.Add(_ModulePromptInfo);
  9432. }
  9433. _view.ModulePromptInfos = _ModulePromptInfos;
  9434. return Ok(JsonView(true, "操作成功!", _view));
  9435. }
  9436. catch (Exception ex)
  9437. {
  9438. return Ok(JsonView(false, ex.Message));
  9439. }
  9440. }
  9441. /// <summary>
  9442. /// 根据黑屏代码重新生成行程
  9443. /// </summary>
  9444. /// <param name="dto"></param>
  9445. /// <returns></returns>
  9446. [HttpPost]
  9447. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9448. {
  9449. var jw = JsonView(false);
  9450. var Create = _GroupCostRepository.
  9451. CreateGroupCostByBlackCode(dto.Diid);
  9452. jw.Msg = Create.Msg;
  9453. if (Create.Code == 0)
  9454. {
  9455. jw.Code = 200;
  9456. jw.Data = new
  9457. {
  9458. groupCost = Create.Data,
  9459. blackCodeIsTrue = true
  9460. };
  9461. }
  9462. else
  9463. {
  9464. jw.Code = 400;
  9465. jw.Data = new
  9466. {
  9467. groupCost = Create.Data,
  9468. blackCodeIsTrue = false,
  9469. };
  9470. }
  9471. return Ok(jw);
  9472. }
  9473. /// <summary>
  9474. /// 成本获取OP历史车费用
  9475. /// </summary>
  9476. /// <param name="dto"></param>
  9477. /// <returns></returns>
  9478. [HttpPost]
  9479. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9480. {
  9481. var jw = JsonView(false);
  9482. try
  9483. {
  9484. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9485. //获取现有所有车的数据
  9486. if (!dto.Param.IsNullOrWhiteSpace())
  9487. {
  9488. string sql = $@"
  9489. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9490. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9491. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9492. 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
  9493. AND gctggr.ServiceEndTime is not NULL
  9494. ORDER by gctggrc.id DESC
  9495. ";
  9496. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9497. var numeberResult = await Task.Run(() =>
  9498. {
  9499. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9500. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9501. return numberArr;
  9502. });
  9503. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9504. foreach (var item in numeberResult)
  9505. {
  9506. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9507. {
  9508. Country = "数据异常!",
  9509. City = string.Empty,
  9510. };
  9511. item.Area = find.Country + " " + find.City;
  9512. }
  9513. dbResult.AddRange(numeberResult);
  9514. if (dto.Param.Contains("、"))
  9515. {
  9516. var sp = dto.Param.Split("、");
  9517. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9518. .Where(x =>
  9519. {
  9520. return System.Array.Exists(sp, e =>
  9521. {
  9522. bool where = false;
  9523. if (x.Area != null)
  9524. {
  9525. where = x.Area.Contains(e);
  9526. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9527. {
  9528. return false;
  9529. }
  9530. }
  9531. if (x.PriceName != null && !where)
  9532. {
  9533. where = x.PriceName.Contains(e);
  9534. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9535. {
  9536. return false;
  9537. }
  9538. }
  9539. return where;
  9540. });
  9541. }).ToList();
  9542. }
  9543. else
  9544. {
  9545. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9546. .Where(x =>
  9547. {
  9548. bool where = false;
  9549. if (x.Area != null)
  9550. {
  9551. where = x.Area.Contains(dto.Param);
  9552. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9553. {
  9554. return false;
  9555. }
  9556. }
  9557. if (x.PriceName != null && !where)
  9558. {
  9559. where = x.PriceName.Contains(dto.Param);
  9560. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9561. {
  9562. return false;
  9563. }
  9564. }
  9565. return where;
  9566. }
  9567. )
  9568. .ToList();
  9569. }
  9570. }
  9571. var view = dbResult.Select(x =>
  9572. {
  9573. decimal dp = 0.00M;
  9574. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9575. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9576. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9577. {
  9578. if (startB && endB)
  9579. {
  9580. var timesp = endD.Subtract(startD);
  9581. if ((timesp.Days + 1) != 0)
  9582. {
  9583. dp = x.Price / (timesp.Days + 1);
  9584. }
  9585. }
  9586. }
  9587. else
  9588. {
  9589. dp = x.Price;
  9590. }
  9591. return new
  9592. {
  9593. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9594. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9595. x.Area,
  9596. x.id,
  9597. price = x.Price.ToString("F2"),
  9598. x.PriceName,
  9599. x.PriceContent,
  9600. x.TeamName,
  9601. x.DatePrice,
  9602. dayPrice = dp.ToString("F2"),
  9603. };
  9604. }).OrderByDescending(x => x.id).ToList();
  9605. jw = JsonView(true, "获取成功!", view);
  9606. }
  9607. catch (Exception e)
  9608. {
  9609. jw = JsonView(false, e.Message);
  9610. }
  9611. return Ok(jw);
  9612. }
  9613. #endregion
  9614. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9615. /// <summary>
  9616. /// 酒店预订
  9617. /// 酒店费用列表 根据团组Id查询
  9618. /// </summary>
  9619. /// <param name="_dto"></param>
  9620. /// <returns></returns>
  9621. [HttpPost]
  9622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9623. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9624. {
  9625. #region 参数验证
  9626. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9627. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9628. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9629. #region 团组操作权限验证 76 酒店预定模块
  9630. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9631. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9632. #endregion
  9633. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9634. #region 页面操作权限验证
  9635. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9636. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9637. #endregion
  9638. #endregion
  9639. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9640. }
  9641. /// <summary>
  9642. /// 酒店预订
  9643. /// 基础数据
  9644. /// </summary>
  9645. /// <param name="_dto"></param>
  9646. /// <returns></returns>
  9647. [HttpPost]
  9648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9649. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9650. {
  9651. #region 参数验证
  9652. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9653. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9654. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9655. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9656. #region 页面操作权限验证
  9657. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9658. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9659. #endregion
  9660. #region 团组操作权限验证 76 酒店预定模块
  9661. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9662. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9663. #endregion
  9664. #endregion
  9665. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9666. }
  9667. /// <summary>
  9668. /// 酒店预订
  9669. /// 创建 入住卷号码
  9670. /// </summary>
  9671. /// <param name="_dto"></param>
  9672. /// <returns></returns>
  9673. [HttpPost]
  9674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9675. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9676. {
  9677. #region 参数验证
  9678. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9679. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9680. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9681. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9682. #region 页面操作权限验证
  9683. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9684. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9685. #endregion
  9686. #region 团组操作权限验证 76 酒店预定模块
  9687. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9688. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9689. #endregion
  9690. #endregion
  9691. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9692. if (data.Code != 0)
  9693. {
  9694. return Ok(JsonView(false, data.Msg));
  9695. }
  9696. return Ok(JsonView(true, data.Msg, data.Data));
  9697. }
  9698. /// <summary>
  9699. /// 酒店预订
  9700. /// 详情
  9701. /// </summary>
  9702. /// <param name="_dto"></param>
  9703. /// <returns></returns>
  9704. [HttpPost]
  9705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9706. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9707. {
  9708. #region 参数验证
  9709. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9710. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9711. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9712. #region 团组操作权限验证 76 酒店预定模块
  9713. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9714. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9715. #endregion
  9716. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9717. #region 页面操作权限验证
  9718. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9719. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9720. #endregion
  9721. #endregion
  9722. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9723. }
  9724. /// <summary>
  9725. /// 酒店预订
  9726. /// Add Or Edit
  9727. /// </summary>
  9728. /// <param name="_dto"></param>
  9729. /// <returns></returns>
  9730. [HttpPost]
  9731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9732. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9733. {
  9734. #region 参数验证
  9735. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9736. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9737. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9738. #region 团组操作权限验证 76 酒店预定模块
  9739. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9740. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9741. #endregion
  9742. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9743. #region 页面操作权限验证
  9744. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9745. if (_dto.Id == 0) // Add
  9746. {
  9747. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9748. }
  9749. else if (_dto.Id > 1) // Edit
  9750. {
  9751. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9752. }
  9753. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9754. #endregion
  9755. #endregion
  9756. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9757. if (_view.Code != 200)
  9758. {
  9759. return Ok(_view);
  9760. }
  9761. #region 应用推送
  9762. try
  9763. {
  9764. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9765. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9766. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9767. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  9768. //2024-10-21 新增LZ UID
  9769. var userIds = new List<int>() { 21 };
  9770. string title = $"费用审核";
  9771. var diId = _dto.DiId;
  9772. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9773. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9774. string content = "";
  9775. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9776. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9777. try
  9778. {
  9779. var iosRes1 = await APNsTools.iOS_PushNotifications1("051", title, "", content);
  9780. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  9781. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  9782. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  9783. }
  9784. catch (Exception ex )
  9785. {
  9786. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  9787. }
  9788. }
  9789. catch (Exception ex)
  9790. {
  9791. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  9792. }
  9793. try
  9794. {
  9795. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9796. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9797. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9798. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9799. //自动审核
  9800. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9801. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9802. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9803. //2024-10-21 新增LZ UID
  9804. var userIds = new List<int>() { 21 };
  9805. string title = $"系统通知";
  9806. var diId = _dto.DiId;
  9807. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9808. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9809. string content = "";
  9810. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9811. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9812. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9813. }
  9814. catch (Exception ex)
  9815. {
  9816. }
  9817. #endregion
  9818. return Ok(_view);
  9819. }
  9820. /// <summary>
  9821. /// 酒店自动审核测试
  9822. /// Add Or Edit
  9823. /// </summary>
  9824. /// <param name="_dto"></param>
  9825. /// <returns></returns>
  9826. [HttpPost]
  9827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9828. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9829. {
  9830. #region 应用推送
  9831. try
  9832. {
  9833. //自动审核
  9834. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9835. }
  9836. catch (Exception ex)
  9837. {
  9838. return Ok(JsonView(false, "操作失败"));
  9839. }
  9840. #endregion
  9841. return Ok(JsonView(false, "操作成功"));
  9842. }
  9843. /// <summary>
  9844. /// 酒店预订
  9845. /// Del
  9846. /// </summary>
  9847. /// <param name="_dto"></param>
  9848. /// <returns></returns>
  9849. [HttpPost]
  9850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9851. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9852. {
  9853. #region 参数验证
  9854. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9855. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9856. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9857. #region 团组操作权限验证 76 酒店预定模块
  9858. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9859. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9860. #endregion
  9861. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9862. #region 页面操作权限验证
  9863. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9864. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9865. #endregion
  9866. #endregion
  9867. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9868. }
  9869. /// <summary>
  9870. /// 酒店预订
  9871. /// 生成VOUCHER
  9872. /// 2024.05.06 之前版本
  9873. /// </summary>
  9874. /// <param name="_dto"></param>
  9875. /// <returns></returns>
  9876. [HttpPost]
  9877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9878. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9879. {
  9880. try
  9881. {
  9882. #region 参数验证
  9883. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9884. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9885. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9886. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9887. #region 团组操作权限验证 76 酒店预定模块
  9888. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9889. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9890. #endregion
  9891. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9892. #region 页面操作权限验证
  9893. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9894. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9895. #endregion
  9896. #endregion
  9897. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9898. //判断数据是否完整
  9899. if (hr != null)
  9900. {
  9901. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9902. {
  9903. string strFileName = "HotelStatement/";
  9904. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9905. if (dele != null)
  9906. strFileName += dele.TourCode;
  9907. //载入模板
  9908. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9909. Document doc = new Document(sss);
  9910. DocumentBuilder builder = new DocumentBuilder(doc);
  9911. #region 替换Word模板书签内容
  9912. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9913. //入住卷预定号码
  9914. if (doc.Range.Bookmarks["VNO"] != null)
  9915. {
  9916. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9917. mark.Text = hr.CheckNumber;
  9918. }
  9919. //酒店时间
  9920. if (doc.Range.Bookmarks["Date"] != null)
  9921. {
  9922. Bookmark mark = doc.Range.Bookmarks["Date"];
  9923. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9924. }
  9925. //团号
  9926. if (doc.Range.Bookmarks["TNo"] != null)
  9927. {
  9928. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9929. mark.Text = dele.TourCode;
  9930. }
  9931. //预定号码
  9932. if (doc.Range.Bookmarks["BookingId"] != null)
  9933. {
  9934. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9935. mark.Text = hr.ReservationsNo;
  9936. }
  9937. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9938. {
  9939. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9940. mark.Text = hr.DetermineNo;
  9941. }
  9942. //酒店城市
  9943. if (doc.Range.Bookmarks["City"] != null)
  9944. {
  9945. Bookmark mark = doc.Range.Bookmarks["City"];
  9946. mark.Text = hr.City;
  9947. }
  9948. //酒店名称
  9949. if (doc.Range.Bookmarks["HName"] != null)
  9950. {
  9951. Bookmark mark = doc.Range.Bookmarks["HName"];
  9952. mark.Text = hr.HotelName;
  9953. }
  9954. //酒店地址
  9955. if (doc.Range.Bookmarks["Address"] != null)
  9956. {
  9957. Bookmark mark = doc.Range.Bookmarks["Address"];
  9958. mark.Text = hr.HotelAddress;
  9959. }
  9960. //酒店电话
  9961. if (doc.Range.Bookmarks["Tel"] != null)
  9962. {
  9963. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9964. mark.Text = hr.HotelTel;
  9965. }
  9966. //酒店传真
  9967. if (doc.Range.Bookmarks["Fax"] != null)
  9968. {
  9969. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9970. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9971. {
  9972. mark.Text = hr.HotelFax;
  9973. }
  9974. }
  9975. //入住时间
  9976. if (doc.Range.Bookmarks["CIn"] != null)
  9977. {
  9978. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9979. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9980. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9981. }
  9982. //退房时间
  9983. if (doc.Range.Bookmarks["COut"] != null)
  9984. {
  9985. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9986. Bookmark mark = doc.Range.Bookmarks["COut"];
  9987. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9988. }
  9989. //客户名称
  9990. if (doc.Range.Bookmarks["GName"] != null)
  9991. {
  9992. string guestName = "";
  9993. string[] clients = new string[] { };
  9994. if (hr.GuestName.Contains(","))
  9995. {
  9996. clients = hr.GuestName.Split(",");
  9997. }
  9998. else
  9999. {
  10000. clients = new string[] { hr.GuestName };
  10001. }
  10002. List<int> clientIds_int = new List<int>();
  10003. if (clients.Length > 0)
  10004. {
  10005. foreach (var item in clients)
  10006. {
  10007. if (item.IsNumeric())
  10008. {
  10009. clientIds_int.Add(int.Parse(item));
  10010. }
  10011. }
  10012. }
  10013. if (clientIds_int.Count > 0)
  10014. {
  10015. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  10016. foreach (var client in _clientDatas)
  10017. {
  10018. //男
  10019. if (client.Sex == 0) guestName += $"Mr.";
  10020. //女
  10021. else if (client.Sex == 1) guestName += $"Ms.";
  10022. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  10023. {
  10024. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  10025. }
  10026. //guestName += $"{client.Pinyin},";
  10027. }
  10028. if (guestName.Length > 0)
  10029. {
  10030. guestName = guestName.Substring(0, guestName.Length - 1);
  10031. }
  10032. }
  10033. else
  10034. {
  10035. guestName = hr.GuestName;
  10036. }
  10037. Bookmark mark = doc.Range.Bookmarks["GName"];
  10038. mark.Text = guestName;
  10039. }
  10040. //房间介绍
  10041. if (doc.Range.Bookmarks["ROOM"] != null)
  10042. {
  10043. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  10044. mark.Text = hr.RoomExplanation;
  10045. }
  10046. //报价描述
  10047. if (doc.Range.Bookmarks["NOTE"] != null)
  10048. {
  10049. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  10050. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  10051. if (ss != null)
  10052. mark.Text = ss.Name;
  10053. }
  10054. //入住时间
  10055. if (doc.Range.Bookmarks["CheckIn"] != null)
  10056. {
  10057. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  10058. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  10059. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10060. }
  10061. //退房时间
  10062. if (doc.Range.Bookmarks["CheckOut"] != null)
  10063. {
  10064. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  10065. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  10066. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  10067. }
  10068. //日期
  10069. if (doc.Range.Bookmarks["DT"] != null)
  10070. {
  10071. Bookmark mark = doc.Range.Bookmarks["DT"];
  10072. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  10073. }
  10074. //名称
  10075. if (doc.Range.Bookmarks["VName"] != null)
  10076. {
  10077. Bookmark mark = doc.Range.Bookmarks["VName"];
  10078. mark.Text = hr.HotelName;
  10079. }
  10080. //号码
  10081. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  10082. {
  10083. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  10084. mark.Text = hr.CheckNumber;
  10085. }
  10086. #endregion
  10087. strFileName += "VOUCHER.doc";
  10088. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10089. doc.Save(fileDir);
  10090. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10091. return Ok(JsonView(true, "操作成功!", Url));
  10092. }
  10093. else
  10094. {
  10095. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  10096. }
  10097. }
  10098. else
  10099. {
  10100. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  10101. }
  10102. }
  10103. catch (Exception ex)
  10104. {
  10105. return Ok(JsonView(false, ex.Message));
  10106. }
  10107. }
  10108. /// <summary>
  10109. /// 酒店预订
  10110. /// 生成VOUCHER
  10111. /// 2024.05.06 之后版本
  10112. /// </summary>
  10113. /// <param name="_dto"></param>
  10114. /// <returns></returns>
  10115. [HttpPost]
  10116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10117. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  10118. {
  10119. #region 参数验证
  10120. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10121. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10122. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10123. #region 团组操作权限验证 76 酒店预定模块
  10124. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10125. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10126. #endregion
  10127. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10128. #region 页面操作权限验证
  10129. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10130. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10131. #endregion
  10132. #endregion
  10133. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10134. //判断数据是否完整
  10135. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10136. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10137. string strFileName = "HotelStatement/";
  10138. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10139. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  10140. #region 数据处理
  10141. List<int> guestIds = new List<int>();
  10142. int index = 0;
  10143. foreach (var item in hrDtas)
  10144. {
  10145. if (item.GuestName.Contains(","))
  10146. {
  10147. string[] guestIdArr = item.GuestName.Split(',');
  10148. foreach (var guestIdStr in guestIdArr)
  10149. {
  10150. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  10151. if (guestBool)
  10152. {
  10153. guestIds.Add(guestId);
  10154. }
  10155. }
  10156. }
  10157. else guestNames += item.GuestName;
  10158. var voucherInfo = new HotelVoucherInfoView()
  10159. {
  10160. HotelName = item.HotelName,
  10161. CheckInDate = item.CheckInDate,
  10162. CheckOutDate = item.CheckOutDate,
  10163. ConfirmationNumber = item.DetermineNo.Trim(),
  10164. RoomType = item.RoomExplanation
  10165. };
  10166. vouchers.Add(voucherInfo);
  10167. }
  10168. if (guestIds.Count > 0)
  10169. {
  10170. guestIds = guestIds.Distinct().ToList();
  10171. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  10172. if (guestDatas.Count > 0)
  10173. {
  10174. guestNames = "";
  10175. foreach (var guest in guestDatas)
  10176. {
  10177. string guestName = "";
  10178. if (guest.Sex == 0) guestName += @"MR.";
  10179. else if (guest.Sex == 1) guestName += @"MS.";
  10180. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10181. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10182. guestNames += @$"{guestName.Trim()}、";
  10183. }
  10184. if (guestNames.Length > 0)
  10185. {
  10186. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10187. }
  10188. }
  10189. }
  10190. #endregion
  10191. //载入模板
  10192. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10193. Document doc = new Document(sss);
  10194. DocumentBuilder builder = new DocumentBuilder(doc);
  10195. if (doc.Range.Bookmarks["GuestName"] != null)
  10196. {
  10197. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10198. mark.Text = guestNames;
  10199. }
  10200. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10201. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10202. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10203. for (int i = 1; i <= vouchers.Count; i++)
  10204. {
  10205. HotelVoucherInfoView hviv = vouchers[i - 1];
  10206. builder.MoveToCell(0, i, 0, 0);
  10207. builder.Write(hviv.HotelName);
  10208. builder.MoveToCell(0, i, 1, 0);
  10209. builder.Write(hviv.CheckInDate);
  10210. builder.MoveToCell(0, i, 2, 0);
  10211. builder.Write(hviv.CheckOutDate);
  10212. builder.MoveToCell(0, i, 3, 0);
  10213. builder.Write(hviv.RoomType);
  10214. builder.MoveToCell(0, i, 4, 0);
  10215. builder.Write(hviv.ConfirmationNumber);
  10216. }
  10217. //删除多余行
  10218. int currRowIndex = vouchers.Count + 1;
  10219. int delRows = 21 - currRowIndex;
  10220. if (delRows > 0)
  10221. {
  10222. for (int i = 0; i < delRows; i++)
  10223. {
  10224. table.Rows.RemoveAt(currRowIndex);
  10225. //cultivateRowIndex++;
  10226. }
  10227. }
  10228. strFileName += "VOUCHER.docx";
  10229. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10230. doc.Save(fileDir);
  10231. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10232. return Ok(JsonView(true, "操作成功!", Url));
  10233. }
  10234. /// <summary>
  10235. /// 酒店预订
  10236. /// 生成VOUCHER 批量生成
  10237. /// New
  10238. /// </summary>
  10239. /// <param name="_dto"></param>
  10240. /// <returns></returns>
  10241. [HttpPost]
  10242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10243. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10244. {
  10245. #region 参数验证
  10246. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10247. if (_dto.PageId < 1) _dto.PageId = 28;
  10248. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10249. #region 团组操作权限验证 76 酒店预定模块
  10250. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10251. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10252. #endregion
  10253. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10254. #region 页面操作权限验证
  10255. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10256. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10257. #endregion
  10258. #endregion
  10259. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10260. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10261. .OrderBy(x => x.CheckInDate)
  10262. .ToListAsync();
  10263. //判断数据是否完整
  10264. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10265. string strFileName = "HotelStatement/";
  10266. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10267. if (dele != null)
  10268. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10269. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10270. for (int i = 0; i < hrDtas.Count; i++)
  10271. {
  10272. string guestNames = string.Empty;
  10273. List<int> guestIds = new List<int>();
  10274. var item = hrDtas[i];
  10275. //处理客户姓名
  10276. if (item.GuestName.Contains(","))
  10277. {
  10278. string[] guestIdArr = item.GuestName.Split(',');
  10279. foreach (var guestIdStr in guestIdArr)
  10280. if (int.TryParse(guestIdStr, out int guestId))
  10281. guestIds.Add(guestId);
  10282. }
  10283. else
  10284. {
  10285. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10286. if (guestIdBool)
  10287. {
  10288. guestIds.Add(guestId);
  10289. }
  10290. //NaN
  10291. if (item.GuestName.Contains("NaN"))
  10292. {
  10293. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10294. }
  10295. }
  10296. if (guestIds.Count > 0)
  10297. {
  10298. guestIds = guestIds.Distinct().ToList();
  10299. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10300. if (guestDatas1.Count > 0)
  10301. {
  10302. guestNames = "";
  10303. foreach (var guest in guestDatas1)
  10304. {
  10305. string guestName = "";
  10306. if (guest.Sex == 0) guestName += @"MR.";
  10307. else if (guest.Sex == 1) guestName += @"MS.";
  10308. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10309. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10310. guestNames += @$"{guestName.Trim()}、";
  10311. }
  10312. if (guestNames.Length > 0)
  10313. {
  10314. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10315. }
  10316. }
  10317. }
  10318. //if (!string.IsNullOrEmpty(guestNames))
  10319. //{
  10320. hrDtas[i].GuestName = guestNames;
  10321. //}
  10322. }
  10323. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10324. Document doc = new Document();
  10325. DocumentBuilder builder = new DocumentBuilder(doc);
  10326. try
  10327. {
  10328. builder.MoveToDocumentStart();
  10329. foreach (var item in hrDtas)
  10330. {
  10331. //标题
  10332. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10333. builder.ParagraphFormat.LineSpacing = 1;
  10334. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10335. builder.ParagraphFormat.Style.Font.Size = 9;
  10336. builder.ParagraphFormat.Style.Font.Bold = true;
  10337. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10338. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10339. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10340. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10341. builder.ParagraphFormat.LineSpacing = 1;
  10342. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10343. builder.ParagraphFormat.Style.Font.Size = 9;
  10344. builder.ParagraphFormat.Style.Font.Bold = true;
  10345. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10346. builder.StartTable();
  10347. // 设置边框颜色
  10348. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10349. //设置边框样式
  10350. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10351. //表格
  10352. #region 第一行
  10353. builder.InsertCell();
  10354. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10355. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10356. //builder.CellFormat.AllowAutoFit = false;
  10357. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10358. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10359. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10360. builder.CellFormat.WrapText = true; //自动换行
  10361. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10362. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10363. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10364. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10365. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10366. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10367. builder.Write("TOUR NO:");
  10368. builder.InsertCell();
  10369. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10370. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10371. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10372. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10373. builder.ParagraphFormat.Style.Font.Bold = false;
  10374. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10375. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10376. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10377. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10378. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10379. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10380. builder.Write($"{dele?.TourCode ?? "-"}");
  10381. builder.InsertCell();
  10382. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10383. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10384. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10385. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10386. builder.ParagraphFormat.Style.Font.Bold = false;
  10387. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10388. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10389. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10390. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10391. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10392. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10393. builder.Write($"CITY:");
  10394. builder.InsertCell();
  10395. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10396. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10397. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10398. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10399. builder.ParagraphFormat.Style.Font.Bold = false;
  10400. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10401. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10402. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10403. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10404. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10405. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10406. builder.Write($"{item.City}");
  10407. builder.EndRow();
  10408. #endregion
  10409. #region 第二行
  10410. builder.InsertCell();
  10411. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10412. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10413. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10414. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10415. builder.ParagraphFormat.Style.Font.Bold = false;
  10416. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10417. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10418. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10419. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10420. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10421. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10422. builder.Write("CONFIRMATION NO:");
  10423. builder.InsertCell();
  10424. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10425. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10426. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10427. builder.ParagraphFormat.Style.Font.Bold = false;
  10428. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10429. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10430. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10431. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10432. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10433. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10434. builder.CellFormat.VerticalMerge = CellMerge.None;
  10435. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10436. builder.Write($"{item.DetermineNo}");
  10437. builder.InsertCell();
  10438. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10439. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10440. builder.InsertCell();
  10441. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10442. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10443. builder.EndRow();
  10444. #endregion
  10445. #region 第三行
  10446. builder.InsertCell();
  10447. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10448. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10449. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10450. builder.ParagraphFormat.Style.Font.Bold = false;
  10451. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10452. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10453. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10454. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10455. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10456. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10457. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10458. builder.Write($"HOTEL NAME:");
  10459. builder.InsertCell();
  10460. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10461. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10462. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10463. builder.ParagraphFormat.Style.Font.Bold = false;
  10464. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10465. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10466. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10467. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10468. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10469. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10470. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10471. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10472. builder.Write($"{item.HotelName}");
  10473. builder.InsertCell();
  10474. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10475. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10476. builder.InsertCell();
  10477. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10478. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10479. builder.EndRow();
  10480. #endregion
  10481. #region 第四行
  10482. builder.InsertCell();
  10483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10484. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10485. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10486. builder.ParagraphFormat.Style.Font.Bold = false;
  10487. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10490. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10491. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10492. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10493. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10494. builder.Write($"HOTEL ADDRESS:");
  10495. builder.InsertCell();
  10496. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10497. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10498. builder.ParagraphFormat.Style.Font.Size = 8;
  10499. builder.ParagraphFormat.Style.Font.Bold = false;
  10500. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10501. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10502. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10503. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10504. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10505. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10506. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10507. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10508. builder.Write($"{item.HotelAddress}");
  10509. builder.InsertCell();
  10510. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10511. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10512. builder.InsertCell();
  10513. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10514. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10515. builder.EndRow();
  10516. #endregion
  10517. #region 第五行
  10518. builder.InsertCell();
  10519. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10520. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10521. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10522. builder.ParagraphFormat.Style.Font.Bold = false;
  10523. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10524. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10525. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10526. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10527. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10528. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10529. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10530. builder.Write("TEL:");
  10531. builder.InsertCell();
  10532. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10533. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10534. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10535. builder.ParagraphFormat.Style.Font.Bold = false;
  10536. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10537. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10538. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10539. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10540. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10541. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10542. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10543. builder.Write($"{item.HotelTel}");
  10544. builder.InsertCell();
  10545. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10546. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10547. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10548. builder.ParagraphFormat.Style.Font.Bold = false;
  10549. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10550. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10551. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10552. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10553. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10554. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10555. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10556. builder.Write($"FAX:");
  10557. builder.InsertCell();
  10558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10559. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10560. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10561. builder.ParagraphFormat.Style.Font.Bold = false;
  10562. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10563. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10564. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10565. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10566. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10567. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10568. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10569. builder.Write($"{item.HotelFax}");
  10570. builder.EndRow();
  10571. #endregion
  10572. #region 第六行
  10573. builder.InsertCell();
  10574. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10575. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10576. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10577. builder.ParagraphFormat.Style.Font.Bold = false;
  10578. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10579. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10581. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10582. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10583. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10584. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10585. builder.Write("CHECK IN:");
  10586. builder.InsertCell();
  10587. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10588. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10589. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10590. builder.ParagraphFormat.Style.Font.Bold = false;
  10591. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10592. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10593. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10594. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10595. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10596. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10597. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10598. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10599. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10600. builder.Write($"{checkInStr}");
  10601. builder.InsertCell();
  10602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10603. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10604. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10605. builder.ParagraphFormat.Style.Font.Bold = false;
  10606. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10607. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10608. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10609. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10610. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10611. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10612. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10613. builder.Write($"CHECK OUT:");
  10614. builder.InsertCell();
  10615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10616. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10617. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10618. builder.ParagraphFormat.Style.Font.Bold = false;
  10619. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10620. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10621. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10622. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10623. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10624. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10625. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10626. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10627. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10628. builder.Write($"{checkOutStr}");
  10629. builder.EndRow();
  10630. #endregion
  10631. #region 第七行
  10632. builder.InsertCell();
  10633. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10634. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10635. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10636. builder.ParagraphFormat.Style.Font.Bold = false;
  10637. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10638. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10639. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10640. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10641. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10642. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10643. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10644. builder.Write($"GUEST NAME:");
  10645. builder.InsertCell();
  10646. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10647. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10648. builder.ParagraphFormat.Style.Font.Size = 8;
  10649. builder.ParagraphFormat.Style.Font.Bold = false;
  10650. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10651. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10652. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10653. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10654. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10655. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10656. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10657. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10658. builder.Write($"{item.GuestName}");
  10659. builder.InsertCell();
  10660. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10661. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10662. builder.InsertCell();
  10663. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10664. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10665. builder.EndRow();
  10666. #endregion
  10667. #region 第八行
  10668. builder.InsertCell();
  10669. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10670. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10671. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10672. builder.ParagraphFormat.Style.Font.Bold = false;
  10673. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10674. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10675. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10676. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10677. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10678. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10679. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10680. builder.Write($"ROOM TYPE:");
  10681. builder.InsertCell();
  10682. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10683. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10684. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10685. builder.ParagraphFormat.Style.Font.Bold = false;
  10686. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10687. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10688. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10689. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10690. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10691. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10692. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10693. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10694. builder.Write($"{item.RoomExplanation}");
  10695. builder.InsertCell();
  10696. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10697. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10698. builder.InsertCell();
  10699. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10700. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10701. builder.EndRow();
  10702. #endregion
  10703. #region 第九行
  10704. builder.InsertCell();
  10705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10706. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10707. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10708. builder.ParagraphFormat.Style.Font.Bold = false;
  10709. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10710. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10712. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10713. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10714. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10715. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10716. builder.Write($"NOTE:");
  10717. builder.InsertCell();
  10718. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10719. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10720. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10721. builder.ParagraphFormat.Style.Font.Bold = false;
  10722. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10723. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10724. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10725. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10726. 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.");
  10727. builder.InsertCell();
  10728. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10729. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10730. builder.InsertCell();
  10731. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10732. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10733. builder.EndRow();
  10734. #endregion
  10735. builder.EndTable();
  10736. //换行
  10737. builder.Writeln("");
  10738. builder.Writeln("");
  10739. }
  10740. #region 获取文档中的所有表格 设置文字自适应
  10741. // 获取文档中的所有表格。
  10742. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10743. {
  10744. // 遍历表格中的所有行。
  10745. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10746. {
  10747. foreach (Cell cell in row.Cells)
  10748. {
  10749. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10750. cellFormat.Width = 0;
  10751. }
  10752. }
  10753. }
  10754. #endregion
  10755. #region 设置页眉
  10756. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10757. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10758. if (System.IO.File.Exists(voucherHeaderPath))
  10759. {
  10760. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10761. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10762. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10763. Shape shape = builder.InsertImage(imageBytes);
  10764. // 调整图片位置
  10765. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10766. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10767. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10768. shape.Left = 0; // 将图片距离页面左边缘的距离
  10769. shape.Width = 81; // 设置图片宽度
  10770. shape.Height = 36; // 设置图片高度
  10771. }
  10772. //靠右
  10773. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10774. //// 设置页脚上下边距
  10775. //builder.PageSetup.HeaderDistance = 42;
  10776. // 添加页眉线
  10777. Aspose.Words.Border borderHeader = null;
  10778. try
  10779. {
  10780. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10781. }
  10782. catch (Exception e)
  10783. {
  10784. // TODO Auto-generated catch block
  10785. //e.printStackTrace();
  10786. }
  10787. borderHeader.Shadow = true;
  10788. borderHeader.DistanceFromText = 2;
  10789. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10790. #endregion
  10791. }
  10792. catch (Exception ex)
  10793. {
  10794. }
  10795. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10796. doc.Save(fileDir);
  10797. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10798. return Ok(JsonView(true, "操作成功!", Url));
  10799. }
  10800. /// <summary>
  10801. /// 酒店预订
  10802. /// 生成 预定成本 Excel
  10803. /// </summary>
  10804. /// <param name="_dto"></param>
  10805. /// <returns></returns>
  10806. [HttpPost]
  10807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10808. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10809. {
  10810. #region 参数验证
  10811. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10812. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10813. if (!vadalitorRes.IsValid)
  10814. {
  10815. var errors = new StringBuilder();
  10816. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10817. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10818. }
  10819. #region 团组操作权限验证 76 酒店预定模块
  10820. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10821. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10822. #endregion
  10823. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10824. #region 页面操作权限验证
  10825. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10826. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10827. #endregion
  10828. #endregion
  10829. decimal _rate = 1.00M;
  10830. string _currency = string.Empty;
  10831. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10832. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10833. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10834. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10835. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10836. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  10837. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10838. if (_GroupCostParameter == null)
  10839. {
  10840. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10841. bool isIntType = int.TryParse(_currency, out int currId);
  10842. if (isIntType)
  10843. {
  10844. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10845. }
  10846. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10847. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10848. if (currInfo == null)
  10849. {
  10850. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10851. }
  10852. else _rate = currInfo.Rate;
  10853. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  10854. {
  10855. _rate = _GroupCostParameter.Rate;
  10856. }
  10857. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10858. string strFileName = "HotelStatement/";
  10859. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10860. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10861. var rateDatas = new List<dynamic>();
  10862. #region 数据处理
  10863. foreach (var item in hrDtas)
  10864. {
  10865. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10866. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10867. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10868. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10869. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10870. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  10871. {
  10872. continue;
  10873. }
  10874. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10875. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  10876. string singleRoomFeeStr = string.Empty,
  10877. doubleRoomFeeStr = string.Empty,
  10878. suiteRoomFeeStr = string.Empty,
  10879. otherRoomFeeStr = string.Empty,
  10880. payMoneyStr = string.Empty,
  10881. cardPriceStr = string.Empty;
  10882. if (roomCurr.Equals("CNY"))
  10883. {
  10884. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  10885. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10886. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10887. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10888. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10889. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  10890. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  10891. }
  10892. else
  10893. {
  10894. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10895. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10896. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10897. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10898. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10899. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10900. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10901. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10902. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10903. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10904. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  10905. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  10906. if (ccpPaymentCurrency.Equals("CNY"))
  10907. {
  10908. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  10909. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10910. }
  10911. else
  10912. {
  10913. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  10914. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  10915. }
  10916. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  10917. if (hotelcardPriceCurrency.Equals("CNY"))
  10918. {
  10919. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10920. }
  10921. else
  10922. {
  10923. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  10924. }
  10925. }
  10926. string breakfastPriceStr = string.Empty,
  10927. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10928. governmentRentStr = string.Empty,
  10929. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10930. cityTaxStr = string.Empty,
  10931. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10932. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  10933. if (!string.IsNullOrEmpty(breakfastCurrency1))
  10934. {
  10935. if (breakfastCurrency1.Equals("CNY"))
  10936. {
  10937. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10938. }
  10939. else
  10940. {
  10941. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  10942. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  10943. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  10944. }
  10945. }
  10946. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10947. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  10948. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  10949. {
  10950. if (governmentRentCurrency.Equals("CNY"))
  10951. {
  10952. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10953. }
  10954. else
  10955. {
  10956. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  10957. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  10958. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  10959. }
  10960. }
  10961. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10962. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  10963. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  10964. {
  10965. if (cityTaxStrCurrency1.Equals("CNY"))
  10966. {
  10967. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10968. }
  10969. else
  10970. {
  10971. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  10972. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  10973. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  10974. }
  10975. }
  10976. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10977. int payDId = roomInfo?.PayDId ?? 0;
  10978. pcfds.Add(new HotelReservations_PCFD_View()
  10979. {
  10980. City = item.City,
  10981. HotelName = item.HotelName,
  10982. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10983. // SingleRoomCount = item.SingleRoomCount,
  10984. SingleRoomPrice = singleRoomFeeStr,
  10985. // DoubleRoomCount = item.DoubleRoomCount,
  10986. DoubleRoomPrice = doubleRoomFeeStr,
  10987. //SuiteRoomCount = item.SuiteRoomCount,
  10988. SuiteRoomPrice = suiteRoomFeeStr,
  10989. OtherRoomPrice = otherRoomFeeStr,
  10990. //OtherRoomCount = item.OtherRoomCount,
  10991. BreakfastPrice = breakfastPriceStr,
  10992. GovernmentRent = governmentRentStr,
  10993. CityTax = cityTaxStr,
  10994. RoomExplanation = item.RoomExplanation,
  10995. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10996. PayTime = roomInfo?.ConsumptionDate,
  10997. BankNo = roomInfo?.BankNo,
  10998. PayMoney = payMoneyStr,
  10999. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11000. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11001. CardPrice = cardPriceStr,
  11002. Remark = ccpInfo.Remark
  11003. });
  11004. }
  11005. #endregion
  11006. //载入模板
  11007. WorkbookDesigner designer = new WorkbookDesigner();
  11008. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11009. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11010. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11011. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11012. var rateDatas1 = rateDatas.Distinct();
  11013. var rateStr = string.Empty;
  11014. foreach (var item in rateDatas1)
  11015. {
  11016. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  11017. }
  11018. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  11019. designer.SetDataSource("Opertor", userInfo.CnName);
  11020. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11021. dt.TableName = "ViewMyHotelReservations";
  11022. designer.SetDataSource(dt);
  11023. designer.Process();
  11024. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11025. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11026. designer.Workbook.Save(serverPath);
  11027. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11028. #region 删除指定行
  11029. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11030. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11031. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11032. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11033. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11034. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11035. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11036. cssIndex = dt.Columns["CityTax"].Ordinal,
  11037. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11038. remarkIndex = dt.Columns["Remark"].Ordinal;
  11039. //删除指定列
  11040. foreach (DataRow item in dt.Rows)
  11041. {
  11042. string singleStr = item["SingleRoomPrice"].ToString();
  11043. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11044. if (containsDigitButNotZero1) singleDel = false;
  11045. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11046. string doubleStr = item["DoubleRoomPrice"].ToString();
  11047. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11048. if (containsDigitButNotZero2) doubleDel = false;
  11049. string suiteStr = item["SuiteRoomPrice"].ToString();
  11050. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11051. if (containsDigitButNotZero3) suiteDel = false;
  11052. string otherStr = item["OtherRoomPrice"].ToString();
  11053. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11054. if (containsDigitButNotZero4) otherDel = false;
  11055. string zcStr = item["BreakfastPrice"].ToString();
  11056. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11057. if (containsDigitButNotZero5) zcDel = false;
  11058. string dsStr = item["GovernmentRent"].ToString();
  11059. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11060. if (containsDigitButNotZero6) dsDel = false;
  11061. string cssStr = item["CityTax"].ToString();
  11062. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11063. if (containsDigitButNotZero7) cssDel = false;
  11064. string cpStr = item["ConsumptionPatterns"].ToString();
  11065. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11066. string remarkStr = item["Remark"].ToString();
  11067. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11068. }
  11069. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11070. DeleteColumn(serverPath, cpIndex, cpDel);
  11071. DeleteColumn(serverPath, dsIndex, dsDel);
  11072. DeleteColumn(serverPath, cssIndex, cssDel);
  11073. DeleteColumn(serverPath, zcIndex, zcDel);
  11074. DeleteColumn(serverPath, otherIndex, otherDel);
  11075. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11076. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11077. DeleteColumn(serverPath, singleIndex, singleDel);
  11078. #endregion
  11079. //只保留第一个表格
  11080. DeleteSheet(serverPath);
  11081. return Ok(JsonView(true, "操作成功", url = rst));
  11082. }
  11083. else
  11084. {
  11085. _currency = _GroupCostParameter.Currency;
  11086. bool isIntType = int.TryParse(_currency, out int currId);
  11087. if (isIntType)
  11088. {
  11089. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11090. }
  11091. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11092. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11093. if (currInfo == null)
  11094. {
  11095. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11096. }
  11097. if (!_currency.ToUpper().Equals("CNY"))
  11098. {
  11099. _rate = _GroupCostParameter.Rate;
  11100. }
  11101. _rate = currInfo.Rate;
  11102. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11103. string strFileName = "HotelStatement/";
  11104. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11105. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  11106. #region 数据处理
  11107. foreach (var item in hrDtas)
  11108. {
  11109. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  11110. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  11111. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  11112. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  11113. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  11114. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  11115. string singleRoomFeeStr = string.Empty,
  11116. doubleRoomFeeStr = string.Empty,
  11117. suiteRoomFeeStr = string.Empty,
  11118. otherRoomFeeStr = string.Empty,
  11119. payMoneyStr = string.Empty,
  11120. cardPriceStr = string.Empty;
  11121. if (roomCurr.Equals(_currency))
  11122. {
  11123. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  11124. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  11125. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  11126. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  11127. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  11128. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  11129. }
  11130. else
  11131. {
  11132. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11133. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11134. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11135. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11136. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  11137. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11138. }
  11139. string breakfastPriceStr = string.Empty,
  11140. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11141. governmentRentStr = string.Empty,
  11142. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11143. cityTaxStrStr = string.Empty,
  11144. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11145. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  11146. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  11147. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  11148. int payDId = roomInfo?.PayDId ?? 0;
  11149. pcfds.Add(new HotelReservations_PCFD_View()
  11150. {
  11151. City = item.City,
  11152. HotelName = item.HotelName,
  11153. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11154. // SingleRoomCount = item.SingleRoomCount,
  11155. SingleRoomPrice = singleRoomFeeStr,
  11156. // DoubleRoomCount = item.DoubleRoomCount,
  11157. DoubleRoomPrice = doubleRoomFeeStr,
  11158. //SuiteRoomCount = item.SuiteRoomCount,
  11159. SuiteRoomPrice = suiteRoomFeeStr,
  11160. OtherRoomPrice = otherRoomFeeStr,
  11161. //OtherRoomCount = item.OtherRoomCount,
  11162. BreakfastPrice = breakfastPriceStr,
  11163. GovernmentRent = governmentRentStr,
  11164. CityTax = cityTaxStrStr,
  11165. RoomExplanation = item.RoomExplanation,
  11166. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11167. PayTime = roomInfo?.ConsumptionDate,
  11168. BankNo = roomInfo?.BankNo,
  11169. PayMoney = payMoneyStr,
  11170. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11171. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11172. CardPrice = cardPriceStr,
  11173. Remark = ccpInfo.Remark
  11174. });
  11175. }
  11176. #endregion
  11177. //载入模板
  11178. WorkbookDesigner designer = new WorkbookDesigner();
  11179. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11180. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11181. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11182. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11183. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  11184. designer.SetDataSource("Opertor", userInfo.CnName);
  11185. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11186. dt.TableName = "ViewMyHotelReservations";
  11187. designer.SetDataSource(dt);
  11188. designer.Process();
  11189. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11190. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11191. designer.Workbook.Save(serverPath);
  11192. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11193. #region 删除指定行
  11194. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11195. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11196. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11197. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11198. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11199. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11200. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11201. cssIndex = dt.Columns["CityTax"].Ordinal,
  11202. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11203. remarkIndex = dt.Columns["Remark"].Ordinal;
  11204. //删除指定列
  11205. foreach (DataRow item in dt.Rows)
  11206. {
  11207. string singleStr = item["SingleRoomPrice"].ToString();
  11208. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11209. if (containsDigitButNotZero1) singleDel = false;
  11210. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11211. string doubleStr = item["DoubleRoomPrice"].ToString();
  11212. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11213. if (containsDigitButNotZero2) doubleDel = false;
  11214. string suiteStr = item["SuiteRoomPrice"].ToString();
  11215. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11216. if (containsDigitButNotZero3) suiteDel = false;
  11217. string otherStr = item["OtherRoomPrice"].ToString();
  11218. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11219. if (containsDigitButNotZero4) otherDel = false;
  11220. string zcStr = item["BreakfastPrice"].ToString();
  11221. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11222. if (containsDigitButNotZero5) zcDel = false;
  11223. string dsStr = item["GovernmentRent"].ToString();
  11224. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11225. if (containsDigitButNotZero6) dsDel = false;
  11226. string cssStr = item["CityTax"].ToString();
  11227. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11228. if (containsDigitButNotZero7) cssDel = false;
  11229. string cpStr = item["ConsumptionPatterns"].ToString();
  11230. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11231. string remarkStr = item["Remark"].ToString();
  11232. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11233. }
  11234. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11235. DeleteColumn(serverPath, cpIndex, cpDel);
  11236. DeleteColumn(serverPath, dsIndex, dsDel);
  11237. DeleteColumn(serverPath, cssIndex, cssDel);
  11238. DeleteColumn(serverPath, zcIndex, zcDel);
  11239. DeleteColumn(serverPath, otherIndex, otherDel);
  11240. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11241. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11242. DeleteColumn(serverPath, singleIndex, singleDel);
  11243. #endregion
  11244. //只保留第一个表格
  11245. DeleteSheet(serverPath);
  11246. return Ok(JsonView(true, "操作成功", url = rst));
  11247. }
  11248. return Ok(JsonView(false));
  11249. }
  11250. /// <summary>
  11251. /// 删除指定列
  11252. /// </summary>
  11253. /// <param name="file"></param>
  11254. /// <param name="columnIndex"></param>
  11255. /// <param name="isDel"></param>
  11256. private void DeleteColumn(string file, int columnIndex, bool isDel)
  11257. {
  11258. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11259. //wb.Save(file);
  11260. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  11261. if (sheet1 != null)
  11262. {
  11263. if (isDel)
  11264. {
  11265. Cells cells = sheet1.Cells;
  11266. cells.DeleteColumn(columnIndex);
  11267. }
  11268. }
  11269. wb.Save(file);
  11270. }
  11271. /// <summary>
  11272. /// 删除sheet
  11273. /// </summary>
  11274. /// <param name="file"></param>
  11275. /// <param name="sheetName"></param>
  11276. private void DeleteSheet(string file, string sheetName = "")
  11277. {
  11278. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11279. //wb.Save(file);
  11280. List<string> sheets = new List<string>();
  11281. foreach (var item in wb.Worksheets)
  11282. {
  11283. sheets.Add(item.Name);
  11284. }
  11285. if (sheets.Count > 0)
  11286. {
  11287. sheets.RemoveAt(0);//不删除第一个sheet
  11288. foreach (var item in sheets)
  11289. {
  11290. wb.Worksheets.RemoveAt(item);
  11291. }
  11292. }
  11293. wb.Save(file);
  11294. }
  11295. /// <summary>
  11296. /// 酒店预订
  11297. /// 确认单
  11298. /// </summary>
  11299. /// <param name="_dto"></param>
  11300. /// <returns></returns>
  11301. [HttpPost]
  11302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11303. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  11304. {
  11305. try
  11306. {
  11307. #region 参数验证
  11308. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11309. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11310. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11311. #region 团组操作权限验证 76 酒店预定模块
  11312. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11313. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11314. #endregion
  11315. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11316. #region 页面操作权限验证
  11317. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11318. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11319. #endregion
  11320. #endregion
  11321. //团组信息
  11322. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  11323. //酒店数据
  11324. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  11325. if (listhoteldata.Count < 0)
  11326. {
  11327. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  11328. }
  11329. //利datatable存储
  11330. DataTable dt = new DataTable();
  11331. dt.Columns.Add("CheckInDate", typeof(string));
  11332. dt.Columns.Add("City", typeof(string));
  11333. dt.Columns.Add("Hotel", typeof(string));
  11334. dt.Columns.Add("Room", typeof(string));
  11335. for (int i = 0; i < listhoteldata.Count; i++)
  11336. {
  11337. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  11338. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  11339. while (dayStart < dayEnd)
  11340. {
  11341. string temp = "";
  11342. DataRow row = dt.NewRow();
  11343. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  11344. row["City"] = listhoteldata[i].City;
  11345. row["Hotel"] = listhoteldata[i].HotelName;
  11346. if (listhoteldata[i].SingleRoomCount > 0)
  11347. {
  11348. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  11349. }
  11350. if (listhoteldata[i].DoubleRoomCount > 0)
  11351. {
  11352. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  11353. }
  11354. if (listhoteldata[i].SuiteRoomCount > 0)
  11355. {
  11356. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  11357. }
  11358. if (listhoteldata[i].OtherRoomCount > 0)
  11359. {
  11360. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  11361. }
  11362. row["Room"] = temp;
  11363. dt.Rows.Add(row);
  11364. dayStart = dayStart.AddDays(1);
  11365. }
  11366. }
  11367. Dictionary<string, string> dic = new Dictionary<string, string>();
  11368. dic.Add("Dele", di.TeamName);
  11369. dic.Add("City", di.VisitCountry);
  11370. //模板路径
  11371. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  11372. //载入模板
  11373. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  11374. DocumentBuilder builder = new DocumentBuilder(doc);
  11375. foreach (var key in dic.Keys)
  11376. {
  11377. builder.MoveToBookmark(key);
  11378. builder.Write(dic[key]);
  11379. }
  11380. //获取word里所有表格
  11381. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11382. //获取所填表格的序数
  11383. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11384. var rowStart = tableOne.Rows[0]; //获取第1行
  11385. //循环赋值
  11386. for (int i = 0; i < dt.Rows.Count; i++)
  11387. {
  11388. builder.MoveToCell(0, i + 1, 0, 0);
  11389. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  11390. builder.MoveToCell(0, i + 1, 1, 0);
  11391. builder.Write(dt.Rows[i]["City"].ToString());
  11392. builder.MoveToCell(0, i + 1, 2, 0);
  11393. builder.Write(dt.Rows[i]["Hotel"].ToString());
  11394. builder.MoveToCell(0, i + 1, 3, 0);
  11395. builder.Write(dt.Rows[i]["Room"].ToString());
  11396. }
  11397. //删除多余行
  11398. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  11399. {
  11400. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  11401. }
  11402. string strFileName = di.TeamName + "酒店确认单.doc";
  11403. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  11404. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  11405. return Ok(JsonView(true, "成功", url));
  11406. }
  11407. catch (Exception ex)
  11408. {
  11409. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  11410. }
  11411. }
  11412. #endregion
  11413. #region 团组状态
  11414. /// <summary>
  11415. /// 团组状态列表 Page
  11416. /// </summary>
  11417. /// <param name="dto">团组列表请求dto</param>
  11418. /// <returns></returns>
  11419. [HttpPost]
  11420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11421. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11422. {
  11423. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11424. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11425. {
  11426. string sqlWhere = string.Empty;
  11427. if (dto.IsSure == 0) //未完成
  11428. {
  11429. sqlWhere += string.Format(@" And IsSure = 0");
  11430. }
  11431. else if (dto.IsSure == 1) //已完成
  11432. {
  11433. sqlWhere += string.Format(@" And IsSure = 1");
  11434. }
  11435. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11436. {
  11437. string tj = dto.SearchCriteria;
  11438. 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}%')",
  11439. tj, tj, tj, tj, tj);
  11440. }
  11441. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11442. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11443. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11444. From (
  11445. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11446. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11447. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11448. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11449. From Grp_DelegationInfo gdi
  11450. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11451. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11452. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11453. Where gdi.IsDel = 0 {0}
  11454. ) temp ", sqlWhere);
  11455. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11456. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11457. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11458. }
  11459. else
  11460. {
  11461. return Ok(JsonView(false, "查询失败"));
  11462. }
  11463. }
  11464. /// <summary>
  11465. /// 团组状态
  11466. /// 设置操作完成
  11467. /// </summary>
  11468. /// <param name="dto">团组列表请求dto</param>
  11469. /// <returns></returns>
  11470. [HttpPost]
  11471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11472. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11473. {
  11474. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11475. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11476. {
  11477. Id = dto.Id,
  11478. IsSure = 1
  11479. };
  11480. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11481. .UpdateColumns(it => new { it.IsSure })
  11482. .WhereColumns(it => new { it.Id })
  11483. .ExecuteCommandAsync();
  11484. if (result > 0)
  11485. {
  11486. return Ok(JsonView(true, "操作完成!"));
  11487. }
  11488. return Ok(JsonView(false, "操作失败!"));
  11489. }
  11490. #endregion
  11491. #region 保险费用录入
  11492. /// <summary>
  11493. /// 根据团组Id查询保险费用列表
  11494. /// </summary>
  11495. /// <param name="dto"></param>
  11496. /// <returns></returns>
  11497. [HttpPost]
  11498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11499. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11500. {
  11501. Result groupData = await _customersRep.CustomersByDiId(dto);
  11502. if (groupData.Code != 0)
  11503. {
  11504. return Ok(JsonView(false, groupData.Msg));
  11505. }
  11506. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11507. }
  11508. /// <summary>
  11509. /// 根据保险费用Id查询保险费用详细
  11510. /// </summary>
  11511. /// <param name="dto"></param>
  11512. /// <returns></returns>
  11513. [HttpPost]
  11514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11515. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11516. {
  11517. try
  11518. {
  11519. Result groupData = await _customersRep.CustomersById(dto);
  11520. if (groupData.Code != 0)
  11521. {
  11522. return Ok(JsonView(false, groupData.Msg));
  11523. }
  11524. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11525. }
  11526. catch (Exception ex)
  11527. {
  11528. return Ok(JsonView(false, ex.Message));
  11529. }
  11530. }
  11531. /// <summary>
  11532. /// 保险费用录入页面初始化绑定
  11533. /// </summary>
  11534. /// <param name="dto"></param>
  11535. /// <returns></returns>
  11536. [HttpPost]
  11537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11538. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11539. {
  11540. try
  11541. {
  11542. Result groupData = await _customersRep.CustomersInitialize(dto);
  11543. if (groupData.Code != 0)
  11544. {
  11545. return Ok(JsonView(false, groupData.Msg));
  11546. }
  11547. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11548. }
  11549. catch (Exception ex)
  11550. {
  11551. return Ok(JsonView(false, ex.Message));
  11552. }
  11553. }
  11554. /// <summary>
  11555. /// 保险费用操作(Status:1.新增,2.修改)
  11556. /// </summary>
  11557. /// <param name="dto"></param>
  11558. /// <returns></returns>
  11559. [HttpPost]
  11560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11561. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11562. {
  11563. Result groupData = await _customersRep.OpCustomers(dto);
  11564. if (groupData.Code != 0)
  11565. {
  11566. return Ok(JsonView(false, groupData.Msg));
  11567. }
  11568. #region 应用推送
  11569. try
  11570. {
  11571. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11572. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11573. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11574. //2024-10-21 新增LZ UID
  11575. var userIds = new List<int>() { 21 };
  11576. string title = $"系统通知";
  11577. var diId = dto.DiId;
  11578. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11579. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11580. string content = "";
  11581. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11582. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11583. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11584. await APNsTools.iOS_PushNotifications1("051", $"保险费用审核", "", content);
  11585. }
  11586. catch (Exception ex)
  11587. {
  11588. }
  11589. #endregion
  11590. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11591. }
  11592. /// <summary>
  11593. /// 保险文件上传
  11594. /// </summary>
  11595. /// <param name="file"></param>
  11596. /// <returns></returns>
  11597. [HttpPost]
  11598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11599. public async Task<IActionResult> UploadCus(IFormFile file)
  11600. {
  11601. try
  11602. {
  11603. if (file != null)
  11604. {
  11605. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11606. //文件名称
  11607. string projectFileName = file.FileName;
  11608. //上传的文件的路径
  11609. string filePath = "";
  11610. if (!Directory.Exists(fileDir))
  11611. {
  11612. Directory.CreateDirectory(fileDir);
  11613. }
  11614. //上传的文件的路径
  11615. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11616. using (FileStream fs = System.IO.File.Create(filePath))
  11617. {
  11618. file.CopyTo(fs);
  11619. fs.Flush();
  11620. }
  11621. return Ok(JsonView(true, "上传成功!", projectFileName));
  11622. }
  11623. else
  11624. {
  11625. return Ok(JsonView(false, "上传失败!"));
  11626. }
  11627. }
  11628. catch (Exception ex)
  11629. {
  11630. return Ok(JsonView(false, "程序错误!"));
  11631. throw;
  11632. }
  11633. }
  11634. /// <summary>
  11635. /// 保险删除指定文件
  11636. /// </summary>
  11637. /// <param name="dto"></param>
  11638. /// <returns></returns>
  11639. [HttpPost]
  11640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11641. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11642. {
  11643. try
  11644. {
  11645. string filePath = "";
  11646. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11647. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11648. //int id = 0;
  11649. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11650. // 删除该文件
  11651. try
  11652. {
  11653. System.IO.File.Delete(filePath);
  11654. 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()
  11655. {
  11656. Attachment = "",
  11657. }).ExecuteCommandAsync();
  11658. if (result != 0)
  11659. {
  11660. return Ok(JsonView(true, "成功!"));
  11661. }
  11662. else
  11663. {
  11664. return Ok(JsonView(false, "失败!"));
  11665. }
  11666. }
  11667. catch (Exception)
  11668. {
  11669. 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()
  11670. {
  11671. Attachment = "",
  11672. }).ExecuteCommandAsync();
  11673. if (result != 0)
  11674. {
  11675. return Ok(JsonView(true, "成功!"));
  11676. }
  11677. else
  11678. {
  11679. return Ok(JsonView(false, "失败!"));
  11680. }
  11681. }
  11682. }
  11683. catch (Exception ex)
  11684. {
  11685. return Ok(JsonView(false, "程序错误!"));
  11686. throw;
  11687. }
  11688. }
  11689. /// <summary>
  11690. /// 保险费用操作(删除)
  11691. /// </summary>
  11692. /// <param name="dto"></param>
  11693. /// <returns></returns>
  11694. [HttpPost]
  11695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11696. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11697. {
  11698. try
  11699. {
  11700. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11701. if (!res)
  11702. {
  11703. return Ok(JsonView(false, "删除失败"));
  11704. }
  11705. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11706. {
  11707. IsDel = 1,
  11708. DeleteUserId = dto.DeleteUserId,
  11709. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11710. }).ExecuteCommandAsync();
  11711. return Ok(JsonView(true, "删除成功!"));
  11712. }
  11713. catch (Exception ex)
  11714. {
  11715. return Ok(JsonView(false, "程序错误!"));
  11716. throw;
  11717. }
  11718. }
  11719. #endregion
  11720. #region 接团客户名单 PageId 104
  11721. /// <summary>
  11722. /// 接团客户名单
  11723. /// 迁移数据(慎用!)
  11724. /// </summary>
  11725. /// <param name="dto"></param>
  11726. /// <returns></returns>
  11727. [HttpPost]
  11728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11729. public async Task<IActionResult> PostTourClientListChange()
  11730. {
  11731. try
  11732. {
  11733. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11734. //var groupClinetData1
  11735. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11736. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11737. int updateCount = 0;
  11738. if (oldOAClientList.Count > 0)
  11739. {
  11740. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11741. _sqlSugar.BeginTran();
  11742. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11743. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11744. foreach (var item in oldOAClientList)
  11745. {
  11746. int comId = 0;
  11747. string format = "yyyy-MM-dd HH:mm:ss";
  11748. string data11 = "1990-01-01 00:00";
  11749. var data1 = IsValidDate(item.OPdate, format);
  11750. if (data1) data11 = item.OPdate;
  11751. //客户公司验证
  11752. if (!string.IsNullOrEmpty(item.Company))
  11753. {
  11754. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11755. if (clientComInfo == null) // add
  11756. {
  11757. var addInfo = new Crm_CustomerCompany()
  11758. {
  11759. CompanyAbbreviation = "",
  11760. CompanyFullName = item.Company,
  11761. Address = "",
  11762. PostCodes = "",
  11763. LastedOpUserId = item.OPer,
  11764. LastedOpDt = Convert.ToDateTime(data11),
  11765. CreateUserId = item.OPer,
  11766. CreateTime = Convert.ToDateTime(data11),
  11767. IsDel = 0
  11768. };
  11769. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11770. if (comId1 > 0) comId = comId1;
  11771. }
  11772. else comId = clientComInfo.Id;
  11773. }
  11774. //客户人员验证
  11775. int clientId = 0;
  11776. string name = item.LastName + item.Name;
  11777. if (!string.IsNullOrEmpty(name))
  11778. {
  11779. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11780. if (clientInfo == null)
  11781. {
  11782. DateTime? dateTime = null;
  11783. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11784. if (isDt) dateTime = birthDayDt;
  11785. var addInfo1 = new Crm_DeleClient()
  11786. {
  11787. CrmCompanyId = comId,
  11788. DiId = -1,
  11789. LastName = item.LastName,
  11790. FirstName = item.Name,
  11791. OldName = "",
  11792. Pinyin = item.Pinyin,
  11793. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11794. Marriage = 0,
  11795. Phone = item.Phone,
  11796. Job = item.Job,
  11797. BirthDay = dateTime
  11798. };
  11799. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11800. if (clientId1 > 0) clientId = clientId1;
  11801. }
  11802. else clientId = clientInfo.Id;
  11803. }
  11804. if (clientId < 1)
  11805. {
  11806. continue;
  11807. }
  11808. int airType = 0;
  11809. if (item.AirType == "超经舱") airType = 459;
  11810. else if (item.AirType == "公务舱") airType = 458;
  11811. else if (item.AirType == "经济舱") airType = 460;
  11812. else if (item.AirType == "其他") airType = 565;
  11813. else if (item.AirType == "头等舱") airType = 457;
  11814. var _TourClientListEntity = new Grp_TourClientList()
  11815. {
  11816. DiId = item.Diid,
  11817. ClientId = clientId,
  11818. CreateUserId = item.OPer,
  11819. CreateTime = Convert.ToDateTime(data11),
  11820. Remark = item.Remark,
  11821. IsDel = item.Isdel,
  11822. ShippingSpaceTypeId = airType,
  11823. ShippingSpaceSpecialNeeds = item.AirRemark,
  11824. HotelSpecialNeeds = item.RoomType
  11825. };
  11826. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11827. if (_TourClientList > 0)
  11828. {
  11829. updateCount++;
  11830. }
  11831. }
  11832. _sqlSugar.CommitTran();
  11833. }
  11834. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11835. }
  11836. catch (Exception ex)
  11837. {
  11838. _sqlSugar.RollbackTran();
  11839. return Ok(JsonView(false, ex.Message));
  11840. }
  11841. return Ok(JsonView(true));
  11842. }
  11843. private bool IsValidDate(string dateString, string format)
  11844. {
  11845. DateTime dateValue;
  11846. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11847. return valid;
  11848. }
  11849. /// <summary>
  11850. /// 接团客户名单
  11851. /// 根据团组Id查询List
  11852. /// </summary>
  11853. /// <param name="dto"></param>
  11854. /// <returns></returns>
  11855. [HttpPost]
  11856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11857. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11858. {
  11859. #region 参数验证
  11860. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11861. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11862. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11863. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11864. #region 页面操作权限验证
  11865. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11866. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11867. #endregion
  11868. #endregion
  11869. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11870. if (viewData.Code != 0)
  11871. {
  11872. return Ok(JsonView(false, viewData.Msg));
  11873. }
  11874. return Ok(JsonView(viewData.Data));
  11875. }
  11876. /// <summary>
  11877. /// 接团客户名单
  11878. /// 基础数据 Init
  11879. /// </summary>
  11880. /// <param name="_dto"></param>
  11881. /// <returns></returns>
  11882. [HttpPost]
  11883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11884. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11885. {
  11886. #region 参数验证
  11887. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11888. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11889. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11890. #region 页面操作权限验证
  11891. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11892. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11893. #endregion
  11894. #endregion
  11895. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11896. }
  11897. /// <summary>
  11898. /// 接团客户名单
  11899. /// 根据 Id查询 Details
  11900. /// </summary>
  11901. /// <param name="_dto"></param>
  11902. /// <returns></returns>
  11903. [HttpPost]
  11904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11905. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11906. {
  11907. #region 参数验证
  11908. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11909. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11910. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11911. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11912. #region 页面操作权限验证
  11913. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11914. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11915. #endregion
  11916. #endregion
  11917. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11918. if (viewData.Code != 0)
  11919. {
  11920. return Ok(JsonView(false, viewData.Msg));
  11921. }
  11922. return Ok(JsonView(viewData.Data));
  11923. }
  11924. /// <summary>
  11925. /// 接团客户名单
  11926. /// Add Or Edit
  11927. /// </summary>
  11928. /// <param name="_dto"></param>
  11929. /// <returns></returns>
  11930. [HttpPost]
  11931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11932. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11933. {
  11934. #region 参数验证
  11935. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11936. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11937. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11938. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11939. #region 页面操作权限验证
  11940. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11941. if (_dto.Id == 0) //添加
  11942. {
  11943. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11944. }
  11945. else if (_dto.Id >= 0) //修改
  11946. {
  11947. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11948. }
  11949. #endregion
  11950. #endregion
  11951. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11952. if (viewData.Code != 0)
  11953. {
  11954. return Ok(JsonView(false, viewData.Msg));
  11955. }
  11956. return Ok(JsonView(true));
  11957. }
  11958. /// <summary>
  11959. /// 接团客户名单
  11960. /// AddMultiple(添加多个)
  11961. /// </summary>
  11962. /// <param name="_dto"></param>
  11963. /// <returns></returns>
  11964. [HttpPost]
  11965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11966. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11967. {
  11968. #region 参数验证
  11969. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11970. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11971. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11972. #region 页面操作权限验证
  11973. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11974. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11975. #endregion
  11976. #endregion
  11977. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11978. if (viewData.Code != 0)
  11979. {
  11980. return Ok(JsonView(false, viewData.Msg));
  11981. }
  11982. return Ok(JsonView(true));
  11983. }
  11984. /// <summary>
  11985. /// 接团客户名单
  11986. /// Del
  11987. /// </summary>
  11988. /// <param name="_dto"></param>
  11989. /// <returns></returns>
  11990. [HttpPost]
  11991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11992. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11993. {
  11994. #region 参数验证
  11995. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11996. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11997. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11998. #region 页面操作权限验证
  11999. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12000. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12001. #endregion
  12002. #endregion
  12003. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  12004. if (viewData.Code != 0)
  12005. {
  12006. return Ok(JsonView(false, viewData.Msg));
  12007. }
  12008. return Ok(JsonView(true));
  12009. }
  12010. /// <summary>
  12011. /// 接团客户名单
  12012. /// 文件下载 客户名单
  12013. /// </summary>
  12014. /// <param name="_dto"></param>
  12015. /// <returns></returns>
  12016. [HttpPost]
  12017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12018. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  12019. {
  12020. #region 参数验证
  12021. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12022. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12023. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  12024. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12025. #region 页面操作权限验证
  12026. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12027. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12028. #endregion
  12029. #endregion
  12030. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  12031. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  12032. From Grp_TourClientList tcl
  12033. Left Join
  12034. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  12035. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  12036. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  12037. From Crm_DeleClient dc
  12038. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  12039. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  12040. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  12041. Where dc.IsDel = 0) temp
  12042. On temp.DcId =tcl.ClientId
  12043. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  12044. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  12045. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  12046. //载入模板
  12047. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  12048. if (_dto.Language == 1)
  12049. {
  12050. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  12051. }
  12052. //载入模板
  12053. var doc = new Document(tempPath);
  12054. DocumentBuilder builder = new DocumentBuilder(doc);
  12055. //获取word里所有表格
  12056. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12057. //获取所填表格的序数
  12058. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12059. var rowStart = tableOne.Rows[0]; //获取第1行
  12060. if (_dto.Language == 0)
  12061. {
  12062. //循环赋值
  12063. for (int i = 0; i < DcList.Count; i++)
  12064. {
  12065. builder.MoveToCell(0, i + 1, 0, 0);
  12066. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  12067. builder.MoveToCell(0, i + 1, 1, 0);
  12068. int sex = DcList[i].Sex;
  12069. string sexStr = string.Empty;
  12070. if (sex == 0) sexStr = "男";
  12071. else if (sex == 1) sexStr = "女";
  12072. else sexStr = "未设置";
  12073. builder.Write(sexStr);
  12074. builder.MoveToCell(0, i + 1, 2, 0);
  12075. string birthDay = DcList[i].BirthDay;
  12076. string birthDayStr = string.Empty;
  12077. if (!string.IsNullOrEmpty(birthDay))
  12078. {
  12079. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  12080. }
  12081. builder.Write(birthDayStr);
  12082. builder.MoveToCell(0, i + 1, 3, 0);
  12083. string company = "";
  12084. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12085. {
  12086. company = DcList[i].CompanyFullName.ToString();
  12087. }
  12088. builder.Write(company);
  12089. builder.MoveToCell(0, i + 1, 4, 0);
  12090. builder.Write(DcList[i].Job);
  12091. }
  12092. }
  12093. else if (_dto.Language == 1)
  12094. {
  12095. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  12096. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  12097. List<string> transArrayStr = new List<string>();
  12098. string transStrRes1 = "";
  12099. for (int i = 0; i < DcList.Count; i++)
  12100. {
  12101. var dc = DcList[i];
  12102. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  12103. if (dc.Job.Equals("暂无")) dc.Job = "-";
  12104. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  12105. if (DcList.Count - 1 == i) transStrRes1 += str1;
  12106. else transStrRes1 += $"{str1}|";
  12107. }
  12108. //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";
  12109. string transStrRes = "";
  12110. if (transStrRes1.Length > 0)
  12111. {
  12112. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  12113. }
  12114. //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
  12115. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  12116. //List<string> transArray = new List<string> { };
  12117. List<TranslateInfo> transArray = new List<TranslateInfo>();
  12118. if (transStrRes.Contains("|"))
  12119. {
  12120. string[] transArray1 = transStrRes.Split('|');
  12121. if (transArray1.Length > 0)
  12122. {
  12123. foreach (var item in transArray1)
  12124. {
  12125. if (item.Contains("&"))
  12126. {
  12127. string[] transArray2 = item.Split('&');
  12128. int index = 0;
  12129. string companyName = "", job = "";
  12130. if (transArray2.Length > 0)
  12131. {
  12132. bool success = int.TryParse(transArray2[0].Trim(), out index);
  12133. if (1 < transArray2.Length) companyName = transArray2[1];
  12134. if (2 < transArray2.Length) job = transArray2[2];
  12135. }
  12136. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  12137. }
  12138. }
  12139. }
  12140. }
  12141. //循环赋值
  12142. for (int i = 0; i < DcList.Count; i++)
  12143. {
  12144. string PYName = "";
  12145. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  12146. {
  12147. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  12148. string PY_First = DcList[i].Pinyin.Split('/')[1];
  12149. PYName = PY_First + " " + PY_Last;
  12150. }
  12151. else
  12152. {
  12153. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  12154. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  12155. PYName = PY_First + " " + PY_Last;
  12156. }
  12157. builder.MoveToCell(0, i + 1, 0, 0);
  12158. builder.Write(PYName);
  12159. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  12160. builder.MoveToCell(0, i + 1, 1, 0);
  12161. builder.Write(sex);
  12162. DateTime birthDt;
  12163. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  12164. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  12165. builder.MoveToCell(0, i + 1, 2, 0);
  12166. builder.Write(birthday);
  12167. string company = string.Empty, job = string.Empty;
  12168. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  12169. if (dcTransInfo != null)
  12170. {
  12171. company = dcTransInfo.CompanyName;
  12172. job = dcTransInfo.Job;
  12173. }
  12174. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12175. {
  12176. //查询对照表
  12177. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  12178. if (tempCec != null)
  12179. {
  12180. company = tempCec.enName;
  12181. }
  12182. //翻译
  12183. else
  12184. {
  12185. }
  12186. }
  12187. builder.MoveToCell(0, i + 1, 3, 0);
  12188. builder.Write(company);
  12189. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  12190. {
  12191. //查询对照表
  12192. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  12193. if (tempPec != null)
  12194. {
  12195. job = tempPec.enName;
  12196. }
  12197. //翻译
  12198. else
  12199. {
  12200. }
  12201. }
  12202. builder.MoveToCell(0, i + 1, 4, 0);
  12203. builder.Write(job);
  12204. }
  12205. }
  12206. //删除多余行
  12207. while (tableOne.Rows.Count > DcList.Count + 1)
  12208. {
  12209. tableOne.Rows.RemoveAt(DcList.Count + 1);
  12210. }
  12211. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  12212. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  12213. doc.Save(fileDir);
  12214. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  12215. return Ok(JsonView(true, "操作成功!", Url));
  12216. }
  12217. private class TranslateInfo
  12218. {
  12219. public int Index { get; set; }
  12220. public string CompanyName { get; set; }
  12221. public string Job { get; set; }
  12222. }
  12223. #endregion
  12224. #region 团组倒推表
  12225. /// <summary>
  12226. /// 倒推表基础数据
  12227. /// Init
  12228. /// </summary>
  12229. /// <param name="dto"></param>
  12230. /// <returns></returns>
  12231. [HttpPost]
  12232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12233. public async Task<IActionResult> PostInvertedListInit()
  12234. {
  12235. var viewData = await _invertedListRep._Init();
  12236. if (viewData.Code != 0)
  12237. {
  12238. return Ok(JsonView(false, viewData.Msg));
  12239. }
  12240. return Ok(JsonView(viewData.Data));
  12241. }
  12242. /// <summary>
  12243. /// 倒推表
  12244. /// Info
  12245. /// </summary>
  12246. /// <param name="dto"></param>
  12247. /// <returns></returns>
  12248. [HttpPost]
  12249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12250. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  12251. {
  12252. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  12253. if (viewData.Code != 0)
  12254. {
  12255. return Ok(JsonView(false, viewData.Msg));
  12256. }
  12257. return Ok(JsonView(viewData.Data));
  12258. }
  12259. /// <summary>
  12260. /// 倒推表
  12261. /// Create
  12262. /// </summary>
  12263. /// <param name="dto"></param>
  12264. /// <returns></returns>
  12265. [HttpPost]
  12266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12267. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  12268. {
  12269. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  12270. if (viewData.Code != 0)
  12271. {
  12272. return Ok(JsonView(false, viewData.Msg));
  12273. }
  12274. return Ok(JsonView(viewData.Data));
  12275. }
  12276. /// <summary>
  12277. /// 倒推表
  12278. /// Update
  12279. /// </summary>
  12280. /// <param name="dto"></param>
  12281. /// <returns></returns>
  12282. [HttpPost]
  12283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12284. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  12285. {
  12286. var viewData = await _invertedListRep._Update(dto);
  12287. if (viewData.Code != 0)
  12288. {
  12289. return Ok(JsonView(false, viewData.Msg));
  12290. }
  12291. return Ok(JsonView(viewData.Data));
  12292. }
  12293. /// <summary>
  12294. /// 倒推表
  12295. /// File Download
  12296. /// </summary>
  12297. /// <param name="dto"></param>
  12298. /// <returns></returns>
  12299. [HttpPost]
  12300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12301. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  12302. {
  12303. var info2 = await _invertedListRep._Info(1, dto.DiId);
  12304. if (info2.Code != 0)
  12305. {
  12306. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  12307. }
  12308. var info1 = info2.Data as InvertedListInfoView;
  12309. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  12310. string teamName = "";
  12311. if (info != null) teamName = info.TeamName;
  12312. //载入模板
  12313. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  12314. DocumentBuilder builder = new DocumentBuilder(doc);
  12315. //利用键值对存放数据
  12316. Dictionary<string, string> dic = new Dictionary<string, string>();
  12317. dic.Add("TeamName", teamName);
  12318. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  12319. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  12320. dic.Add("BPRemark", info1.ApprovalDataRemark);
  12321. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  12322. dic.Add("SQRemark", info1.ApprovalRemark);
  12323. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  12324. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  12325. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  12326. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  12327. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  12328. dic.Add("QZRemark", info1.VisaInformationRemark);
  12329. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  12330. dic.Add("SQQZRemark", info1.SendVisaRemark);
  12331. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  12332. dic.Add("CQRemark", info1.IssueVisaRemark);
  12333. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  12334. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  12335. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  12336. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  12337. #region 填充word模板书签内容
  12338. foreach (var key in dic.Keys)
  12339. {
  12340. builder.MoveToBookmark(key);
  12341. builder.Write(dic[key]);
  12342. }
  12343. #endregion
  12344. var fileDir = AppSettingsHelper.Get("WordBasePath");
  12345. string fileName = $"{teamName}团出行准备流程表.doc";
  12346. string filePath = fileDir + $@"InvertedList/{fileName}";
  12347. doc.Save(filePath);
  12348. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  12349. return Ok(JsonView(true, "操作成功!", Url));
  12350. }
  12351. #endregion
  12352. #region 三公签证费用(签证费、代办费)
  12353. /// <summary>
  12354. /// 三公签证费用(签证费、代办费)
  12355. /// List
  12356. /// </summary>
  12357. /// <returns></returns>
  12358. [HttpPost]
  12359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12360. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  12361. {
  12362. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  12363. if (_view.Code != 0)
  12364. {
  12365. return Ok(JsonView(false, _view.Msg));
  12366. }
  12367. return Ok(JsonView(true, "操作成功!", _view.Data));
  12368. }
  12369. /// <summary>
  12370. /// 三公签证费用(签证费、代办费)
  12371. /// Add Or Update
  12372. /// </summary>
  12373. /// <returns></returns>
  12374. [HttpPost]
  12375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12376. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  12377. {
  12378. var _view = await _visaFeeInfoRep._Update(_dto);
  12379. if (_view.Code != 0)
  12380. {
  12381. return Ok(JsonView(false, _view.Msg));
  12382. }
  12383. return Ok(JsonView(true, _view.Msg));
  12384. }
  12385. #endregion
  12386. #region 酒店询价
  12387. /// <summary>
  12388. /// 酒店询价
  12389. /// Init
  12390. /// </summary>
  12391. /// <param name="dto"></param>
  12392. /// <returns></returns>
  12393. [HttpPost]
  12394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12395. public async Task<IActionResult> PostHotelInquiryInit()
  12396. {
  12397. var res = await _hotelInquiryRep._Init();
  12398. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12399. return Ok(JsonView(true, res.Msg, res.Data));
  12400. }
  12401. /// <summary>
  12402. /// 酒店询价
  12403. /// page Item
  12404. /// </summary>
  12405. /// <param name="_dto"></param>
  12406. /// <returns></returns>
  12407. [HttpPost]
  12408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12409. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  12410. {
  12411. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  12412. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12413. var view = res.Data as PageDataViewBase;
  12414. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  12415. }
  12416. /// <summary>
  12417. /// 酒店询价
  12418. /// info
  12419. /// </summary>
  12420. /// <param name="_dto"></param>
  12421. /// <returns></returns>
  12422. [HttpPost]
  12423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12424. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12425. {
  12426. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12427. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12428. return Ok(JsonView(true, res.Msg, res.Data));
  12429. }
  12430. /// <summary>
  12431. /// 酒店询价
  12432. /// Add Or Edit
  12433. /// </summary>
  12434. /// <param name="_dto"></param>
  12435. /// <returns></returns>
  12436. [HttpPost]
  12437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12438. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12439. {
  12440. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12441. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12442. return Ok(JsonView(true, res.Msg, res.Data));
  12443. }
  12444. /// <summary>
  12445. /// 酒店询价
  12446. /// Del
  12447. /// </summary>
  12448. /// <param name="_dto"></param>
  12449. /// <returns></returns>
  12450. [HttpPost]
  12451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12452. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12453. {
  12454. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12455. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12456. return Ok(JsonView(true, res.Msg, res.Data));
  12457. }
  12458. #endregion
  12459. #region 下载匹配op行程单
  12460. /// <summary>
  12461. /// 匹配op行程单
  12462. /// Init
  12463. /// </summary>
  12464. /// <param name="dto">团组列表请求dto</param>
  12465. /// <returns></returns>
  12466. [HttpPost]
  12467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12468. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12469. {
  12470. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12471. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12472. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12473. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12474. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12475. .Where(it => it.IsDel == 0)
  12476. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12477. .OrderByDescending(it => it.CreateUserId)
  12478. .ToList();
  12479. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12480. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12481. var diids = groupInfos.Select(it => it.Id).ToList();
  12482. List<string> countrys = new List<string>();
  12483. foreach (var item in country)
  12484. {
  12485. var data = _groupRepository.FormartTeamName(item);
  12486. var dataArray = _groupRepository.GroupSplitCountry(data);
  12487. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12488. }
  12489. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12490. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12491. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12492. foreach (var item in areaItem)
  12493. {
  12494. string areaStr = item.Value;
  12495. if (!string.IsNullOrEmpty(areaStr))
  12496. {
  12497. string[] str1 = areaStr.Split("-");
  12498. if (str1.Length > 0)
  12499. {
  12500. areaArray.AddRange(str1);
  12501. }
  12502. }
  12503. }
  12504. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12505. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12506. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12507. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12508. .ToList();
  12509. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12510. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12511. .Where(it => countriesIds.Contains(it.Id))
  12512. .Select(it => new { it.Id, Name = it.Name_CN })
  12513. .ToList();
  12514. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12515. .Select(it => it.TeamName).ToList();
  12516. stopwatch.Stop();
  12517. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12518. }
  12519. ///// <summary>
  12520. ///// 匹配op行程单
  12521. ///// Init 查询区域数据
  12522. ///// </summary>
  12523. ///// <param name="dto">团组列表请求dto</param>
  12524. ///// <returns></returns>
  12525. //[HttpPost]
  12526. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12527. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12528. //{
  12529. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12530. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12531. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12532. // if (string.IsNullOrEmpty(countriesDataStr))
  12533. // {
  12534. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12535. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12536. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12537. // }
  12538. // else
  12539. // {
  12540. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12541. // }
  12542. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12543. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12544. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12545. // List<dynamic> childList = new List<dynamic>();
  12546. // int parentId = dto.CountriesId;
  12547. // if (provinceData.Count > 1)
  12548. // {
  12549. // foreach (var item1 in provinceData)
  12550. // {
  12551. // List<dynamic> childList1 = new List<dynamic>();
  12552. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12553. // foreach (var item2 in citiesData1)
  12554. // {
  12555. // List<dynamic> childList2 = new List<dynamic>();
  12556. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12557. // foreach (var item3 in countiesData1)
  12558. // {
  12559. // childList2.Add(new
  12560. // {
  12561. // id = item3.Id,
  12562. // parentId = item2.Id,
  12563. // level = "district",
  12564. // name = item3.Name_CN,
  12565. // });
  12566. // }
  12567. // childList1.Add(new
  12568. // {
  12569. // id = item2.Id,
  12570. // parentId = item1.Id,
  12571. // level = "city",
  12572. // name = item2.Name_CN,
  12573. // childList = childList2
  12574. // });
  12575. // }
  12576. // childList.Add(new
  12577. // {
  12578. // id = item1.Id,
  12579. // parentId = parentId,
  12580. // level = "province",
  12581. // name = item1.Name_CN,
  12582. // childList = childList1
  12583. // });
  12584. // }
  12585. // //城市
  12586. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12587. // foreach (var item2 in citiesData2)
  12588. // {
  12589. // List<dynamic> childList22 = new List<dynamic>();
  12590. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12591. // foreach (var item3 in countiesData1)
  12592. // {
  12593. // childList22.Add(new
  12594. // {
  12595. // id = item3.Id,
  12596. // parentId = item2.Id,
  12597. // level = "district",
  12598. // name = item3.Name_CN,
  12599. // });
  12600. // }
  12601. // childList.Add(new
  12602. // {
  12603. // id = item2.Id,
  12604. // parentId = parentId,
  12605. // level = "city",
  12606. // name = item2.Name_CN,
  12607. // childList = childList22
  12608. // });
  12609. // }
  12610. // }
  12611. // else
  12612. // {
  12613. // foreach (var item2 in citiesData)
  12614. // {
  12615. // string cname = item2.Name_CN;
  12616. // List<dynamic> childList1 = new List<dynamic>();
  12617. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12618. // foreach (var item3 in countiesData1)
  12619. // {
  12620. // childList1.Add(new
  12621. // {
  12622. // Id = item3.Id,
  12623. // parentId = item2.Id,
  12624. // level = "district",
  12625. // name = item3.Name_CN
  12626. // });
  12627. // }
  12628. // childList.Add(new
  12629. // {
  12630. // id = item2.Id,
  12631. // parentId = parentId,
  12632. // level = "city",
  12633. // name = item2.Name_CN,
  12634. // childList = childList1
  12635. // });
  12636. // }
  12637. // }
  12638. // stopwatch.Stop();
  12639. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12640. //}
  12641. /// <summary>
  12642. /// 匹配op行程单
  12643. /// 接团信息列表 Page
  12644. /// </summary>
  12645. /// <param name="dto">团组列表请求dto</param>
  12646. /// <returns></returns>
  12647. [HttpPost]
  12648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12649. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12650. {
  12651. var swatch = new Stopwatch();
  12652. swatch.Start();
  12653. #region 参数验证
  12654. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12655. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12656. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12657. #region 页面操作权限验证
  12658. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12659. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12660. #endregion
  12661. #endregion
  12662. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12663. {
  12664. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12665. string sqlWhere = "";
  12666. if (!string.IsNullOrEmpty(dto.Country))
  12667. {
  12668. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12669. }
  12670. if (!string.IsNullOrEmpty(dto.Area))
  12671. {
  12672. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12673. }
  12674. if (!string.IsNullOrEmpty(dto.TeamName))
  12675. {
  12676. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12677. }
  12678. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12679. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12680. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12681. swatch.Stop();
  12682. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12683. }
  12684. else
  12685. {
  12686. return Ok(JsonView(false, "查询失败"));
  12687. }
  12688. }
  12689. /// <summary>
  12690. /// 匹配op行程单
  12691. /// 行程单下载
  12692. /// </summary>
  12693. /// <param name="dto">团组列表请求dto</param>
  12694. /// <returns></returns>
  12695. [HttpPost]
  12696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12697. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12698. {
  12699. #region 参数验证
  12700. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12701. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12702. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12703. #region 页面操作权限验证
  12704. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12705. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12706. #endregion
  12707. #endregion
  12708. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12709. {
  12710. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12711. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12712. }
  12713. else
  12714. {
  12715. return Ok(JsonView(false, "下载失败!"));
  12716. }
  12717. }
  12718. #endregion
  12719. #region 国家信息 数据 注释
  12720. //[HttpPost]
  12721. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12722. //{
  12723. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12724. // foreach (var item in dto)
  12725. // {
  12726. // infos.Add(new Grp_GroupsTaskAssignment()
  12727. // {
  12728. // DIId = item,
  12729. // CTId = 82,
  12730. // UId = 248,
  12731. // IsEnable = 1,
  12732. // CreateUserId = 233,
  12733. // CreateTime = DateTime.Now,
  12734. // IsDel = 0
  12735. // });
  12736. // infos.Add(new Grp_GroupsTaskAssignment()
  12737. // {
  12738. // DIId = item,
  12739. // CTId = 82,
  12740. // UId = 286,
  12741. // IsEnable = 1,
  12742. // CreateUserId = 233,
  12743. // CreateTime = DateTime.Now,
  12744. // IsDel = 0
  12745. // });
  12746. // }
  12747. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12748. // return Ok("操作成功");
  12749. //}
  12750. //public class paramJsonDto
  12751. //{
  12752. // public List<CountriesInfo> str { get; set; }
  12753. //}
  12754. //[HttpPost]
  12755. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12756. //{
  12757. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12758. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12759. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12760. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12761. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12762. // _sqlSugar.BeginTran();
  12763. // int countitiesIndex = 0;
  12764. // foreach (var item in dto.str)
  12765. // {
  12766. // dynamic data = item.c;
  12767. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12768. // if (data != null)
  12769. // {
  12770. // countitiesIndex++;
  12771. // foreach (var item1 in data)
  12772. // {
  12773. // string cnname = item1.cn;
  12774. // string enname = item1.en;
  12775. // Sys_Cities provinceInfo = new Sys_Cities()
  12776. // {
  12777. // CountriesId = countriesId,
  12778. // Name_CN = cnname,
  12779. // Name_EN = enname,
  12780. // ParentId = 0,
  12781. // IsCapital = 1,
  12782. // CreateUserId = 208,
  12783. // CreateTime = DateTime.Now,
  12784. // IsDel = 0
  12785. // };
  12786. // if (item1.lv == "province") //省份
  12787. // {
  12788. // provinceInfo.Level = 1;
  12789. // int provinceId = 0;
  12790. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12791. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12792. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12793. // var data1 = item1.c;
  12794. // foreach (var item2 in data1)
  12795. // {
  12796. // if (item2.lv == "city")
  12797. // {
  12798. // string citycnname = item2.cn;
  12799. // string cityenname = item2.en;
  12800. // Sys_Cities cityInfo = new Sys_Cities()
  12801. // {
  12802. // CountriesId = countriesId,
  12803. // ParentId = provinceId,
  12804. // Level = 2,
  12805. // Name_CN = citycnname,
  12806. // Name_EN = cityenname,
  12807. // IsCapital = 1,
  12808. // CreateUserId = 208,
  12809. // CreateTime = DateTime.Now,
  12810. // IsDel = 0
  12811. // };
  12812. // if (item2.c != null)
  12813. // {
  12814. // int cityId = 0;
  12815. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12816. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12817. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12818. // foreach (var item3 in item2.c)
  12819. // {
  12820. // if (item3.lv == "district")
  12821. // {
  12822. // var districtInfo = new Sys_Cities()
  12823. // {
  12824. // CountriesId = countriesId,
  12825. // Name_CN = item3.cn,
  12826. // Name_EN = item3.en,
  12827. // Level = 3,
  12828. // ParentId = cityId,
  12829. // IsCapital = 1,
  12830. // CreateUserId = 208,
  12831. // CreateTime = DateTime.Now,
  12832. // IsDel = 0
  12833. // };
  12834. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12835. // //{
  12836. // districts.Add(districtInfo);
  12837. // //}
  12838. // }
  12839. // }
  12840. // }
  12841. // else
  12842. // {
  12843. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12844. // //{
  12845. // cities.Add(cityInfo);
  12846. // //}
  12847. // }
  12848. // }
  12849. // }
  12850. // }
  12851. // else if (item1.lv == "city")//城市
  12852. // {
  12853. // provinceInfo.Level = 2;
  12854. // if (item1.c != null)
  12855. // {
  12856. // int cityId = 0;
  12857. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12858. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12859. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12860. // foreach (var item3 in item1.c)
  12861. // {
  12862. // if (item3.lv == "district")
  12863. // {
  12864. // var districtInfo = new Sys_Cities()
  12865. // {
  12866. // CountriesId = countriesId,
  12867. // Name_CN = item3.cn,
  12868. // Name_EN = item3.en,
  12869. // Level = 3,
  12870. // ParentId = cityId,
  12871. // IsCapital = 1,
  12872. // CreateUserId = 208,
  12873. // CreateTime = DateTime.Now,
  12874. // IsDel = 0
  12875. // };
  12876. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12877. // //{
  12878. // districts.Add(districtInfo);
  12879. // //}
  12880. // }
  12881. // }
  12882. // }
  12883. // else
  12884. // {
  12885. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12886. // //{
  12887. // cities.Add(provinceInfo);
  12888. // //}
  12889. // }
  12890. // }
  12891. // }
  12892. // }
  12893. // }
  12894. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12895. // cities = cities.Distinct().ToList();
  12896. // districts = districts.Distinct().ToList();
  12897. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12898. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12899. // cities.AddRange(districts);
  12900. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12901. // //_sqlSugar.RollbackTran();
  12902. // _sqlSugar.CommitTran();
  12903. // return Ok(JsonView(false, "操作成功!"));
  12904. //}
  12905. //[HttpPost]
  12906. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12907. //{
  12908. // List<CountitiesInfo> infos = dto.MyProperty;
  12909. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12910. // _sqlSugar.BeginTran();
  12911. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12912. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12913. // foreach (var item in infos)
  12914. // {
  12915. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12916. // if (countryInfo != null)
  12917. // {
  12918. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12919. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12920. // if (cityInfo1 != null)
  12921. // {
  12922. // cityInfo1.IsCapital = 0;
  12923. // cityInfos.Add(cityInfo1);
  12924. // }
  12925. // }
  12926. // }
  12927. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12928. // .UpdateColumns(it => it.IsCapital)
  12929. // .WhereColumns(it => it.Id)
  12930. // .ExecuteCommand();
  12931. // //_sqlSugar.RollbackTran();
  12932. // _sqlSugar.CommitTran();
  12933. // return Ok(JsonView(false, "操作成功!"));
  12934. //}
  12935. //public class CounrtiesDto
  12936. //{
  12937. // public List<CountitiesInfo> MyProperty { get; set; }
  12938. //}
  12939. //public class CountitiesInfo
  12940. //{
  12941. // /// <summary>
  12942. // /// 圣约翰
  12943. // /// </summary>
  12944. // public string capital_name_chinese { get; set; }
  12945. // /// <summary>
  12946. // ///
  12947. // /// </summary>
  12948. // public string capital_name { get; set; }
  12949. // /// <summary>
  12950. // ///
  12951. // /// </summary>
  12952. // public string country_type { get; set; }
  12953. // /// <summary>
  12954. // /// 安提瓜和巴布达
  12955. // /// </summary>
  12956. // public string country_name_chinese { get; set; }
  12957. // /// <summary>
  12958. // /// 安提瓜和巴布达
  12959. // /// </summary>
  12960. // public string country_name_chinese_short { get; set; }
  12961. // /// <summary>
  12962. // /// 安提瓜和巴布达
  12963. // /// </summary>
  12964. // public string country_name_chinese_UN { get; set; }
  12965. // /// <summary>
  12966. // ///
  12967. // /// </summary>
  12968. // public string country_name_english_abbreviation { get; set; }
  12969. // /// <summary>
  12970. // ///
  12971. // /// </summary>
  12972. // public string country_name_english_formal { get; set; }
  12973. // /// <summary>
  12974. // ///
  12975. // /// </summary>
  12976. // public string country_name_english_UN { get; set; }
  12977. // /// <summary>
  12978. // ///
  12979. // /// </summary>
  12980. // public string continent_name { get; set; }
  12981. // /// <summary>
  12982. // ///
  12983. // /// </summary>
  12984. // public string subregion_name { get; set; }
  12985. // /// <summary>
  12986. // ///
  12987. // /// </summary>
  12988. // public string country_code2 { get; set; }
  12989. // /// <summary>
  12990. // ///
  12991. // /// </summary>
  12992. // public string country_code3 { get; set; }
  12993. // /// <summary>
  12994. // ///
  12995. // /// </summary>
  12996. // public string phone_code { get; set; }
  12997. //}
  12998. //public class CountriesInfo : BasicInfo
  12999. //{
  13000. // public List<CitiesInfo> c { get; set; }
  13001. //}
  13002. //public class CitiesInfo : BasicInfo
  13003. //{
  13004. // public List<AreaInfo> c { get; set; }
  13005. //}
  13006. //public class AreaInfo : BasicInfo
  13007. //{
  13008. // public List<AreaInfo> c { get; set; }
  13009. //}
  13010. //public class BasicInfo
  13011. //{
  13012. // public string code { get; set; }
  13013. // public string cn { get; set; }
  13014. // public string lv { get; set; }
  13015. // public string en { get; set; }
  13016. //}
  13017. #endregion
  13018. #region 查看邀请方
  13019. /// <summary>
  13020. /// 查看邀请方
  13021. /// 邀请方信息 Init
  13022. /// </summary>
  13023. /// <param name="dto"></param>
  13024. /// <returns></returns>
  13025. [HttpPost]
  13026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13027. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  13028. {
  13029. string sqlWhere = string.Empty;
  13030. if (!string.IsNullOrEmpty(dto.Search))
  13031. {
  13032. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  13033. }
  13034. string sql = string.Format($@"Select
  13035. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  13036. Id,
  13037. UnitName
  13038. From Res_InvitationOfficialActivityData
  13039. Where IsDel = 0
  13040. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  13041. RefAsync<int> total = 0;
  13042. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13043. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  13044. }
  13045. /// <summary>
  13046. /// 查看邀请方
  13047. /// 国家信息 Init
  13048. /// </summary>
  13049. /// <param name="dto"></param>
  13050. /// <returns></returns>
  13051. [HttpPost]
  13052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13053. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  13054. {
  13055. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  13056. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13057. var diids = groupInfos.Select(it => it.Id).ToList();
  13058. List<string> countrys = new List<string>();
  13059. foreach (var item in country)
  13060. {
  13061. var data = _groupRepository.FormartTeamName(item);
  13062. var dataArray = _groupRepository.GroupSplitCountry(data);
  13063. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13064. }
  13065. countrys = countrys.Distinct().ToList();
  13066. for (int i = 0; i < countrys.Count; i++)
  13067. {
  13068. string item = countrys[i];
  13069. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  13070. {
  13071. countrys.Remove(item);
  13072. i--;
  13073. }
  13074. }
  13075. RefAsync<int> total = 0;
  13076. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  13077. .Where(it => countrys.Contains(it.Name_CN))
  13078. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13079. .Select(it => new { id = it.Id, name = it.Name_CN })
  13080. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13081. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13082. }
  13083. /// <summary>
  13084. /// 查看邀请方
  13085. /// 城市信息 Init
  13086. /// </summary>
  13087. /// <param name="dto"></param>
  13088. /// <returns></returns>
  13089. [HttpPost]
  13090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13091. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  13092. {
  13093. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  13094. RefAsync<int> total = 0;
  13095. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  13096. .Where(it => it.CountriesId == dto.CountiesId)
  13097. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13098. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  13099. .Select(it => new { id = it.Id, name = it.Name_CN })
  13100. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13101. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13102. }
  13103. /// <summary>
  13104. /// 查看邀请方
  13105. /// 团组名称 Init
  13106. /// </summary>
  13107. /// <param name="dto"></param>
  13108. /// <returns></returns>
  13109. [HttpPost]
  13110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13111. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  13112. {
  13113. var watch = new Stopwatch();
  13114. watch.Start();
  13115. RefAsync<int> total = 0;
  13116. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  13117. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  13118. .Where((oa, di) => oa.IsDel == 0)
  13119. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  13120. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  13121. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  13122. .Distinct()
  13123. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13124. watch.Stop();
  13125. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  13126. }
  13127. /// <summary>
  13128. /// 查看邀请方
  13129. /// 团组 & 邀请方信息
  13130. /// </summary>
  13131. /// <param name="dto"></param>
  13132. /// <returns></returns>
  13133. [HttpPost]
  13134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13135. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  13136. {
  13137. var watch = new Stopwatch();
  13138. watch.Start();
  13139. RefAsync<int> total = 0;
  13140. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  13141. .AS("Grp_DelegationInfo")
  13142. .Includes(x => x.InvitingInfos)
  13143. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  13144. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  13145. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  13146. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  13147. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  13148. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  13149. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13150. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  13151. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  13152. infos.ForEach(x =>
  13153. {
  13154. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  13155. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  13156. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  13157. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  13158. });
  13159. watch.Stop();
  13160. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  13161. }
  13162. #endregion
  13163. #region 报批行程
  13164. /// <summary>
  13165. /// 报批行程初始化
  13166. /// </summary>
  13167. /// <param name="dto"></param>
  13168. /// <returns></returns>
  13169. [HttpPost]
  13170. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  13171. {
  13172. const int chiNumber = 5;
  13173. var jw = JsonView(false);
  13174. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  13175. var group = groupList.First();
  13176. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13177. group = groupList.First(x => x.Id == diid);
  13178. if (group == null)
  13179. {
  13180. jw.Msg = "暂无团组!";
  13181. return Ok(jw);
  13182. }
  13183. var data = new
  13184. {
  13185. groupList = groupList.Select(x => new
  13186. {
  13187. x.TeamName,
  13188. x.Id
  13189. }),
  13190. content = new ArrayList(),
  13191. groupInfo = new
  13192. {
  13193. group.VisitDays,
  13194. group.TourCode,
  13195. group.VisitPNumber,
  13196. group.TeamName,
  13197. group.Id,
  13198. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  13199. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  13200. },
  13201. };
  13202. var resultArr = new ArrayList();
  13203. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  13204. if (content.Count == 0)
  13205. {
  13206. var stay = "-";
  13207. var cityPath = "-";
  13208. //添加城市路径以及住宿地
  13209. //黑屏代码数据
  13210. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13211. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13212. {
  13213. jw = JsonView(true, "黑屏代码有误!", data);
  13214. return Ok(jw);
  13215. }
  13216. foreach (DataRow row in dtBlack.Rows)
  13217. {
  13218. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13219. {
  13220. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  13221. return Ok(jw);
  13222. }
  13223. }
  13224. //黑屏代码获取时间区间
  13225. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13226. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13227. _sqlSugar.BeginTran();
  13228. for (int i = 0; i < timeArr.Count; i++)
  13229. {
  13230. stay = "-";
  13231. cityPath = "-";
  13232. DateTime NewData = DateTime.Parse(timeArr[i]);
  13233. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13234. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13235. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13236. if (tbSelect.Length > 0)
  13237. {
  13238. List<string> threeCodeStr = new List<string>();
  13239. foreach (var item in tbSelect)
  13240. {
  13241. var threeCode = item["Three"].ToString() ?? "";
  13242. if (threeCode.Length == 6)
  13243. {
  13244. var start = threeCode.Substring(0, 3);
  13245. var end = threeCode.Substring(3, 3);
  13246. if (threeCodeStr.Count == 0)
  13247. {
  13248. threeCodeStr.Add(start);
  13249. threeCodeStr.Add(end);
  13250. }
  13251. else
  13252. {
  13253. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13254. {
  13255. threeCodeStr.Add(end);
  13256. }
  13257. else
  13258. {
  13259. threeCodeStr.Add(start);
  13260. threeCodeStr.Add(end);
  13261. }
  13262. }
  13263. }
  13264. }
  13265. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13266. var last = threeCodeStr.Last();
  13267. foreach (var item in threeCodeStr)
  13268. {
  13269. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13270. if (item.Equals(last))
  13271. {
  13272. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13273. }
  13274. }
  13275. cityPath = cityPath.Trim('-');
  13276. }
  13277. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13278. appro.Diid = diid ?? -1;
  13279. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13280. appro.Id = thisId;
  13281. appro.CreateUserId = dto.UserId;
  13282. appro.CreateTime = DateTime.Now;
  13283. content.Add(appro);
  13284. }
  13285. _sqlSugar.CommitTran();
  13286. }
  13287. foreach (var x in content)
  13288. {
  13289. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  13290. if (chiList.Count < chiNumber)
  13291. {
  13292. for (int i = chiList.Count; i < chiNumber; i++)
  13293. {
  13294. chiList.Add(new Grp_ApprovalTravelDetails());
  13295. }
  13296. }
  13297. resultArr.Add(new
  13298. {
  13299. x.Id,
  13300. x.Date,
  13301. x.Diid,
  13302. chiList = chiList.Select(x1 => new
  13303. {
  13304. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13305. x1.Details,
  13306. x1.ParentId,
  13307. x1.Id
  13308. })
  13309. });
  13310. }
  13311. data = data with
  13312. {
  13313. content = resultArr,
  13314. };
  13315. jw = JsonView(true, "获取成功!", data);
  13316. return Ok(jw);
  13317. }
  13318. /// <summary>
  13319. /// 报批行程删除
  13320. /// </summary>
  13321. /// <param name="dto"></param>
  13322. /// <returns></returns>
  13323. [HttpPost]
  13324. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  13325. {
  13326. var jw = JsonView(false);
  13327. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13328. if (group == null)
  13329. {
  13330. jw.Msg = "团组参数有误!";
  13331. return Ok(jw);
  13332. }
  13333. try
  13334. {
  13335. _sqlSugar.BeginTran();
  13336. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  13337. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  13338. {
  13339. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13340. DeleteUserId = dto.uesrId,
  13341. IsDel = 1
  13342. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  13343. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  13344. {
  13345. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13346. DeleteUserId = dto.uesrId,
  13347. IsDel = 1
  13348. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  13349. _sqlSugar.CommitTran();
  13350. jw = JsonView(true, "删除成功");
  13351. }
  13352. catch (Exception ex)
  13353. {
  13354. jw = JsonView(false, ex.Message);
  13355. }
  13356. return Ok(jw);
  13357. }
  13358. /// <summary>
  13359. /// 报批行程保存
  13360. /// </summary>
  13361. /// <param name="dto"></param>
  13362. /// <returns></returns>
  13363. [HttpPost]
  13364. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  13365. {
  13366. var jw = JsonView(false);
  13367. var Find = dto.Arr.Find(x => x.id == 0);
  13368. if (Find != null)
  13369. {
  13370. jw.Msg = "生成的ID为0!";
  13371. return Ok(jw);
  13372. }
  13373. foreach (var item in dto.Arr)
  13374. {
  13375. foreach (var chi in item.chiList)
  13376. {
  13377. if (chi.parentId == 0)
  13378. {
  13379. chi.parentId = item.id;
  13380. }
  13381. }
  13382. }
  13383. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  13384. _sqlSugar.BeginTran();
  13385. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  13386. {
  13387. var parentIds = dto.Arr.Select(x => x.id).ToList();
  13388. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  13389. {
  13390. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13391. DeleteUserId = dto.UserId,
  13392. IsDel = 1
  13393. }).ExecuteCommand();
  13394. }
  13395. try
  13396. {
  13397. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  13398. {
  13399. CreateTime = DateTime.Now,
  13400. CreateUserId = dto.UserId,
  13401. Details = x.details,
  13402. ParentId = x.parentId,
  13403. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13404. Remark = "",
  13405. IsDel = 0
  13406. }).ToList()).ExecuteCommand();
  13407. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  13408. {
  13409. Id = x.id,
  13410. Details = x.details,
  13411. ParentId = x.parentId,
  13412. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13413. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  13414. {
  13415. Details = x.Details,
  13416. ParentId = x.ParentId,
  13417. Time = x.Time
  13418. }).ExecuteCommand();
  13419. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  13420. {
  13421. Id = x.id,
  13422. Date = x.date,
  13423. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13424. {
  13425. Date = x.Date
  13426. }).ExecuteCommand();
  13427. _sqlSugar.CommitTran();
  13428. jw = JsonView(true, "保存成功!");
  13429. }
  13430. catch (Exception ex)
  13431. {
  13432. _sqlSugar.RollbackTran();
  13433. jw = JsonView(false, "保存失败!" + ex.Message);
  13434. }
  13435. return Ok(jw);
  13436. }
  13437. /// <summary>
  13438. /// 报批行程生成
  13439. /// </summary>
  13440. /// <param name="dto"></param>
  13441. /// <returns></returns>
  13442. [HttpPost]
  13443. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13444. {
  13445. var jw = JsonView(false);
  13446. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13447. if (group == null)
  13448. {
  13449. jw.Msg = "暂无该团组!";
  13450. return Ok(jw);
  13451. }
  13452. //黑屏代码数据
  13453. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13454. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13455. {
  13456. jw.Msg = "黑屏代码有误!";
  13457. return Ok(jw);
  13458. }
  13459. foreach (DataRow row in dtBlack.Rows)
  13460. {
  13461. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13462. {
  13463. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13464. return Ok(jw);
  13465. }
  13466. }
  13467. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13468. var resultArr = new ArrayList();
  13469. if (officialActivitiesArr.Count == 0)
  13470. {
  13471. jw.Msg = "暂无公务出访信息!";
  13472. return Ok(jw);
  13473. }
  13474. try
  13475. {
  13476. _sqlSugar.BeginTran();
  13477. DeleteApprovalJourney(new
  13478. Domain.Dtos.Groups.DeleteApprovalJourney
  13479. {
  13480. Diid = dto.Diid,
  13481. uesrId = dto.Userid
  13482. });
  13483. var stay = "-";
  13484. var cityPath = "-";
  13485. //添加城市路径以及住宿地
  13486. //黑屏代码获取时间区间
  13487. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13488. var empty = "【未收入该三字码!请机票同事录入】";
  13489. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13490. for (int i = 0; i < timeArr.Count; i++)
  13491. {
  13492. stay = "-";
  13493. cityPath = "-";
  13494. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13495. DateTime NewData = DateTime.Parse(timeArr[i]);
  13496. 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();
  13497. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13498. if (tbSelect.Length > 0)
  13499. {
  13500. List<string> threeCodeStr = new List<string>();
  13501. bool isTrade = false;
  13502. string trip = string.Empty;
  13503. var rowLast = tbSelect.Last();
  13504. var rowFirst = tbSelect.First();
  13505. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13506. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13507. var takeOffTime = DateTime.Parse(timeArr[i]);
  13508. var fallToTime = DateTime.Parse(timeArr[i]);
  13509. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13510. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13511. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13512. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13513. foreach (var item in tbSelect)
  13514. {
  13515. var start = string.Empty;
  13516. var end = string.Empty;
  13517. var threeCode = item["Three"].ToString() ?? "";
  13518. if (threeCode.Length == 6)
  13519. {
  13520. start = threeCode.Substring(0, 3);
  13521. end = threeCode.Substring(3, 3);
  13522. if (threeCodeStr.Count == 0)
  13523. {
  13524. threeCodeStr.Add(start);
  13525. threeCodeStr.Add(end);
  13526. }
  13527. else
  13528. {
  13529. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13530. {
  13531. threeCodeStr.Add(end);
  13532. }
  13533. else
  13534. {
  13535. threeCodeStr.Add(start);
  13536. threeCodeStr.Add(end);
  13537. }
  13538. }
  13539. }
  13540. //处理机票信息
  13541. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13542. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13543. if (start_Object == null)
  13544. {
  13545. start_Object = new Res_ThreeCode()
  13546. {
  13547. AirPort = empty,
  13548. AirPort_En = empty,
  13549. City = empty,
  13550. Country = empty,
  13551. Four = empty,
  13552. Three = empty,
  13553. };
  13554. }
  13555. if (end_Object == null)
  13556. {
  13557. end_Object = new Res_ThreeCode()
  13558. {
  13559. AirPort = empty,
  13560. AirPort_En = empty,
  13561. City = empty,
  13562. Country = empty,
  13563. Four = empty,
  13564. Three = empty,
  13565. };
  13566. }
  13567. //机型判断
  13568. string airModel = item["AirModel"].ToString();
  13569. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13570. string flightTime = item["FlightTime"].ToString();
  13571. if (flightTime!.Contains(":"))
  13572. {
  13573. flightTime = flightTime.Replace(":", "小时");
  13574. flightTime += "分钟";
  13575. }
  13576. if (flightTime.Contains("H"))
  13577. {
  13578. flightTime = flightTime.Replace("H", "小时");
  13579. }
  13580. if (flightTime.Contains("M"))
  13581. {
  13582. flightTime = flightTime.Replace("M", "分钟");
  13583. }
  13584. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13585. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13586. {
  13587. flightTime = flightDataTime.Hour > 0
  13588. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13589. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13590. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13591. }
  13592. //航班号
  13593. string flightcode = item["Fliagtcode"].ToString();
  13594. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13595. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13596. if (aircompany == null)
  13597. {
  13598. aircompany = new Res_AirCompany
  13599. {
  13600. CnName = hsEmpty,
  13601. EnName = hsEmpty,
  13602. ShortCode = hsEmpty,
  13603. };
  13604. }
  13605. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13606. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13607. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13608. if (isTrade)
  13609. {
  13610. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13611. }
  13612. else
  13613. {
  13614. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13615. }
  13616. }
  13617. chiarr.Add(new Grp_ApprovalTravelDetails
  13618. {
  13619. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13620. CreateTime = DateTime.Now,
  13621. CreateUserId = dto.Userid,
  13622. ParentId = 0,
  13623. Details = trip
  13624. });
  13625. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13626. var last = threeCodeStr.Last();
  13627. foreach (var item in threeCodeStr)
  13628. {
  13629. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13630. if (item.Equals(last))
  13631. {
  13632. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13633. }
  13634. }
  13635. cityPath = cityPath.Trim('-');
  13636. }
  13637. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13638. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13639. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13640. appro.Diid = dto.Diid;
  13641. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13642. appro.Id = thisId;
  13643. appro.CreateUserId = dto.Userid;
  13644. appro.CreateTime = DateTime.Now;
  13645. foreach (var item in gwinfo)
  13646. {
  13647. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13648. chi.Details = "拜访" + item.Client;
  13649. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13650. {
  13651. chi.Details += "," + item.ReqSample;
  13652. }
  13653. chi.ParentId = thisId;
  13654. chi.Time = item.Time;
  13655. chiarr.Add(chi);
  13656. }
  13657. if (chiarr.Count < 5)
  13658. {
  13659. for (int j = chiarr.Count; j < 5; j++)
  13660. {
  13661. chiarr.Add(new
  13662. Grp_ApprovalTravelDetails());
  13663. }
  13664. }
  13665. resultArr.Add(new
  13666. {
  13667. appro.Id,
  13668. appro.Date,
  13669. appro.Diid,
  13670. chiList = chiarr.Select(x1 => new
  13671. {
  13672. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13673. x1.Details,
  13674. x1.ParentId,
  13675. x1.Id
  13676. })
  13677. });
  13678. }
  13679. _sqlSugar.CommitTran();
  13680. jw = JsonView(true, "生成成功!", resultArr);
  13681. }
  13682. catch (Exception ex)
  13683. {
  13684. jw.Code = 400;
  13685. jw.Msg = "生成失败!" + ex.Message;
  13686. }
  13687. return Ok(jw);
  13688. }
  13689. /// <summary>
  13690. /// 报批行程word导出
  13691. /// </summary>
  13692. /// <param name="dto"></param>
  13693. /// <returns></returns>
  13694. [HttpPost]
  13695. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13696. {
  13697. var jw = JsonView(false);
  13698. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13699. if (group == null)
  13700. {
  13701. jw.Msg = "暂无该团组!";
  13702. return Ok(jw);
  13703. }
  13704. //模板路径
  13705. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13706. //载入模板
  13707. Document doc = new Document(tempPath);
  13708. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13709. //获取所填表格的序数
  13710. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13711. Aspose.Words.Tables.Row titleRowClone = null;
  13712. Aspose.Words.Tables.Row CenterRowClone = null;
  13713. int index = 0;
  13714. int indexChi = 0;
  13715. int SetIndex = 0;
  13716. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13717. //获取数据,放到datatable
  13718. foreach (var item in ApprovalTravelArr)
  13719. {
  13720. if (index > 0)
  13721. {
  13722. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13723. tableOne.AppendChild(titleRowClone);
  13724. }
  13725. var textTime = item.Date;
  13726. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13727. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13728. SetIndex++;
  13729. if (ChiRep.Count > 0)
  13730. {
  13731. foreach (var itemChi in ChiRep)
  13732. {
  13733. var txtTime = itemChi.Time;
  13734. var txtDetail = itemChi.Details;
  13735. if (indexChi > 0)
  13736. {
  13737. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13738. tableOne.AppendChild(CenterRowClone);
  13739. }
  13740. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13741. {
  13742. SetCells(tableOne, doc, SetIndex, 0, "");
  13743. SetCells(tableOne, doc, SetIndex, 1, "");
  13744. indexChi++;
  13745. SetIndex++;
  13746. break;
  13747. }
  13748. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13749. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13750. indexChi++;
  13751. SetIndex++;
  13752. }
  13753. }
  13754. else
  13755. {
  13756. if (indexChi > 0)
  13757. {
  13758. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13759. tableOne.AppendChild(CenterRowClone);
  13760. }
  13761. SetCells(tableOne, doc, SetIndex, 0, "");
  13762. SetCells(tableOne, doc, SetIndex, 1, "");
  13763. indexChi++;
  13764. SetIndex++;
  13765. }
  13766. index++;
  13767. }
  13768. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13769. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13770. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13771. jw.Code = 200;
  13772. jw.Msg = "";
  13773. return Ok(jw);
  13774. }
  13775. private string intToString(int numberVal)
  13776. {
  13777. string numberval = numberVal.ToString();
  13778. Dictionary<char, string> Number = new Dictionary<char, string>();
  13779. Number.Add('1', "一");
  13780. Number.Add('2', "二");
  13781. Number.Add('3', "三");
  13782. Number.Add('4', "四");
  13783. Number.Add('5', "五");
  13784. Number.Add('6', "六");
  13785. Number.Add('7', "七");
  13786. Number.Add('8', "八");
  13787. Number.Add('9', "九");
  13788. string stringNumberVal = string.Empty;
  13789. for (int i = 0; i < numberval.Length; i++)
  13790. {
  13791. if (i == 0)
  13792. {
  13793. stringNumberVal += Number[numberval[i]];
  13794. }
  13795. else if (i >= 1)
  13796. {
  13797. if (numberval[i] == '0')
  13798. {
  13799. stringNumberVal = "十";
  13800. }
  13801. else
  13802. {
  13803. stringNumberVal += "十" + Number[numberval[i]];
  13804. }
  13805. }
  13806. }
  13807. return stringNumberVal;
  13808. }
  13809. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13810. {
  13811. //获取table中的某个单元格,从0开始
  13812. Cell lshCell = table.Rows[rows].Cells[cells];
  13813. //将单元格中段落移除
  13814. foreach (Node item in lshCell.Paragraphs)
  13815. {
  13816. lshCell.Paragraphs.Remove(item);
  13817. }
  13818. if (val.Contains("\r\n"))
  13819. {
  13820. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13821. foreach (var item in spArr)
  13822. {
  13823. //新建一个段落
  13824. Paragraph p = new Paragraph(doc);
  13825. var r = new Run(doc, item);
  13826. //把设置的值赋给之前新建的段落
  13827. p.AppendChild(r);
  13828. //将此段落加到单元格内
  13829. lshCell.AppendChild(p);
  13830. }
  13831. }
  13832. else
  13833. {
  13834. //新建一个段落
  13835. Paragraph p = new Paragraph(doc);
  13836. var r = new Run(doc, val);
  13837. //把设置的值赋给之前新建的段落
  13838. p.AppendChild(r);
  13839. //将此段落加到单元格内
  13840. lshCell.AppendChild(p);
  13841. }
  13842. }
  13843. [HttpPost]
  13844. public async Task<IActionResult> ServerHttp(string paramStr)
  13845. {
  13846. paramStr = paramStr.TrimEnd('\'');
  13847. paramStr = paramStr.TrimStart('\'');
  13848. JsonView jw = JsonView(false);
  13849. JObject param = JObject.Parse(paramStr);
  13850. if (!param.ContainsKey("url"))
  13851. {
  13852. jw.Msg = "url null";
  13853. return Ok(jw);
  13854. }
  13855. string url = param["url"]!.ToString();
  13856. var methon = "get";
  13857. Dictionary<string, string> headValues = null;
  13858. string bodyStr = string.Empty;
  13859. if (param.ContainsKey("methon"))
  13860. {
  13861. methon = param["methon"]!.ToString().ToLower();
  13862. }
  13863. if (param.ContainsKey("header"))
  13864. {
  13865. var header = param["header"]!.ToString();
  13866. JObject headerJobject = JObject.Parse(header);
  13867. headValues = new Dictionary<string, string>();
  13868. foreach (JProperty item in headerJobject.Properties())
  13869. {
  13870. var value = item.Value.ToString();
  13871. var head = item.Path;
  13872. headValues.Add(head, value);
  13873. }
  13874. }
  13875. HttpClient client = new HttpClient();
  13876. string responseString = string.Empty;
  13877. StringContent content = null;
  13878. if (headValues != null)
  13879. {
  13880. foreach (var item in headValues.Keys)
  13881. {
  13882. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13883. {
  13884. if (param.ContainsKey("body"))
  13885. {
  13886. bodyStr = param["body"]!.ToString();
  13887. }
  13888. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13889. }
  13890. else
  13891. {
  13892. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13893. }
  13894. }
  13895. }
  13896. try
  13897. {
  13898. if (methon == "get")
  13899. {
  13900. responseString = await client.GetStringAsync(url);
  13901. }
  13902. else if (methon == "post")
  13903. {
  13904. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13905. {
  13906. Content = content
  13907. };
  13908. var response = await client.SendAsync(request);
  13909. try
  13910. {
  13911. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13912. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13913. {
  13914. using (StreamReader reader = new StreamReader(gzipStream))
  13915. {
  13916. responseString = await reader.ReadToEndAsync();
  13917. }
  13918. }
  13919. }
  13920. catch (Exception)
  13921. {
  13922. responseString = await response.Content.ReadAsStringAsync();
  13923. }
  13924. }
  13925. else
  13926. {
  13927. responseString = "methon error";
  13928. }
  13929. jw = JsonView(true, "success", responseString);
  13930. }
  13931. catch (Exception ex)
  13932. {
  13933. jw.Msg = "error " + ex.Message;
  13934. jw.Data = ex.StackTrace;
  13935. }
  13936. finally
  13937. {
  13938. client.Dispose();
  13939. }
  13940. return Ok(jw);
  13941. }
  13942. #endregion
  13943. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13944. /// <summary>
  13945. /// 团组接待意见调查 - 信息管理
  13946. /// 基础数据(团组)
  13947. /// </summary>
  13948. /// <param name="dto"></param>
  13949. /// <returns></returns>
  13950. [HttpGet]
  13951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13952. public async Task<IActionResult> OpinionaireInit()
  13953. {
  13954. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13955. .Select(x => new
  13956. {
  13957. x.Id,
  13958. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13959. })
  13960. .OrderByDescending(x => x.Id)
  13961. .ToListAsync();
  13962. return Ok(JsonView(groupData, groupData.Count));
  13963. }
  13964. /// <summary>
  13965. /// 团组接待意见调查 - 信息管理
  13966. /// 列表
  13967. /// </summary>
  13968. /// <param name="groupId"></param>
  13969. /// <returns></returns>
  13970. [HttpGet("{groupId}")]
  13971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13972. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13973. {
  13974. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13975. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13976. .Select(x => new
  13977. {
  13978. x.Id,
  13979. x.TourGuideName,
  13980. x.CityName,
  13981. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13982. x.CreateTime
  13983. })
  13984. .OrderBy(x => x.Id)
  13985. .ToListAsync();
  13986. return Ok(JsonView(data));
  13987. }
  13988. /// <summary>
  13989. /// 团组接待意见调查 - 信息管理
  13990. /// 保存
  13991. /// </summary>
  13992. /// <param name="dto"></param>
  13993. /// <returns></returns>
  13994. [HttpPost]
  13995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13996. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  13997. {
  13998. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13999. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14000. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14001. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  14002. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  14003. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  14004. _opinionaireRep.BeginTran();
  14005. if (addData != null && addData.Count > 0)
  14006. {
  14007. foreach (var item in addData)
  14008. {
  14009. item.CreateUserId = currUserInfo.UserId;
  14010. item.DiId = dto.DiId;
  14011. }
  14012. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  14013. }
  14014. if (updData != null && updData.Count > 0)
  14015. {
  14016. var upd = await _opinionaireRep._sqlSugar
  14017. .Updateable(updData)
  14018. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  14019. .WhereColumns(x => new { x.Id })
  14020. .ExecuteCommandAsync();
  14021. }
  14022. _opinionaireRep.CommitTran();
  14023. return Ok(JsonView("操作成功!"));
  14024. }
  14025. /// <summary>
  14026. /// 团组接待意见调查 - 信息管理
  14027. /// 删除
  14028. /// </summary>
  14029. /// <param name="id"></param>
  14030. /// <returns></returns>
  14031. [HttpDelete("{id}")]
  14032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14033. public async Task<IActionResult> OpinionaireManageDel(int id)
  14034. {
  14035. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  14036. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14037. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  14038. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  14039. if (!del) return Ok(JsonView("操作失败!"));
  14040. return Ok(JsonView("操作成功!"));
  14041. }
  14042. /// <summary>
  14043. /// 团组接待意见调查 - 用户
  14044. /// 列表
  14045. /// </summary>
  14046. /// <param name="id"></param>
  14047. /// <returns></returns>
  14048. [HttpGet("{diId}")]
  14049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14050. public async Task<IActionResult> OpinionaireUserList(int diId)
  14051. {
  14052. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14053. var sql = string.Format(@"
  14054. SELECT
  14055. o.Id,
  14056. o.DiId,
  14057. di.TeamName AS 'GroupName',
  14058. di.VisitPNumber AS 'PeopleNumber',
  14059. di.ClientName AS 'LeadGroup',
  14060. di.VisitCountry AS 'Travel',
  14061. di.VisitDays AS 'Days',
  14062. o.CityName,
  14063. o.TourGuideName,
  14064. o.Catering,
  14065. o.CateringReason,
  14066. o.Stay,
  14067. o.StayReason,
  14068. o.[Route],
  14069. o.RouteReason,
  14070. o.OfficialActivity,
  14071. o.OfficialActivityReason,
  14072. o.TourGuide,
  14073. o.TourGuideReason,
  14074. o.[Translate],
  14075. o.TranslateReason,
  14076. o.Trip,
  14077. o.TripReason,
  14078. o.ESFileName,
  14079. o.SignatureDate,
  14080. o.Remark
  14081. FROM
  14082. Grp_Opinionaire o
  14083. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  14084. WHERE
  14085. o.IsDel = 0
  14086. AND o.DiId = {0}
  14087. ORDER BY
  14088. o.Id ASC", diId);
  14089. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  14090. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  14091. return Ok(JsonView(data));
  14092. }
  14093. /// <summary>
  14094. /// 团组接待意见调查 - 用户
  14095. /// 保存
  14096. /// </summary>
  14097. /// <param name="id"></param>
  14098. /// <returns></returns>
  14099. [HttpPost]
  14100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14101. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  14102. {
  14103. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  14104. foreach (var item in dto)
  14105. {
  14106. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  14107. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  14108. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  14109. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  14110. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  14111. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  14112. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  14113. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  14114. }
  14115. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  14116. if (!Directory.Exists(filePathBase))
  14117. {
  14118. Directory.CreateDirectory(filePathBase);
  14119. }
  14120. #region 上传文件
  14121. var filePaths = new List<string>();
  14122. foreach (var item in dto)
  14123. {
  14124. var file = item.File;
  14125. // 将文件保存到指定位置
  14126. var filePath = Path.Combine(filePathBase, file.FileName);
  14127. using (var stream = new FileStream(filePath, FileMode.Create))
  14128. {
  14129. await file.CopyToAsync(stream);
  14130. }
  14131. //验证文件是否上传成功
  14132. if (!System.IO.File.Exists(filePath))
  14133. {
  14134. foreach (var filePathStr in filePaths)
  14135. {
  14136. System.IO.File.Delete(filePathStr);
  14137. }
  14138. return Ok(JsonView(false, "文件上传失败!"));
  14139. }
  14140. item.ESFileName = file.FileName;
  14141. }
  14142. #endregion
  14143. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  14144. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  14145. .UpdateColumns(x => new
  14146. {
  14147. x.Catering,
  14148. x.CateringReason,
  14149. x.Stay,
  14150. x.StayReason,
  14151. x.Route,
  14152. x.RouteReason,
  14153. x.OfficialActivity,
  14154. x.OfficialActivityReason,
  14155. x.TourGuide,
  14156. x.TourGuideReason,
  14157. x.Translate,
  14158. x.TranslateReason,
  14159. x.Trip,
  14160. x.TripReason,
  14161. x.ESFileName,
  14162. x.SignatureDate,
  14163. x.Remark
  14164. })
  14165. .WhereColumns(x => new { x.Id })
  14166. .ExecuteCommandAsync();
  14167. if (upd < 1)
  14168. {
  14169. foreach (var filePathStr in filePaths)
  14170. {
  14171. System.IO.File.Delete(filePathStr);
  14172. }
  14173. return Ok(JsonView(false));
  14174. }
  14175. return Ok(JsonView(true));
  14176. }
  14177. #endregion
  14178. // /// <summary>
  14179. // ///
  14180. // /// </summary>
  14181. // /// <param name="_dto"></param>
  14182. // /// <returns></returns>
  14183. // [HttpPost]
  14184. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14185. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14186. // {
  14187. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14188. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  14189. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  14190. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14191. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  14192. // dic_psg.Add("客人", 974);
  14193. // dic_psg.Add("司机", 975);
  14194. // dic_psg.Add("导游", 976);
  14195. // dic_psg.Add("公司内部人员", 977);
  14196. // dic_psg.Add("司机/导游/公司内部人员", 978);
  14197. // foreach (var item in list_visa)
  14198. // {
  14199. // Grp_VisaInfo temp = new Grp_VisaInfo();
  14200. // temp.Id = item.Id;
  14201. // temp.DIId = item.DIId;
  14202. // temp.VisaClient = item.VisaClient;
  14203. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  14204. // temp.VisaCurrency = item.VisaCurrency;
  14205. // temp.IsThird = item.IsThird;
  14206. // if (dic_psg.ContainsKey(item.PassengerType))
  14207. // {
  14208. // temp.PassengerType = dic_psg[item.PassengerType];
  14209. // }
  14210. // else {
  14211. // temp.PassengerType = -1;
  14212. // }
  14213. // temp.VisaNumber = item.VisaNumber;
  14214. // temp.VisaFreeNumber = item.VisaFreeNumber;
  14215. // temp.CreateUserId = item.Operators;
  14216. // DateTime dt_ct;
  14217. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  14218. // if (b_ct)
  14219. // {
  14220. // temp.CreateTime = dt_ct;
  14221. // }
  14222. // else
  14223. // {
  14224. // temp.CreateTime = DateTime.Now;
  14225. // }
  14226. // temp.DeleteTime = "";
  14227. // temp.DeleteUserId = 0;
  14228. // temp.Remark = item.Remark;
  14229. // if (string.IsNullOrEmpty(temp.Remark)) {
  14230. // temp.Remark = "";
  14231. // }
  14232. // temp.IsDel = item.IsDel;
  14233. // temp.VisaDescription = item.VisaAttachment;
  14234. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  14235. //([Id]
  14236. // ,[DIId]
  14237. // ,[VisaClient]
  14238. // ,[VisaPrice]
  14239. // ,[VisaCurrency]
  14240. // ,[IsThird]
  14241. // ,[PassengerType]
  14242. // ,[VisaNumber]
  14243. // ,[VisaFreeNumber]
  14244. // ,[CreateUserId]
  14245. // ,[CreateTime]
  14246. // ,[DeleteTime]
  14247. // ,[DeleteUserId]
  14248. // ,[Remark]
  14249. // ,[IsDel]
  14250. // ,[visaDescription])
  14251. // VALUES
  14252. // ({0},{1},'{2}',{3},{4}
  14253. //,{5},{6},{7},{8},{9}
  14254. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  14255. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  14256. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  14257. //);
  14258. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  14259. // }
  14260. // return Ok(JsonView(true, "操作成功!"));
  14261. // }
  14262. /// <summary>
  14263. /// 123132123
  14264. /// </summary>
  14265. /// <param name="_dto"></param>
  14266. /// <returns></returns>
  14267. [HttpPost]
  14268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14269. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14270. {
  14271. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14272. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  14273. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  14274. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14275. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  14276. dicDetail.Add(789, 1034);
  14277. dicDetail.Add(790, 1035);
  14278. dicDetail.Add(791, 1036);
  14279. dicDetail.Add(792, 1037);
  14280. dicDetail.Add(793, 1038);
  14281. dicDetail.Add(794, 1039);
  14282. dicDetail.Add(795, 1040);
  14283. dicDetail.Add(796, 1041);
  14284. dicDetail.Add(797, 1042);
  14285. dicDetail.Add(798, 1043);
  14286. dicDetail.Add(801, 1044);
  14287. dicDetail.Add(802, 1045);
  14288. dicDetail.Add(803, 1046);
  14289. Dictionary<int, int> dic = new Dictionary<int, int>();
  14290. dic.Add(806, 1027);
  14291. dic.Add(807, 1028);
  14292. dic.Add(808, 1029);
  14293. dic.Add(809, 1030);
  14294. dic.Add(810, 1031);
  14295. dic.Add(811, 1032);
  14296. dic.Add(812, 1033);
  14297. foreach (var item in list_visa)
  14298. {
  14299. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  14300. temp.Coefficient = item.coefficient;
  14301. DateTime dtCrt;
  14302. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  14303. if (b1)
  14304. {
  14305. temp.CreateTime = dtCrt;
  14306. }
  14307. else
  14308. {
  14309. temp.CreateTime = DateTime.Now;
  14310. }
  14311. temp.CreateUserId = item.Operators;
  14312. temp.DeleteTime = "";
  14313. temp.DeleteUserId = 0;
  14314. temp.DiId = int.Parse(item.DIID);
  14315. temp.FilePath = item.FilePath;
  14316. temp.IsDel = item.IsDel;
  14317. temp.Price = item.Price;
  14318. temp.PriceCount = 1;
  14319. temp.PriceCurrency = item.Currency;
  14320. int detailId = 0;
  14321. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  14322. {
  14323. detailId = dicDetail[item.PriceTypeDetail];
  14324. }
  14325. temp.PriceDetailType = detailId;
  14326. temp.PriceDt = DateTime.Now;
  14327. temp.PriceName = item.PriceName;
  14328. temp.PriceSum = item.Price;
  14329. int tid = 0;
  14330. if (dic.ContainsKey(item.PriceType))
  14331. {
  14332. tid = dic[item.PriceType];
  14333. }
  14334. temp.PriceType = tid;
  14335. temp.Remark = item.Remark;
  14336. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  14337. }
  14338. return Ok(JsonView(true, "操作成功!"));
  14339. }
  14340. }
  14341. }