GroupsController.cs 654 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Tables;
  4. using Microsoft.AspNetCore.SignalR;
  5. using NPOI.HSSF.UserModel;
  6. using NPOI.SS.UserModel;
  7. using NPOI.SS.Util;
  8. using NPOI.XSSF.UserModel;
  9. using OASystem.API.OAMethodLib;
  10. using OASystem.API.OAMethodLib.File;
  11. using OASystem.API.OAMethodLib.Hub.HubClients;
  12. using OASystem.API.OAMethodLib.Hub.Hubs;
  13. using OASystem.API.OAMethodLib.JuHeAPI;
  14. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  15. using OASystem.Domain.Dtos.CRM;
  16. using OASystem.Domain.Dtos.FileDto;
  17. using OASystem.Domain.Dtos.Groups;
  18. using OASystem.Domain.Entities.Customer;
  19. using OASystem.Domain.Entities.Financial;
  20. using OASystem.Domain.Entities.Groups;
  21. using OASystem.Domain.ViewModels.Groups;
  22. using OASystem.Infrastructure.Repositories.Groups;
  23. using Quartz.Util;
  24. using SqlSugar.Extensions;
  25. using System.Collections;
  26. using System.Data;
  27. using System.Diagnostics;
  28. using System.Globalization;
  29. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  30. using Bookmark = Aspose.Words.Bookmark;
  31. using Cell = Aspose.Words.Tables.Cell;
  32. using Table = Aspose.Words.Tables.Table;
  33. namespace OASystem.API.Controllers
  34. {
  35. /// <summary>
  36. /// 团组相关
  37. /// </summary>
  38. //[Authorize]
  39. [Route("api/[controller]/[action]")]
  40. public class GroupsController : ControllerBase
  41. {
  42. private readonly ILogger<GroupsController> _logger;
  43. private readonly GrpScheduleRepository _grpScheduleRep;
  44. private readonly IMapper _mapper;
  45. private readonly DelegationInfoRepository _groupRepository;
  46. private readonly TaskAssignmentRepository _taskAssignmentRep;
  47. private readonly AirTicketResRepository _airTicketResRep;
  48. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  49. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  50. private readonly DelegationEnDataRepository _delegationEnDataRep;
  51. private readonly DelegationVisaRepository _delegationVisaRep;
  52. private readonly VisaPriceRepository _visaPriceRep;
  53. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  54. private readonly HotelPriceRepository _hotelPriceRep;
  55. private readonly CustomersRepository _customersRep;
  56. private readonly MessageRepository _message;
  57. private readonly SqlSugarClient _sqlSugar;
  58. private readonly TourClientListRepository _tourClientListRep;
  59. private readonly TeamRateRepository _teamRateRep;
  60. #region 成本相关
  61. private readonly CheckBoxsRepository _checkBoxs;
  62. private readonly GroupCostRepository _GroupCostRepository;
  63. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  64. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  65. #endregion
  66. private readonly SetDataRepository _setDataRep;
  67. private string url;
  68. private string path;
  69. private readonly EnterExitCostRepository _enterExitCostRep;
  70. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  71. private readonly UsersRepository _usersRep;
  72. private readonly IJuHeApiService _juHeApi;
  73. private readonly InvertedListRepository _invertedListRep;
  74. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  75. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  76. private readonly ThreeCodeRepository _threeCodeRepository;
  77. private readonly HotelInquiryRepository _hotelInquiryRep;
  78. private readonly FeeAuditRepository _feeAuditRep;
  79. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  80. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  81. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  82. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  83. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  84. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  85. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  86. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  87. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep)
  88. {
  89. _logger = logger;
  90. _mapper = mapper;
  91. _grpScheduleRep = grpScheduleRep;
  92. _groupRepository = groupRepository;
  93. _taskAssignmentRep = taskAssignmentRep;
  94. _airTicketResRep = airTicketResRep;
  95. _sqlSugar = sqlSugar;
  96. url = AppSettingsHelper.Get("ExcelBaseUrl");
  97. path = AppSettingsHelper.Get("ExcelBasePath");
  98. if (!System.IO.Directory.Exists(path))
  99. {
  100. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  101. }
  102. _decreasePaymentsRep = decreasePaymentsRep;
  103. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  104. _delegationEnDataRep = delegationEnDataRep;
  105. _enterExitCostRep = enterExitCostRep;
  106. _delegationVisaRep = delegationVisaRep;
  107. _message = message;
  108. _visaPriceRep = visaPriceRep;
  109. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  110. _checkBoxs = checkBoxs;
  111. _GroupCostRepository = GroupCostRepository;
  112. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  113. _GroupCostParameterRepository = GroupCostParameterRepository;
  114. _hotelPriceRep = hotelPriceRep;
  115. _customersRep = customersRep;
  116. _setDataRep = setDataRep;
  117. _tourClientListRep = tourClientListRep;
  118. _teamRateRep = teamRateRep;
  119. _hubContext = hubContext;
  120. _usersRep = usersRep;
  121. _juHeApi = juHeApi;
  122. _invertedListRep = invertedListRep;
  123. _visaFeeInfoRep = visaFeeInfoRep;
  124. _ticketBlackCodeRep = ticketBlackCodeRep;
  125. _hotelInquiryRep = hotelInquiryRep;
  126. _threeCodeRepository = threeCodeRepository;
  127. _feeAuditRep = feeAuditRep;
  128. }
  129. #region 流程管控
  130. /// <summary>
  131. /// 获取团组流程管控信息
  132. /// </summary>
  133. /// <param name="paras">参数Json字符串</param>
  134. /// <returns></returns>
  135. [HttpPost]
  136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  137. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  138. {
  139. if (string.IsNullOrEmpty(_jsonDto.Paras))
  140. {
  141. return Ok(JsonView(false, "参数为空"));
  142. }
  143. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  144. if (_ScheduleDto != null)
  145. {
  146. if (_ScheduleDto.SearchType == 2)//获取列表
  147. {
  148. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  149. return Ok(JsonView(_grpScheduleViewList));
  150. }
  151. else//获取对象
  152. {
  153. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  154. if (_grpScheduleView != null)
  155. {
  156. return Ok(JsonView(_grpScheduleView));
  157. }
  158. }
  159. }
  160. else
  161. {
  162. return Ok(JsonView(false, "参数反序列化失败"));
  163. }
  164. return Ok(JsonView(false, "暂无数据!"));
  165. }
  166. /// <summary>
  167. /// 修改团组流程管控详细表数据
  168. /// </summary>
  169. /// <param name="paras"></param>
  170. /// <returns></returns>
  171. [HttpPost]
  172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  173. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  174. {
  175. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  176. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  177. .SetColumns(it => it.Duty == _detail.Duty)
  178. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  179. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  180. .SetColumns(it => it.JobContent == _detail.JobContent)
  181. .SetColumns(it => it.Remark == _detail.Remark)
  182. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  183. .Where(s => s.Id == dto.Id)
  184. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  185. .ExecuteCommandAsync();
  186. if (result > 0)
  187. {
  188. return Ok(JsonView(true, "保存成功!"));
  189. }
  190. return Ok(JsonView(false, "保存失败!"));
  191. }
  192. /// <summary>
  193. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  194. /// </summary>
  195. /// <param name="dto"></param>
  196. /// <returns></returns>
  197. [HttpPost]
  198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  199. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  200. {
  201. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  202. _detail.IsDel = 1;
  203. _detail.DeleteUserId = dto.Duty;
  204. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  205. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  206. .SetColumns(it => it.IsDel == _detail.IsDel)
  207. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  208. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  209. .Where(it => it.Id == dto.Id)
  210. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  211. //.WhereColumns(s => s.Id == dto.Id)
  212. .ExecuteCommandAsync();
  213. if (result > 0)
  214. {
  215. return Ok(JsonView(true, "删除成功!"));
  216. }
  217. return Ok(JsonView(false, "删除失败!"));
  218. }
  219. /// <summary>
  220. /// 增加团组流程管控详细表数据
  221. /// </summary>
  222. /// <param name="dto"></param>
  223. /// <returns></returns>
  224. [HttpPost]
  225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  226. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  227. {
  228. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  229. if (DateTime.Now < _detail.ExpectBeginDt)
  230. {
  231. _detail.StepStatus = 0;
  232. }
  233. else
  234. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  235. _detail.StepStatus = 1;
  236. }
  237. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  238. if (result > 0)
  239. {
  240. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  241. return Ok(JsonView(true, "添加成功!", _result));
  242. }
  243. return Ok(JsonView(false, "添加失败!"));
  244. }
  245. #endregion
  246. #region 团组基本信息
  247. /// <summary>
  248. /// 接团信息列表
  249. /// </summary>
  250. /// <param name="dto">团组列表请求dto</param>
  251. /// <returns></returns>
  252. [HttpPost]
  253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  254. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  255. {
  256. var groupData = await _groupRepository.GetGroupList(dto);
  257. if (groupData.Code != 0)
  258. {
  259. return Ok(JsonView(false, groupData.Msg));
  260. }
  261. return Ok(JsonView(groupData.Data));
  262. }
  263. /// <summary>
  264. /// 分页查询团组列表
  265. /// </summary>
  266. /// <param name="dto"></param>
  267. /// <returns></returns>
  268. [HttpPost]
  269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  270. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  271. {
  272. var watch = new Stopwatch();
  273. watch.Start();
  274. RefAsync<int> total = 0;
  275. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  276. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  277. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  278. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  279. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  280. .Distinct()
  281. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  282. watch.Stop();
  283. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  284. }
  285. /// <summary>
  286. /// 接团信息列表 Page
  287. /// </summary>
  288. /// <param name="dto">团组列表请求dto</param>
  289. /// <returns></returns>
  290. [HttpPost]
  291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  292. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  293. {
  294. #region 参数验证
  295. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  296. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  297. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  298. #region 页面操作权限验证
  299. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  300. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  301. #endregion
  302. #endregion
  303. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  304. {
  305. string sqlWhere = string.Empty;
  306. if (dto.IsSure == 0) //未完成
  307. {
  308. sqlWhere += string.Format(@" And IsSure = 0");
  309. }
  310. else if (dto.IsSure == 1) //已完成
  311. {
  312. sqlWhere += string.Format(@" And IsSure = 1");
  313. }
  314. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  315. {
  316. string tj = dto.SearchCriteria;
  317. 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}%')",
  318. tj, tj, tj, tj, tj);
  319. }
  320. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  321. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  322. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  323. JietuanOperator,IsSure,CreateTime,IsBid
  324. From (
  325. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  326. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  327. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  328. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  329. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  330. From Grp_DelegationInfo gdi
  331. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  332. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  333. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  334. Where gdi.IsDel = 0 {0}
  335. ) temp", sqlWhere);
  336. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  337. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  338. #region 处理所属部门
  339. /*
  340. * 1.sq 和 gyy 等显示 市场部
  341. * 2.王鸽和主管及张总还有管理员号统一国交部
  342. * 2-1. 4 管理员 ,21 张海麟
  343. */
  344. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  345. List<int> userIds1 = new List<int>() { 4, 21 };
  346. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  347. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  348. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  349. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  350. .ToList();
  351. foreach (var item in _DelegationList)
  352. {
  353. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  354. }
  355. #endregion
  356. var _view = new
  357. {
  358. PageFuncAuth = pageFunAuthView,
  359. Data = _DelegationList
  360. };
  361. return Ok(JsonView(true, "查询成功!", _view, total));
  362. }
  363. else
  364. {
  365. return Ok(JsonView(false, "查询失败"));
  366. }
  367. }
  368. /// <summary>
  369. /// 团组列表
  370. /// </summary>
  371. /// <returns></returns>
  372. [HttpPost]
  373. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  374. {
  375. #region 参数验证
  376. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  377. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  378. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  379. #region 页面操作权限验证
  380. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  381. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  382. #endregion
  383. #endregion
  384. if (dto.PortType != 1 && dto.PortType != 2)
  385. {
  386. return Ok(JsonView(false, "查询失败!"));
  387. }
  388. string orderbyStr = "order by gdi.CreateTime Desc";
  389. string sqlWhere = string.Empty;
  390. if (dto.IsSure == 0) //未完成
  391. {
  392. sqlWhere += string.Format(@" And IsSure = 0");
  393. }
  394. else if (dto.IsSure == 1) //已完成
  395. {
  396. sqlWhere += string.Format(@" And IsSure = 1");
  397. }
  398. //团组类型
  399. if (dto.TeamDid > 0)
  400. {
  401. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  402. }
  403. //团组名称
  404. if (!string.IsNullOrEmpty(dto.TeamName))
  405. {
  406. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  407. }
  408. //客户名称
  409. if (!string.IsNullOrEmpty(dto.ClientName))
  410. {
  411. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  412. }
  413. //客户单位
  414. if (!string.IsNullOrEmpty(dto.ClientUnit))
  415. {
  416. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  417. }
  418. //出访时间
  419. if (!string.IsNullOrEmpty(dto.visitDataTime))
  420. {
  421. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  422. orderbyStr = "order by gdi.VisitDate";
  423. }
  424. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  425. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  426. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  427. JietuanOperator,IsSure,CreateTime
  428. From (
  429. Select row_number() over({0}) as Row_Number,
  430. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  431. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  432. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  433. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  434. From Grp_DelegationInfo gdi
  435. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  436. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  437. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  438. Where gdi.IsDel = 0 {1}
  439. ) temp ", orderbyStr, sqlWhere);
  440. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  441. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  442. #region 处理所属部门
  443. /*
  444. * 1.sq 和 gyy 等显示 市场部
  445. * 2.王鸽和主管及张总还有管理员号统一国交部
  446. * 2-1. 4 管理员 ,21 张海麟
  447. */
  448. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  449. List<int> userIds1 = new List<int>() { 4, 21 };
  450. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  451. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  452. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  453. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  454. .ToList();
  455. foreach (var item in _DelegationList)
  456. {
  457. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  458. }
  459. #endregion
  460. var _view = new
  461. {
  462. PageFuncAuth = pageFunAuthView,
  463. Data = _DelegationList
  464. };
  465. return Ok(JsonView(true, "查询成功!", _view, total));
  466. }
  467. /// <summary>
  468. /// 接团信息详情
  469. /// </summary>
  470. /// <param name="dto">团组info请求dto</param>
  471. /// <returns></returns>
  472. [HttpPost]
  473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  474. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  475. {
  476. var groupData = await _groupRepository.GetGroupInfo(dto);
  477. if (groupData.Code != 0)
  478. {
  479. return Ok(JsonView(false, groupData.Msg));
  480. }
  481. return Ok(JsonView(groupData.Data));
  482. }
  483. /// <summary>
  484. /// 接团信息 编辑添加
  485. /// 基础信息数据源
  486. /// </summary>
  487. /// <param name="dto"></param>
  488. /// <returns></returns>
  489. [HttpPost]
  490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  491. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  492. {
  493. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  494. if (groupData.Code != 0)
  495. {
  496. return Ok(JsonView(false, groupData.Msg));
  497. }
  498. return Ok(JsonView(groupData.Data));
  499. }
  500. /// <summary>
  501. /// 接团信息 操作(增改)
  502. /// </summary>
  503. /// <param name="dto"></param>
  504. /// <returns></returns>
  505. [HttpPost]
  506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  507. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  508. {
  509. try
  510. {
  511. var groupData = await _groupRepository.GroupOperation(dto);
  512. if (groupData.Code != 0)
  513. {
  514. return Ok(JsonView(false, groupData.Msg));
  515. }
  516. int diId = 0;
  517. //添加时 默认加入团组汇率
  518. if (dto.Status == 1) //添加
  519. {
  520. diId = groupData.Data;
  521. //添加默认币种
  522. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  523. //默认分配权限
  524. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  525. //消息提示 王鸽 主管号
  526. List<int> _managerIds = new List<int>() { 22, 32 };
  527. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  528. if (userIds.Count > 0)
  529. {
  530. userIds.Add(208);
  531. //创建团组管控
  532. GroupStepForDelegation.CreateWorkStep(diId);
  533. //发送消息
  534. string groupName = dto.TeamName;
  535. string createGroupUser = string.Empty;
  536. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  537. if (userInfo != null) createGroupUser = userInfo.CnName;
  538. string title = $"系统通知";
  539. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  540. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  541. }
  542. //默认创建倒推表
  543. await _invertedListRep._Create(dto.UserId, diId);
  544. }
  545. else if (dto.Status == 2)
  546. {
  547. diId = dto.Id;
  548. }
  549. return Ok(JsonView(true, "操作成功!", diId));
  550. }
  551. catch (Exception ex)
  552. {
  553. Logs("[response]" + JsonConvert.SerializeObject(dto));
  554. Logs(ex.Message);
  555. return Ok(JsonView(false, ex.Message));
  556. }
  557. }
  558. /// <summary>
  559. /// 接团流程操作(增改)
  560. /// 安卓端使用 建团时添加客户名单
  561. /// </summary>
  562. /// <param name="dto"></param>
  563. /// <returns></returns>
  564. [HttpPost]
  565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  566. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  567. {
  568. try
  569. {
  570. #region 参数验证
  571. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  572. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  573. #region 页面操作权限验证
  574. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  575. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  576. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  577. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  578. #endregion
  579. #endregion
  580. _sqlSugar.BeginTran();
  581. var _dto = new GroupOperationDto();
  582. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  583. var groupData = await _groupRepository.GroupOperation(_dto);
  584. if (groupData.Code != 0)
  585. {
  586. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  587. }
  588. int diId = 0;
  589. //添加时 默认加入团组汇率
  590. if (dto.Status == 1) //添加
  591. {
  592. diId = groupData.Data;
  593. //添加默认币种
  594. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  595. //默认分配权限
  596. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  597. //消息提示 王鸽 主管号
  598. List<int> _managerIds = new List<int>() { 22, 32 };
  599. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  600. if (userIds.Count > 0)
  601. {
  602. userIds.Add(208);
  603. //创建团组管控
  604. GroupStepForDelegation.CreateWorkStep(diId);
  605. //发送消息
  606. string groupName = dto.TeamName;
  607. string createGroupUser = string.Empty;
  608. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  609. if (userInfo != null) createGroupUser = userInfo.CnName;
  610. string title = $"系统通知";
  611. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  612. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  613. }
  614. }
  615. if (dto.Status == 2)
  616. {
  617. diId = dto.Id;
  618. if (diId == 0)
  619. {
  620. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  621. }
  622. }
  623. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  624. if (viewData.Code != 0)
  625. {
  626. _sqlSugar.RollbackTran();
  627. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  628. }
  629. _sqlSugar.CommitTran();
  630. return Ok(JsonView(true, "添加成功"));
  631. }
  632. catch (Exception ex)
  633. {
  634. _sqlSugar.RollbackTran();
  635. return Ok(JsonView(false, ex.Message));
  636. }
  637. }
  638. /// <summary>
  639. /// 接团信息 操作(删除)
  640. /// </summary>
  641. /// <param name="dto"></param>
  642. /// <returns></returns>
  643. [HttpPost]
  644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  645. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  646. {
  647. try
  648. {
  649. var groupData = await _groupRepository.GroupDel(dto);
  650. if (groupData.Code != 0)
  651. {
  652. return Ok(JsonView(false, groupData.Msg));
  653. }
  654. return Ok(JsonView(true));
  655. }
  656. catch (Exception ex)
  657. {
  658. Logs("[response]" + JsonConvert.SerializeObject(dto));
  659. Logs(ex.Message);
  660. return Ok(JsonView(false, ex.Message));
  661. }
  662. }
  663. /// <summary>
  664. /// 获取团组销售报价号
  665. /// 团组添加时 使用
  666. /// </summary>
  667. /// <returns></returns>
  668. [HttpPost]
  669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  670. public async Task<IActionResult> GetGroupSalesQuoteNo()
  671. {
  672. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  673. if (groupData.Code != 0)
  674. {
  675. return Ok(JsonView(false, groupData.Msg));
  676. }
  677. object salesQuoteNo = new
  678. {
  679. SalesQuoteNo = groupData.Data
  680. };
  681. return Ok(JsonView(salesQuoteNo));
  682. }
  683. /// <summary>
  684. /// 设置确认出团
  685. /// </summary>
  686. /// <param name="dto"></param>
  687. /// <returns></returns>
  688. [HttpPost]
  689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  690. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  691. {
  692. var groupData = await _groupRepository.ConfirmationGroup(dto);
  693. if (groupData.Code != 0)
  694. {
  695. return Ok(JsonView(false, groupData.Msg));
  696. }
  697. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  698. #region OA消息推送
  699. try
  700. {
  701. string groupName = groupInfo.TeamName;
  702. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  703. List<int> userIds = new List<int>();
  704. listUser.ForEach(s => userIds.Add(s.Id));
  705. string title = $"系统通知";
  706. string content = $"团组[{groupName}]已确认出团!";
  707. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  708. }
  709. catch (Exception ex)
  710. {
  711. }
  712. #endregion
  713. #region 应用推送
  714. try
  715. {
  716. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  717. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  718. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  719. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  720. {
  721. List<string> userList = new List<string>() { users.QiyeChatUserId };
  722. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  723. }
  724. }
  725. catch (Exception ex)
  726. {
  727. }
  728. #endregion
  729. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  730. return Ok(JsonView(true, "操作成功!", groupData.Data));
  731. }
  732. /// <summary>
  733. /// 获取团组名称data And 签证国别Data
  734. /// </summary>
  735. /// <param name="dto"></param>
  736. /// <returns></returns>
  737. [HttpPost]
  738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  739. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  740. {
  741. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  742. if (groupData.Code != 0)
  743. {
  744. return Ok(JsonView(false, groupData.Msg));
  745. }
  746. return Ok(JsonView(groupData.Data));
  747. }
  748. /// <summary>
  749. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  750. /// </summary>
  751. /// <returns></returns>
  752. [HttpPost]
  753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  754. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  755. {
  756. try
  757. {
  758. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  759. if (groupData.Code != 0)
  760. {
  761. return Ok(JsonView(false, groupData.Msg));
  762. }
  763. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  764. }
  765. catch (Exception ex)
  766. {
  767. return Ok(JsonView(false, "程序错误!"));
  768. throw;
  769. }
  770. }
  771. #endregion
  772. #region 团组&签证
  773. /// <summary>
  774. /// 根据团组Id获取签证客户信息List
  775. /// </summary>
  776. /// <param name="dto">请求dto</param>
  777. /// <returns></returns>
  778. [HttpPost]
  779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  780. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  781. {
  782. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  783. if (groupData.Code != 0)
  784. {
  785. return Ok(JsonView(false, groupData.Msg));
  786. }
  787. return Ok(JsonView(groupData.Data));
  788. }
  789. /// <summary>
  790. /// IOS获取团组签证拍照上传进度01(团组列表)
  791. /// </summary>
  792. /// <param name="dto">请求dto</param>
  793. /// <returns></returns>
  794. [HttpPost]
  795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  796. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  797. {
  798. if (dto == null)
  799. {
  800. return Ok(JsonView(false, "参数为空"));
  801. }
  802. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  803. return Ok(JsonView(visaList));
  804. }
  805. /// <summary>
  806. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  807. /// </summary>
  808. /// <returns></returns>
  809. [HttpPost]
  810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  811. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  812. {
  813. if (dto == null)
  814. {
  815. return Ok(JsonView(false, "请求错误:"));
  816. }
  817. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  818. return Ok(JsonView(list));
  819. }
  820. /// <summary>
  821. /// IOS获取团组签证拍照上传进度03(相册)
  822. /// </summary>
  823. /// <returns></returns>
  824. [HttpPost]
  825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  826. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  827. {
  828. if (dto == null)
  829. {
  830. return Ok(JsonView(false, "请求错误:"));
  831. }
  832. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  833. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  834. list.ForEach(s => s.url = url);
  835. return Ok(JsonView(list));
  836. }
  837. /// <summary>
  838. /// IOS获取团组签证拍照上传进度04(图片上传)
  839. /// </summary>
  840. /// <param name="dto"></param>
  841. /// <returns></returns>
  842. [HttpPost]
  843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  844. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  845. {
  846. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  847. //if (!string.IsNullOrEmpty(result))
  848. //{
  849. //}
  850. //else {
  851. // return Ok(JsonView(false, "上传失败"));
  852. //}
  853. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  854. int sucNum = 0;
  855. try
  856. {
  857. foreach (var item in dto.base64DataList)
  858. {
  859. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  860. string result = decodeBase64ToImage(item, imageName);
  861. if (!string.IsNullOrEmpty(result))
  862. {
  863. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  864. pic.CreateUserId = dto.CreateUserId;
  865. pic.PicName = imageName;
  866. pic.PicPath = result;
  867. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  868. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  869. if (insertResult > 0)
  870. {
  871. sucNum++;
  872. }
  873. }
  874. }
  875. }
  876. catch (Exception ex)
  877. {
  878. return Ok(JsonView(false, ex.Message));
  879. }
  880. string msg = string.Format(@"成功上传{0}张", sucNum);
  881. return Ok(JsonView(true, msg));
  882. }
  883. private string decodeBase64ToImage(string base64DataURL, string imgName)
  884. {
  885. string filename = "";//声明一个string类型的相对路径
  886. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  887. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  888. try//会有异常抛出,try,catch一下
  889. {
  890. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  891. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  892. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  893. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  894. //文件名称
  895. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  896. //上传的文件的路径
  897. string filePath = "";
  898. if (!Directory.Exists(fileDir))
  899. {
  900. Directory.CreateDirectory(fileDir);
  901. }
  902. //上传的文件的路径
  903. filePath = fileDir + filename;
  904. //string url = HttpRuntime.AppDomainAppPath.ToString();
  905. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  906. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  907. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  908. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  909. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  910. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  911. ms.Close();//关闭当前流,并释放所有与之关联的资源
  912. bitmap.Dispose();
  913. }
  914. catch (Exception e)
  915. {
  916. string massage = e.Message;
  917. Logs("IOS图片上传Error:" + massage);
  918. //filename = e.Message;
  919. }
  920. return filename;//返回相对路径
  921. }
  922. /// <summary>
  923. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  924. /// </summary>
  925. /// <param name="dto"></param>
  926. /// <returns></returns>
  927. [HttpPost]
  928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  929. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  930. {
  931. if (dto == null)
  932. {
  933. return Ok(JsonView(false, "请求错误:"));
  934. }
  935. string msg = "参数错误";
  936. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  937. {
  938. try
  939. {
  940. //_delegationVisaRep.BeginTran();
  941. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  942. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  943. .Where(s => s.Id == dto.visaProgressCustomerId)
  944. .ExecuteCommandAsync();
  945. if (updCount > 0 && dto.publishCode == 1)
  946. {
  947. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  948. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  949. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  950. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  951. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  952. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  953. if (groupData == null)
  954. {
  955. _delegationVisaRep.RollbackTran();
  956. }
  957. string title = string.Format(@"[签证进度更新]");
  958. string content = string.Format(@"测试文本");
  959. bool rst = await _message.AddMsg(new MessageDto()
  960. {
  961. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  962. IssuerId = dto.publisher,
  963. Title = title,
  964. Content = content,
  965. ReleaseTime = DateTime.Now,
  966. UIdList = new List<int> {
  967. 234
  968. }
  969. });
  970. if (rst)
  971. {
  972. return Ok(JsonView(true, "发送通知成功"));
  973. }
  974. }
  975. //_delegationVisaRep.CommitTran();
  976. }
  977. catch (Exception)
  978. {
  979. //_delegationVisaRep.RollbackTran();
  980. }
  981. }
  982. return Ok(JsonView(true, msg));
  983. }
  984. #endregion
  985. #region 团组任务分配
  986. /// <summary>
  987. /// 团组任务分配初始化
  988. /// </summary>
  989. /// <param name="dto"></param>
  990. /// <returns></returns>
  991. [HttpPost]
  992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  993. public async Task<IActionResult> GetTaskAssignmen()
  994. {
  995. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  996. if (groupData.Code != 0)
  997. {
  998. return Ok(JsonView(false, groupData.Msg));
  999. }
  1000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1001. }
  1002. /// <summary>
  1003. /// 团组任务分配查询
  1004. /// </summary>
  1005. /// <param name="dto"></param>
  1006. /// <returns></returns>
  1007. [HttpPost]
  1008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1009. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1010. {
  1011. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1012. if (groupData.Code != 0)
  1013. {
  1014. return Ok(JsonView(false, groupData.Msg));
  1015. }
  1016. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1017. }
  1018. /// <summary>
  1019. /// 团组任务分配操作
  1020. /// </summary>
  1021. /// <param name="dto"></param>
  1022. /// <returns></returns>
  1023. [HttpPost]
  1024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1025. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1026. {
  1027. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1028. if (groupData.Code != 0)
  1029. {
  1030. return Ok(JsonView(false, groupData.Msg));
  1031. }
  1032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1033. }
  1034. /// <summary>
  1035. /// 团组任务分配
  1036. /// 批量分配
  1037. /// 查询团组
  1038. /// </summary>
  1039. /// <param name="dto"></param>
  1040. /// <returns></returns>
  1041. [HttpPost]
  1042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1043. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1044. {
  1045. //参数验证
  1046. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1047. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1048. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1049. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1050. }
  1051. /// <summary>
  1052. /// 团组任务分配
  1053. /// 批量分配
  1054. /// </summary>
  1055. /// <param name="dto"></param>
  1056. /// <returns></returns>
  1057. [HttpPost]
  1058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1059. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1060. {
  1061. //参数验证
  1062. if (dto.UserId < 1 ) return Ok(JsonView(false, MsgTips.UserId));
  1063. if (dto.OperateId < 1) return Ok(JsonView(false, MsgTips.OperateId));
  1064. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请传入有效的GroupIds数组参数!"));
  1065. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1066. }
  1067. #endregion
  1068. #region 团组费用审核
  1069. /// <summary>
  1070. /// 费用审核
  1071. /// 团组列表 Page
  1072. /// </summary>
  1073. /// <param name="_dto">团组列表请求dto</param>
  1074. /// <returns></returns>
  1075. [HttpPost]
  1076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1077. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1078. {
  1079. #region 参数验证
  1080. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1081. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1082. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1083. #region 页面操作权限验证
  1084. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1085. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1086. #endregion
  1087. #endregion
  1088. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1089. {
  1090. string sqlWhere = string.Empty;
  1091. if (_dto.IsSure == 0) //未完成
  1092. {
  1093. sqlWhere += string.Format(@" And IsSure = 0");
  1094. }
  1095. else if (_dto.IsSure == 1) //已完成
  1096. {
  1097. sqlWhere += string.Format(@" And IsSure = 1");
  1098. }
  1099. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1100. {
  1101. string tj = _dto.SearchCriteria;
  1102. 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}%')",
  1103. tj, tj, tj, tj, tj);
  1104. }
  1105. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1106. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1107. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1108. From (
  1109. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1110. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1111. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1112. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1113. From Grp_DelegationInfo gdi
  1114. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1115. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1116. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1117. Where gdi.IsDel = 0 {0}
  1118. ) temp ", sqlWhere);
  1119. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1120. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1121. var _view = new
  1122. {
  1123. PageFuncAuth = pageFunAuthView,
  1124. Data = _DelegationList
  1125. };
  1126. return Ok(JsonView(true, "查询成功!", _view, total));
  1127. }
  1128. else
  1129. {
  1130. return Ok(JsonView(false, "查询失败"));
  1131. }
  1132. }
  1133. /// <summary>
  1134. /// 获取团组费用审核
  1135. /// </summary>
  1136. /// <param name="paras">参数Json字符串</param>
  1137. /// <returns></returns>
  1138. [HttpPost]
  1139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1140. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1141. {
  1142. try
  1143. {
  1144. #region 参数验证
  1145. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1146. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1147. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1148. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1149. #region 页面操作权限验证
  1150. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1151. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1152. #endregion
  1153. #endregion
  1154. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1155. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1156. #region 费用清单
  1157. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1158. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1159. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1160. List<Grp_CreditCardPayment> entityList = _groupRepository
  1161. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1162. .Where(exp.ToExpression())
  1163. .ToList();
  1164. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1165. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1166. /*
  1167. * 76://酒店预订
  1168. */
  1169. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1170. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1171. .ToListAsync();
  1172. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1173. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1174. .ToListAsync();
  1175. /*
  1176. * 79://车/导游地接
  1177. */
  1178. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1179. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1180. .ToListAsync();
  1181. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1182. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1183. .ToListAsync();
  1184. /*
  1185. * 80: //签证
  1186. */
  1187. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1188. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1189. .ToListAsync();
  1190. /*
  1191. *81: //邀请/公务活动
  1192. */
  1193. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1194. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1195. .ToListAsync();
  1196. /*
  1197. * 82: //团组客户保险
  1198. */
  1199. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1200. /*
  1201. * Lable = 85 机票预订
  1202. */
  1203. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1204. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1205. .ToListAsync();
  1206. /*
  1207. * 85 机票预定
  1208. */
  1209. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1210. /*
  1211. * 98 其他款项
  1212. */
  1213. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1214. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1215. .ToListAsync();
  1216. /*
  1217. * 285:收款退还
  1218. */
  1219. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1220. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1221. .ToListAsync();
  1222. /*
  1223. * 1015: //超支费用
  1224. */
  1225. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1226. /*
  1227. * 币种信息
  1228. */
  1229. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1230. /*
  1231. * 车/导游地接 费用类型
  1232. */
  1233. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1234. /*
  1235. * 车/导游地接 费用类型
  1236. */
  1237. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1238. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1239. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1240. /*
  1241. * 用户信息
  1242. */
  1243. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1244. /*
  1245. * 费用模块
  1246. */
  1247. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1248. string priceModule = string.Empty;
  1249. if (sdPriceName != null)
  1250. {
  1251. priceModule = sdPriceName.Name;
  1252. }
  1253. /*
  1254. * 成本信息
  1255. */
  1256. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1257. decimal _groupRate = 0.0000M;
  1258. string _groupCurrencyCode = "-";
  1259. if (groupCost != null)
  1260. {
  1261. _groupRate = groupCost.Rate;
  1262. if (int.TryParse(groupCost.Currency, out int _currency))
  1263. {
  1264. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1265. }
  1266. else _groupCurrencyCode = groupCost.Currency;
  1267. }
  1268. string costContentSql = $"Select * From Grp_GroupCost";
  1269. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1270. //处理日期为空的天数
  1271. for (int i = 0; i < groupCostDetails.Count; i++)
  1272. if (i != 0)
  1273. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1274. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1275. /*
  1276. * 处理详情数据
  1277. */
  1278. foreach (var entity in entityList)
  1279. {
  1280. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1281. _detail.Id = entity.Id;
  1282. _detail.PriceName = priceModule;
  1283. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1284. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1285. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1286. /*
  1287. * 应付款金额
  1288. */
  1289. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1290. string PaymentCurrency_WaitPay = "Unknown";
  1291. string hotelCurrncyCode = "Unknown";
  1292. string hotelCurrncyName = "Unknown";
  1293. if (sdPaymentCurrency_WaitPay != null)
  1294. {
  1295. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1296. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1297. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1298. if (hotelCurrncyCode.Equals("CNY"))
  1299. {
  1300. entity.DayRate = 1.0000M;
  1301. }
  1302. }
  1303. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1304. /*
  1305. * 此次付款金额
  1306. */
  1307. decimal CurrPayStr = 0;
  1308. if (entity.PayPercentage == 0)
  1309. {
  1310. if (entity.PayThenMoney != 0)
  1311. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1312. }
  1313. else
  1314. {
  1315. if (entity.PayMoney != 0)
  1316. {
  1317. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1318. }
  1319. }
  1320. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1321. /*
  1322. * 剩余尾款
  1323. */
  1324. decimal BalanceStr = 0;
  1325. if (CurrPayStr != 0)
  1326. {
  1327. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1328. BalanceStr = 0;
  1329. else
  1330. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1331. }
  1332. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1333. /*
  1334. * Bus名称
  1335. */
  1336. _detail.BusName = "待增加";
  1337. /*
  1338. *费用所属
  1339. */
  1340. switch (entity.CTable)
  1341. {
  1342. case 76://酒店预订
  1343. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1344. if (hotelReservations != null)
  1345. {
  1346. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1347. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1348. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1349. string roomFeeStr = "", roomFeestr1 = "";
  1350. //是否比较房型价格
  1351. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1352. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1353. roomFeeStr += $"<br/>";
  1354. if (hotelReservations.SingleRoomPrice > 0)
  1355. {
  1356. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1357. __isSingle = true;
  1358. }
  1359. if (hotelReservations.DoubleRoomPrice > 0)
  1360. {
  1361. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1362. __isDouble = true;
  1363. }
  1364. if (hotelReservations.SuiteRoomPrice > 0)
  1365. {
  1366. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1367. __isSuite = true;
  1368. }
  1369. if (hotelReservations.OtherRoomPrice > 0)
  1370. {
  1371. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1372. __isOther = true;
  1373. }
  1374. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1375. else roomFeeStr += " 0.00 * 0";
  1376. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1377. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1378. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1379. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1380. /*
  1381. * 费用类型
  1382. * 1:房费
  1383. * 2:早餐
  1384. * 3:地税
  1385. * 4:城市税
  1386. * </summary>
  1387. */
  1388. //地税
  1389. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1390. if (governmentRentData != null)
  1391. {
  1392. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1393. governmentRentFee = governmentRentData.Price;
  1394. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1395. if (governmentRentCurrData != null)
  1396. {
  1397. governmentRentCode = governmentRentCurrData.Name;
  1398. governmentRentName = $"({governmentRentCurrData.Remark})";
  1399. }
  1400. }
  1401. //城市税
  1402. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1403. if (cityTaxData != null)
  1404. {
  1405. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1406. cityTaxFee = cityTaxData.Price;
  1407. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1408. if (cityTaxCurrData != null)
  1409. {
  1410. cityTaxCode = cityTaxCurrData.Name;
  1411. cityTaxName = $"({cityTaxCurrData.Remark})";
  1412. }
  1413. }
  1414. //酒店早餐
  1415. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1416. if (breakfastData != null)
  1417. {
  1418. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1419. breakfastFee = breakfastData.Price;
  1420. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1421. if (breakfastCurrData != null)
  1422. {
  1423. breakfastCode = breakfastCurrData.Name;
  1424. breakfastName = $"({breakfastCurrData.Remark})";
  1425. }
  1426. }
  1427. //房间费用
  1428. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1429. if (roomData != null)
  1430. {
  1431. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1432. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1433. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1434. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1435. roomFee = roomData.Price;
  1436. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1437. if (roomCurrData != null)
  1438. {
  1439. roomCode = roomCurrData.Name;
  1440. roomName = $"({roomCurrData.Remark})";
  1441. }
  1442. }
  1443. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1444. string hotelCostStr = "";
  1445. decimal hotelCsotTotal = 0.00M;
  1446. if (groupCost != null)
  1447. {
  1448. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1449. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1450. }
  1451. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1452. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1453. string hotelCost_day = "";
  1454. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1455. foreach (var item in hotelCostDetails1)
  1456. {
  1457. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1458. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1459. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1460. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1461. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1462. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1463. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1464. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1465. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1466. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1467. hotelCost_day += @$"</br>";
  1468. }
  1469. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1470. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1471. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1472. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1473. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1474. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1475. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1476. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1477. $"房间说明: {hotelReservations.Remark} <br/>" +
  1478. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1479. $"{hotelBreakfastStr}" +
  1480. $"{hotelGovernmentRentStr}" +
  1481. $"{hotelCityTaxStr}";
  1482. _detail.PriceNameContent = hotelReservations.HotelName;
  1483. }
  1484. break;
  1485. case 79://车/导游地接
  1486. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1487. if (touristGuideGroundReservations != null)
  1488. {
  1489. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1490. {
  1491. _detail.BusName = touristGuideGroundReservations.BusName;
  1492. }
  1493. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1494. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1495. //if (isInt)
  1496. //{
  1497. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1498. // if (cityInfo != null)
  1499. // {
  1500. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1501. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1502. // if (carFeeItem != null)
  1503. // {
  1504. // nameContent += $@"({carFeeItem.Name})";
  1505. // }
  1506. // _detail.PriceNameContent = nameContent;
  1507. // }
  1508. //}
  1509. //else
  1510. //{
  1511. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1512. //}
  1513. var touristGuideGroundReservationsContents =
  1514. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1515. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1516. foreach (var item in touristGuideGroundReservationsContents)
  1517. {
  1518. string typeName = "Unknown";
  1519. string carCurrencyCode = "Unknown";
  1520. string carCurrencyName = "Unknown";
  1521. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1522. if (carTypeData != null) typeName = carTypeData.Name;
  1523. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1524. if (currencyData != null)
  1525. {
  1526. carCurrencyCode = currencyData.Name;
  1527. carCurrencyName = currencyData.Remark;
  1528. }
  1529. //op、成本 币种是否一致
  1530. bool IsCurrencyAgreement = false;
  1531. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1532. string opCostStr = string.Empty;
  1533. decimal opCostTypePrice = 0.00M;
  1534. #region 处理成本各项费用
  1535. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1536. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1537. if (opCost.Count > 0)
  1538. {
  1539. switch (item.SId)
  1540. {
  1541. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1542. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1543. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1544. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1545. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1546. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1547. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1548. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1549. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1550. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1551. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1552. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1553. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1554. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1555. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1556. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1557. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1558. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1559. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1560. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1561. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1562. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1563. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1564. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1565. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1566. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1567. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1568. }
  1569. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1570. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1571. }
  1572. #endregion
  1573. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1574. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1575. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1576. $"{opTypeStr} {opCostStr}<br/>" +
  1577. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1578. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1579. }
  1580. _detail.PriceMsgContent = priceMsg;
  1581. }
  1582. break;
  1583. case 80: //签证
  1584. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1585. if (visaInfo != null)
  1586. {
  1587. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1588. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1589. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1590. }
  1591. break;
  1592. case 81: //邀请/公务活动
  1593. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1594. if (_ioa != null)
  1595. {
  1596. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1597. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1598. sendCurrName = "Unknown", //快递费用币种 Name
  1599. sendCurrCode = "Unknown", //快递费用币种 Code
  1600. eventsCurrName = "Unknown", //公务活动费币种 Name
  1601. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1602. translateCurrName = "Unknown", //公务翻译费 Name
  1603. translateCurrCode = "Unknown"; //公务翻译费 Code
  1604. #region 处理费用币种
  1605. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1606. if (inviteCurrData != null)
  1607. {
  1608. inviteCurrName = inviteCurrData.Remark;
  1609. inviteCurrCode = inviteCurrData.Name;
  1610. }
  1611. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1612. if (sendCurrData != null)
  1613. {
  1614. sendCurrName = sendCurrData.Remark;
  1615. sendCurrCode = sendCurrData.Name;
  1616. }
  1617. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1618. if (eventsCurrData != null)
  1619. {
  1620. eventsCurrName = eventsCurrData.Remark;
  1621. eventsCurrCode = eventsCurrData.Name;
  1622. }
  1623. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1624. if (translateCurrData != null)
  1625. {
  1626. translateCurrName = translateCurrData.Remark;
  1627. translateCurrCode = translateCurrData.Name;
  1628. }
  1629. #endregion
  1630. _detail.PriceNameContent = _ioa.InviterArea;
  1631. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1632. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1633. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1634. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1635. $@"备注:" + _ioa.Remark + "<br/>";
  1636. }
  1637. break;
  1638. case 82: //团组客户保险
  1639. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1640. if (customers != null)
  1641. {
  1642. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1643. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1644. }
  1645. break;
  1646. case 85: //机票预订
  1647. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1648. if (jpRes != null)
  1649. {
  1650. string FlightsDescription = jpRes.FlightsDescription;
  1651. string PriceDescription = jpRes.PriceDescription;
  1652. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1653. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1654. }
  1655. break;
  1656. case 98://其他款项
  1657. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1658. if (gdpRes != null)
  1659. {
  1660. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1661. _detail.PriceNameContent = gdpRes.PriceName;
  1662. }
  1663. break;
  1664. case 285://收款退还
  1665. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1666. if (refundAndOtherMoney != null)
  1667. {
  1668. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1669. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1670. }
  1671. break;
  1672. case 751://酒店早餐
  1673. break;
  1674. case 1015://超支费用
  1675. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1676. if (groupExtraCost != null)
  1677. {
  1678. _detail.PriceNameContent = groupExtraCost.PriceName;
  1679. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1680. }
  1681. break;
  1682. default:
  1683. break;
  1684. }
  1685. /*
  1686. * 申请人
  1687. */
  1688. string operatorName = " - ";
  1689. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1690. if (_opUser != null)
  1691. {
  1692. operatorName = _opUser.CnName;
  1693. }
  1694. _detail.OperatorName = operatorName;
  1695. /*
  1696. * 审核人
  1697. */
  1698. string auditOperatorName = "Unknown";
  1699. if (entity.AuditGMOperate == 0)
  1700. auditOperatorName = " - ";
  1701. else if (entity.AuditGMOperate == 4)
  1702. auditOperatorName = "自动审核";
  1703. else
  1704. {
  1705. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1706. if (_adUser != null)
  1707. {
  1708. auditOperatorName = _adUser.CnName;
  1709. }
  1710. }
  1711. _detail.AuditOperatorName = auditOperatorName;
  1712. /*
  1713. * 超预算比例
  1714. */
  1715. string overBudgetStr = "";
  1716. if (entity.ExceedBudget == -1)
  1717. overBudgetStr = sdPriceName.Name + "尚无预算";
  1718. else if (entity.ExceedBudget == 0)
  1719. {
  1720. if (entity.CTable == 76 || entity.CTable == 79)
  1721. {
  1722. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1723. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1724. }
  1725. else
  1726. {
  1727. overBudgetStr = "未超预算";
  1728. }
  1729. }
  1730. else
  1731. overBudgetStr = entity.ExceedBudget.ToString("P");
  1732. _detail.OverBudget = overBudgetStr;
  1733. /*
  1734. * 费用总计
  1735. */
  1736. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1737. {
  1738. CurrencyId = entity.PaymentCurrency,
  1739. CurrencyName = PaymentCurrency_WaitPay,
  1740. AmountPayable = entity.PayMoney,
  1741. ThisPayment = CurrPayStr,
  1742. BalancePayment = BalanceStr,
  1743. AuditedFunds = CurrPayStr
  1744. });
  1745. _detail.IsAuditGM = entity.IsAuditGM;
  1746. detailList.Add(_detail);
  1747. }
  1748. #endregion
  1749. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1750. /*
  1751. * 下方描述处理
  1752. */
  1753. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1754. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1755. if (ccpCurrencyPrice != null)
  1756. {
  1757. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1758. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1759. }
  1760. else
  1761. {
  1762. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1763. }
  1764. string amountPayableStr = string.Format(@"应付款总金额: ");
  1765. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1766. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1767. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1768. foreach (var item in nonDuplicat)
  1769. {
  1770. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1771. if (strs.Count > 0)
  1772. {
  1773. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1774. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1775. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1776. //单独处理此次付款金额
  1777. if (item.CurrencyId == 836) //人民币
  1778. {
  1779. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1780. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1781. }
  1782. else
  1783. {
  1784. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1785. }
  1786. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1787. //单独处理已审核费用
  1788. if (item.CurrencyId == 836) //人民币
  1789. {
  1790. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1791. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1792. }
  1793. else
  1794. {
  1795. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1796. }
  1797. }
  1798. }
  1799. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1800. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1801. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1802. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1803. var _view1 = new
  1804. {
  1805. PageFuncAuth = pageFunAuthView,
  1806. Data = _view
  1807. };
  1808. return Ok(JsonView(_view1));
  1809. }
  1810. catch (Exception ex)
  1811. {
  1812. return Ok(JsonView(false, ex.Message));
  1813. }
  1814. }
  1815. /// <summary>
  1816. /// 费用审核
  1817. /// 修改团组费用审核状态
  1818. /// </summary>
  1819. /// <param name="_dto">参数Json字符串</param>
  1820. /// <returns></returns>
  1821. [HttpPost]
  1822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1823. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1824. {
  1825. #region 参数验证
  1826. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1827. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1828. #endregion
  1829. #region 页面操作权限验证
  1830. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1831. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1832. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1833. #endregion
  1834. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1835. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1836. DateTime dtNow = DateTime.Now;
  1837. _groupRepository.BeginTran();
  1838. int rst = 0;
  1839. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1840. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1841. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1842. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1843. List<dynamic> msgDatas = new List<dynamic>();
  1844. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1845. foreach (var item in idList)
  1846. {
  1847. int CreditId = int.Parse(item);
  1848. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1849. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1850. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1851. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1852. .Where(s => s.Id == CreditId)
  1853. .ExecuteCommandAsync();
  1854. if (result < 1)
  1855. {
  1856. rst = -1;
  1857. _groupRepository.RollbackTran();
  1858. return Ok(JsonView(false, "操作失败并回滚!"));
  1859. }
  1860. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1861. if (creditData != null)
  1862. {
  1863. #region 应用通知配置
  1864. try
  1865. {
  1866. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1867. }
  1868. catch (Exception ex)
  1869. {
  1870. }
  1871. #endregion
  1872. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1873. string groupNameStr = string.Empty;
  1874. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1875. if (groupData != null) groupNameStr = groupData.TeamName;
  1876. string creditTypeStr = string.Empty;
  1877. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1878. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1879. string creditCurrency = string.Empty;
  1880. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1881. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1882. if (creditCurrency.Equals("CNY"))
  1883. {
  1884. creditData.DayRate = 1.0000M;
  1885. }
  1886. if (creditData.PayPercentage == 0.00M)
  1887. {
  1888. creditData.PayPercentage = 100M;
  1889. }
  1890. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1891. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1892. string msgContent = "";
  1893. if (creditCurrency.Equals("CNY"))
  1894. {
  1895. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1896. }
  1897. else
  1898. {
  1899. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1900. }
  1901. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1902. }
  1903. }
  1904. if (rst == 0)
  1905. {
  1906. _groupRepository.CommitTran();
  1907. foreach (var item in msgDatas)
  1908. {
  1909. //发送消息
  1910. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1911. }
  1912. #region 应用推送
  1913. try
  1914. {
  1915. foreach (var ccpId in dic_ccp_user.Keys)
  1916. {
  1917. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1918. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1919. }
  1920. }
  1921. catch (Exception)
  1922. {
  1923. }
  1924. #endregion
  1925. return Ok(JsonView(true, "操作成功!"));
  1926. }
  1927. return Ok(JsonView(false, "操作失败!"));
  1928. }
  1929. #endregion
  1930. #region 机票费用录入
  1931. /// <summary>
  1932. /// 机票录入当前登录人可操作团组
  1933. /// </summary>
  1934. /// <param name="dto"></param>
  1935. /// <returns></returns>
  1936. [HttpPost]
  1937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1938. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1939. {
  1940. try
  1941. {
  1942. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1943. if (groupData.Code != 0)
  1944. {
  1945. return Ok(JsonView(false, groupData.Msg));
  1946. }
  1947. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1948. }
  1949. catch (Exception ex)
  1950. {
  1951. return Ok(JsonView(false, "程序错误!"));
  1952. throw;
  1953. }
  1954. }
  1955. /// <summary>
  1956. /// 机票费用录入列表
  1957. /// </summary>
  1958. /// <param name="dto"></param>
  1959. /// <returns></returns>
  1960. [HttpPost]
  1961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1962. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1963. {
  1964. try
  1965. {
  1966. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1967. if (groupData.Code != 0)
  1968. {
  1969. return Ok(JsonView(false, groupData.Msg));
  1970. }
  1971. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1972. }
  1973. catch (Exception ex)
  1974. {
  1975. return Ok(JsonView(false, ex.Message));
  1976. throw;
  1977. }
  1978. }
  1979. /// <summary>
  1980. /// 根据id查询费用录入信息
  1981. /// </summary>
  1982. /// <param name="dto"></param>
  1983. /// <returns></returns>
  1984. [HttpPost]
  1985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1986. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1987. {
  1988. try
  1989. {
  1990. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1991. if (groupData.Code != 0)
  1992. {
  1993. return Ok(JsonView(false, groupData.Msg));
  1994. }
  1995. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1996. }
  1997. catch (Exception ex)
  1998. {
  1999. return Ok(JsonView(false, "程序错误!"));
  2000. throw;
  2001. }
  2002. }
  2003. /// <summary>
  2004. /// 机票费用录入操作(Status:1.新增,2.修改)
  2005. /// </summary>
  2006. /// <param name="dto"></param>
  2007. /// <returns></returns>
  2008. [HttpPost]
  2009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2010. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2011. {
  2012. try
  2013. {
  2014. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2015. if (groupData.Code != 0)
  2016. {
  2017. return Ok(JsonView(false, groupData.Msg));
  2018. }
  2019. #region 应用推送
  2020. try
  2021. {
  2022. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2023. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2024. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2025. }
  2026. catch (Exception ex)
  2027. {
  2028. }
  2029. #endregion
  2030. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2031. }
  2032. catch (Exception ex)
  2033. {
  2034. return Ok(JsonView(false, "程序错误!"));
  2035. throw;
  2036. }
  2037. }
  2038. /// <summary>
  2039. /// 根据舱位类型查询接团客户名单信息
  2040. /// </summary>
  2041. /// <param name="dto"></param>
  2042. /// <returns></returns>
  2043. [HttpPost]
  2044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2045. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2046. {
  2047. try
  2048. {
  2049. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2050. if (crm_Groups.Count != 0)
  2051. {
  2052. List<dynamic> Customer = new List<dynamic>();
  2053. foreach (var item in crm_Groups)
  2054. {
  2055. var data = new
  2056. {
  2057. Id = item.Id,
  2058. Pinyin = item.Pinyin,
  2059. Name = item.LastName + item.FirstName
  2060. };
  2061. Customer.Add(data);
  2062. }
  2063. return Ok(JsonView(true, "查询成功!", Customer));
  2064. }
  2065. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2066. }
  2067. catch (Exception ex)
  2068. {
  2069. return Ok(JsonView(false, "程序错误!"));
  2070. throw;
  2071. }
  2072. }
  2073. /// <summary>
  2074. /// 根据团号获取客户信息
  2075. /// </summary>
  2076. /// <param name="dto"></param>
  2077. /// <returns></returns>
  2078. [HttpPost]
  2079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2080. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2081. {
  2082. var jw = JsonView(false);
  2083. if (dto.DIID < 1)
  2084. {
  2085. jw.Msg += "请输入正确的diid";
  2086. return Ok(jw);
  2087. }
  2088. var arr = getSimplClientList(dto.DIID);
  2089. jw = JsonView(true, "获取成功!", arr);
  2090. return Ok(jw);
  2091. }
  2092. private List<SimplClientInfo> getSimplClientList(int diId)
  2093. {
  2094. 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);
  2095. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2096. return arr;
  2097. }
  2098. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2099. {
  2100. string result = origin;
  2101. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2102. {
  2103. string[] temparr = origin.Split(',');
  2104. string fistrStr = temparr[0];
  2105. int count = temparr.Count();
  2106. int tempId;
  2107. bool success = int.TryParse(fistrStr, out tempId);
  2108. if (success)
  2109. {
  2110. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2111. if (tempInfo != null)
  2112. {
  2113. if (count > 1)
  2114. {
  2115. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2116. }
  2117. else
  2118. {
  2119. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2120. }
  2121. }
  2122. }
  2123. }
  2124. return result;
  2125. }
  2126. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2127. {
  2128. string result = origin;
  2129. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2130. {
  2131. string[] temparr = origin.Split(',');
  2132. result = "";
  2133. foreach (var item in temparr)
  2134. {
  2135. int tempId;
  2136. bool success = int.TryParse(item, out tempId);
  2137. if (success)
  2138. {
  2139. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2140. if (tempInfo != null)
  2141. {
  2142. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2143. }
  2144. }
  2145. }
  2146. }
  2147. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2148. return result;
  2149. }
  2150. /// <summary>
  2151. /// 机票费用录入,删除
  2152. /// </summary>
  2153. /// <param name="dto"></param>
  2154. /// <returns></returns>
  2155. [HttpPost]
  2156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2157. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2158. {
  2159. try
  2160. {
  2161. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2162. if (res)
  2163. {
  2164. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2165. {
  2166. IsDel = 1,
  2167. DeleteUserId = dto.DeleteUserId,
  2168. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2169. }).ExecuteCommandAsync();
  2170. return Ok(JsonView(true, "删除成功!"));
  2171. }
  2172. return Ok(JsonView(false, "删除失败!"));
  2173. }
  2174. catch (Exception ex)
  2175. {
  2176. return Ok(JsonView(false, "程序错误!"));
  2177. throw;
  2178. }
  2179. }
  2180. /// <summary>
  2181. /// 导出机票录入报表
  2182. /// </summary>
  2183. /// <param name="dto"></param>
  2184. /// <returns></returns>
  2185. [HttpPost]
  2186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2187. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2188. {
  2189. try
  2190. {
  2191. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2192. if (groupData.Code != 0)
  2193. {
  2194. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2195. }
  2196. else
  2197. {
  2198. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2199. if (AirTicketReservations.Count != 0)
  2200. {
  2201. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2202. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2203. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2204. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2205. WorkbookDesigner designer = new WorkbookDesigner();
  2206. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2207. decimal countCost = 0;
  2208. foreach (var item in AirTicketReservations)
  2209. {
  2210. #region 处理客人姓名
  2211. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2212. item.ClientName = clientNames;
  2213. #endregion
  2214. if (item.BankType == "其他")
  2215. {
  2216. item.BankNo = "--";
  2217. }
  2218. else
  2219. {
  2220. if (!string.IsNullOrEmpty(item.BankType))
  2221. {
  2222. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2223. }
  2224. }
  2225. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2226. item.Price = System.Decimal.Round(item.Price, 2);
  2227. countCost += Convert.ToDecimal(item.Price);
  2228. }
  2229. designer.SetDataSource("Export", AirTicketReservations);
  2230. designer.SetDataSource("ExportDiCode", diCode);
  2231. designer.SetDataSource("ExportDiName", diName);
  2232. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2233. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2234. designer.Process();
  2235. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2236. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2237. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2238. return Ok(JsonView(true, "成功", url = rst));
  2239. }
  2240. else
  2241. {
  2242. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2243. }
  2244. }
  2245. }
  2246. catch (Exception ex)
  2247. {
  2248. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2249. throw;
  2250. }
  2251. }
  2252. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2253. /// <summary>
  2254. /// 行程单导出
  2255. /// </summary>
  2256. /// <param name="dto"></param>
  2257. /// <returns></returns>
  2258. [HttpPost]
  2259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2260. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2261. {
  2262. try
  2263. {
  2264. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2265. if (groupData.Code != 0)
  2266. {
  2267. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2268. }
  2269. else
  2270. {
  2271. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2272. if (dto.Language == "CN")
  2273. {
  2274. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2275. DocumentBuilder builder = new DocumentBuilder(doc);
  2276. int tableIndex = 0;//表格索引
  2277. //得到文档中的第一个表格
  2278. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2279. foreach (var item in _AirTicketReservations)
  2280. {
  2281. #region 处理固定数据
  2282. string[] FlightsCode = item.FlightsCode.Split('/');
  2283. if (FlightsCode.Length != 0)
  2284. {
  2285. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2286. if (_AirCompany != null)
  2287. {
  2288. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2289. }
  2290. else
  2291. {
  2292. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2293. }
  2294. }
  2295. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2296. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2297. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2298. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2299. string name = "";
  2300. foreach (string clientName in nameArray)
  2301. {
  2302. if (!name.Contains(clientName))
  2303. {
  2304. name += clientName + ",";
  2305. }
  2306. }
  2307. if (!string.IsNullOrWhiteSpace(name))
  2308. {
  2309. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2310. }
  2311. else
  2312. {
  2313. table.Range.Bookmarks["ClientName"].Text = "--";
  2314. }
  2315. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2316. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2317. table.Range.Bookmarks["JointTicket"].Text = "--";
  2318. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2319. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2320. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2321. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2322. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2323. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2324. #endregion
  2325. #region 循环数据处理
  2326. List<AirInfo> airs = new List<AirInfo>();
  2327. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2328. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2329. for (int i = 0; i < FlightsCode.Length; i++)
  2330. {
  2331. AirInfo air = new AirInfo();
  2332. string[] tempstr = DayArray[i]
  2333. .Replace("\r\n", string.Empty)
  2334. .Replace("\\r\\n", string.Empty)
  2335. .TrimStart().TrimEnd()
  2336. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2337. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2338. string starCity = "";
  2339. if (star_Three != null)
  2340. {
  2341. starCity = star_Three.AirPort;
  2342. }
  2343. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2344. string EndCity = "";
  2345. if (End_Three != null)
  2346. {
  2347. EndCity = End_Three.AirPort;
  2348. }
  2349. air.Destination = starCity + "/" + EndCity;
  2350. air.Flight = FlightsCode[i];
  2351. air.SeatingClass = item.CTypeName;
  2352. string dateTime = tempstr[2];
  2353. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2354. air.FlightDate = DateTemp;
  2355. air.DepartureTime = tempstr[5];
  2356. air.LandingTime = tempstr[6];
  2357. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2358. air.TicketStatus = "--";
  2359. air.Luggage = "--";
  2360. air.DepartureTerminal = "--";
  2361. air.LandingTerminal = "--";
  2362. airs.Add(air);
  2363. }
  2364. int row = 13;
  2365. for (int i = 0; i < airs.Count; i++)
  2366. {
  2367. if (airs.Count > 2)
  2368. {
  2369. for (int j = 0; j < airs.Count - 2; j++)
  2370. {
  2371. var CopyRow = table.Rows[12].Clone(true);
  2372. table.Rows.Add(CopyRow);
  2373. }
  2374. }
  2375. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2376. int index = 0;
  2377. foreach (PropertyInfo property in properties)
  2378. {
  2379. string value = property.GetValue(airs[i]).ToString();
  2380. Cell ishcel0 = table.Rows[row].Cells[index];
  2381. Paragraph p = new Paragraph(doc);
  2382. string s = value;
  2383. p.AppendChild(new Run(doc, s));
  2384. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2385. ishcel0.AppendChild(p);
  2386. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2387. index++;
  2388. }
  2389. row++;
  2390. }
  2391. #endregion
  2392. Paragraph lastParagraph = new Paragraph(doc);
  2393. //第一个表格末尾加段落
  2394. table.ParentNode.InsertAfter(lastParagraph, table);
  2395. //复制第一个表格
  2396. Table cloneTable = (Table)table.Clone(true);
  2397. //在文档末尾段落后面加入复制的表格
  2398. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2399. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2400. {
  2401. int rownewsIndex = 13;
  2402. for (int i = 0; i < 2; i++)
  2403. {
  2404. var CopyRow = table.Rows[12].Clone(true);
  2405. table.Rows.RemoveAt(13);
  2406. table.Rows.Add(CopyRow);
  2407. rownewsIndex++;
  2408. }
  2409. }
  2410. else
  2411. {
  2412. table.Rows.RemoveAt(12);
  2413. }
  2414. cloneTable.Rows.RemoveAt(12);
  2415. }
  2416. if (_AirTicketReservations.Count != 0)
  2417. {
  2418. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2419. if (FlightsCode.Length != 0)
  2420. {
  2421. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2422. if (_AirCompany != null)
  2423. {
  2424. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2425. }
  2426. else
  2427. {
  2428. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2429. }
  2430. }
  2431. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2432. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2433. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2434. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2435. string name = "";
  2436. foreach (string clientName in nameArray)
  2437. {
  2438. if (!name.Contains(clientName))
  2439. {
  2440. name += clientName + ",";
  2441. }
  2442. }
  2443. if (!string.IsNullOrWhiteSpace(name))
  2444. {
  2445. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2446. }
  2447. else
  2448. {
  2449. table.Range.Bookmarks["ClientName"].Text = "--";
  2450. }
  2451. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2452. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2453. table.Range.Bookmarks["JointTicket"].Text = "--";
  2454. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2455. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2456. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2457. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2458. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2459. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2460. }
  2461. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2462. //保存合并后的文档
  2463. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2464. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2465. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2466. return Ok(JsonView(true, "成功!", rst));
  2467. }
  2468. else
  2469. {
  2470. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2471. DocumentBuilder builder = new DocumentBuilder(doc);
  2472. int tableIndex = 0;//表格索引
  2473. //得到文档中的第一个表格
  2474. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2475. List<string> texts = new List<string>();
  2476. foreach (var item in _AirTicketReservations)
  2477. {
  2478. string[] FlightsCode = item.FlightsCode.Split('/');
  2479. if (FlightsCode.Length != 0)
  2480. {
  2481. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2482. if (_AirCompany != null)
  2483. {
  2484. if (!transDic.ContainsKey(_AirCompany.CnName))
  2485. {
  2486. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2487. }
  2488. }
  2489. else
  2490. {
  2491. if (!transDic.ContainsKey("--"))
  2492. {
  2493. transDic.Add("--", "--");
  2494. }
  2495. }
  2496. }
  2497. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2498. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2499. string name = "";
  2500. foreach (string clientName in nameArray)
  2501. {
  2502. name += clientName + ",";
  2503. }
  2504. if (!texts.Contains(name))
  2505. {
  2506. texts.Add(name);
  2507. }
  2508. List<AirInfo> airs = new List<AirInfo>();
  2509. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2510. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2511. for (int i = 0; i < FlightsCode.Length; i++)
  2512. {
  2513. AirInfo air = new AirInfo();
  2514. string[] tempstr = DayArray[i]
  2515. .Replace("\r\n", string.Empty)
  2516. .Replace("\\r\\n", string.Empty)
  2517. .TrimStart().TrimEnd()
  2518. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2519. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2520. if (star_Three != null)
  2521. {
  2522. if (!transDic.ContainsKey(star_Three.AirPort))
  2523. {
  2524. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2525. }
  2526. }
  2527. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2528. if (End_Three != null)
  2529. {
  2530. if (!transDic.ContainsKey(End_Three.AirPort))
  2531. {
  2532. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2533. }
  2534. }
  2535. if (!texts.Contains(item.CTypeName))
  2536. {
  2537. texts.Add(item.CTypeName);
  2538. }
  2539. }
  2540. }
  2541. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2542. if (transData.Count > 0)
  2543. {
  2544. foreach (TranslateResult item in transData)
  2545. {
  2546. if (!transDic.ContainsKey(item.Query))
  2547. {
  2548. transDic.Add(item.Query, item.Translation);
  2549. }
  2550. }
  2551. }
  2552. foreach (var item in _AirTicketReservations)
  2553. {
  2554. #region 处理固定数据
  2555. string[] FlightsCode = item.FlightsCode.Split('/');
  2556. if (FlightsCode.Length != 0)
  2557. {
  2558. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2559. if (_AirCompany != null)
  2560. {
  2561. string str = "--";
  2562. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2563. if (!string.IsNullOrEmpty(translateResult))
  2564. {
  2565. str = translateResult;
  2566. str = _airTicketResRep.Processing(str);
  2567. }
  2568. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2569. }
  2570. else
  2571. {
  2572. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2573. }
  2574. }
  2575. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2576. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2577. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2578. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2579. string names = "";
  2580. foreach (string clientName in nameArray)
  2581. {
  2582. names += clientName + ",";
  2583. }
  2584. if (!string.IsNullOrWhiteSpace(names))
  2585. {
  2586. string str = "--";
  2587. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2588. if (!string.IsNullOrEmpty(translateResult))
  2589. {
  2590. str = translateResult;
  2591. str = _airTicketResRep.Processing(str);
  2592. }
  2593. table.Range.Bookmarks["ClientName"].Text = str;
  2594. }
  2595. else
  2596. {
  2597. table.Range.Bookmarks["ClientName"].Text = "--";
  2598. }
  2599. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2600. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2601. table.Range.Bookmarks["JointTicket"].Text = "--";
  2602. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2603. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2604. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2605. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2606. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2607. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2608. #endregion
  2609. #region 循环数据处理
  2610. List<AirInfo> airs = new List<AirInfo>();
  2611. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2612. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2613. for (int i = 0; i < FlightsCode.Length; i++)
  2614. {
  2615. AirInfo air = new AirInfo();
  2616. string[] tempstr = DayArray[i]
  2617. .Replace("\r\n", string.Empty)
  2618. .Replace("\\r\\n", string.Empty)
  2619. .TrimStart().TrimEnd()
  2620. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2621. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2622. string starCity = "";
  2623. if (star_Three != null)
  2624. {
  2625. string str2 = "--";
  2626. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2627. if (!string.IsNullOrEmpty(translateResult2))
  2628. {
  2629. str2 = translateResult2;
  2630. str2 = _airTicketResRep.Processing(str2);
  2631. }
  2632. starCity = str2;
  2633. }
  2634. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2635. string EndCity = "";
  2636. if (End_Three != null)
  2637. {
  2638. string str1 = "--";
  2639. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2640. if (!string.IsNullOrEmpty(translateResult1))
  2641. {
  2642. str1 = translateResult1;
  2643. str1 = _airTicketResRep.Processing(str1);
  2644. }
  2645. EndCity = str1;
  2646. }
  2647. air.Destination = starCity + "/" + EndCity;
  2648. air.Flight = FlightsCode[i];
  2649. string str = "--";
  2650. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2651. if (!string.IsNullOrEmpty(translateResult))
  2652. {
  2653. str = translateResult;
  2654. str = _airTicketResRep.Processing(str);
  2655. }
  2656. air.SeatingClass = str;
  2657. string dateTime = tempstr[2];
  2658. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2659. air.FlightDate = DateTemp;
  2660. air.DepartureTime = tempstr[5];
  2661. air.LandingTime = tempstr[6];
  2662. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2663. air.TicketStatus = "--";
  2664. air.Luggage = "--";
  2665. air.DepartureTerminal = "--";
  2666. air.LandingTerminal = "--";
  2667. airs.Add(air);
  2668. }
  2669. int row = 13;
  2670. for (int i = 0; i < airs.Count; i++)
  2671. {
  2672. if (airs.Count > 2)
  2673. {
  2674. for (int j = 0; j < airs.Count - 2; j++)
  2675. {
  2676. var CopyRow = table.Rows[12].Clone(true);
  2677. table.Rows.Add(CopyRow);
  2678. }
  2679. }
  2680. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2681. int index = 0;
  2682. foreach (PropertyInfo property in properties)
  2683. {
  2684. string value = property.GetValue(airs[i]).ToString();
  2685. Cell ishcel0 = table.Rows[row].Cells[index];
  2686. Paragraph p = new Paragraph(doc);
  2687. string s = value;
  2688. p.AppendChild(new Run(doc, s));
  2689. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2690. ishcel0.AppendChild(p);
  2691. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2692. //ishcel0.CellFormat.VerticalAlignment=
  2693. index++;
  2694. }
  2695. row++;
  2696. }
  2697. #endregion
  2698. Paragraph lastParagraph = new Paragraph(doc);
  2699. //第一个表格末尾加段落
  2700. table.ParentNode.InsertAfter(lastParagraph, table);
  2701. //复制第一个表格
  2702. Table cloneTable = (Table)table.Clone(true);
  2703. //在文档末尾段落后面加入复制的表格
  2704. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2705. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2706. {
  2707. int rownewsIndex = 13;
  2708. for (int i = 0; i < 2; i++)
  2709. {
  2710. var CopyRow = table.Rows[12].Clone(true);
  2711. table.Rows.RemoveAt(13);
  2712. table.Rows.Add(CopyRow);
  2713. rownewsIndex++;
  2714. }
  2715. }
  2716. else
  2717. {
  2718. table.Rows.RemoveAt(12);
  2719. }
  2720. cloneTable.Rows.RemoveAt(12);
  2721. }
  2722. if (_AirTicketReservations.Count != 0)
  2723. {
  2724. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2725. if (FlightsCode.Length != 0)
  2726. {
  2727. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2728. if (_AirCompany != null)
  2729. {
  2730. string str = "--";
  2731. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2732. if (!string.IsNullOrEmpty(translateResult))
  2733. {
  2734. str = translateResult;
  2735. str = _airTicketResRep.Processing(str);
  2736. }
  2737. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2738. }
  2739. else
  2740. {
  2741. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2742. }
  2743. }
  2744. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2745. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2746. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2747. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2748. string names = "";
  2749. foreach (string clientName in nameArray)
  2750. {
  2751. names += clientName + ",";
  2752. }
  2753. if (!string.IsNullOrWhiteSpace(names))
  2754. {
  2755. string str = "--";
  2756. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2757. if (!string.IsNullOrEmpty(translateResult))
  2758. {
  2759. str = translateResult;
  2760. str = _airTicketResRep.Processing(str);
  2761. }
  2762. table.Range.Bookmarks["ClientName"].Text = str;
  2763. }
  2764. else
  2765. {
  2766. table.Range.Bookmarks["ClientName"].Text = "--";
  2767. }
  2768. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2769. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2770. table.Range.Bookmarks["JointTicket"].Text = "--";
  2771. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2772. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2773. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2774. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2775. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2776. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2777. }
  2778. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2779. //保存合并后的文档
  2780. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2781. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2782. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2783. return Ok(JsonView(true, "成功!", rst));
  2784. }
  2785. }
  2786. }
  2787. catch (Exception ex)
  2788. {
  2789. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2790. throw;
  2791. }
  2792. }
  2793. #endregion
  2794. #region 团组增减款项 --> 其他款项
  2795. /// <summary>
  2796. /// 团组增减款项下拉框绑定
  2797. /// </summary>
  2798. /// <param name="dto"></param>
  2799. /// <returns></returns>
  2800. [HttpPost]
  2801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2802. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2803. {
  2804. #region 参数验证
  2805. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2806. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2807. #endregion
  2808. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2809. }
  2810. /// <summary>
  2811. /// 根据团组Id查询团组增减款项
  2812. /// </summary>
  2813. /// <param name="dto"></param>
  2814. /// <returns></returns>
  2815. [HttpPost]
  2816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2817. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2818. {
  2819. #region 参数验证
  2820. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2821. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2822. #endregion
  2823. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2824. }
  2825. /// <summary>
  2826. /// 团组增减款项操作(Status:1.新增,2.修改)
  2827. /// </summary>
  2828. /// <param name="dto"></param>
  2829. /// <returns></returns>
  2830. [HttpPost]
  2831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2832. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2833. {
  2834. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2835. if (groupData.Code != 200)
  2836. {
  2837. return Ok(JsonView(false, groupData.Msg));
  2838. }
  2839. #region 应用推送
  2840. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2841. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2842. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2843. #endregion
  2844. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2845. }
  2846. /// <summary>
  2847. /// 团组增减款项操作 删除
  2848. /// </summary>
  2849. /// <param name="dto"></param>
  2850. /// <returns></returns>
  2851. [HttpPost]
  2852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2853. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2854. {
  2855. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2856. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2857. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2858. if (res.Code == 0)
  2859. {
  2860. return Ok(JsonView(true, "删除成功!"));
  2861. }
  2862. return Ok(JsonView(false, "删除失败!"));
  2863. }
  2864. /// <summary>
  2865. /// 根据团组增减款项Id查询
  2866. /// </summary>
  2867. /// <param name="dto"></param>
  2868. /// <returns></returns>
  2869. [HttpPost]
  2870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2871. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2872. {
  2873. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2874. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2875. }
  2876. /// <summary>
  2877. /// 查询供应商名称
  2878. /// </summary>
  2879. /// <param name="dto"></param>
  2880. /// <returns></returns>
  2881. [HttpPost]
  2882. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2883. {
  2884. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2885. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2886. ?? new List<Grp_DecreasePayments>();
  2887. dbResult = dbResult.Distinct(new
  2888. ProductComparer()).ToList();
  2889. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2890. {
  2891. x.Id,
  2892. x.SupplierAddress,
  2893. x.SupplierArea,
  2894. x.SupplierContact,
  2895. x.SupplierContactNumber,
  2896. x.SupplierEmail,
  2897. x.SupplierName,
  2898. x.SupplierSocialAccount,
  2899. x.SupplierTypeId,
  2900. }).ToList());
  2901. return Ok(jw);
  2902. }
  2903. #endregion
  2904. #region 文件上传、删除
  2905. /// <summary>
  2906. /// region 文件上传 可以带参数
  2907. /// </summary>
  2908. /// <param name="file"></param>
  2909. /// <returns></returns>
  2910. [HttpPost]
  2911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2912. public async Task<IActionResult> UploadProject(IFormFile file)
  2913. {
  2914. try
  2915. {
  2916. var TypeName = Request.Headers["TypeName"].ToString();
  2917. if (file != null)
  2918. {
  2919. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2920. //文件名称
  2921. string projectFileName = file.FileName;
  2922. //上传的文件的路径
  2923. string filePath = "";
  2924. if (TypeName == "A")//A代表团组增减款项
  2925. {
  2926. if (!Directory.Exists(fileDir))
  2927. {
  2928. Directory.CreateDirectory(fileDir);
  2929. }
  2930. //上传的文件的路径
  2931. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2932. }
  2933. else if (TypeName == "B")//B代表商邀相关文件
  2934. {
  2935. if (!Directory.Exists(fileDir))
  2936. {
  2937. Directory.CreateDirectory(fileDir);
  2938. }
  2939. //上传的文件的路径
  2940. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2941. }
  2942. using (FileStream fs = System.IO.File.Create(filePath))
  2943. {
  2944. file.CopyTo(fs);
  2945. fs.Flush();
  2946. }
  2947. return Ok(JsonView(true, "上传成功!", projectFileName));
  2948. }
  2949. else
  2950. {
  2951. return Ok(JsonView(false, "上传失败!"));
  2952. }
  2953. }
  2954. catch (Exception ex)
  2955. {
  2956. return Ok(JsonView(false, "程序错误!"));
  2957. throw;
  2958. }
  2959. }
  2960. /// <summary>
  2961. /// 删除指定文件
  2962. /// </summary>
  2963. /// <param name="dto"></param>
  2964. /// <returns></returns>
  2965. [HttpPost]
  2966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2967. public async Task<IActionResult> DelFile(DelFileDto dto)
  2968. {
  2969. try
  2970. {
  2971. var TypeName = Request.Headers["TypeName"].ToString();
  2972. string filePath = "";
  2973. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2974. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2975. int id = 0;
  2976. if (TypeName == "A")
  2977. {
  2978. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2979. // 删除该文件
  2980. System.IO.File.Delete(filePath);
  2981. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2982. }
  2983. else if (TypeName == "B")
  2984. {
  2985. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2986. // 删除该文件
  2987. System.IO.File.Delete(filePath);
  2988. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2989. }
  2990. if (id != 0)
  2991. {
  2992. return Ok(JsonView(true, "成功!"));
  2993. }
  2994. else
  2995. {
  2996. return Ok(JsonView(false, "失败!"));
  2997. }
  2998. }
  2999. catch (Exception ex)
  3000. {
  3001. return Ok(JsonView(false, "程序错误!"));
  3002. throw;
  3003. }
  3004. }
  3005. #endregion
  3006. #region 商邀费用录入
  3007. /// <summary>
  3008. /// 根据团组Id查询商邀费用列表
  3009. /// </summary>
  3010. /// <param name="dto"></param>
  3011. /// <returns></returns>
  3012. [HttpPost]
  3013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3014. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3015. {
  3016. try
  3017. {
  3018. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3019. if (groupData.Code != 0)
  3020. {
  3021. return Ok(JsonView(false, groupData.Msg));
  3022. }
  3023. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3024. }
  3025. catch (Exception ex)
  3026. {
  3027. return Ok(JsonView(false, "程序错误!"));
  3028. throw;
  3029. }
  3030. }
  3031. //
  3032. /// <summary>
  3033. /// 商邀费用 Info Page 基础数据源
  3034. /// </summary>
  3035. /// <param name="dto"></param>
  3036. /// <returns></returns>
  3037. [HttpPost]
  3038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3039. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3040. {
  3041. try
  3042. {
  3043. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3044. if (groupData.Code != 0)
  3045. {
  3046. return Ok(JsonView(false, groupData.Msg));
  3047. }
  3048. return Ok(JsonView(true, "操作成功", groupData.Data));
  3049. }
  3050. catch (Exception ex)
  3051. {
  3052. return Ok(JsonView(false, ex.Message));
  3053. throw;
  3054. }
  3055. }
  3056. /// <summary>
  3057. /// 根据商邀费用ID查询C表和商邀费用数据
  3058. /// </summary>
  3059. /// <param name="dto"></param>
  3060. /// <returns></returns>
  3061. [HttpPost]
  3062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3063. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3064. {
  3065. try
  3066. {
  3067. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3068. if (groupData.Code != 0)
  3069. {
  3070. return Ok(JsonView(false, groupData.Msg));
  3071. }
  3072. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3073. }
  3074. catch (Exception ex)
  3075. {
  3076. return Ok(JsonView(false, ex.Message));
  3077. throw;
  3078. }
  3079. }
  3080. /// <summary>
  3081. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3082. /// </summary>
  3083. /// <param name="dto"></param>
  3084. /// <returns></returns>
  3085. [HttpPost]
  3086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3087. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3088. {
  3089. try
  3090. {
  3091. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3092. if (groupData.Code != 0)
  3093. {
  3094. return Ok(JsonView(false, groupData.Msg));
  3095. }
  3096. #region 应用推送
  3097. try
  3098. {
  3099. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3100. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3101. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3102. }
  3103. catch (Exception ex)
  3104. {
  3105. }
  3106. #endregion
  3107. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3108. }
  3109. catch (Exception ex)
  3110. {
  3111. return Ok(JsonView(false, "程序错误!"));
  3112. throw;
  3113. }
  3114. }
  3115. /// <summary>
  3116. /// 商邀删除
  3117. /// </summary>
  3118. /// <param name="dto"></param>
  3119. /// <returns></returns>
  3120. [HttpPost]
  3121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3122. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3123. {
  3124. try
  3125. {
  3126. _sqlSugar.BeginTran();
  3127. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3128. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3129. {
  3130. IsDel = 1,
  3131. DeleteUserId = dto.DeleteUserId,
  3132. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3133. })
  3134. .Where(it => it.Id == dto.Id)
  3135. .ExecuteCommand();
  3136. if (res1 > 0)
  3137. {
  3138. int _diId = 0;
  3139. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3140. if (_ioaInfo != null)
  3141. {
  3142. _diId = _ioaInfo.DiId;
  3143. }
  3144. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3145. .SetColumns(a => new Grp_CreditCardPayment()
  3146. {
  3147. IsDel = 1,
  3148. DeleteUserId = dto.DeleteUserId,
  3149. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3150. })
  3151. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3152. .ExecuteCommand();
  3153. if (res2 > 0)
  3154. {
  3155. _sqlSugar.CommitTran();
  3156. return Ok(JsonView(true, "删除成功!"));
  3157. }
  3158. }
  3159. _sqlSugar.RollbackTran();
  3160. return Ok(JsonView(false, "删除失败"));
  3161. }
  3162. catch (Exception ex)
  3163. {
  3164. _sqlSugar.RollbackTran();
  3165. return Ok(JsonView(false, ex.Message));
  3166. }
  3167. }
  3168. /// <summary>
  3169. /// 团组模块文件上传
  3170. /// </summary>
  3171. /// <param name="dto"></param>
  3172. /// <returns></returns>
  3173. [HttpPost]
  3174. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3175. {
  3176. var jw = JsonView(false);
  3177. long M = 1024 * 1024;
  3178. if (dto.Files == null || dto.Files.Count == 0)
  3179. {
  3180. jw.Msg = "无文件信息!";
  3181. return Ok(jw);
  3182. }
  3183. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3184. {
  3185. jw.Msg = "文件大小超过20M!";
  3186. return Ok(jw);
  3187. }
  3188. //var nameSp = dto.File.FileName.Split(".");
  3189. //if (nameSp.Length < 2)
  3190. //{
  3191. // jw.Msg = "拓展名称有误!";
  3192. // return Ok(jw);
  3193. //}
  3194. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3195. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3196. //{
  3197. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3198. // return Ok(jw);
  3199. //}
  3200. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3201. if (Ctable == null)
  3202. {
  3203. jw.Msg = "Ctable指向有误!";
  3204. return Ok(jw);
  3205. }
  3206. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3207. if (groupInfo == null)
  3208. {
  3209. jw.Msg = "团组信息不存在!";
  3210. return Ok(jw);
  3211. }
  3212. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3213. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3214. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3215. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3216. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3217. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3218. try
  3219. {
  3220. if (!Directory.Exists(fileBase))
  3221. {
  3222. Directory.CreateDirectory(fileBase);
  3223. }
  3224. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3225. foreach (var fileStream in dto.Files)
  3226. {
  3227. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3228. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3229. {
  3230. Cid = dto.Cid,
  3231. CreateTime = DateTime.Now,
  3232. CreateUserId = dto.Userid,
  3233. Ctable = dto.Ctable,
  3234. Diid = dto.Diid,
  3235. IsDel = 0,
  3236. FilePath = saveFilePath,
  3237. FileName = fileStream.FileName
  3238. };
  3239. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3240. {
  3241. fileStream.CopyTo(fs);
  3242. fs.Flush();
  3243. }
  3244. saveArr.Add(file);
  3245. }
  3246. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3247. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3248. jw = JsonView(true, "保存成功!", new
  3249. {
  3250. count = addResult,
  3251. filesName = saveArr.Select(x => x.FileName)
  3252. }) ;
  3253. }
  3254. catch (Exception ex)
  3255. {
  3256. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3257. {
  3258. count = 0,
  3259. filesName = new string[0],
  3260. }) ;
  3261. }
  3262. return Ok(jw);
  3263. }
  3264. /// <summary>
  3265. /// 查询各模块已保存文件
  3266. /// </summary>
  3267. /// <param name="dto"></param>
  3268. /// <returns></returns>
  3269. [HttpPost]
  3270. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3271. {
  3272. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3273. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3274. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3275. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3276. {
  3277. expression = Expressionable.Create<Grp_GroupModelFile>()
  3278. .And(x=>visaIds.Contains(x.CreateUserId));
  3279. }
  3280. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3281. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3282. .Where(expression.ToExpression())
  3283. .ToList();
  3284. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3285. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3286. {
  3287. x.FileName,
  3288. x.Id,
  3289. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3290. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3291. })));
  3292. }
  3293. /// <summary>
  3294. /// 下载该团组下的所有文件
  3295. /// </summary>
  3296. /// <param name="dto"></param>
  3297. /// <returns></returns>
  3298. [HttpPost]
  3299. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3300. {
  3301. var jw = JsonView(false);
  3302. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3303. if (groupInfo == null)
  3304. {
  3305. jw.Msg = "团组信息不存在!";
  3306. return Ok(jw);
  3307. }
  3308. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3309. var isModule = Convert.ToBoolean(dto.isModule);
  3310. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3311. IOOperatorHelper io = new IOOperatorHelper();
  3312. if (isModule)
  3313. {
  3314. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3315. foreach (var moduleArr in moduleGroup)
  3316. {
  3317. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3318. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3319. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3320. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3321. foreach (var item in moduleArr)
  3322. {
  3323. if (System.IO.File.Exists(item.FilePath))
  3324. {
  3325. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3326. {
  3327. byte[] bytes = new byte[fileStream.Length];
  3328. fileStream.Read(bytes, 0, bytes.Length);
  3329. fileStream.Close();
  3330. Stream stream = new MemoryStream(bytes);
  3331. chiZips.Add(item.FileName, stream);
  3332. }
  3333. }
  3334. }
  3335. if (chiZips.Count > 0)
  3336. {
  3337. var byts = io.ConvertZipStream(chiZips);
  3338. Stream stream = new MemoryStream(byts);
  3339. Zips.Add(key.Name+"_.zip", stream);
  3340. }
  3341. }
  3342. }
  3343. else
  3344. {
  3345. foreach (var item in dbQuery)
  3346. {
  3347. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3348. {
  3349. byte[] bytes = new byte[fileStream.Length];
  3350. fileStream.Read(bytes, 0, bytes.Length);
  3351. fileStream.Close();
  3352. Stream stream = new MemoryStream(bytes);
  3353. while (Zips.Keys.Contains(item.FileName))
  3354. {
  3355. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3356. }
  3357. Zips.Add(item.FileName, stream);
  3358. }
  3359. }
  3360. }
  3361. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3362. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3363. if (Zips.Count > 0)
  3364. {
  3365. var byts = io.ConvertZipStream(Zips);
  3366. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3367. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3368. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3369. }
  3370. else
  3371. {
  3372. jw.Msg = "暂无生成文件!";
  3373. }
  3374. return Ok(jw);
  3375. }
  3376. /// <summary>
  3377. /// 下载该团组下此模块的所有文件
  3378. /// </summary>
  3379. /// <param name="dto"></param>
  3380. /// <returns></returns>
  3381. [HttpPost]
  3382. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3383. {
  3384. var jw = JsonView(false);
  3385. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3386. if (groupInfo == null)
  3387. {
  3388. jw.Msg = "团组信息不存在!";
  3389. return Ok(jw);
  3390. }
  3391. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3392. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3393. && x.IsDel == 0);
  3394. if (key == null)
  3395. {
  3396. jw.Msg = "Ctable指向错误!";
  3397. return Ok(jw);
  3398. }
  3399. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3400. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3401. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3402. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3403. IOOperatorHelper io = new IOOperatorHelper();
  3404. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3405. foreach (var item in dbQuery)
  3406. {
  3407. if (System.IO.File.Exists(item.FilePath))
  3408. {
  3409. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3410. {
  3411. byte[] bytes = new byte[fileStream.Length];
  3412. fileStream.Read(bytes, 0, bytes.Length);
  3413. fileStream.Close();
  3414. Stream stream = new MemoryStream(bytes);
  3415. while (Zips.Keys.Contains(item.FileName))
  3416. {
  3417. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3418. }
  3419. Zips.Add(item.FileName, stream);
  3420. }
  3421. }
  3422. }
  3423. if (Zips.Count > 0)
  3424. {
  3425. var byts = io.ConvertZipStream(Zips);
  3426. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3427. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3428. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3429. }
  3430. else
  3431. {
  3432. jw.Msg = "暂无生成文件!";
  3433. }
  3434. return Ok(jw);
  3435. }
  3436. /// <summary>
  3437. /// 删除该团组下的指定文件
  3438. /// </summary>
  3439. /// <param name="dto"></param>
  3440. /// <returns></returns>
  3441. [HttpPost]
  3442. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3443. {
  3444. var jw = JsonView(false);
  3445. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3446. if (sing == null)
  3447. {
  3448. jw.Msg = "暂无";
  3449. return Ok(jw);
  3450. }
  3451. if (System.IO.File.Exists(sing.FilePath))
  3452. {
  3453. try
  3454. {
  3455. System.IO.File.Delete(sing.FilePath);
  3456. }
  3457. catch (Exception ex)
  3458. {
  3459. jw.Msg = "删除失败!" + ex.Message;
  3460. return Ok(jw);
  3461. }
  3462. }
  3463. sing.IsDel = 1;
  3464. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3465. sing.DeleteUserId = dto.UserId;
  3466. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3467. jw = JsonView(true, "删除成功!");
  3468. return Ok(jw);
  3469. }
  3470. #endregion
  3471. #region 团组英文资料
  3472. /// <summary>
  3473. /// 查询团组英文所有资料
  3474. /// </summary>
  3475. /// <param name="dto"></param>
  3476. /// <returns></returns>
  3477. [HttpPost]
  3478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3479. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3480. {
  3481. try
  3482. {
  3483. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3484. if (groupData.Code != 0)
  3485. {
  3486. return Ok(JsonView(false, groupData.Msg));
  3487. }
  3488. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3489. }
  3490. catch (Exception ex)
  3491. {
  3492. return Ok(JsonView(false, "程序错误!"));
  3493. throw;
  3494. }
  3495. }
  3496. /// <summary>
  3497. /// 团组英文资料操作(Status:1.新增,2.修改)
  3498. /// </summary>
  3499. /// <param name="dto"></param>
  3500. /// <returns></returns>
  3501. [HttpPost]
  3502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3503. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3504. {
  3505. try
  3506. {
  3507. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3508. if (groupData.Code != 0)
  3509. {
  3510. return Ok(JsonView(false, groupData.Msg));
  3511. }
  3512. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3513. }
  3514. catch (Exception ex)
  3515. {
  3516. return Ok(JsonView(false, "程序错误!"));
  3517. throw;
  3518. }
  3519. }
  3520. /// <summary>
  3521. /// 团组英文资料Id查询数据
  3522. /// </summary>
  3523. /// <param name="dto"></param>
  3524. /// <returns></returns>
  3525. [HttpPost]
  3526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3527. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3528. {
  3529. try
  3530. {
  3531. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3532. if (_DelegationEnData != null)
  3533. {
  3534. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3535. }
  3536. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3537. }
  3538. catch (Exception ex)
  3539. {
  3540. return Ok(JsonView(false, "程序错误!"));
  3541. throw;
  3542. }
  3543. }
  3544. /// <summary>
  3545. /// 团组英文资料删除
  3546. /// </summary>
  3547. /// <param name="dto"></param>
  3548. /// <returns></returns>
  3549. [HttpPost]
  3550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3551. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3552. {
  3553. try
  3554. {
  3555. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3556. if (!res)
  3557. {
  3558. return Ok(JsonView(false, "删除失败"));
  3559. }
  3560. return Ok(JsonView(true, "删除成功!"));
  3561. }
  3562. catch (Exception ex)
  3563. {
  3564. return Ok(JsonView(false, "程序错误!"));
  3565. throw;
  3566. }
  3567. }
  3568. #endregion
  3569. #region 导出邀请函
  3570. /// <summary>
  3571. /// 导出邀请函页面初始化
  3572. /// </summary>
  3573. /// <param name="dto"></param>
  3574. /// <returns></returns>
  3575. [HttpPost]
  3576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3577. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3578. {
  3579. try
  3580. {
  3581. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3582. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3583. if (dto.DiId == 0)
  3584. {
  3585. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3586. }
  3587. else
  3588. {
  3589. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3590. }
  3591. return Ok(JsonView(true, "查询成功!", new
  3592. {
  3593. deleClient = crm_Deles,
  3594. delegations = grp_Delegations
  3595. }));
  3596. }
  3597. catch (Exception ex)
  3598. {
  3599. return Ok(JsonView(false, "程序错误!"));
  3600. throw;
  3601. }
  3602. }
  3603. /// <summary>
  3604. /// 导出邀请函
  3605. /// </summary>
  3606. /// <param name="dto"></param>
  3607. /// <returns></returns>
  3608. [HttpPost]
  3609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3610. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3611. {
  3612. #region 参数验证
  3613. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3614. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3615. #endregion
  3616. try
  3617. {
  3618. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3619. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3620. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3621. From Grp_TourClientList tcl
  3622. Left Join
  3623. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3624. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3625. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3626. From Crm_DeleClient dc
  3627. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3628. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3629. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3630. Where dc.IsDel = 0) temp
  3631. On temp.DcId =tcl.ClientId
  3632. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3633. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3634. List<string> texts = new List<string>();
  3635. if (datas.Count != 0)
  3636. {
  3637. foreach (TourClientListDetailsView item in datas)
  3638. {
  3639. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3640. {
  3641. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3642. }
  3643. else
  3644. {
  3645. string name = item.LastName + item.FirstName;
  3646. texts.Add(name);
  3647. }
  3648. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3649. {
  3650. if (!transDic.ContainsKey(item.Job))
  3651. {
  3652. texts.Add(item.Job);
  3653. }
  3654. }
  3655. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3656. {
  3657. texts.Add(item.CompanyFullName);
  3658. }
  3659. }
  3660. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3661. if (transData.Count > 0)
  3662. {
  3663. foreach (TranslateResult item in transData)
  3664. {
  3665. if (!transDic.ContainsKey(item.Query))
  3666. {
  3667. transDic.Add(item.Query, item.Translation);
  3668. }
  3669. }
  3670. }
  3671. List<GuestList> list = new List<GuestList>();
  3672. foreach (TourClientListDetailsView dele in datas)
  3673. {
  3674. GuestList guestList = new GuestList();
  3675. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3676. {
  3677. guestList.Name = dele.Pinyin;
  3678. }
  3679. else
  3680. {
  3681. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3682. guestList.Name = Name;
  3683. }
  3684. if (dele.Sex == 0)
  3685. {
  3686. guestList.Sex = "Male";
  3687. }
  3688. else if (dele.Sex == 1)
  3689. {
  3690. guestList.Sex = "Female";
  3691. }
  3692. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3693. if (!string.IsNullOrEmpty(dele.Job))
  3694. {
  3695. guestList.Job = dele.Job;
  3696. }
  3697. list.Add(guestList);
  3698. }
  3699. //载入模板
  3700. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3701. DocumentBuilder builder = new DocumentBuilder(doc);
  3702. //获取word里所有表格
  3703. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3704. //获取所填表格的序数
  3705. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3706. var rowStart = tableOne.Rows[0]; //获取第1行
  3707. //循环赋值
  3708. for (int i = 0; i < list.Count; i++)
  3709. {
  3710. builder.MoveToCell(0, i + 1, 0, 0);
  3711. builder.Write(list[i].Name.ToString());
  3712. builder.MoveToCell(0, i + 1, 1, 0);
  3713. builder.Write(list[i].Sex.ToString());
  3714. builder.MoveToCell(0, i + 1, 2, 0);
  3715. builder.Write(list[i].DOB.ToString());
  3716. builder.MoveToCell(0, i + 1, 3, 0);
  3717. builder.Write(list[i].Job.ToString());
  3718. }
  3719. //删除多余行
  3720. while (tableOne.Rows.Count > list.Count + 1)
  3721. {
  3722. tableOne.Rows.RemoveAt(list.Count + 1);
  3723. }
  3724. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3725. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3726. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3727. doc.Save(filePath);
  3728. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3729. return Ok(JsonView(true, "操作成功!", Url));
  3730. }
  3731. else
  3732. {
  3733. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3734. }
  3735. }
  3736. catch (Exception ex)
  3737. {
  3738. return Ok(JsonView(false, ex.Message));
  3739. throw;
  3740. }
  3741. }
  3742. #endregion
  3743. #region 团组经理模块 出入境费用
  3744. ///// <summary>
  3745. ///// 团组模块 - 出入境费用
  3746. ///// </summary>
  3747. ///// <returns></returns>
  3748. //[HttpPost]
  3749. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3750. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3751. //{
  3752. // try
  3753. // {
  3754. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3755. // if (data.Code != 0)
  3756. // {
  3757. // return Ok(JsonView(false, data.Msg));
  3758. // }
  3759. // return Ok(JsonView(true, "查询成功!"));
  3760. // }
  3761. // catch (Exception ex)
  3762. // {
  3763. // return Ok(JsonView(false, ex.Message));
  3764. // throw;
  3765. // }
  3766. //}
  3767. /// <summary>
  3768. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3769. /// </summary>
  3770. /// <returns></returns>
  3771. [HttpPost]
  3772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3773. public async Task<IActionResult> SetDayAndCostAreaChange()
  3774. {
  3775. try
  3776. {
  3777. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3778. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3779. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3780. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3781. foreach (var item in unite) //处理交集数据
  3782. {
  3783. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3784. }
  3785. foreach (var item in merge) //处理差集数据
  3786. {
  3787. int nationalTravelFeeId = 0;
  3788. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3789. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3790. else
  3791. {
  3792. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3793. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3794. }
  3795. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3796. }
  3797. //只更新dayAndCost 的 nationalTravelFeeId;
  3798. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3799. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3800. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3801. }
  3802. catch (Exception ex)
  3803. {
  3804. return Ok(JsonView(false, ex.Message));
  3805. throw;
  3806. }
  3807. }
  3808. /// <summary>
  3809. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3810. /// </summary>
  3811. /// <returns></returns>
  3812. [HttpPost]
  3813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3814. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3815. {
  3816. try
  3817. {
  3818. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3819. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3820. //SetDataInfoView
  3821. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3822. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3823. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3824. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3825. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3826. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3827. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3828. //默认币种显示
  3829. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3830. {
  3831. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3832. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3833. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3834. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3835. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3836. };
  3837. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3838. if (_currencyRate.Count > 0)
  3839. {
  3840. foreach (var item in _currencyInfos)
  3841. {
  3842. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3843. if (rateInfo != null)
  3844. {
  3845. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3846. rate1 *= 1.035M;
  3847. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3848. }
  3849. }
  3850. }
  3851. return Ok(JsonView(true, "查询成功!", new
  3852. {
  3853. GroupNameData = groupNameData.Data,
  3854. CurrencyData = _CurrencyData,
  3855. WordTypeData = _WordTypeData,
  3856. ExcelTypeData = _ExcelTypeData,
  3857. CurrencyInit = _currencyInfos
  3858. }));
  3859. }
  3860. catch (Exception ex)
  3861. {
  3862. return Ok(JsonView(false, ex.Message));
  3863. throw;
  3864. }
  3865. }
  3866. /// <summary>
  3867. /// 团组模块 - 出入境费用
  3868. /// 实时汇率 tips
  3869. /// 签证费用 tips
  3870. /// </summary>
  3871. /// <returns></returns>
  3872. [HttpPost]
  3873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3874. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3875. {
  3876. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3877. //默认币种显示
  3878. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3879. {
  3880. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3881. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3882. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3883. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3884. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3885. };
  3886. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3887. List<dynamic> reteInfos = new List<dynamic>();
  3888. if (_currencyRate.Count > 0)
  3889. {
  3890. foreach (var item in _currencyInfos)
  3891. {
  3892. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3893. if (rateInfo != null)
  3894. {
  3895. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3896. decimal rate1 = item.Rate;
  3897. rate1 *= 1.03M;
  3898. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3899. reteInfos.Add(new
  3900. {
  3901. currCode = item.CurrencyCode,
  3902. currName = item.CurrencyName,
  3903. rate = rate2,
  3904. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3905. });
  3906. }
  3907. }
  3908. }
  3909. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3910. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3911. return Ok(JsonView(true, "查询成功!", new
  3912. {
  3913. //GroupNameData = groupNameData.Data,
  3914. visaData = visaData.Data,
  3915. airData = airData.Data,
  3916. reteInfos = reteInfos
  3917. }));
  3918. }
  3919. /// <summary>
  3920. /// 团组模块 - 出入境费用 - Info
  3921. /// </summary>
  3922. /// <returns></returns>
  3923. [HttpPost]
  3924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3925. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3926. {
  3927. try
  3928. {
  3929. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3930. if (data.Code != 0)
  3931. {
  3932. return Ok(JsonView(false, data.Msg));
  3933. }
  3934. return Ok(JsonView(true, "查询成功!", data.Data));
  3935. }
  3936. catch (Exception ex)
  3937. {
  3938. return Ok(JsonView(false, ex.Message));
  3939. }
  3940. }
  3941. /// <summary>
  3942. /// 团组模块 - 出入境费用 - Add And Update
  3943. /// </summary>
  3944. /// <returns></returns>
  3945. [HttpPost]
  3946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3947. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3948. {
  3949. try
  3950. {
  3951. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3952. if (data.Code != 0)
  3953. {
  3954. return Ok(JsonView(false, data.Msg));
  3955. }
  3956. //生成默认文件pdf并且通知人员
  3957. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3958. {
  3959. DiId = dto.DiId,
  3960. ExportType = 1,
  3961. SubTypeId = 1005
  3962. }, "pdf");
  3963. //发送通知
  3964. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3965. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3966. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3967. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3968. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3969. return Ok(JsonView(true, data.Msg, data.Data));
  3970. }
  3971. catch (Exception ex)
  3972. {
  3973. return Ok(JsonView(false, ex.Message));
  3974. }
  3975. }
  3976. /// <summary>
  3977. /// 团组模块 - 出入境费用 - Confirm 费用
  3978. /// </summary>
  3979. /// <returns></returns>
  3980. [HttpPost]
  3981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3982. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3983. {
  3984. //TODO:测试完毕需把对应的用户ID更改
  3985. //1、数据表添加字段
  3986. //2、更改字段接口()
  3987. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3988. //3、确认成功 给财务发送消息
  3989. if (_view.Code == 200)
  3990. {
  3991. if (dto.Type == 1)
  3992. {
  3993. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3994. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  3995. }
  3996. }
  3997. return Ok(_view);
  3998. }
  3999. /// <summary>
  4000. /// 团组模块 - 出入境费用 - File downlaod
  4001. /// </summary>
  4002. /// <param name="dto"></param>
  4003. /// <returns></returns>
  4004. [HttpPost]
  4005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4006. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4007. {
  4008. try
  4009. {
  4010. if (dto.DiId < 1)
  4011. {
  4012. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4013. }
  4014. if (dto.ExportType < 1)
  4015. {
  4016. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4017. }
  4018. if (dto.SubTypeId < 1)
  4019. {
  4020. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4021. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4022. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4023. 3 团组成员名单 1 团组成员名单"));
  4024. }
  4025. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4026. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4027. if (_EnterExitCosts == null)
  4028. {
  4029. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4030. }
  4031. //数据源
  4032. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4033. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4034. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4035. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4036. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4037. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4038. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4039. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4040. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4041. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4042. .Select((tcl, dc, cc) => new
  4043. {
  4044. Name = dc.LastName + dc.FirstName,
  4045. Sex = dc.Sex,
  4046. Birthday = dc.BirthDay,
  4047. Company = cc.CompanyFullName,
  4048. Job = dc.Job
  4049. })
  4050. .ToList();
  4051. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4052. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4053. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4054. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4055. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4056. if (dto.ExportType == 1) //明细表
  4057. {
  4058. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4059. {
  4060. //获取模板
  4061. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4062. //载入模板
  4063. Document doc = new Document(tempPath);
  4064. DocumentBuilder builder = new DocumentBuilder(doc);
  4065. //利用键值对存放数据
  4066. Dictionary<string, string> dic = new Dictionary<string, string>();
  4067. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4068. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4069. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4070. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4071. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4072. //境内费用(其他费用)
  4073. if (_EnterExitCosts.ChoiceOne == 1)
  4074. {
  4075. string row1_1 = "";
  4076. if (_EnterExitCosts.Visa > 0)
  4077. {
  4078. //insidePayTotal += _EnterExitCosts.Visa;
  4079. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4080. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4081. {
  4082. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4083. }
  4084. }
  4085. string row1_2 = "";
  4086. if (_EnterExitCosts.YiMiao > 0)
  4087. {
  4088. //insidePayTotal += _EnterExitCosts.YiMiao;
  4089. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4090. }
  4091. if (_EnterExitCosts.HeSuan > 0)
  4092. {
  4093. //insidePayTotal += _EnterExitCosts.HeSuan;
  4094. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4095. }
  4096. if (_EnterExitCosts.Service > 0)
  4097. {
  4098. //insidePayTotal += _EnterExitCosts.Service;
  4099. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4100. }
  4101. string row1_3 = "";
  4102. if (_EnterExitCosts.Safe > 0)
  4103. {
  4104. //insidePayTotal += _EnterExitCosts.Safe;
  4105. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4106. }
  4107. if (_EnterExitCosts.Ticket > 0)
  4108. {
  4109. //insidePayTotal += _EnterExitCosts.Ticket;
  4110. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4111. }
  4112. string row1 = "";
  4113. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4114. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4115. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4116. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4117. dic.Add("Row1Str", row1);
  4118. }
  4119. string airTotalStr = string.Empty,
  4120. airPriceStr = string.Empty;
  4121. //经济舱
  4122. if (_EnterExitCosts.SumJJC == 1)
  4123. {
  4124. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4125. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4126. }
  4127. //公务舱
  4128. if (_EnterExitCosts.SumGWC == 1)
  4129. {
  4130. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4131. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4132. }
  4133. //头等舱
  4134. if (_EnterExitCosts.SumTDC == 1)
  4135. {
  4136. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4137. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4138. }
  4139. dic.Add("AirTotalStr", airTotalStr);
  4140. dic.Add("AirPriceStr", airPriceStr);
  4141. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4142. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4143. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4144. int table1Row = 0,
  4145. table2Row = 0,
  4146. table3Row = 0,
  4147. table4Row = 0;
  4148. //住宿费
  4149. if (_EnterExitCosts.ChoiceThree == 1)
  4150. {
  4151. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4152. table1Row = dac1.Count;
  4153. #region 填充word表格内容
  4154. for (int i = 0; i < dac1.Count; i++)
  4155. {
  4156. Grp_DayAndCost dac = dac1[i];
  4157. if (dac == null) continue;
  4158. builder.MoveToCell(0, i, 0, 0);
  4159. builder.Write("第" + dac.Days.ToString() + "晚:");
  4160. builder.MoveToCell(0, i, 1, 0);
  4161. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4162. //builder.Write(dac.Place == null ? "" : dac.Place);
  4163. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4164. builder.MoveToCell(0, i, 2, 0);
  4165. builder.Write("费用标准:");
  4166. string curr = "";
  4167. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4168. if (currData != null)
  4169. {
  4170. curr = currData.Name;
  4171. }
  4172. builder.MoveToCell(0, i, 3, 0);
  4173. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4174. builder.MoveToCell(0, i, 4, 0);
  4175. builder.Write("费用小计:");
  4176. builder.MoveToCell(0, i, 5, 0);
  4177. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4178. }
  4179. #endregion
  4180. }else dic.Add("SubZS","0.00");
  4181. //删除多余行
  4182. while (table1.Rows.Count > table1Row)
  4183. {
  4184. table1.Rows.RemoveAt(table1Row);
  4185. }
  4186. //伙食费
  4187. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4188. if (_EnterExitCosts.ChoiceFour == 1)
  4189. {
  4190. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4191. table2Row = dac2.Count;
  4192. #region 填充word表格内容
  4193. for (int i = 0; i < dac2.Count; i++)
  4194. {
  4195. Grp_DayAndCost dac = dac2[i];
  4196. if (dac == null) continue;
  4197. builder.MoveToCell(1, i, 0, 0);
  4198. builder.Write("第" + dac.Days.ToString() + "天:");
  4199. builder.MoveToCell(1, i, 1, 0);
  4200. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4201. builder.MoveToCell(1, i, 2, 0);
  4202. builder.Write("费用标准:");
  4203. string curr = "";
  4204. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4205. if (currData != null)
  4206. {
  4207. curr = currData.Name;
  4208. }
  4209. builder.MoveToCell(1, i, 3, 0);
  4210. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4211. builder.MoveToCell(1, i, 4, 0);
  4212. builder.Write("费用小计:");
  4213. builder.MoveToCell(1, i, 5, 0);
  4214. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4215. }
  4216. #endregion
  4217. }else dic.Add("SubHS","0.00");
  4218. //删除多余行
  4219. while (table2.Rows.Count > table2Row)
  4220. {
  4221. table2.Rows.RemoveAt(table2Row);
  4222. }
  4223. //公杂费
  4224. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4225. if (_EnterExitCosts.ChoiceFive == 1)
  4226. {
  4227. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4228. table3Row = dac3.Count;
  4229. #region 填充word表格内容
  4230. for (int i = 0; i < dac3.Count; i++)
  4231. {
  4232. Grp_DayAndCost dac = dac3[i];
  4233. if (dac == null) continue;
  4234. builder.MoveToCell(2, i, 0, 0);
  4235. builder.Write("第" + dac.Days.ToString() + "天:");
  4236. builder.MoveToCell(2, i, 1, 0);
  4237. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4238. builder.MoveToCell(2, i, 2, 0);
  4239. builder.Write("费用标准:");
  4240. string curr = "";
  4241. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4242. if (currData != null)
  4243. {
  4244. curr = currData.Name;
  4245. }
  4246. builder.MoveToCell(2, i, 3, 0);
  4247. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4248. builder.MoveToCell(2, i, 4, 0);
  4249. builder.Write("费用小计:");
  4250. builder.MoveToCell(2, i, 5, 0);
  4251. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4252. }
  4253. //删除多余行
  4254. while (table3.Rows.Count > table3Row)
  4255. {
  4256. table3.Rows.RemoveAt(table3Row);
  4257. }
  4258. #endregion
  4259. }else dic.Add("SubGZF", "0.00");
  4260. //删除多余行
  4261. while (table3.Rows.Count > table3Row)
  4262. {
  4263. table3.Rows.RemoveAt(table3Row);
  4264. }
  4265. //培训费
  4266. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4267. if (_EnterExitCosts.ChoiceSix == 1)
  4268. {
  4269. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4270. dic.Add("SubPX", pxStr);
  4271. table4Row = dac4.Count;
  4272. #region 填充word表格内容
  4273. for (int i = 0; i < dac4.Count; i++)
  4274. {
  4275. Grp_DayAndCost dac = dac4[i];
  4276. if (dac == null) continue;
  4277. builder.MoveToCell(3, i, 0, 0);
  4278. builder.Write("第" + dac.Days.ToString() + "天:");
  4279. builder.MoveToCell(3, i, 1, 0);
  4280. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4281. builder.MoveToCell(3, i, 2, 0);
  4282. builder.Write("费用标准:");
  4283. string curr = "";
  4284. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4285. if (currData != null)
  4286. {
  4287. curr = currData.Name;
  4288. }
  4289. builder.MoveToCell(3, i, 3, 0);
  4290. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4291. builder.MoveToCell(3, i, 4, 0);
  4292. builder.Write("费用小计:");
  4293. builder.MoveToCell(3, i, 5, 0);
  4294. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4295. }
  4296. #endregion
  4297. }
  4298. //else dic.Add("SubPX","0.00");
  4299. //删除多余行
  4300. while (table4.Rows.Count > table4Row)
  4301. {
  4302. table4.Rows.RemoveAt(table4Row);
  4303. }
  4304. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4305. decimal subJJC = 0.00M,
  4306. subGWC = 0.00M,
  4307. subTDC = 0.00M;
  4308. //经济舱
  4309. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4310. //公务舱
  4311. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4312. //头等舱
  4313. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4314. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4315. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4316. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4317. #region 填充word模板书签内容
  4318. foreach (var key in dic.Keys)
  4319. {
  4320. builder.MoveToBookmark(key);
  4321. builder.Write(dic[key]);
  4322. }
  4323. #endregion
  4324. //文件名
  4325. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4326. AsposeHelper.removewatermark_v2180();
  4327. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4328. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4329. return Ok(JsonView(true, "成功", new { Url = url }));
  4330. }
  4331. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4332. {
  4333. //获取模板
  4334. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4335. //载入模板
  4336. Document doc = new Document(tempPath);
  4337. DocumentBuilder builder = new DocumentBuilder(doc);
  4338. Dictionary<string, string> dic = new Dictionary<string, string>();
  4339. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4340. {
  4341. List<string> list = new List<string>();
  4342. try
  4343. {
  4344. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4345. foreach (var item in spilitArr)
  4346. {
  4347. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4348. var depCode = spDotandEmpty[2].Substring(0, 3);
  4349. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4350. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4351. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4352. list.Add(depName);
  4353. list.Add(arrName);
  4354. }
  4355. list = list.Distinct().ToList();
  4356. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4357. }
  4358. catch (Exception)
  4359. {
  4360. dic.Add("ReturnCode", "行程录入不正确!");
  4361. }
  4362. }
  4363. else
  4364. {
  4365. dic.Add("ReturnCode", "未录入行程!");
  4366. }
  4367. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4368. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4369. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4370. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4371. {
  4372. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4373. dic.Add("Day", sp.Days.ToString());
  4374. }
  4375. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4376. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4377. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4378. //dic.Add("Names", Names);
  4379. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4380. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4381. decimal dac1totalPrice = 0.00M;
  4382. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4383. foreach (var dac in dac1)
  4384. {
  4385. if (dac.SubTotal == 0.00M)
  4386. {
  4387. continue;
  4388. }
  4389. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4390. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4391. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4392. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4393. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4394. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4395. builder.Write(currency);//币种
  4396. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4397. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4398. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4399. builder.Write("");//人数
  4400. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4401. builder.Write("");//天数
  4402. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4403. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4404. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4405. decimal rate = 0.00M;
  4406. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4407. builder.Write(rate.ToString("#0.0000"));//汇率
  4408. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4409. decimal rbmPrice = dac.SubTotal;
  4410. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4411. accommodationStartIndex++;
  4412. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4413. }
  4414. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4415. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4416. {
  4417. table1.Rows.RemoveAt(i - 1);
  4418. foodandotherStartIndex--;
  4419. }
  4420. if (dac2.Count == dac3.Count)//国家 币种 金额
  4421. {
  4422. for (int i = 0; i < dac2.Count; i++)
  4423. {
  4424. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4425. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4426. }
  4427. }
  4428. decimal dac2totalPrice = 0.00M;
  4429. foreach (var dac in dac2)
  4430. {
  4431. if (dac.SubTotal == 0)
  4432. {
  4433. continue;
  4434. }
  4435. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4436. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4437. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4438. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4439. builder.Write(currency);//币种
  4440. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4441. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4442. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4443. builder.Write("");//人数
  4444. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4445. builder.Write("");//天数
  4446. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4447. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4448. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4449. decimal rate = 0.00M;
  4450. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4451. builder.Write(rate.ToString("#0.0000"));//汇率
  4452. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4453. decimal rbmPrice = dac.SubTotal;
  4454. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4455. foodandotherStartIndex++;
  4456. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4457. }
  4458. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4459. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4460. {
  4461. table1.Rows.RemoveAt(i - 1);
  4462. }
  4463. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4464. string otherFeeStr = "";
  4465. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4466. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4467. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4468. if (otherFeeStr.Length > 0)
  4469. {
  4470. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4471. otherFeeStr = $"({otherFeeStr})";
  4472. dic.Add("OtherFeeStr", otherFeeStr);
  4473. }
  4474. //总计
  4475. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4476. //国际旅费
  4477. string outsideAir = string.Empty;
  4478. string allPriceAir = string.Empty;
  4479. if (_EnterExitCosts.SumJJC == 1)
  4480. {
  4481. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4482. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4483. }
  4484. if (_EnterExitCosts.SumGWC == 1)
  4485. {
  4486. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4487. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4488. }
  4489. if (_EnterExitCosts.SumTDC == 1)
  4490. {
  4491. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4492. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4493. }
  4494. dic.Add("InTravelPrice", $"({outsideAir})");
  4495. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4496. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4497. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4498. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4499. foreach (var key in dic.Keys)
  4500. {
  4501. builder.MoveToBookmark(key);
  4502. builder.Write(dic[key]);
  4503. }
  4504. //模板文件名
  4505. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4506. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4507. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4508. return Ok(JsonView(true, "成功", new { Url = url }));
  4509. }
  4510. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4511. {
  4512. //获取模板
  4513. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4514. //载入模板
  4515. WorkbookDesigner designer = new WorkbookDesigner();
  4516. designer.Workbook = new Workbook(tempPath);
  4517. Dictionary<string, string> dic = new Dictionary<string, string>();
  4518. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4519. {
  4520. List<string> list = new List<string>();
  4521. try
  4522. {
  4523. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4524. foreach (var item in spilitArr)
  4525. {
  4526. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4527. var depCode = spDotandEmpty[2].Substring(0, 3);
  4528. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4529. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4530. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4531. list.Add(depName);
  4532. list.Add(arrName);
  4533. }
  4534. list = list.Distinct().ToList();
  4535. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4536. }
  4537. catch (Exception)
  4538. {
  4539. dic.Add("ReturnCode", "行程录入不正确!");
  4540. }
  4541. }
  4542. else
  4543. {
  4544. dic.Add("ReturnCode", "未录入行程!");
  4545. }
  4546. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4547. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4548. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4549. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4550. {
  4551. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4552. dic.Add("Day", sp.Days.ToString());
  4553. }
  4554. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4555. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4556. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4557. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4558. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4559. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4560. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4561. designer.SetDataSource("Name", Names);
  4562. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4563. designer.SetDataSource("Day", dic["Day"] + "天");
  4564. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4565. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4566. int startIndex = 10;
  4567. const int startIndexcopy = 10;
  4568. if (dac2.Count == dac3.Count)//国家 币种 金额
  4569. {
  4570. for (int i = 0; i < dac2.Count; i++)
  4571. {
  4572. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4573. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4574. }
  4575. }
  4576. DataTable dtdac1 = new DataTable();
  4577. List<string> place = new List<string>();
  4578. dtdac1.Columns.AddRange(new DataColumn[] {
  4579. new DataColumn(){ ColumnName = "city"},
  4580. new DataColumn(){ ColumnName = "curr"},
  4581. new DataColumn(){ ColumnName = "criterion"},
  4582. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4583. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4584. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4585. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4586. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4587. });
  4588. DataTable dtdac2 = new DataTable();
  4589. dtdac2.Columns.AddRange(new DataColumn[] {
  4590. new DataColumn(){ ColumnName = "city"},
  4591. new DataColumn(){ ColumnName = "curr"},
  4592. new DataColumn(){ ColumnName = "criterion"},
  4593. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4594. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4595. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4596. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4597. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4598. });
  4599. dtdac1.TableName = "tb1";
  4600. dtdac2.TableName = "tb2";
  4601. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4602. foreach (var item in dac1)
  4603. {
  4604. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4605. if (place.Contains(item.Place))
  4606. {
  4607. continue;
  4608. }
  4609. DataRow row = dtdac1.NewRow();
  4610. row["city"] = item.Place;
  4611. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4612. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4613. row["curr"] = currency;
  4614. row["rate"] = rate.ToString("#0.0000");
  4615. row["criterion"] = item.Cost.ToString("#0.00");
  4616. row["number"] = 1;
  4617. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4618. //row["costRMB"] = rbmPrice;
  4619. dtdac1.Rows.Add(row);
  4620. place.Add(item.Place);
  4621. }
  4622. place = new List<string>();
  4623. foreach (var item in dac2)
  4624. {
  4625. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4626. if (place.Contains(item.Place))
  4627. {
  4628. continue;
  4629. }
  4630. DataRow row = dtdac2.NewRow();
  4631. row["city"] = item.Place;
  4632. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4633. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4634. row["curr"] = currency;
  4635. row["rate"] = rate.ToString("#0.0000");
  4636. row["criterion"] = item.Cost.ToString("#0.00");
  4637. row["number"] = 1;
  4638. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4639. //row["cost"] = item.SubTotal;
  4640. //row["costRMB"] = rbmPrice;
  4641. dtdac2.Rows.Add(row);
  4642. place.Add(item.Place);
  4643. //dac2totalPrice += rbmPrice;
  4644. }
  4645. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4646. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4647. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4648. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4649. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4650. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4651. string cell4Str1 = string.Empty;
  4652. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4653. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4654. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4655. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4656. string cellStr = $" 5.其他费用(";
  4657. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4658. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4659. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4660. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4661. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4662. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4663. if (cellStr.Length > 8)
  4664. {
  4665. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4666. }
  4667. cellStr += ")";
  4668. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4669. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4670. decimal pxFee = dac4.Sum(it => it.Cost);
  4671. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4672. string celllastStr1 = "";
  4673. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4674. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4675. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4676. celllastStr1 += $",国际旅费 元";
  4677. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4678. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4679. designer.SetDataSource("cell4Str", cell4Str);
  4680. designer.SetDataSource("cellStr", cellStr);
  4681. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4682. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4683. designer.SetDataSource("celllastStr", celllastStr);
  4684. Workbook wb = designer.Workbook;
  4685. var sheet = wb.Worksheets[0];
  4686. //绑定datatable数据集
  4687. designer.SetDataSource(dtdac1);
  4688. designer.SetDataSource(dtdac2);
  4689. designer.Process();
  4690. var rowStart = dtdac1.Rows.Count;
  4691. while (rowStart > 0)
  4692. {
  4693. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4694. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4695. startIndex++;
  4696. rowStart--;
  4697. }
  4698. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4699. startIndex += 1; //总计行
  4700. rowStart = dtdac2.Rows.Count;
  4701. while (rowStart > 0)
  4702. {
  4703. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4704. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4705. startIndex++;
  4706. rowStart--;
  4707. }
  4708. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4709. wb.CalculateFormula(true);
  4710. //模板文件名
  4711. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4712. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4713. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4714. return Ok(JsonView(true, "成功", new { Url = url }));
  4715. }
  4716. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4717. {
  4718. //获取模板
  4719. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4720. //载入模板
  4721. Document doc = new Document(tempPath);
  4722. DocumentBuilder builder = new DocumentBuilder(doc);
  4723. Dictionary<string, string> dic = new Dictionary<string, string>();
  4724. dic.Add("GroupName", _DelegationInfo.TeamName);
  4725. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4726. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4727. string missionLeaderJob = "";//负责人job
  4728. int groupNumber = 0; //团人数
  4729. if (DeleClientList.Count > 0)
  4730. {
  4731. missionLeader = DeleClientList[0]?.Name ?? "";
  4732. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4733. }
  4734. dic.Add("MissionLeader", missionLeader); //团负责人
  4735. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4736. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4737. #region MyRegion
  4738. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4739. //{
  4740. // List<string> list = new List<string>();
  4741. // try
  4742. // {
  4743. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4744. // foreach (var item in spilitArr)
  4745. // {
  4746. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4747. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4748. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4749. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4750. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4751. // list.Add(depName);
  4752. // list.Add(arrName);
  4753. // }
  4754. // list = list.Distinct().ToList();
  4755. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4756. // }
  4757. // catch (Exception)
  4758. // {
  4759. // dic.Add("ReturnCode", "行程录入不正确!");
  4760. // }
  4761. //}
  4762. //else
  4763. //{
  4764. // dic.Add("ReturnCode", "未录入行程!");
  4765. //}
  4766. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4767. dic.Add("ReturnCode", string.Join("、", countrys));
  4768. #endregion
  4769. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4770. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4771. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4772. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4773. //{
  4774. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4775. // dic.Add("Day", sp.Days.ToString());
  4776. //}
  4777. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4778. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4779. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4780. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4781. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4782. //培训人员名单
  4783. int cultivateRowIndex = 7;
  4784. foreach (var item in DeleClientList)
  4785. {
  4786. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4787. builder.Write(item.Name);
  4788. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4789. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4790. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4791. string birthDay = "";
  4792. if (item.Birthday != null)
  4793. {
  4794. DateTime dt = Convert.ToDateTime(item.Birthday);
  4795. birthDay = $"{dt.Year}.{dt.Month}";
  4796. }
  4797. builder.Write(birthDay);
  4798. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4799. builder.Write(item.Company);
  4800. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4801. builder.Write(item.Job);
  4802. cultivateRowIndex++;
  4803. }
  4804. //删除多余行
  4805. //cultivateRowIndex -= 2;
  4806. int delRows = 10 + 7 - cultivateRowIndex;
  4807. if (delRows > 0)
  4808. {
  4809. for (int i = 0; i < delRows; i++)
  4810. {
  4811. table1.Rows.RemoveAt(cultivateRowIndex);
  4812. //cultivateRowIndex++;
  4813. }
  4814. }
  4815. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4816. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4817. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4818. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4819. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4820. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4821. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4822. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4823. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4824. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4825. //其他费用
  4826. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4827. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4828. //其他费用合计
  4829. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4830. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4831. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4832. //公务舱合计
  4833. //国际旅费
  4834. string outsideJJ = "";
  4835. string allPriceJJ = "";
  4836. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4837. {
  4838. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4839. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4840. }
  4841. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4842. {
  4843. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4844. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4845. }
  4846. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4847. {
  4848. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4849. dic.Add("AirFeeTotal", airFeeTotalStr);
  4850. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4851. dic.Add("FeeTotal", feeTotalStr);
  4852. }
  4853. foreach (var key in dic.Keys)
  4854. {
  4855. builder.MoveToBookmark(key);
  4856. builder.Write(dic[key]);
  4857. }
  4858. //模板文件名
  4859. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4860. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4861. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4862. return Ok(JsonView(true, "成功", new { Url = url }));
  4863. }
  4864. }
  4865. else if (dto.ExportType == 2) //表格
  4866. {
  4867. //利用键值对存放数据
  4868. Dictionary<string, string> dic = new Dictionary<string, string>();
  4869. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4870. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4871. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4872. dic.Add("Day", sp.Days.ToString());
  4873. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4874. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4875. {
  4876. //获取模板
  4877. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4878. //载入模板
  4879. Document doc = new Document(tempPath);
  4880. DocumentBuilder builder = new DocumentBuilder(doc);
  4881. dic.Add("TeamName", _DelegationInfo.TeamName);
  4882. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4883. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4884. string missionLeaderName = "",
  4885. missionLeaderJob = "";
  4886. if (DeleClientList.Count > 0)
  4887. {
  4888. missionLeaderName = DeleClientList[0].Name;
  4889. missionLeaderJob = DeleClientList[0].Job;
  4890. }
  4891. dic.Add("MissionLeaderName", missionLeaderName);
  4892. dic.Add("MissionLeaderJob", missionLeaderJob);
  4893. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4894. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4895. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4896. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4897. int rowCount = 10;//总人数行
  4898. int startRowIndex = 7; //起始行
  4899. for (int i = 0; i < DeleClientList.Count; i++)
  4900. {
  4901. builder.MoveToCell(0, startRowIndex, 0, 0);
  4902. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4903. builder.MoveToCell(0, startRowIndex, 1, 0);
  4904. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4905. builder.Write(sex);//性别
  4906. builder.MoveToCell(0, startRowIndex, 2, 0);
  4907. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4908. builder.MoveToCell(0, startRowIndex, 3, 0);
  4909. builder.Write(DeleClientList[i].Company);//工作单位
  4910. builder.MoveToCell(0, startRowIndex, 4, 0);
  4911. builder.Write(DeleClientList[i].Job);//职务及级别
  4912. builder.MoveToCell(0, startRowIndex, 5, 0);
  4913. builder.Write("");//人员属性
  4914. builder.MoveToCell(0, startRowIndex, 6, 0);
  4915. builder.Write("");//上次出国时间
  4916. startRowIndex++;
  4917. }
  4918. int nullRow = rowCount - DeleClientList.Count;//空行
  4919. for (int i = 0; i < nullRow; i++)
  4920. {
  4921. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4922. }
  4923. foreach (var key in dic.Keys)
  4924. {
  4925. builder.MoveToBookmark(key);
  4926. builder.Write(dic[key]);
  4927. }
  4928. //模板文件名
  4929. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4930. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4931. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4932. return Ok(JsonView(true, "成功", new { Url = url }));
  4933. }
  4934. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4935. {
  4936. //获取模板
  4937. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4938. //载入模板
  4939. Document doc = new Document(tempPath);
  4940. DocumentBuilder builder = new DocumentBuilder(doc);
  4941. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4942. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4943. dic.Add("Names", Names);
  4944. int accommodationRows = 12, foodandotherRows = 12;
  4945. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4946. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4947. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4948. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4949. int accommodationStartIndex = 6;
  4950. decimal dac1totalPrice = 0.00M;
  4951. foreach (var dac in dac1)
  4952. {
  4953. if (dac.SubTotal == 0)
  4954. {
  4955. continue;
  4956. }
  4957. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4958. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4959. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4960. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4961. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4962. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4963. builder.Write(currency);//币种
  4964. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4965. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4966. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4967. builder.Write("");//人数
  4968. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4969. builder.Write("");//天数
  4970. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4971. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4972. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4973. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4974. builder.Write(rate.ToString("#0.0000"));//汇率
  4975. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4976. decimal rbmPrice = rate * dac.SubTotal;
  4977. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4978. accommodationStartIndex++;
  4979. dac1totalPrice += rbmPrice;
  4980. }
  4981. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4982. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4983. builder.Write("小计");
  4984. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4985. builder.Write(dac1totalPrice.ToString("#0.00"));
  4986. accommodationStartIndex++;
  4987. int nullRow = accommodationRows - dac1.Count;
  4988. //删除空行
  4989. //if (nullRow > 0)
  4990. //{
  4991. // int rowIndex = accommodationStartIndex;
  4992. // for (int i = 0; i < nullRow; i++)
  4993. // {
  4994. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  4995. // row.Remove();
  4996. // rowIndex++;
  4997. // }
  4998. //}
  4999. if (dac2.Count == dac3.Count)//国家 币种 金额
  5000. {
  5001. for (int i = 0; i < dac2.Count; i++)
  5002. {
  5003. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5004. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5005. }
  5006. }
  5007. int foodandotherStartIndex = 19;//
  5008. decimal dac2totalPrice = 0.00M;
  5009. foreach (var dac in dac2)
  5010. {
  5011. if (dac.SubTotal == 0)
  5012. {
  5013. continue;
  5014. }
  5015. //foodandotherStartIndex = 12;
  5016. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5017. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5018. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5019. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5020. builder.Write(currency);//币种
  5021. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5022. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5023. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5024. builder.Write("");//人数
  5025. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5026. builder.Write("");//天数
  5027. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5028. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5029. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5030. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5031. builder.Write(rate.ToString("#0.0000"));//汇率
  5032. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5033. decimal rbmPrice = rate * dac.SubTotal;
  5034. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5035. foodandotherStartIndex++;
  5036. dac2totalPrice += rbmPrice;
  5037. }
  5038. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5039. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5040. //删除空行
  5041. //if (dac2.Count < foodandotherRows)
  5042. //{
  5043. // while (table2.Rows.Count > dac2.Count)
  5044. // {
  5045. // table2.Rows.RemoveAt(dac2.Count);
  5046. // }
  5047. //}
  5048. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5049. string otherFeeStr = "";
  5050. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5051. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5052. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5053. if (otherFeeStr.Length > 0)
  5054. {
  5055. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5056. otherFeeStr = $"({otherFeeStr})";
  5057. dic.Add("OtherFeeStr", otherFeeStr);
  5058. }
  5059. foreach (var key in dic.Keys)
  5060. {
  5061. builder.MoveToBookmark(key);
  5062. builder.Write(dic[key]);
  5063. }
  5064. //模板文件名
  5065. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5066. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5067. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5068. return Ok(JsonView(true, "成功", new { Url = url }));
  5069. }
  5070. }
  5071. else if (dto.ExportType == 3)
  5072. {
  5073. if (dto.SubTypeId == 1) //团组成员名单
  5074. {
  5075. if (DeleClientList.Count < 1)
  5076. {
  5077. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5078. }
  5079. //获取模板
  5080. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5081. //载入模板
  5082. Document doc = new Document(tempPath);
  5083. DocumentBuilder builder = new DocumentBuilder(doc);
  5084. //获取word里所有表格
  5085. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5086. //获取所填表格的序数
  5087. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5088. var rowStart = tableOne.Rows[0]; //获取第1行
  5089. //循环赋值
  5090. for (int i = 0; i < DeleClientList.Count; i++)
  5091. {
  5092. builder.MoveToCell(0, i + 1, 0, 0);
  5093. builder.Write(DeleClientList[i].Name);
  5094. builder.MoveToCell(0, i + 1, 1, 0);
  5095. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5096. builder.Write(sex);
  5097. builder.MoveToCell(0, i + 1, 2, 0);
  5098. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5099. builder.MoveToCell(0, i + 1, 3, 0);
  5100. builder.Write(DeleClientList[i].Company);
  5101. builder.MoveToCell(0, i + 1, 4, 0);
  5102. builder.Write(DeleClientList[i].Job);
  5103. }
  5104. //删除多余行
  5105. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5106. {
  5107. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5108. }
  5109. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5110. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5111. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5112. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5113. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5114. return Ok(JsonView(true, "成功", new { Url = url }));
  5115. }
  5116. }
  5117. return Ok(JsonView(false, "操作失败!"));
  5118. }
  5119. catch (Exception ex)
  5120. {
  5121. return Ok(JsonView(false, ex.Message));
  5122. }
  5123. }
  5124. /// <summary>
  5125. /// 获取三公费用标准city
  5126. /// </summary>
  5127. /// <param name="placeData"></param>
  5128. /// <param name="nationalTravelFeeId"></param>
  5129. /// <returns></returns>
  5130. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5131. {
  5132. string _city = string.Empty;
  5133. if (placeData.Count < 1) return _city;
  5134. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5135. if (data == null) return _city;
  5136. string country = data.Country;
  5137. string city = data.City;
  5138. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5139. else _city = city;
  5140. return _city;
  5141. }
  5142. /// <summary>
  5143. /// 团组模块 - 出入境费用 - 明细表导出
  5144. /// </summary>
  5145. /// <returns></returns>
  5146. [HttpPost]
  5147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5148. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5149. {
  5150. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5151. if (data.Code != 0)
  5152. {
  5153. return Ok(JsonView(false, data.Msg));
  5154. }
  5155. return Ok(JsonView(true, data.Msg, data.Data));
  5156. }
  5157. /// <summary>
  5158. /// 团组模块 - 出入境费用 - 一键清空
  5159. /// </summary>
  5160. /// <returns></returns>
  5161. [HttpPost]
  5162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5163. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5164. {
  5165. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5166. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5167. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5168. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5169. if (_view.Code == 0)
  5170. {
  5171. return Ok(JsonView(true, "操作成功"));
  5172. }
  5173. return Ok(JsonView(false, "操作失败"));
  5174. }
  5175. /// <summary>
  5176. /// 团组模块 - 出入境费用 - 子项删除
  5177. /// </summary>
  5178. /// <returns></returns>
  5179. [HttpPost]
  5180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5181. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5182. {
  5183. try
  5184. {
  5185. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5186. if (data.Code != 0)
  5187. {
  5188. return Ok(JsonView(false, data.Msg));
  5189. }
  5190. return Ok(JsonView(true, "操作成功!", data.Data));
  5191. }
  5192. catch (Exception ex)
  5193. {
  5194. return Ok(JsonView(false, ex.Message));
  5195. }
  5196. }
  5197. /// <summary>
  5198. /// 团组模块 - 出入境国家费用标准 List
  5199. /// </summary>
  5200. /// <returns></returns>
  5201. [HttpPost]
  5202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5203. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5204. {
  5205. try
  5206. {
  5207. Stopwatch sw = new Stopwatch();
  5208. sw.Start();
  5209. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5210. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5211. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5212. Where gntf.Isdel = 0");
  5213. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5214. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5215. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5216. //foreach (var item in nationalTravel)
  5217. //{
  5218. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5219. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5220. // if (otherData != null)
  5221. // {
  5222. // cityData.Remove(otherData);
  5223. // cityData.Add(otherData);
  5224. // }
  5225. // nationalTravelFeeData1.Add(new
  5226. // {
  5227. // Country = item.Country,
  5228. // CityData = cityData
  5229. // });
  5230. //}
  5231. sw.Stop();
  5232. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5233. }
  5234. catch (Exception ex)
  5235. {
  5236. return Ok(JsonView(false, ex.Message));
  5237. throw;
  5238. }
  5239. }
  5240. /// <summary>
  5241. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5242. /// </summary>
  5243. /// <returns></returns>
  5244. [HttpPost]
  5245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5246. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5247. {
  5248. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5249. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5250. List<string> countryData = new List<string>();
  5251. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5252. countryData = countryData.Distinct().ToList();
  5253. List<dynamic> dataSource = new List<dynamic>();
  5254. foreach (var item in countryData)
  5255. {
  5256. List<string> cityData1 = new List<string>();
  5257. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5258. var countryData2 = new
  5259. {
  5260. CountryName = item,
  5261. CityData = cityData1
  5262. };
  5263. dataSource.Add(countryData2);
  5264. }
  5265. return Ok(JsonView(true, "查询成功!", dataSource));
  5266. }
  5267. /// <summary>
  5268. /// 团组模块 - 出入境国家费用标准 Page List
  5269. /// </summary>
  5270. /// <returns></returns>
  5271. [HttpPost]
  5272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5273. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5274. {
  5275. int portId = dto.PortType;
  5276. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5277. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5278. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5279. string whereSql = string.Empty;
  5280. if (!string.IsNullOrEmpty(dto.Country))
  5281. {
  5282. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5283. }
  5284. if (!string.IsNullOrEmpty(dto.City))
  5285. {
  5286. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5287. }
  5288. string pageSql = string.Format(@"Select * From (
  5289. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5290. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5291. From Grp_NationalTravelFee gntf
  5292. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5293. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5294. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5295. RefAsync<int> total = 0;
  5296. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5297. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5298. }
  5299. /// <summary>
  5300. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5301. /// </summary>
  5302. /// <returns></returns>
  5303. [HttpPost]
  5304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5305. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5306. {
  5307. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5308. int portId = dto.PortType;
  5309. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5310. string whereSql = string.Empty;
  5311. if (!string.IsNullOrEmpty(dto.Country))
  5312. {
  5313. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5314. }
  5315. if (!string.IsNullOrEmpty(dto.City))
  5316. {
  5317. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5318. }
  5319. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5320. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5321. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5322. From Grp_NationalTravelFee gntf
  5323. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5324. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5325. Where gntf.Isdel = 0 {0} ", whereSql);
  5326. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5327. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5328. }
  5329. /// <summary>
  5330. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5331. /// </summary>
  5332. /// <returns></returns>
  5333. [HttpPost]
  5334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5335. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5336. {
  5337. try
  5338. {
  5339. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5340. if (data.Code != 0)
  5341. {
  5342. return Ok(JsonView(false, data.Msg));
  5343. }
  5344. return Ok(JsonView(true, "操作成功!", data.Data));
  5345. }
  5346. catch (Exception ex)
  5347. {
  5348. return Ok(JsonView(false, ex.Message));
  5349. }
  5350. }
  5351. /// <summary>
  5352. /// 团组模块 - 出入境国家费用标准 - Del
  5353. /// </summary>
  5354. /// <returns></returns>
  5355. [HttpPost]
  5356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5357. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5358. {
  5359. try
  5360. {
  5361. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5362. {
  5363. Id = dto.Id,
  5364. DeleteUserId = dto.DeleteUserId,
  5365. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5366. IsDel = 1
  5367. };
  5368. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5369. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5370. .WhereColumns(it => new { it.Id })
  5371. .ExecuteCommandAsync();
  5372. if (delStatus <= 0)
  5373. {
  5374. return Ok(JsonView(false, "删除失败!"));
  5375. }
  5376. return Ok(JsonView(true, "操作成功!"));
  5377. }
  5378. catch (Exception ex)
  5379. {
  5380. return Ok(JsonView(false, ex.Message));
  5381. }
  5382. }
  5383. #endregion
  5384. #region 签证费用录入
  5385. /// <summary>
  5386. /// 根据diid查询签证费用列表
  5387. /// </summary>
  5388. /// <param name="dto"></param>
  5389. /// <returns></returns>
  5390. [HttpPost]
  5391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5392. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5393. {
  5394. try
  5395. {
  5396. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5397. if (groupData.Code != 0)
  5398. {
  5399. return Ok(JsonView(false, groupData.Msg));
  5400. }
  5401. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5402. }
  5403. catch (Exception ex)
  5404. {
  5405. return Ok(JsonView(false, ex.Message));
  5406. }
  5407. }
  5408. /// <summary>
  5409. /// 根据签证费用Id查询单条数据及c表数据
  5410. /// </summary>
  5411. /// <param name="dto"></param>
  5412. /// <returns></returns>
  5413. [HttpPost]
  5414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5415. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5416. {
  5417. try
  5418. {
  5419. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5420. if (groupData.Code != 0)
  5421. {
  5422. return Ok(JsonView(false, groupData.Msg));
  5423. }
  5424. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5425. }
  5426. catch (Exception ex)
  5427. {
  5428. return Ok(JsonView(false, ex.Message));
  5429. }
  5430. }
  5431. /// <summary>
  5432. /// 签证费用删除
  5433. /// </summary>
  5434. /// <param name="dto"></param>
  5435. /// <returns></returns>
  5436. [HttpPost]
  5437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5438. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5439. {
  5440. _sqlSugar.BeginTran();
  5441. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5442. if (!res)
  5443. {
  5444. _sqlSugar.RollbackTran();
  5445. return Ok(JsonView(false, "删除失败"));
  5446. }
  5447. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5448. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5449. .SetColumns(a => new Grp_CreditCardPayment()
  5450. {
  5451. IsDel = 1,
  5452. DeleteUserId = dto.DeleteUserId,
  5453. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5454. }).ExecuteCommand();
  5455. if (resSub < 1)
  5456. {
  5457. _sqlSugar.RollbackTran();
  5458. return Ok(JsonView(false, "删除失败"));
  5459. }
  5460. _sqlSugar.CommitTran();
  5461. return Ok(JsonView(true, "删除成功!"));
  5462. }
  5463. /// <summary>
  5464. /// 签证费用录入下拉框初始化
  5465. /// </summary>
  5466. /// <returns></returns>
  5467. [HttpPost]
  5468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5469. public async Task<IActionResult> VisaPriceAddSelect()
  5470. {
  5471. try
  5472. {
  5473. //支付方式
  5474. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5475. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5476. //币种
  5477. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5478. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5479. //乘客类型
  5480. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5481. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5482. //卡类型
  5483. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5484. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5485. var data = new
  5486. {
  5487. Payment = _Payment,
  5488. CurrencyList = _CurrencyList,
  5489. PassengerType = _PassengerType,
  5490. BankCard = _BankCard
  5491. };
  5492. return Ok(JsonView(true, "查询成功!", data));
  5493. }
  5494. catch (Exception ex)
  5495. {
  5496. return Ok(JsonView(false, "程序错误!"));
  5497. throw;
  5498. }
  5499. }
  5500. /// <summary>
  5501. /// 签证费用录入操作(Status:1.新增,2.修改)
  5502. /// </summary>
  5503. /// <param name="dto"></param>
  5504. /// <returns></returns>
  5505. [HttpPost]
  5506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5507. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5508. {
  5509. try
  5510. {
  5511. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5512. if (groupData.Code != 0)
  5513. {
  5514. return Ok(JsonView(false, groupData.Msg));
  5515. }
  5516. #region 应用推送
  5517. try
  5518. {
  5519. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5520. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5521. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5522. }
  5523. catch (Exception ex)
  5524. {
  5525. }
  5526. #endregion
  5527. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5528. }
  5529. catch (Exception ex)
  5530. {
  5531. return Ok(JsonView(false, ex.Message));
  5532. }
  5533. }
  5534. #endregion
  5535. #region op费用录入
  5536. /// <summary>
  5537. /// 根据diid查询op费用列表
  5538. /// </summary>
  5539. /// <param name="dto"></param>
  5540. /// <returns></returns>
  5541. [HttpPost]
  5542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5543. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5544. {
  5545. try
  5546. {
  5547. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5548. if (groupData.Code != 0)
  5549. {
  5550. return Ok(JsonView(false, groupData.Msg));
  5551. }
  5552. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5553. }
  5554. catch (Exception ex)
  5555. {
  5556. return Ok(JsonView(false, ex.Message));
  5557. }
  5558. }
  5559. /// <summary>
  5560. /// 根据op费用Id查询单条数据及c表数据
  5561. /// </summary>
  5562. /// <param name="dto"></param>
  5563. /// <returns></returns>
  5564. [HttpPost]
  5565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5566. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5567. {
  5568. try
  5569. {
  5570. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5571. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5572. var data = new
  5573. {
  5574. CarTouristGuideGround = _groupData,
  5575. CreditCardPayment = _creditCardPayment
  5576. };
  5577. return Ok(JsonView(true, "查询成功!", data));
  5578. }
  5579. catch (Exception ex)
  5580. {
  5581. return Ok(JsonView(false, "程序错误!"));
  5582. }
  5583. }
  5584. /// <summary>
  5585. /// op费用删除
  5586. /// </summary>
  5587. /// <param name="dto"></param>
  5588. /// <returns></returns>
  5589. [HttpPost]
  5590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5591. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5592. {
  5593. try
  5594. {
  5595. _sqlSugar.BeginTran();
  5596. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5597. if (!res)
  5598. {
  5599. return Ok(JsonView(false, "删除失败"));
  5600. }
  5601. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5602. {
  5603. IsDel = 1,
  5604. DeleteUserId = dto.DeleteUserId,
  5605. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5606. }).ExecuteCommandAsync();
  5607. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5608. {
  5609. IsDel = 1,
  5610. DeleteUserId = dto.DeleteUserId,
  5611. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5612. }).ExecuteCommandAsync();
  5613. #region 删除超支相关数据
  5614. //删除导入的超支数据
  5615. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5616. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5617. {
  5618. IsDel = 1,
  5619. DeleteUserId = dto.DeleteUserId,
  5620. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5621. }).ExecuteCommand();
  5622. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5623. {
  5624. IsDel = 1,
  5625. DeleteUserId = dto.DeleteUserId,
  5626. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5627. }).ExecuteCommand() ;
  5628. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5629. {
  5630. IsDel = 1,
  5631. DeleteUserId = dto.DeleteUserId,
  5632. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5633. }).ExecuteCommand();
  5634. #endregion
  5635. _sqlSugar.CommitTran();
  5636. return Ok(JsonView(true, "删除成功!"));
  5637. }
  5638. catch (Exception ex)
  5639. {
  5640. _sqlSugar.RollbackTran();
  5641. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5642. }
  5643. }
  5644. /// <summary>
  5645. /// op费用录入操作(Status:1.新增,2.修改)
  5646. /// </summary>
  5647. /// <param name="dto"></param>
  5648. /// <returns></returns>
  5649. [HttpPost]
  5650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5651. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5652. {
  5653. try
  5654. {
  5655. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5656. if (groupData.Code != 0)
  5657. {
  5658. return Ok(JsonView(false, groupData.Msg));
  5659. }
  5660. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5661. }
  5662. catch (Exception ex)
  5663. {
  5664. return Ok(JsonView(false, ex.Message));
  5665. }
  5666. }
  5667. /// <summary>
  5668. /// 填写费用详细页面初始化绑定
  5669. /// </summary>
  5670. /// <param name="dto"></param>
  5671. /// <returns></returns>
  5672. [HttpPost]
  5673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5674. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5675. {
  5676. try
  5677. {
  5678. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5679. if (groupData.Code != 0)
  5680. {
  5681. return Ok(JsonView(false, groupData.Msg));
  5682. }
  5683. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5684. }
  5685. catch (Exception ex)
  5686. {
  5687. return Ok(JsonView(false, ex.Message));
  5688. }
  5689. }
  5690. /// <summary>
  5691. /// 根据op费用Id查询详细数据
  5692. /// </summary>
  5693. /// <param name="dto"></param>
  5694. /// <returns></returns>
  5695. [HttpPost]
  5696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5697. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5698. {
  5699. try
  5700. {
  5701. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5702. if (groupData.Code != 0)
  5703. {
  5704. return Ok(JsonView(false, groupData.Msg));
  5705. }
  5706. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5707. }
  5708. catch (Exception ex)
  5709. {
  5710. return Ok(JsonView(false, ex.Message));
  5711. }
  5712. }
  5713. /// <summary>
  5714. /// OP费用录入填写详情
  5715. /// </summary>
  5716. /// <param name="dto"></param>
  5717. /// <returns></returns>
  5718. [HttpPost]
  5719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5720. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5721. {
  5722. try
  5723. {
  5724. #region 参数校验
  5725. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5726. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5727. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5728. #endregion
  5729. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5730. if (groupData.Code != 0)
  5731. {
  5732. return Ok(JsonView(false, groupData.Msg));
  5733. }
  5734. //自动审核
  5735. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5736. #region 应用推送
  5737. try
  5738. {
  5739. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5740. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5741. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5742. }
  5743. catch (Exception ex)
  5744. {
  5745. }
  5746. #endregion
  5747. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5748. }
  5749. catch (Exception ex)
  5750. {
  5751. return Ok(JsonView(false, ex.Message));
  5752. }
  5753. }
  5754. /// <summary>
  5755. /// 获取三公详细所有城市
  5756. /// </summary>
  5757. /// <returns></returns>
  5758. [HttpGet]
  5759. public IActionResult OpCarCityResult()
  5760. {
  5761. var jw = JsonView(false);
  5762. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5763. {
  5764. x.Id,
  5765. x.Country,
  5766. x.City,
  5767. }).ToList();
  5768. if (data.Count > 0)
  5769. {
  5770. jw = JsonView(true, "获取成功!", data);
  5771. }
  5772. else
  5773. {
  5774. jw.Msg = "城市数据为空!";
  5775. jw.Data = new string[0];
  5776. }
  5777. return Ok(jw);
  5778. }
  5779. /// <summary>
  5780. /// 导出地接费用明细
  5781. /// </summary>
  5782. /// <param name="dto"></param>
  5783. /// <returns></returns>
  5784. [HttpPost]
  5785. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5786. {
  5787. var jw = JsonView(false);
  5788. if (dto.Diid < 1)
  5789. {
  5790. jw.Msg = "请输入正确的diid!";
  5791. return Ok(jw);
  5792. }
  5793. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5794. if (group == null)
  5795. {
  5796. jw.Msg = "未找到团组信息!";
  5797. return Ok(jw);
  5798. }
  5799. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5800. if (localGuideArr.Count == 0)
  5801. {
  5802. jw.Msg = "该团组暂无地接信息!";
  5803. return Ok(jw);
  5804. }
  5805. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5806. var overspendSoure = new Dictionary<int, int>
  5807. {
  5808. { 91, 982 }, //车
  5809. { 92 , 1059} ,//导游
  5810. { 994 , 1073}, //翻译
  5811. { 988 , 1074 }, //早餐
  5812. { 93 , 1075 }, //午餐
  5813. { 989 , 1076 }, //晚餐
  5814. };
  5815. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5816. foreach (var groupArr in localGroup)
  5817. {
  5818. var keyValue = groupArr.Key;
  5819. if (int.TryParse(keyValue, out int cityid))
  5820. {
  5821. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5822. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5823. }
  5824. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5825. foreach (var item in groupArr)
  5826. {
  5827. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5828. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5829. new Grp_CarTouristGuideGroundReservationsContentExtend
  5830. {
  5831. Count = a.Count,
  5832. CreateTime = a.CreateTime,
  5833. CreateUserId = a.CreateUserId,
  5834. CTGGRId = a.CTGGRId,
  5835. Currency = a.Currency,
  5836. DatePrice = a.DatePrice,
  5837. DeleteTime = a.DeleteTime,
  5838. DeleteUserId = a.DeleteUserId,
  5839. DiId = a.DiId,
  5840. Id = a.Id,
  5841. IsDel = a.IsDel,
  5842. Price = a.Price,
  5843. PriceContent = a.PriceContent,
  5844. Remark = a.Remark,
  5845. SId = a.SId,
  5846. SidName = b.Name,
  5847. Units = a.Units,
  5848. }
  5849. ).ToList();
  5850. if (content.Count > 0)
  5851. {
  5852. contentArr.Add(content);
  5853. }
  5854. }
  5855. //open excel
  5856. //set excel
  5857. //save excel
  5858. try
  5859. {
  5860. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5861. IWorkbook workbook;
  5862. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5863. {
  5864. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5865. }
  5866. else
  5867. {
  5868. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5869. }
  5870. ISheet sheet = workbook.GetSheetAt(0);
  5871. var rowStartIndex = 2;
  5872. var clounmCount = 10;
  5873. var initStyleRow = sheet.GetRow(2);
  5874. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5875. //var overspendArrDetail =
  5876. var existsId = new List<CarCompare>();
  5877. var lastElem = arr.Last();
  5878. var thisSid = -1;
  5879. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5880. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5881. {
  5882. Name = "未知币种!",
  5883. Remark = "未知币种!",
  5884. };
  5885. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5886. Action cloneRowFn = () =>
  5887. {
  5888. rowStartIndex++;
  5889. var cloneRow = sheet.CreateRow(rowStartIndex);
  5890. // 复制样式
  5891. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5892. {
  5893. ICell sourceCell = initStyleRow.GetCell(i);
  5894. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5895. // 确保单元格存在样式
  5896. if (sourceCell.CellStyle != null)
  5897. {
  5898. targetCell.CellStyle = sourceCell.CellStyle;
  5899. }
  5900. }
  5901. };
  5902. var mergeRow = () =>
  5903. {
  5904. for (int i = 2; i < sheet.LastRowNum; i++)
  5905. {
  5906. var row = sheet.GetRow(i);
  5907. var cellFirst = row.GetCell(0);
  5908. var thisIndex = i + 1;
  5909. while (thisIndex < sheet.LastRowNum)
  5910. {
  5911. var nextRow = sheet.GetRow(thisIndex);
  5912. var nextCellFirst = nextRow.GetCell(0);
  5913. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5914. {
  5915. thisIndex++;
  5916. }
  5917. else
  5918. {
  5919. break;
  5920. }
  5921. }
  5922. thisIndex--;
  5923. if (thisIndex != i)
  5924. {
  5925. //合并row
  5926. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5927. i, // 起始行索引(0-based)
  5928. thisIndex, // 结束行索引(0-based)
  5929. 0, // 起始列索引(0-based)
  5930. 0 // 结束列索引(0-based)
  5931. );
  5932. sheet.AddMergedRegion(cellRangeAddress);
  5933. i = thisIndex;
  5934. }
  5935. }
  5936. };
  5937. var chaoshiNumber = 0;
  5938. var totalNumber = 0.00M;
  5939. string lastStr = "";
  5940. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5941. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5942. {
  5943. b.IsAuditGM,
  5944. x.Id,
  5945. x.Area,
  5946. b.PayPercentage,
  5947. b.PayMoney,
  5948. }).ToList();
  5949. string yesPayment = "", noPayment = "";
  5950. foreach (var item in queryCarArrByCityAndDiid)
  5951. {
  5952. if (item.IsAuditGM == 1)
  5953. {
  5954. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5955. }
  5956. else
  5957. {
  5958. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5959. }
  5960. }
  5961. lastStr = yesPayment + noPayment;
  5962. foreach (var item in arr)
  5963. {
  5964. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5965. {
  5966. if (thisSid != item.SId)
  5967. {
  5968. if (thisSid == -1)
  5969. {
  5970. thisSid = item.SId;
  5971. }
  5972. else
  5973. {
  5974. //合并小计行
  5975. //创建合并区域的实例
  5976. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5977. rowStartIndex, // 起始行索引(0-based)
  5978. rowStartIndex, // 结束行索引(0-based)
  5979. 0, // 起始列索引(0-based)
  5980. 3 // 结束列索引(0-based)
  5981. );
  5982. sheet.AddMergedRegion(cellRangeAddress);
  5983. var CellStyle = workbook.CreateCellStyle();
  5984. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5985. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5986. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5987. for (int i = 0; i <= clounmCount; i++)
  5988. {
  5989. if (i > 6)
  5990. {
  5991. var CellStyle1 = workbook.CreateCellStyle();
  5992. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5993. IFont Font = workbook.CreateFont(); // 创建字体
  5994. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5995. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5996. CellStyle1.SetFont(Font);
  5997. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5998. }
  5999. else
  6000. {
  6001. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6002. }
  6003. }
  6004. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6005. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6006. //超时合计
  6007. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6008. //超时数
  6009. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6010. //超时合计费用
  6011. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6012. thisSid = item.SId;
  6013. cloneRowFn();
  6014. chaoshiNumber = 0;
  6015. totalNumber = 0;
  6016. }
  6017. }
  6018. IRow row = sheet.GetRow(rowStartIndex);
  6019. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6020. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6021. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6022. if (isOpenOverspendSoure)
  6023. {
  6024. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6025. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6026. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6027. }
  6028. for (int i = 0; i <= clounmCount; i++)
  6029. {
  6030. var cell = row.GetCell(i);
  6031. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6032. if (cell == null)
  6033. {
  6034. cell = row.CreateCell(i);
  6035. }
  6036. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6037. fontRed.CloneStyleFrom(cell.CellStyle);
  6038. IFont Font = workbook.CreateFont(); // 创建字体
  6039. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6040. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6041. fontRed.SetFont(Font);
  6042. byte[] rgb = new byte[3] { 255, 242, 204 };
  6043. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6044. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6045. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6046. if (workbook is XSSFWorkbook)
  6047. {
  6048. BackgroundColor255_242_204.FillForegroundColor = 0;
  6049. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6050. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6051. }
  6052. else
  6053. {
  6054. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6055. }
  6056. if (i == 1 || i > 6)
  6057. {
  6058. if (i > 6)
  6059. {
  6060. fontRed.FillForegroundColor = 0;
  6061. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6062. fontRed.FillPattern = FillPattern.SolidForeground;
  6063. }
  6064. cell.CellStyle = fontRed;
  6065. }
  6066. if (i > 2 && i < 7)
  6067. {
  6068. cell.CellStyle = BackgroundColor255_242_204;
  6069. }
  6070. cell.SetCellValue(setCellValue); //写入单元格
  6071. }
  6072. if (overspendSoure.ContainsKey(thisSid))
  6073. {
  6074. var overspendId = overspendSoure[thisSid];
  6075. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6076. }
  6077. cloneRowFn();
  6078. existsId.Add(new CarCompare
  6079. {
  6080. DataPrice = item.DatePrice.ObjToDate(),
  6081. Sid = item.SId
  6082. });
  6083. }
  6084. if (item.Equals(lastElem))
  6085. {
  6086. //合并小计行
  6087. //创建合并区域的实例
  6088. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6089. rowStartIndex, // 起始行索引(0-based)
  6090. rowStartIndex, // 结束行索引(0-based)
  6091. 0, // 起始列索引(0-based)
  6092. 3 // 结束列索引(0-based)
  6093. );
  6094. sheet.AddMergedRegion(cellRangeAddress);
  6095. var CellStyle = workbook.CreateCellStyle();
  6096. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6097. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6098. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6099. for (int i = 0; i <= clounmCount; i++)
  6100. {
  6101. if (i > 6)
  6102. {
  6103. var CellStyle1 = workbook.CreateCellStyle();
  6104. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6105. IFont Font = workbook.CreateFont(); // 创建字体
  6106. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6107. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6108. CellStyle1.SetFont(Font);
  6109. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6110. }
  6111. else
  6112. {
  6113. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6114. }
  6115. }
  6116. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6117. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6118. //超时合计
  6119. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6120. //超时数
  6121. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6122. //超时合计费用
  6123. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6124. cloneRowFn();
  6125. // 创建合并区域的实例
  6126. cellRangeAddress = new CellRangeAddress(
  6127. rowStartIndex, // 起始行索引(0-based)
  6128. rowStartIndex, // 结束行索引(0-based)
  6129. 0, // 起始列索引(0-based)
  6130. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6131. );
  6132. // 添加合并区域
  6133. sheet.AddMergedRegion(cellRangeAddress);
  6134. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6135. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6136. }
  6137. }
  6138. mergeRow();
  6139. // 保存修改后的Excel文件到新文件
  6140. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6141. // new FileStream(newFilePath, FileMode.CreateNew)
  6142. using (var stream = new MemoryStream())
  6143. {
  6144. workbook.Write(stream, true);
  6145. stream.Flush();
  6146. stream.Seek(0, SeekOrigin.Begin);
  6147. MemoryStream memoryStream = new MemoryStream();
  6148. stream.CopyTo(memoryStream);
  6149. memoryStream.Seek(0, SeekOrigin.Begin);
  6150. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6151. }
  6152. workbook.Close();
  6153. workbook.Dispose();
  6154. }
  6155. catch (Exception ex)
  6156. {
  6157. jw.Msg = "出现异常!" + ex.Message;
  6158. return Ok(jw);
  6159. }
  6160. }
  6161. if (Zips.Count > 0)
  6162. {
  6163. IOOperatorHelper io = new IOOperatorHelper();
  6164. var byts = io.ConvertZipStream(Zips);
  6165. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6166. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6167. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6168. }
  6169. else
  6170. {
  6171. jw.Msg = "暂无生成文件!";
  6172. }
  6173. return Ok(jw);
  6174. }
  6175. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6176. {
  6177. string outStr = string.Empty;
  6178. switch (i)
  6179. {
  6180. case 0:
  6181. outStr = arr[0].SidName;
  6182. break;
  6183. case 1:
  6184. outStr = arr[0].DataPriceStr;
  6185. break;
  6186. case 2:
  6187. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6188. break;
  6189. case 4:
  6190. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6191. break;
  6192. case 7:
  6193. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6194. {
  6195. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6196. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6197. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6198. }
  6199. break;
  6200. case 8:
  6201. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6202. {
  6203. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6204. }
  6205. break;
  6206. case 9:
  6207. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6208. {
  6209. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6210. }
  6211. break;
  6212. case 10:
  6213. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6214. {
  6215. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6216. }
  6217. break;
  6218. }
  6219. return outStr;
  6220. }
  6221. #region OP行程单
  6222. /// <summary>
  6223. /// OP行程单初始化
  6224. /// </summary>
  6225. /// <param name="dto"></param>
  6226. /// <returns></returns>
  6227. [HttpPost]
  6228. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6229. {
  6230. var jw = JsonView(false);
  6231. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6232. var group = groupList.First();
  6233. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6234. if (group == null)
  6235. {
  6236. jw.Msg = "暂无团组!";
  6237. return Ok(jw);
  6238. }
  6239. group = groupList.Find(x => x.Id == diid);
  6240. if (group == null)
  6241. {
  6242. jw.Msg = "请输入正确的团组ID!";
  6243. return Ok(jw);
  6244. }
  6245. string city = string.Empty;
  6246. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6247. if (blackCode.Count > 0)
  6248. {
  6249. var black = blackCode.First();
  6250. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6251. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6252. if (blackSp.Length > 0)
  6253. {
  6254. try
  6255. {
  6256. var cityArrCode = new List<string>(20);
  6257. foreach (var item in blackSp)
  6258. {
  6259. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6260. var IndexSelect = itemSp[2];
  6261. var cityArrCodeLength = cityArrCode.Count - 1;
  6262. var startCity = IndexSelect.Substring(0, 3);
  6263. if (cityArrCodeLength > 0)
  6264. {
  6265. var arrEndCity = cityArrCode[cityArrCodeLength];
  6266. if (arrEndCity != startCity)
  6267. {
  6268. cityArrCode.Add(startCity.ToUpper());
  6269. }
  6270. }
  6271. else
  6272. {
  6273. cityArrCode.Add(startCity.ToUpper());
  6274. }
  6275. var endCity = IndexSelect.Substring(3, 3);
  6276. cityArrCode.Add(endCity.ToUpper());
  6277. }
  6278. var cityThree = string.Empty;
  6279. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6280. cityThree = cityThree.TrimEnd(',');
  6281. if (string.IsNullOrWhiteSpace(cityThree))
  6282. {
  6283. throw new
  6284. Exception("error");
  6285. }
  6286. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6287. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6288. foreach (var item in cityArrCode)
  6289. {
  6290. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6291. if (find != null)
  6292. {
  6293. city += find.City + "/";
  6294. }
  6295. else
  6296. {
  6297. city += item + "三字码未收入/";
  6298. }
  6299. }
  6300. city = city.TrimEnd('/');
  6301. }
  6302. catch (Exception e)
  6303. {
  6304. city = "黑屏代码格式不正确!";
  6305. }
  6306. }
  6307. }
  6308. else
  6309. {
  6310. city = "未录入黑屏代码";
  6311. }
  6312. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6313. {
  6314. Date = x.Date,
  6315. Days = x.Days,
  6316. Diffgroup = x.Diffgroup,
  6317. Diid = x.Diid,
  6318. Traffic_First = x.Traffic_First,
  6319. Traffic_Second = x.Traffic_Second,
  6320. Trip = x.Trip,
  6321. WeekDay = x.WeekDay,
  6322. Id = x.Id
  6323. }).ToList();
  6324. jw.Data = new
  6325. {
  6326. groupList = groupList.Select(x => new
  6327. {
  6328. x.Id,
  6329. x.TeamName,
  6330. x.TourCode
  6331. }).ToList(),
  6332. groupInfo = new
  6333. {
  6334. group.VisitDays,
  6335. group.TourCode,
  6336. group.VisitPNumber,
  6337. group.TeamName,
  6338. city
  6339. },
  6340. OpTravelList
  6341. };
  6342. jw.Code = 200;
  6343. jw.Msg = "操作成功!";
  6344. return Ok(jw);
  6345. }
  6346. /// <summary>
  6347. /// 删除团组行程单
  6348. /// </summary>
  6349. /// <returns></returns>
  6350. [HttpPost]
  6351. public IActionResult DelTravel(DelOpTravelDto dto)
  6352. {
  6353. var jw = JsonView(false);
  6354. if (dto.UserId <= 0 || dto.Diid <= 0)
  6355. {
  6356. jw.Msg = "请输入正确的参数!";
  6357. return Ok(jw);
  6358. }
  6359. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6360. .SetColumns(x => new Grp_TravelList
  6361. {
  6362. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6363. DeleteUserId = dto.UserId,
  6364. IsDel = 1,
  6365. }).ExecuteCommand();
  6366. jw = JsonView(true);
  6367. return Ok(jw);
  6368. }
  6369. /// <summary>
  6370. /// 行程单保存
  6371. /// </summary>
  6372. /// <returns></returns>
  6373. [HttpPost]
  6374. public IActionResult TravelSave(TravelSaveDto dto)
  6375. {
  6376. var jw = JsonView(false);
  6377. if (dto.Arr.Count > 0)
  6378. {
  6379. try
  6380. {
  6381. _sqlSugar.BeginTran();
  6382. foreach (var item in dto.Arr)
  6383. {
  6384. if (item.Id == 0)
  6385. {
  6386. throw new Exception("请传入正确的Id");
  6387. }
  6388. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6389. .SetColumns(x => new Grp_TravelList
  6390. {
  6391. Trip = item.Trip
  6392. }).ExecuteCommand();
  6393. }
  6394. _sqlSugar.CommitTran();
  6395. jw = JsonView(true);
  6396. }
  6397. catch (Exception ex)
  6398. {
  6399. _sqlSugar.RollbackTran();
  6400. jw.Msg = "程序异常!" + ex.Message;
  6401. }
  6402. }
  6403. else
  6404. {
  6405. jw.Msg = "请传入正确的参数!";
  6406. }
  6407. return Ok(jw);
  6408. }
  6409. /// <summary>
  6410. /// 导出行程单
  6411. /// </summary>
  6412. /// <param name="dto"></param>
  6413. /// <returns></returns>
  6414. [HttpPost]
  6415. public IActionResult ExportTravel(ExportTravelDto dto)
  6416. {
  6417. var jw = JsonView(false);
  6418. jw.Data = "";
  6419. int diid = 0;
  6420. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6421. if (Find == null)
  6422. {
  6423. jw.Msg = "请选择正确的团组!";
  6424. return Ok(jw);
  6425. }
  6426. else
  6427. {
  6428. diid = Find.Id;
  6429. }
  6430. //数据源
  6431. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6432. DataTable dtBlack = null;
  6433. try
  6434. {
  6435. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6436. }
  6437. catch (Exception)
  6438. {
  6439. jw.Msg = "机票黑屏代码有误!";
  6440. return Ok(jw);
  6441. }
  6442. string CityStr = string.Empty;
  6443. if (dtBlack.Rows.Count == 0)
  6444. {
  6445. jw.Msg = "机票黑屏代码有误!";
  6446. return Ok(jw);
  6447. }
  6448. else
  6449. {
  6450. foreach (DataRow row in dtBlack.Rows)
  6451. {
  6452. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6453. {
  6454. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6455. return Ok(jw);
  6456. }
  6457. }
  6458. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6459. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6460. }
  6461. //创建数据源Table
  6462. DataTable dtSource = new DataTable();
  6463. dtSource.Columns.Add("Days", typeof(string));
  6464. dtSource.Columns.Add("Date", typeof(string));
  6465. dtSource.Columns.Add("Week", typeof(string));
  6466. dtSource.Columns.Add("Traffic", typeof(string));
  6467. dtSource.Columns.Add("Trip", typeof(string));
  6468. //获取数据,放到datatable
  6469. foreach (var item in _travelList)
  6470. {
  6471. DataRow dr = dtSource.NewRow();
  6472. dr["Days"] = item.Days;
  6473. dr["Date"] = item.Date;
  6474. dr["Week"] = item.WeekDay;
  6475. dr["Traffic"] = item.Traffic_First
  6476. + "\r\n"
  6477. + item.Traffic_Second;
  6478. dr["Trip"] = item.Trip;
  6479. dtSource.Rows.Add(dr);
  6480. }
  6481. Dictionary<string, string> dic = new Dictionary<string, string>();
  6482. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6483. dic.Add("City", CityStr);
  6484. dic.Add("Days", Find.VisitDays.ToString());
  6485. dic.Add("DeleCode", Find.TourCode);
  6486. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6487. //模板路径
  6488. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6489. //载入模板
  6490. Document doc = null;
  6491. DocumentBuilder builder = null;
  6492. try
  6493. {
  6494. //载入模板
  6495. doc = new Document(tempPath);
  6496. builder = new DocumentBuilder(doc);
  6497. }
  6498. catch (Exception)
  6499. {
  6500. jw.Msg = "模板位置不存在!";
  6501. return Ok(jw);
  6502. }
  6503. foreach (var key in dic.Keys)
  6504. {
  6505. Bookmark bookmark = doc.Range.Bookmarks[key];
  6506. if (bookmark != null)
  6507. {
  6508. builder.MoveToBookmark(key);
  6509. builder.Write(dic[key]);
  6510. }
  6511. }
  6512. //获取word里所有表格
  6513. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6514. //获取所填表格的序数
  6515. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6516. try
  6517. {
  6518. //循环赋值
  6519. for (int i = 0; i < dtSource.Rows.Count; i++)
  6520. {
  6521. builder.MoveToCell(0, i + 1, 0, 0);
  6522. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6523. builder.MoveToCell(0, i + 1, 1, 0);
  6524. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6525. builder.MoveToCell(0, i + 1, 2, 0);
  6526. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6527. var trip = dtSource.Rows[i]["Trip"].ToString();
  6528. builder.MoveToCell(0, i + 1, 3, 0);
  6529. builder.Write(trip);
  6530. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6531. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6532. // 获取特定索引的段落
  6533. Paragraph paragraph = (Paragraph)paragraphs[0];
  6534. Run run = paragraph.Runs[0];
  6535. Aspose.Words.Font font = run.Font;
  6536. font.Name = "黑体";
  6537. //设置双休红色
  6538. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6539. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6540. paragraph = (Paragraph)paragraphs[1];
  6541. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6542. {
  6543. run = paragraph.Runs[0];
  6544. font = run.Font;
  6545. font.Color = Color.Red;
  6546. }
  6547. }
  6548. }
  6549. catch (Exception ex)
  6550. {
  6551. }
  6552. //删除多余行
  6553. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6554. {
  6555. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6556. }
  6557. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6558. if (!Directory.Exists(savePath))
  6559. {
  6560. try
  6561. {
  6562. Directory.CreateDirectory(savePath);
  6563. }
  6564. catch
  6565. {
  6566. }
  6567. }
  6568. string path = savePath + Find.TeamName + "出访日程";
  6569. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6570. try
  6571. {
  6572. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6573. string postfix = ".docx";
  6574. if (dto.IsPDF == 1)
  6575. {
  6576. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6577. postfix = ".pdf";
  6578. }
  6579. doc.Save(path + postfix, saveFormat);
  6580. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6581. }
  6582. catch (Exception)
  6583. {
  6584. jw = JsonView(false);
  6585. }
  6586. return Ok(jw);
  6587. }
  6588. /// <summary>
  6589. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6590. /// </summary>
  6591. /// <param name="num"></param>
  6592. /// <returns></returns>
  6593. string GetNum(string num)
  6594. {
  6595. string str = "";
  6596. switch (num)
  6597. {
  6598. case "1":
  6599. str = "一";
  6600. break;
  6601. case "2":
  6602. str = "二";
  6603. break;
  6604. case "3":
  6605. str = "三";
  6606. break;
  6607. case "4":
  6608. str = "四";
  6609. break;
  6610. case "5":
  6611. str = "五";
  6612. break;
  6613. case "6":
  6614. str = "六";
  6615. break;
  6616. case "7":
  6617. str = "七";
  6618. break;
  6619. case "8":
  6620. str = "八";
  6621. break;
  6622. case "9":
  6623. str = "九";
  6624. break;
  6625. case "10":
  6626. str = "十";
  6627. break;
  6628. case "11":
  6629. str = "十一";
  6630. break;
  6631. case "12":
  6632. str = "十二";
  6633. break;
  6634. case "一":
  6635. str = "1";
  6636. break;
  6637. case "二":
  6638. str = "2";
  6639. break;
  6640. case "三":
  6641. str = "3";
  6642. break;
  6643. case "四":
  6644. str = "4";
  6645. break;
  6646. case "五":
  6647. str = "5";
  6648. break;
  6649. case "六":
  6650. str = "6";
  6651. break;
  6652. case "七":
  6653. str = "7";
  6654. break;
  6655. case "八":
  6656. str = "8";
  6657. break;
  6658. case "九":
  6659. str = "9";
  6660. break;
  6661. case "十":
  6662. str = "10";
  6663. break;
  6664. case "十一":
  6665. str = "11";
  6666. break;
  6667. case "十二":
  6668. str = "12";
  6669. break;
  6670. }
  6671. return str;
  6672. }
  6673. #endregion
  6674. #endregion
  6675. #region 团组成本
  6676. /// <summary>
  6677. /// 团组成本数据初始化
  6678. /// </summary>
  6679. /// <param name="dto"></param>
  6680. /// <returns></returns>
  6681. [HttpPost]
  6682. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6683. {
  6684. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6685. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6686. WHEN COUNT(*) >= 0 THEN 'True'
  6687. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6688. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6689. ").ToList(); //团组列表
  6690. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6691. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6692. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6693. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6694. if (groupinfoValue != null)
  6695. {
  6696. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6697. var spArr = new string[1] { countryArr };
  6698. if (countryArr.Contains("|"))
  6699. {
  6700. spArr = countryArr.Split("|");
  6701. }
  6702. else if (countryArr.Contains("、"))
  6703. {
  6704. spArr = countryArr.Split("、");
  6705. }
  6706. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6707. {
  6708. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6709. if (dbQueryCountry != null)
  6710. {
  6711. visaCountryInfoArr.Add(dbQueryCountry);
  6712. }
  6713. }
  6714. }
  6715. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6716. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6717. var create = _GroupCostRepository.
  6718. CreateGroupCostByBlackCode(dto.Diid);
  6719. if (groupCost.Count == 0 && create.Code == 0)
  6720. {
  6721. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6722. }
  6723. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6724. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6725. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6726. groupCostMap = groupCostMap.Select(x =>
  6727. {
  6728. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6729. {
  6730. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6731. }
  6732. return x;
  6733. }).ToList();
  6734. //GroupCostParameter.Add(new
  6735. // Grp_GroupCostParameter());
  6736. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6737. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6738. return Ok(JsonView(new
  6739. {
  6740. groupList,
  6741. groupInfo,
  6742. groupChecks,
  6743. groupCost = groupCostMap,
  6744. hotelNumber,
  6745. GroupCostParameter = GroupCostParameterMap,
  6746. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6747. {
  6748. x.VisaCountry,
  6749. x.VisaPrice,
  6750. x.Id,
  6751. }).ToList(),
  6752. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6753. blackCodeIsTrue = create.Code == 0 ? true : false,
  6754. hotelIsTrue = hotelIsTrue,
  6755. }));
  6756. }
  6757. /// <summary>
  6758. /// 团组成本信息保存
  6759. /// </summary>
  6760. /// <param name="dto"></param>
  6761. /// <returns></returns>
  6762. [HttpPost]
  6763. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6764. {
  6765. if (dto.Diid <= 0 || dto.Userid <= 0)
  6766. {
  6767. return Ok(JsonView(false));
  6768. }
  6769. JsonView jw = null;
  6770. bool isTrue = false;
  6771. #region 复制团组成本
  6772. //if (dto.Diid == 2581)
  6773. //{
  6774. // dto.Diid = 2599;
  6775. // dto.CheckBoxs.ForEach(x =>
  6776. // {
  6777. // x.Diid = 2599;
  6778. // });
  6779. // dto.GroupCosts.ForEach(x =>
  6780. // {
  6781. // x.Diid = 2599;
  6782. // });
  6783. // dto.CostTypeHotelNumbers.ForEach(x =>
  6784. // {
  6785. // x.Diid = 2599;
  6786. // });
  6787. // dto.GroupCostParameters.ForEach(x =>
  6788. // {
  6789. // x.DiId = 2599;
  6790. // });
  6791. //}
  6792. #endregion
  6793. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6794. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6795. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6796. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6797. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6798. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6799. try
  6800. {
  6801. _sqlSugar.BeginTran();
  6802. isTrue = await _GroupCostRepository.
  6803. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6804. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6805. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6806. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6807. _sqlSugar.CommitTran();
  6808. jw = JsonView(true, "保存成功!", isTrue);
  6809. }
  6810. catch (Exception)
  6811. {
  6812. _sqlSugar.RollbackTran();
  6813. jw = JsonView(false);
  6814. }
  6815. return Ok(jw);
  6816. }
  6817. /// <summary>
  6818. /// 司兼导数据
  6819. /// </summary>
  6820. /// <param name="dto"></param>
  6821. /// <returns></returns>
  6822. [HttpPost]
  6823. public IActionResult GetCarGuides(CarGuidesDto dto)
  6824. {
  6825. JsonView jw = null;
  6826. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6827. jw = JsonView(true, "获取成功!", Data);
  6828. return Ok(jw);
  6829. }
  6830. /// <summary>
  6831. /// 导游数据
  6832. /// </summary>
  6833. /// <param name="dto"></param>
  6834. /// <returns></returns>
  6835. [HttpPost]
  6836. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6837. {
  6838. JsonView jw = null;
  6839. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6840. // 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
  6841. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6842. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6843. jw = JsonView(true, "获取成功!", Data);
  6844. return Ok(jw);
  6845. }
  6846. /// <summary>
  6847. /// 成本车数据
  6848. /// </summary>
  6849. /// <param name="dto"></param>
  6850. /// <returns></returns>
  6851. [HttpPost]
  6852. public IActionResult GetCarInfo(CarGuidesDto dto)
  6853. {
  6854. JsonView jw = null;
  6855. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6856. jw = JsonView(true, "获取成功!", Data);
  6857. return Ok(jw);
  6858. }
  6859. /// <summary>
  6860. /// 景点数据
  6861. /// </summary>
  6862. /// <param name="dto"></param>
  6863. /// <returns></returns>
  6864. [HttpPost]
  6865. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6866. {
  6867. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6868. return Ok(JsonView(true, "获取成功!", Data));
  6869. }
  6870. /// <summary>
  6871. /// 成本通知
  6872. /// </summary>
  6873. /// <param name="dto"></param>
  6874. /// <returns></returns>
  6875. [HttpPost]
  6876. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6877. {
  6878. if (dto.Diid < 0)
  6879. {
  6880. return Ok(JsonView(false));
  6881. }
  6882. JsonView jw = null;
  6883. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6884. if (GroupCostParameter != null)
  6885. {
  6886. int IsShare = 0;
  6887. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6888. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6889. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6890. string msg = string.Empty;
  6891. if (isTrue)
  6892. {
  6893. if (IsShare == 0)
  6894. {
  6895. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6896. }
  6897. else
  6898. {
  6899. #region 企微通知对应岗位用户
  6900. try
  6901. {
  6902. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6903. }
  6904. catch (Exception ex)
  6905. {
  6906. }
  6907. #endregion
  6908. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6909. }
  6910. jw = JsonView(isTrue, msg, new { IsShare });
  6911. }
  6912. else
  6913. {
  6914. msg = "修改失败!";
  6915. jw = JsonView(isTrue, msg);
  6916. }
  6917. }
  6918. else
  6919. {
  6920. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6921. }
  6922. return Ok(jw);
  6923. }
  6924. /// <summary>
  6925. /// 导出报价单
  6926. /// </summary>
  6927. /// <param name="dto"></param>
  6928. /// <returns></returns>
  6929. [HttpPost]
  6930. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6931. {
  6932. if (dto.Diid == 0)
  6933. {
  6934. return Ok(JsonView(false, "请传递团组id"));
  6935. }
  6936. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6937. if (deleInfo.Code != 0)
  6938. {
  6939. return Ok(JsonView(false, "团组信息查询失败!"));
  6940. }
  6941. var di = deleInfo.Data as DelegationInfoWebView;
  6942. if (di != null)
  6943. {
  6944. di.TeamName = di.TeamName.Replace("|","、");
  6945. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  6946. //文件名
  6947. string strFileName = di.TeamName + "-收款账单.doc";
  6948. //获取模板
  6949. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6950. //载入模板
  6951. Document doc = new Document(tmppath);
  6952. decimal TotalPrice = 0.00M;
  6953. string itemStr = string.Empty;
  6954. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6955. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6956. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6957. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6958. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6959. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6960. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6961. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6962. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6963. foreach (var cost in groupCostType)
  6964. {
  6965. var List = cost.ToList();
  6966. if (cost.Key == "A")
  6967. {
  6968. foreach (var ListItem in List)
  6969. {
  6970. if (ListItem.number > 0)
  6971. {
  6972. if (ListItem.code.Contains("TBR"))
  6973. {
  6974. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6975. }
  6976. else
  6977. {
  6978. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6979. }
  6980. TotalPrice += (ListItem.number * ListItem.price);
  6981. }
  6982. }
  6983. }
  6984. else
  6985. {
  6986. itemStr = itemStr.Insert(0, "A段\r\n");
  6987. itemStr += "B段\r\n";
  6988. foreach (var ListItem in List)
  6989. {
  6990. if (ListItem.number > 0)
  6991. {
  6992. if (ListItem.code.Contains("TBR"))
  6993. {
  6994. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6995. }
  6996. else
  6997. {
  6998. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6999. }
  7000. TotalPrice += (ListItem.number * ListItem.price);
  7001. }
  7002. }
  7003. }
  7004. }
  7005. #region 替换Word模板书签内容
  7006. Dictionary<string, string> marks = new Dictionary<string, string>();
  7007. marks.Add("To", di.ClientUnit);//付款方
  7008. marks.Add("ToTel", di.TellPhone);//付款方电话
  7009. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7010. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7011. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7012. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7013. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7014. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7015. marks.Add("PayItemContent", itemStr);//详细信息
  7016. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7017. #endregion
  7018. ////注
  7019. //if (doc.Range.Bookmarks["Attention"] != null)
  7020. //{
  7021. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7022. // mark.Text = frList[0].Attention;
  7023. //}
  7024. foreach (var item in marks.Keys)
  7025. {
  7026. if (doc.Range.Bookmarks[item] != null)
  7027. {
  7028. Bookmark mark = doc.Range.Bookmarks[item];
  7029. mark.Text = marks[item];
  7030. }
  7031. }
  7032. byte[] bytes = null;
  7033. using (MemoryStream stream = new MemoryStream())
  7034. {
  7035. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7036. bytes = stream.ToArray();
  7037. }
  7038. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7039. return Ok(JsonView(true, "", new
  7040. {
  7041. Data = bytes,
  7042. strFileName,
  7043. }));
  7044. }
  7045. else
  7046. {
  7047. return Ok(JsonView(false, "团组信息不存在!"));
  7048. }
  7049. }
  7050. /// <summary>
  7051. /// 导出团组成本
  7052. /// </summary>
  7053. /// <param name="dto"></param>
  7054. /// <returns></returns>
  7055. [HttpPost]
  7056. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7057. {
  7058. var jw = JsonView(false);
  7059. if (dto.Diid == 0)
  7060. {
  7061. return Ok(JsonView(false, "请传递团组id"));
  7062. }
  7063. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7064. if (deleInfo.Code != 0)
  7065. {
  7066. return Ok(JsonView(false, "团组信息查询失败!"));
  7067. }
  7068. var di = deleInfo.Data as DelegationInfoWebView;
  7069. if (di == null)
  7070. {
  7071. return Ok(JsonView(false, "团组信息查询失败!"));
  7072. }
  7073. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7074. WorkbookDesigner designer = new WorkbookDesigner();
  7075. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7076. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7077. for (int i = 0; i < List_GC.Count; i++)
  7078. {
  7079. GroupCost_Excel gc = new GroupCost_Excel();
  7080. gc.Id = List_GC[i].Id;
  7081. gc.Diid = List_GC[i].Diid.ToString();
  7082. gc.DAY = List_GC[i].DAY;
  7083. string week = "";
  7084. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7085. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7086. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7087. gc.ITIN = List_GC[i].ITIN;
  7088. gc.CarType = List_GC[i].CarType;
  7089. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7090. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7091. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7092. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7093. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7094. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7095. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7096. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7097. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7098. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7099. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7100. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7101. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7102. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7103. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7104. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7105. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7106. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7107. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7108. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7109. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7110. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7111. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7112. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7113. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7114. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7115. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7116. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7117. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7118. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7119. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7120. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7121. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7122. List_GC1.Add(gc);
  7123. }
  7124. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7125. dt.TableName = "TB";
  7126. //报表标题等不用dt的值
  7127. designer.SetDataSource("TeamName", dto.title.TeamName);
  7128. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7129. designer.SetDataSource("Tax", dto.title.Tax);
  7130. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7131. designer.SetDataSource("Currency", dto.title.Currency);
  7132. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7133. designer.SetDataSource("Rate", dto.title.Rate);
  7134. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7135. var Aparams = hotels.Find(x => x.Type == "Default");
  7136. if (Aparams == null)
  7137. {
  7138. return Ok(jw);
  7139. }
  7140. //酒店数量
  7141. var txtSGRNumber = Aparams.SGR.ToString();
  7142. var txtTBRNumber = Aparams.TBR.ToString();
  7143. var txtJSESNumber = Aparams.JSES.ToString();
  7144. var txtSUITENumbe = Aparams.SUITE.ToString();
  7145. if (dto.costType == "B")
  7146. {
  7147. Aparams = hotels.Find(x => x.Type == "A");
  7148. var Bparams = hotels.Find(x => x.Type == "B");
  7149. if (Aparams == null || Bparams == null)
  7150. {
  7151. return Ok(jw);
  7152. }
  7153. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7154. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7155. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7156. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7157. }
  7158. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7159. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7160. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7161. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7162. var ws = designer.Workbook.Worksheets[0];
  7163. int Row = List_GC.Count;
  7164. int startIndex = 11;
  7165. int HideRows = 0;
  7166. List<int> hideRowsList = new List<int>();
  7167. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7168. #region A段left数据
  7169. var left = dto.leftInfo.Find(x => x.Type == "A");
  7170. if (left == null)
  7171. {
  7172. return Ok(jw);
  7173. }
  7174. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7175. if (leftBindData != null)
  7176. {
  7177. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7178. designer.SetDataSource("VisaRS", leftBindData.rs);
  7179. designer.SetDataSource("VisaXS", leftBindData.xs);
  7180. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7181. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7182. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7183. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7184. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7185. }
  7186. else
  7187. {
  7188. hideRowsList.Add(Row + startIndex + HideRows);
  7189. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7190. }
  7191. HideRows += 2;
  7192. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7193. if (leftBindData != null)
  7194. {
  7195. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7196. designer.SetDataSource("BXRS", leftBindData.rs);
  7197. designer.SetDataSource("BXXS", leftBindData.xs);
  7198. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7199. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7200. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7201. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7202. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7203. }
  7204. else
  7205. {
  7206. hideRowsList.Add(Row + startIndex + HideRows);
  7207. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7208. }
  7209. HideRows += 2;
  7210. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7211. if (leftBindData != null)
  7212. {
  7213. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7214. designer.SetDataSource("HSRS", leftBindData.rs);
  7215. designer.SetDataSource("HSXS", leftBindData.xs);
  7216. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7217. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7218. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7219. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7220. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7221. }
  7222. else
  7223. {
  7224. hideRowsList.Add(Row + startIndex + HideRows);
  7225. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7226. }
  7227. HideRows += 2;
  7228. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7229. if (leftBindData != null)
  7230. {
  7231. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7232. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7233. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7234. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7235. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7236. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7237. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7238. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7239. }
  7240. else
  7241. {
  7242. hideRowsList.Add(Row + startIndex + HideRows);
  7243. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7244. }
  7245. HideRows += 2;
  7246. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7247. if (leftBindData != null)
  7248. {
  7249. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7250. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7251. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7252. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7253. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7254. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7255. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7256. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7257. }
  7258. else
  7259. {
  7260. hideRowsList.Add(Row + startIndex + HideRows);
  7261. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7262. }
  7263. HideRows += 2;
  7264. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7265. if (leftBindData != null)
  7266. {
  7267. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7268. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7269. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7270. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7271. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7272. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7273. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7274. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7275. }
  7276. else
  7277. {
  7278. hideRowsList.Add(Row + startIndex + HideRows);
  7279. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7280. }
  7281. HideRows += 2;
  7282. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7283. if (leftBindData != null)
  7284. {
  7285. ////TBR
  7286. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7287. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7288. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7289. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7290. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7291. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7292. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7293. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7294. }
  7295. else
  7296. {
  7297. hideRowsList.Add(Row + startIndex + HideRows);
  7298. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7299. }
  7300. HideRows += 2;
  7301. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7302. if (leftBindData != null)
  7303. {
  7304. ////SGR
  7305. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7306. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7307. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7308. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7309. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7310. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7311. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7312. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7313. }
  7314. else
  7315. {
  7316. hideRowsList.Add(Row + startIndex + HideRows);
  7317. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7318. }
  7319. HideRows += 2;
  7320. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7321. if (leftBindData != null)
  7322. {
  7323. ////JS/ES
  7324. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7325. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7326. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7327. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7328. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7329. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7330. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7331. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7332. }
  7333. else
  7334. {
  7335. hideRowsList.Add(Row + startIndex + HideRows);
  7336. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7337. }
  7338. HideRows += 2;
  7339. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7340. if (leftBindData != null)
  7341. {
  7342. ////SUITE
  7343. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7344. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7345. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7346. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7347. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7348. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7349. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7350. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7351. }
  7352. else
  7353. {
  7354. hideRowsList.Add(Row + startIndex + HideRows);
  7355. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7356. }
  7357. HideRows += 2;
  7358. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7359. if (leftBindData != null)
  7360. {
  7361. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7362. designer.SetDataSource("DJRS", leftBindData.rs);
  7363. designer.SetDataSource("DJXS", leftBindData.xs);
  7364. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7365. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7366. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7367. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7368. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7369. }
  7370. else
  7371. {
  7372. hideRowsList.Add(Row + startIndex + HideRows);
  7373. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7374. }
  7375. HideRows += 2;
  7376. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7377. if (leftBindData != null)
  7378. {
  7379. designer.SetDataSource("HCPCB", leftBindData.cb);
  7380. designer.SetDataSource("HCPRS", leftBindData.rs);
  7381. designer.SetDataSource("HCPXS", leftBindData.xs);
  7382. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7383. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7384. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7385. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7386. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7387. }
  7388. else
  7389. {
  7390. hideRowsList.Add(Row + startIndex + HideRows);
  7391. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7392. }
  7393. HideRows += 2;
  7394. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7395. if (leftBindData != null)
  7396. {
  7397. designer.SetDataSource("CPCB", leftBindData.cb);
  7398. designer.SetDataSource("CPRS", leftBindData.rs);
  7399. designer.SetDataSource("CPXS", leftBindData.xs);
  7400. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7401. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7402. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7403. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7404. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7405. }
  7406. else
  7407. {
  7408. hideRowsList.Add(Row + startIndex + HideRows);
  7409. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7410. }
  7411. HideRows += 2;
  7412. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7413. if (leftBindData != null)
  7414. {
  7415. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7416. designer.SetDataSource("GWRS", leftBindData.rs);
  7417. designer.SetDataSource("GWXS", leftBindData.xs);
  7418. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7419. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7420. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7421. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7422. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7423. }
  7424. else
  7425. {
  7426. hideRowsList.Add(Row + startIndex + HideRows);
  7427. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7428. }
  7429. HideRows += 2;
  7430. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7431. if (leftBindData != null)
  7432. {
  7433. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7434. designer.SetDataSource("LYJRS", leftBindData.rs);
  7435. designer.SetDataSource("LYJXS", leftBindData.xs);
  7436. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7437. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7438. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7439. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7440. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7441. }
  7442. else
  7443. {
  7444. hideRowsList.Add(Row + startIndex + HideRows);
  7445. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7446. }
  7447. #endregion
  7448. #region A段Right信息
  7449. var right = dto.rightInfo.Find(x => x.Type == "A");
  7450. if (right == null)
  7451. {
  7452. return Ok(jw);
  7453. }
  7454. HideRows += 4;
  7455. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7456. if (rightBindData != null)
  7457. {
  7458. //经济舱 + 双人间 TBR
  7459. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7460. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7461. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7462. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7463. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7464. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7465. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7466. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7467. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7468. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7469. }
  7470. else
  7471. {
  7472. hideRowsList.Add(Row + startIndex + HideRows);
  7473. }
  7474. HideRows += 2;
  7475. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7476. if (rightBindData != null)
  7477. {
  7478. //经济舱 + 单人间 SGR
  7479. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7480. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7481. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7482. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7483. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7484. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7485. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7486. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7487. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7488. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7489. }
  7490. else
  7491. {
  7492. hideRowsList.Add(Row + startIndex + HideRows);
  7493. }
  7494. HideRows += 2;
  7495. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7496. if (rightBindData != null)
  7497. {
  7498. //公务舱 + 单人间 SGR
  7499. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7500. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7501. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7502. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7503. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7504. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7505. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7506. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7507. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7508. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7509. }
  7510. else
  7511. {
  7512. hideRowsList.Add(Row + startIndex + HideRows);
  7513. }
  7514. HideRows += 2;
  7515. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7516. if (rightBindData != null)
  7517. {
  7518. //公务舱 + 小套房 JSES
  7519. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7520. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7521. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7522. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7523. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7524. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7525. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7526. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7527. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7528. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7529. }
  7530. else
  7531. {
  7532. hideRowsList.Add(Row + startIndex + HideRows);
  7533. }
  7534. HideRows += 2;
  7535. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7536. if (rightBindData != null)
  7537. {
  7538. //公务舱 + 小套房 JSES
  7539. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7540. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7541. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7542. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7543. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7544. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7545. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7546. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7547. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7548. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7549. }
  7550. else
  7551. {
  7552. hideRowsList.Add(Row + startIndex + HideRows);
  7553. }
  7554. HideRows += 2;
  7555. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7556. if (rightBindData != null)
  7557. {
  7558. //经济舱 + 大套房
  7559. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7560. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7561. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7562. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7563. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7564. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7565. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7566. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7567. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7568. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7569. }
  7570. else
  7571. {
  7572. hideRowsList.Add(Row + startIndex + HideRows);
  7573. }
  7574. HideRows += 2;
  7575. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7576. if (rightBindData != null)
  7577. {
  7578. //头等舱 + 小套房 JSES
  7579. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7580. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7581. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7582. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7583. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7584. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7585. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7586. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7587. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7588. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7589. }
  7590. else
  7591. {
  7592. hideRowsList.Add(Row + startIndex + HideRows);
  7593. }
  7594. HideRows += 2;
  7595. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7596. if (rightBindData != null)
  7597. {
  7598. //头等舱 + 大套房
  7599. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7600. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7601. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7602. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7603. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7604. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7605. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7606. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7607. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7608. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7609. }
  7610. else
  7611. {
  7612. hideRowsList.Add(Row + startIndex + HideRows);
  7613. }
  7614. #endregion
  7615. #region B段标题清空
  7616. designer.SetDataSource("CostBDRCB", "");
  7617. designer.SetDataSource("CostBRS", "");
  7618. designer.SetDataSource("CostBXS", "");
  7619. designer.SetDataSource("CostBZCB", "");
  7620. designer.SetDataSource("CostBDRBJ", "");
  7621. designer.SetDataSource("CostBZBJ", "");
  7622. designer.SetDataSource("CostBDRLR", "");
  7623. designer.SetDataSource("CostBZLR", "");
  7624. designer.SetDataSource("CostBDRCBOM", "");
  7625. designer.SetDataSource("CostBRSOM", "");
  7626. designer.SetDataSource("CostBZCBOM", "");
  7627. designer.SetDataSource("CostBDRBJOM", "");
  7628. designer.SetDataSource("CostBZBJOM", "");
  7629. designer.SetDataSource("CostBDRLROM", "");
  7630. designer.SetDataSource("CostBZLROM", "");
  7631. #endregion
  7632. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7633. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7634. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7635. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7636. designer.SetDataSource("DJName", "地接(CNY)");
  7637. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7638. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7639. designer.SetDataSource("GWName", "公务(CNY)");
  7640. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7641. designer.SetDataSource("LYJName", "零用金(CNY)");
  7642. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7643. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7644. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7645. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7646. designer.SetDataSource("BXName", "保险(CNY)");
  7647. designer.SetDataSource("VisaName", "签证(CNY)");
  7648. #region B段基本数据
  7649. if (dto.costType == "B")
  7650. {
  7651. left = dto.leftInfo.Find(x => x.Type == "B");
  7652. if (left == null)
  7653. {
  7654. return Ok(jw);
  7655. }
  7656. #region B段left数据
  7657. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7658. if (leftBindData != null)
  7659. {
  7660. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7661. designer.SetDataSource("BHSRS", leftBindData.rs);
  7662. designer.SetDataSource("BHSXS", leftBindData.xs);
  7663. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7664. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7665. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7666. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7667. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7668. }
  7669. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7670. if (leftBindData != null)
  7671. {
  7672. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7673. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7674. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7675. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7676. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7677. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7678. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7679. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7680. }
  7681. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7682. if (leftBindData != null)
  7683. {
  7684. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7685. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7686. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7687. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7688. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7689. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7690. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7691. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7692. }
  7693. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7694. if (leftBindData != null)
  7695. {
  7696. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  7697. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  7698. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  7699. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7700. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7701. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7702. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7703. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7704. }
  7705. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7706. if (leftBindData != null)
  7707. {
  7708. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7709. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7710. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7711. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7712. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7713. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7714. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7715. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7716. }
  7717. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7718. if (leftBindData != null)
  7719. {
  7720. designer.SetDataSource("BCPCB", leftBindData.cb);
  7721. designer.SetDataSource("BCPRS", leftBindData.rs);
  7722. designer.SetDataSource("BCPXS", leftBindData.xs);
  7723. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7724. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7725. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7726. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7727. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7728. }
  7729. //TBR
  7730. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7731. if (leftBindData != null)
  7732. {
  7733. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7734. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7735. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7736. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7737. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7738. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7739. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7740. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7741. }
  7742. //SGR
  7743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7744. if (leftBindData != null)
  7745. {
  7746. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7747. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7748. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7749. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7750. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7751. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7752. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7753. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7754. }
  7755. //JS/ES
  7756. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7757. if (leftBindData != null)
  7758. {
  7759. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7760. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7761. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7762. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7763. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7764. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7765. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7766. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7767. }
  7768. //SUITE
  7769. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7770. if (leftBindData != null)
  7771. {
  7772. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7773. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7774. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7775. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7776. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7777. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7778. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7779. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7780. }
  7781. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7782. if (leftBindData != null)
  7783. {
  7784. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7785. designer.SetDataSource("BDJRS", leftBindData.rs);
  7786. designer.SetDataSource("BDJXS", leftBindData.xs);
  7787. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7788. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7789. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7790. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7791. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7792. }
  7793. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7794. if (leftBindData != null)
  7795. {
  7796. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7797. designer.SetDataSource("BGWRS", leftBindData.rs);
  7798. designer.SetDataSource("BGWXS", leftBindData.xs);
  7799. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7800. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7801. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7802. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7803. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7804. }
  7805. #region 优化方案
  7806. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7807. //excelBind.Add("零用金", new {
  7808. //cb="",
  7809. //rs="",
  7810. //xs ="",
  7811. //zcb = "",
  7812. //});
  7813. #endregion
  7814. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7815. if (leftBindData != null)
  7816. {
  7817. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7818. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7819. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7820. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7821. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7822. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7823. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7824. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7825. }
  7826. #endregion
  7827. #region B段Right信息
  7828. right = dto.rightInfo.Find(x => x.Type == "B");
  7829. if (right == null)
  7830. {
  7831. return Ok(jw);
  7832. }
  7833. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7834. if (rightBindData != null)
  7835. {
  7836. //经济舱 + 双人间 TBR
  7837. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7838. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7839. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7840. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7841. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7842. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7843. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7844. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7845. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7846. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7847. }
  7848. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7849. if (rightBindData != null)
  7850. {
  7851. //经济舱 + 单人间 SGR
  7852. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7853. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7854. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7855. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7856. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7857. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7858. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7859. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7860. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7861. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7862. }
  7863. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7864. if (rightBindData != null)
  7865. {
  7866. //公务舱 + 单人间 SGR
  7867. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7868. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7869. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7870. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7871. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7872. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7873. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7874. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7875. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7876. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7877. }
  7878. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7879. if (rightBindData != null)
  7880. {
  7881. //公务舱 + 小套房 JSES
  7882. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7883. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7884. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7885. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7886. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7887. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7888. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7889. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7890. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7891. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7892. }
  7893. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7894. if (rightBindData != null)
  7895. {
  7896. //公务舱 + 小套房 JSES
  7897. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7898. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7899. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7900. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7901. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7902. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7903. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7904. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7905. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7906. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7907. }
  7908. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7909. if (rightBindData != null)
  7910. {
  7911. //经济舱 + 大套房
  7912. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7913. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7914. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7915. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7916. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7917. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7918. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7919. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7920. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7921. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7922. }
  7923. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7924. if (rightBindData != null)
  7925. {
  7926. //头等舱 + 小套房 JSES
  7927. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  7928. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  7929. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7930. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  7931. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7932. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7933. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7934. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7935. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7936. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7937. }
  7938. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7939. if (rightBindData != null)
  7940. {
  7941. //头等舱 + 大套房
  7942. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  7943. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  7944. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7945. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  7946. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7947. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7948. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7949. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7950. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7951. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7952. }
  7953. #endregion
  7954. #region 标题
  7955. designer.SetDataSource("CostBDRCB", "单人成本");
  7956. designer.SetDataSource("CostBRS", "人数");
  7957. designer.SetDataSource("CostBXS", "系数");
  7958. designer.SetDataSource("CostBZCB", "总成本");
  7959. designer.SetDataSource("CostBDRBJ", "单人报价");
  7960. designer.SetDataSource("CostBZBJ", "总报价");
  7961. designer.SetDataSource("CostBDRLR", "单人利润");
  7962. designer.SetDataSource("CostBZLR", "总利润");
  7963. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7964. designer.SetDataSource("CostBRSOM", "人数");
  7965. designer.SetDataSource("CostBZCBOM", "总成本");
  7966. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7967. designer.SetDataSource("CostBZBJOM", "总报价");
  7968. designer.SetDataSource("CostBDRLROM", "单人利润");
  7969. designer.SetDataSource("CostBZLROM", "总利润");
  7970. #endregion
  7971. }
  7972. #endregion
  7973. designer.SetDataSource("TzZCB2", TzZCB2);
  7974. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7975. designer.SetDataSource("TzZLR2", TzZLR2);
  7976. string[] dataSourceKeys = new string[]
  7977. {
  7978. "VF",
  7979. "TGS",
  7980. "TGOF",
  7981. "TGM",
  7982. "TGA",
  7983. "TGTF",
  7984. "TGEF",
  7985. "CFM",
  7986. "CFOF",
  7987. "B",
  7988. "L",
  7989. "D",
  7990. "TBR",
  7991. "SGR",
  7992. "JSES",
  7993. "Suite",
  7994. "TV",
  7995. "1L",
  7996. "IF",
  7997. "EF",
  7998. "BRF",
  7999. "TE",
  8000. "TGT",
  8001. "DRVT",
  8002. "PC",
  8003. "TLF",
  8004. "ECT"
  8005. };
  8006. foreach (var item in dataSourceKeys)
  8007. {
  8008. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8009. if (find != null)
  8010. {
  8011. designer.SetDataSource(item, find.text);
  8012. }
  8013. else
  8014. {
  8015. designer.SetDataSource(item, 0);
  8016. }
  8017. }
  8018. designer.SetDataSource(dt);
  8019. //根据数据源处理生成报表内容
  8020. designer.Process();
  8021. designer.Workbook.Worksheets[0].Name = "清单";
  8022. Worksheet sheet = designer.Workbook.Worksheets[0];
  8023. foreach (var Rowindex in hideRowsList)
  8024. {
  8025. ws.Cells.HideRows(Rowindex, 2);
  8026. }
  8027. byte[] bytes = null;
  8028. string strFileName = di.TeamName + "-团组-成本.xls";
  8029. using (MemoryStream stream = new MemoryStream())
  8030. {
  8031. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8032. bytes = stream.ToArray();
  8033. }
  8034. return Ok(JsonView(true, "", new
  8035. {
  8036. Data = bytes,
  8037. strFileName,
  8038. }));
  8039. }
  8040. /// <summary>
  8041. /// 导出客户报表
  8042. /// </summary>
  8043. /// <returns></returns>
  8044. [HttpPost]
  8045. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8046. {
  8047. var jw = JsonView(false);
  8048. if (dto.Diid == 0)
  8049. {
  8050. return Ok(JsonView(false, "请传递团组id"));
  8051. }
  8052. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8053. if (deleInfo.Code != 0)
  8054. {
  8055. return Ok(JsonView(false, "团组信息查询失败!"));
  8056. }
  8057. var di = deleInfo.Data as DelegationInfoWebView;
  8058. if (di == null)
  8059. {
  8060. return Ok(JsonView(false, "团组信息查询失败!"));
  8061. }
  8062. //文件名
  8063. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8064. //获取模板
  8065. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8066. //载入模板
  8067. Document doc = new Document(tmppath);
  8068. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8069. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8070. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8071. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8072. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8073. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8074. if (AParameter == null)
  8075. {
  8076. return Ok(JsonView(false, "系数不存在!"));
  8077. }
  8078. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8079. , TzAirDesc, TzZCost;
  8080. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8081. = TzAirDesc = TzZCost = string.Empty;
  8082. TzNumber = AParameter.CostTypenumber.ToString();
  8083. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8084. CarGuides1 = dto.CarGuides1;
  8085. Meal = dto.Meal;
  8086. SubsidizedMeals = dto.SubsidizedMeals;
  8087. NightRepair = dto.NightRepair;
  8088. AttractionsTickets = dto.AttractionsTickets;
  8089. MiscellaneousFees = dto.MiscellaneousFees;
  8090. ATip = dto.ATip;
  8091. TzHotelDesc = "";
  8092. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8093. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8094. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8095. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8096. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8097. TzAirDesc = "";
  8098. TzZCost = dto.TzZCost;
  8099. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8100. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8101. var index = 1;
  8102. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8103. foreach (var item in TzHotelDescArr)
  8104. {
  8105. if (AinfoArr != null)
  8106. {
  8107. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8108. if (Ainfo != null)
  8109. {
  8110. if (int.Parse(Ainfo.rs) <= 0)
  8111. {
  8112. continue;
  8113. }
  8114. var hotelText = string.Empty;
  8115. switch (item)
  8116. {
  8117. case "SGR":
  8118. hotelText = "单人间";
  8119. break;
  8120. case "JSES":
  8121. hotelText = "小套房";
  8122. break;
  8123. case "SUITE":
  8124. hotelText = "套房";
  8125. break;
  8126. case "TBR":
  8127. hotelText = "双人间";
  8128. break;
  8129. }
  8130. if (item != "TBR")
  8131. {
  8132. 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";
  8133. }
  8134. else
  8135. {
  8136. 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";
  8137. }
  8138. index++;
  8139. }
  8140. }
  8141. }
  8142. index = 1;
  8143. foreach (var item in TzAirDescArr)
  8144. {
  8145. if (AinfoArr != null)
  8146. {
  8147. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8148. if (Ainfo != null)
  8149. {
  8150. if (int.Parse(Ainfo.rs) <= 0)
  8151. {
  8152. continue;
  8153. }
  8154. 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";
  8155. index++;
  8156. }
  8157. }
  8158. }
  8159. if (dto.costType == "B")
  8160. {
  8161. if (BParameter == null)
  8162. {
  8163. return Ok(JsonView(false, "B段系数不存在!"));
  8164. }
  8165. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8166. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8167. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8168. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8169. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8170. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8171. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8172. foreach (var item in TzHotelDescArr)
  8173. {
  8174. if (AinfoArr != null)
  8175. {
  8176. TzHotelDesc += "B段信息 \r\n";
  8177. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8178. if (Ainfo != null)
  8179. {
  8180. if (int.Parse(Ainfo.rs) <= 0)
  8181. {
  8182. continue;
  8183. }
  8184. var hotelText = string.Empty;
  8185. switch (item)
  8186. {
  8187. case "SGR":
  8188. hotelText = "单人间";
  8189. break;
  8190. case "JSES":
  8191. hotelText = "小套房";
  8192. break;
  8193. case "SUITE":
  8194. hotelText = "套房";
  8195. break;
  8196. case "TBR":
  8197. hotelText = "双人间";
  8198. break;
  8199. }
  8200. if (item != "TBR")
  8201. {
  8202. 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";
  8203. }
  8204. else
  8205. {
  8206. 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";
  8207. }
  8208. index++;
  8209. }
  8210. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8211. }
  8212. }
  8213. index = 1;
  8214. foreach (var item in TzAirDescArr)
  8215. {
  8216. if (AinfoArr != null)
  8217. {
  8218. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8219. if (Ainfo != null)
  8220. {
  8221. if (int.Parse(Ainfo.rs) <= 0)
  8222. {
  8223. continue;
  8224. }
  8225. 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";
  8226. index++;
  8227. }
  8228. }
  8229. }
  8230. }
  8231. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8232. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8233. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8234. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8235. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8236. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8237. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8238. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8239. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8240. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8241. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8242. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8243. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8244. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8245. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8246. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8247. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8248. DickeyValue.Add("TzZCost", TzZCost);
  8249. foreach (var key in DickeyValue.Keys)
  8250. {
  8251. if (doc.Range.Bookmarks[key] != null)
  8252. {
  8253. Bookmark mark = doc.Range.Bookmarks[key];
  8254. mark.Text = DickeyValue[key];
  8255. }
  8256. }
  8257. byte[] bytes = null;
  8258. string strFileName = di.TeamName + "-客户报价.doc";
  8259. using (MemoryStream stream = new MemoryStream())
  8260. {
  8261. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8262. bytes = stream.ToArray();
  8263. }
  8264. return Ok(JsonView(true, "", new
  8265. {
  8266. Data = bytes,
  8267. strFileName,
  8268. }));
  8269. }
  8270. /// <summary>
  8271. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8272. /// </summary>
  8273. /// <param name="dto"></param>
  8274. /// <returns></returns>
  8275. [HttpPost]
  8276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8277. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8278. {
  8279. try
  8280. {
  8281. #region 参数验证
  8282. if (dto.DiId < 0)
  8283. {
  8284. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8285. }
  8286. List<int> cTableIds = new List<int>() {
  8287. 76 ,//酒店预订
  8288. 77 ,//行程
  8289. 79 ,//车/导游地接
  8290. 80 ,//签证
  8291. 81 ,//邀请/公务活
  8292. 82 ,//团组客户保险
  8293. 85 ,//机票预订
  8294. 98 ,//其他款项
  8295. 285 ,//收款退还
  8296. 751 ,//酒店早餐
  8297. 1015 // 超支费用
  8298. };
  8299. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8300. {
  8301. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8302. }
  8303. #endregion
  8304. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8305. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8306. if (_GroupCostParameters.Count <= 0)
  8307. {
  8308. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8309. }
  8310. if (_GroupCostParameters[0].IsShare == 0)
  8311. {
  8312. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8313. }
  8314. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8315. //处理date为空问题
  8316. if (_GroupCosts.Count > 0)
  8317. {
  8318. for (int i = 0; i < _GroupCosts.Count; i++)
  8319. {
  8320. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8321. {
  8322. if (i > 0)
  8323. {
  8324. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8325. }
  8326. }
  8327. }
  8328. }
  8329. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8330. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8331. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8332. string currCode = "";
  8333. #region currCode 验证
  8334. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8335. if (isInt)
  8336. {
  8337. var currData = currDatas.Find(it => it.Id == intCurrency);
  8338. if (currData != null)
  8339. {
  8340. currCode = currData.Name;
  8341. }
  8342. }
  8343. else
  8344. {
  8345. currCode = _GroupCostParameters[0].Currency.Trim();
  8346. }
  8347. #endregion
  8348. //op,酒店单段模式存储
  8349. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8350. {
  8351. CurrencyCode = currCode,
  8352. Rate = _GroupCostParameters[0].Rate,
  8353. CostType = _GroupCostParameters[0].CostType,
  8354. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8355. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8356. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8357. };
  8358. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8359. if (_GroupCostParameters.Count == 2)
  8360. {
  8361. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8362. }
  8363. foreach (var item in _GroupCostParameters)
  8364. {
  8365. decimal _rate = 1;
  8366. decimal _rate1 = item.Rate;
  8367. decimal _scale = 1;
  8368. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8369. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8370. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8371. //if (userInfo != null)
  8372. //{
  8373. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8374. // {
  8375. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8376. // {
  8377. // _scale = 1.00M;
  8378. // }
  8379. // }
  8380. //}
  8381. #endregion
  8382. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8383. {
  8384. CurrencyCode = currCode,
  8385. Rate = _rate1,
  8386. CostType = item.CostType,
  8387. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8388. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8389. CostTypeNumber = item.CostTypenumber
  8390. };
  8391. if (_GroupCostParameters.Count > 1)
  8392. {
  8393. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8394. }
  8395. else
  8396. {
  8397. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8398. }
  8399. if (dto.CTable == 79)//
  8400. {
  8401. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8402. modulePromptInfo.TotalCost = item.DJCB;
  8403. }
  8404. List<string> costTypes = new List<string>() { "A", "B" };
  8405. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8406. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8407. if (_GroupCostsDuplicates.Count() == 1)
  8408. {
  8409. _GroupCostsTypeData = _GroupCosts;
  8410. }
  8411. else
  8412. {
  8413. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8414. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8415. }
  8416. /*
  8417. * 76 酒店预订
  8418. * 77 行程
  8419. * 79 车/导游地接
  8420. * 80 签证
  8421. * 81 邀请/公务活动
  8422. * 82 团组客户保险
  8423. * 85 机票预订
  8424. * 98 其他款项
  8425. * 285 收款退还
  8426. * 751 酒店早餐
  8427. * 1015 超支费用
  8428. */
  8429. switch (dto.CTable)
  8430. {
  8431. case 76: // 酒店预订
  8432. _ModuleSubPromptInfo.AddRange(
  8433. _GroupCostsTypeData.Select(it => new
  8434. {
  8435. it.DAY,
  8436. it.Date,
  8437. it.ACCON,
  8438. it.ITIN,
  8439. it.SGR,
  8440. it.TBR,
  8441. it.JS_ES,
  8442. it.Suite
  8443. })
  8444. );
  8445. break;
  8446. case 79: // 车/导游地接
  8447. _ModuleSubPromptInfo.AddRange(
  8448. _GroupCostsTypeData.Select(it => new
  8449. {
  8450. Date = it.Date, //日期
  8451. CarFee = it.CarCost * _rate * _scale, //车费用
  8452. CarType = it.CarType, //车型
  8453. DriverFee = it.CFS * _rate * _scale, //司机工资
  8454. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8455. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8456. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8457. GuideFee = it.TGS * _rate * _scale, //导游费用
  8458. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8459. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8460. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8461. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8462. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8463. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8464. Breakfast = it.B * _rate * _scale, //早餐费
  8465. Lunch = it.L * _rate * _scale, //午餐费
  8466. Dinner = it.D * _rate * _scale, //晚餐费
  8467. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8468. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8469. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8470. TicketFee = it.EF * _rate * _scale, //门票费
  8471. TicketRemark = it.EFR, //门票费描述
  8472. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8473. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8474. SpentCash = it.PC * _rate * _scale, //零用金
  8475. LeadersFee = it.TLF * _rate * _scale, //领队费
  8476. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8477. })
  8478. );
  8479. break;
  8480. case 85: // 机票
  8481. List<dynamic> datas = new List<dynamic>();
  8482. datas.Add(
  8483. new
  8484. {
  8485. AirType = "经济舱",
  8486. AirNum = item.JJCRS,
  8487. AirDRCB = item.JJCCB,
  8488. AirZCB = (item.JJCRS * item.JJCCB)
  8489. }
  8490. );
  8491. datas.Add(
  8492. new
  8493. {
  8494. AirType = "公务舱",
  8495. AirNum = item.GWCRS,
  8496. AirDRCB = item.GWCCB,
  8497. AirZCB = (item.GWCRS * item.GWCCB)
  8498. }
  8499. );
  8500. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8501. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8502. modulePromptInfo.Data = new
  8503. {
  8504. airFeeData = datas,
  8505. airInitData = initDatas
  8506. };
  8507. _ModulePromptInfos.Add(modulePromptInfo);
  8508. break;
  8509. default:
  8510. break;
  8511. }
  8512. }
  8513. if (dto.CTable != 85)
  8514. {
  8515. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8516. _ModulePromptInfos.Add(_ModulePromptInfo);
  8517. }
  8518. _view.ModulePromptInfos = _ModulePromptInfos;
  8519. return Ok(JsonView(true, "操作成功!", _view));
  8520. }
  8521. catch (Exception ex)
  8522. {
  8523. return Ok(JsonView(false, ex.Message));
  8524. }
  8525. }
  8526. /// <summary>
  8527. /// 根据黑屏代码重新生成行程
  8528. /// </summary>
  8529. /// <param name="dto"></param>
  8530. /// <returns></returns>
  8531. [HttpPost]
  8532. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8533. {
  8534. var jw = JsonView(false);
  8535. var Create = _GroupCostRepository.
  8536. CreateGroupCostByBlackCode(dto.Diid);
  8537. jw.Msg = Create.Msg;
  8538. if (Create.Code == 0)
  8539. {
  8540. jw.Code = 200;
  8541. jw.Data = new
  8542. {
  8543. groupCost = Create.Data,
  8544. blackCodeIsTrue = true
  8545. };
  8546. }
  8547. else
  8548. {
  8549. jw.Code = 400;
  8550. jw.Data = new
  8551. {
  8552. groupCost = Create.Data,
  8553. blackCodeIsTrue = false,
  8554. };
  8555. }
  8556. return Ok(jw);
  8557. }
  8558. /// <summary>
  8559. /// 成本获取OP历史车费用
  8560. /// </summary>
  8561. /// <param name="dto"></param>
  8562. /// <returns></returns>
  8563. [HttpPost]
  8564. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8565. {
  8566. var jw = JsonView(false);
  8567. try
  8568. {
  8569. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8570. //获取现有所有车的数据
  8571. if (!dto.Param.IsNullOrWhiteSpace())
  8572. {
  8573. string sql = $@"
  8574. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8575. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8576. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8577. 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
  8578. AND gctggr.ServiceEndTime is not NULL
  8579. ORDER by gctggrc.id DESC
  8580. ";
  8581. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8582. var numeberResult = await Task.Run(() =>
  8583. {
  8584. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8585. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8586. return numberArr;
  8587. });
  8588. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8589. foreach (var item in numeberResult)
  8590. {
  8591. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8592. {
  8593. Country = "数据异常!",
  8594. City = string.Empty,
  8595. };
  8596. item.Area = find.Country + " " + find.City;
  8597. }
  8598. dbResult.AddRange(numeberResult);
  8599. if (dto.Param.Contains("、"))
  8600. {
  8601. var sp = dto.Param.Split("、");
  8602. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8603. .Where(x =>
  8604. {
  8605. return System.Array.Exists(sp, e =>
  8606. {
  8607. bool where = false;
  8608. if (x.Area != null)
  8609. {
  8610. where = x.Area.Contains(e);
  8611. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8612. {
  8613. return false;
  8614. }
  8615. }
  8616. if (x.PriceName != null && !where)
  8617. {
  8618. where = x.PriceName.Contains(e);
  8619. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8620. {
  8621. return false;
  8622. }
  8623. }
  8624. return where;
  8625. });
  8626. }).ToList();
  8627. }
  8628. else
  8629. {
  8630. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8631. .Where(x =>
  8632. {
  8633. bool where = false;
  8634. if (x.Area != null)
  8635. {
  8636. where = x.Area.Contains(dto.Param);
  8637. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8638. {
  8639. return false;
  8640. }
  8641. }
  8642. if (x.PriceName != null && !where)
  8643. {
  8644. where = x.PriceName.Contains(dto.Param);
  8645. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8646. {
  8647. return false;
  8648. }
  8649. }
  8650. return where;
  8651. }
  8652. )
  8653. .ToList();
  8654. }
  8655. }
  8656. var view = dbResult.Select(x =>
  8657. {
  8658. decimal dp = 0.00M;
  8659. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8660. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8661. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8662. {
  8663. if (startB && endB)
  8664. {
  8665. var timesp = endD.Subtract(startD);
  8666. if ((timesp.Days + 1) != 0)
  8667. {
  8668. dp = x.Price / (timesp.Days + 1);
  8669. }
  8670. }
  8671. }
  8672. else
  8673. {
  8674. dp = x.Price;
  8675. }
  8676. return new
  8677. {
  8678. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8679. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8680. x.Area,
  8681. x.id,
  8682. price = x.Price.ToString("F2"),
  8683. x.PriceName,
  8684. x.PriceContent,
  8685. x.TeamName,
  8686. x.DatePrice,
  8687. dayPrice = dp.ToString("F2"),
  8688. };
  8689. }).OrderByDescending(x => x.id).ToList();
  8690. jw = JsonView(true, "获取成功!", view);
  8691. }
  8692. catch (Exception e)
  8693. {
  8694. jw = JsonView(false, e.Message);
  8695. }
  8696. return Ok(jw);
  8697. }
  8698. #endregion
  8699. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8700. /// <summary>
  8701. /// 酒店预订
  8702. /// 酒店费用列表 根据团组Id查询
  8703. /// </summary>
  8704. /// <param name="_dto"></param>
  8705. /// <returns></returns>
  8706. [HttpPost]
  8707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8708. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8709. {
  8710. #region 参数验证
  8711. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8712. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8713. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8714. #region 团组操作权限验证 76 酒店预定模块
  8715. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8716. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8717. #endregion
  8718. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8719. #region 页面操作权限验证
  8720. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8721. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8722. #endregion
  8723. #endregion
  8724. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8725. }
  8726. /// <summary>
  8727. /// 酒店预订
  8728. /// 基础数据
  8729. /// </summary>
  8730. /// <param name="_dto"></param>
  8731. /// <returns></returns>
  8732. [HttpPost]
  8733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8734. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8735. {
  8736. #region 参数验证
  8737. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8738. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8739. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8740. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8741. #region 页面操作权限验证
  8742. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8743. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8744. #endregion
  8745. #region 团组操作权限验证 76 酒店预定模块
  8746. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8747. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8748. #endregion
  8749. #endregion
  8750. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8751. }
  8752. /// <summary>
  8753. /// 酒店预订
  8754. /// 创建 入住卷号码
  8755. /// </summary>
  8756. /// <param name="_dto"></param>
  8757. /// <returns></returns>
  8758. [HttpPost]
  8759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8760. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8761. {
  8762. try
  8763. {
  8764. #region 参数验证
  8765. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8766. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8767. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8768. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8769. #region 页面操作权限验证
  8770. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8771. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8772. #endregion
  8773. #region 团组操作权限验证 76 酒店预定模块
  8774. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8775. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8776. #endregion
  8777. #endregion
  8778. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8779. if (data.Code != 0)
  8780. {
  8781. return Ok(JsonView(false, data.Msg));
  8782. }
  8783. return Ok(JsonView(true, data.Msg, data.Data));
  8784. }
  8785. catch (Exception ex)
  8786. {
  8787. return Ok(JsonView(false, ex.Message));
  8788. }
  8789. }
  8790. /// <summary>
  8791. /// 酒店预订
  8792. /// 详情
  8793. /// </summary>
  8794. /// <param name="_dto"></param>
  8795. /// <returns></returns>
  8796. [HttpPost]
  8797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8798. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8799. {
  8800. #region 参数验证
  8801. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8802. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8803. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8804. #region 团组操作权限验证 76 酒店预定模块
  8805. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8806. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8807. #endregion
  8808. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8809. #region 页面操作权限验证
  8810. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8811. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8812. #endregion
  8813. #endregion
  8814. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8815. }
  8816. /// <summary>
  8817. /// 酒店预订
  8818. /// Add Or Edit
  8819. /// </summary>
  8820. /// <param name="_dto"></param>
  8821. /// <returns></returns>
  8822. [HttpPost]
  8823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8824. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8825. {
  8826. #region 参数验证
  8827. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8828. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8829. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8830. #region 团组操作权限验证 76 酒店预定模块
  8831. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8832. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8833. #endregion
  8834. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8835. #region 页面操作权限验证
  8836. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8837. if (_dto.Id == 0) // Add
  8838. {
  8839. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8840. }
  8841. else if (_dto.Id > 1) // Edit
  8842. {
  8843. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8844. }
  8845. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8846. #endregion
  8847. #endregion
  8848. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8849. if (_view.Code != 200)
  8850. {
  8851. return Ok(_view);
  8852. }
  8853. #region 应用推送
  8854. try
  8855. {
  8856. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8857. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8858. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8859. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8860. //自动审核
  8861. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8862. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  8863. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  8864. }
  8865. catch (Exception ex)
  8866. {
  8867. }
  8868. #endregion
  8869. return Ok(_view);
  8870. }
  8871. /// <summary>
  8872. /// 酒店自动审核测试
  8873. /// Add Or Edit
  8874. /// </summary>
  8875. /// <param name="_dto"></param>
  8876. /// <returns></returns>
  8877. [HttpPost]
  8878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8879. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  8880. {
  8881. #region 应用推送
  8882. try
  8883. {
  8884. //自动审核
  8885. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  8886. }
  8887. catch (Exception ex)
  8888. {
  8889. return Ok(JsonView(false, "操作失败"));
  8890. }
  8891. #endregion
  8892. return Ok(JsonView(false,"操作成功"));
  8893. }
  8894. /// <summary>
  8895. /// 酒店预订
  8896. /// Del
  8897. /// </summary>
  8898. /// <param name="_dto"></param>
  8899. /// <returns></returns>
  8900. [HttpPost]
  8901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8902. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8903. {
  8904. #region 参数验证
  8905. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8906. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8907. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8908. #region 团组操作权限验证 76 酒店预定模块
  8909. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8910. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8911. #endregion
  8912. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8913. #region 页面操作权限验证
  8914. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8915. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8916. #endregion
  8917. #endregion
  8918. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8919. }
  8920. /// <summary>
  8921. /// 酒店预订
  8922. /// 生成VOUCHER
  8923. /// 2024.05.06 之前版本
  8924. /// </summary>
  8925. /// <param name="_dto"></param>
  8926. /// <returns></returns>
  8927. [HttpPost]
  8928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8929. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8930. {
  8931. try
  8932. {
  8933. #region 参数验证
  8934. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8935. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8936. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8937. #region 团组操作权限验证 76 酒店预定模块
  8938. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8939. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8940. #endregion
  8941. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8942. #region 页面操作权限验证
  8943. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8944. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8945. #endregion
  8946. #endregion
  8947. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8948. //判断数据是否完整
  8949. if (hr != null)
  8950. {
  8951. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8952. {
  8953. string strFileName = "HotelStatement/";
  8954. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8955. if (dele != null)
  8956. strFileName += dele.TourCode;
  8957. //载入模板
  8958. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8959. Document doc = new Document(sss);
  8960. DocumentBuilder builder = new DocumentBuilder(doc);
  8961. #region 替换Word模板书签内容
  8962. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8963. //入住卷预定号码
  8964. if (doc.Range.Bookmarks["VNO"] != null)
  8965. {
  8966. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8967. mark.Text = hr.CheckNumber;
  8968. }
  8969. //酒店时间
  8970. if (doc.Range.Bookmarks["Date"] != null)
  8971. {
  8972. Bookmark mark = doc.Range.Bookmarks["Date"];
  8973. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8974. }
  8975. //团号
  8976. if (doc.Range.Bookmarks["TNo"] != null)
  8977. {
  8978. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8979. mark.Text = dele.TourCode;
  8980. }
  8981. //预定号码
  8982. if (doc.Range.Bookmarks["BookingId"] != null)
  8983. {
  8984. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8985. mark.Text = hr.ReservationsNo;
  8986. }
  8987. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8988. {
  8989. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8990. mark.Text = hr.DetermineNo;
  8991. }
  8992. //酒店城市
  8993. if (doc.Range.Bookmarks["City"] != null)
  8994. {
  8995. Bookmark mark = doc.Range.Bookmarks["City"];
  8996. mark.Text = hr.City;
  8997. }
  8998. //酒店名称
  8999. if (doc.Range.Bookmarks["HName"] != null)
  9000. {
  9001. Bookmark mark = doc.Range.Bookmarks["HName"];
  9002. mark.Text = hr.HotelName;
  9003. }
  9004. //酒店地址
  9005. if (doc.Range.Bookmarks["Address"] != null)
  9006. {
  9007. Bookmark mark = doc.Range.Bookmarks["Address"];
  9008. mark.Text = hr.HotelAddress;
  9009. }
  9010. //酒店电话
  9011. if (doc.Range.Bookmarks["Tel"] != null)
  9012. {
  9013. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9014. mark.Text = hr.HotelTel;
  9015. }
  9016. //酒店传真
  9017. if (doc.Range.Bookmarks["Fax"] != null)
  9018. {
  9019. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9020. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9021. {
  9022. mark.Text = hr.HotelFax;
  9023. }
  9024. }
  9025. //入住时间
  9026. if (doc.Range.Bookmarks["CIn"] != null)
  9027. {
  9028. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9029. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9030. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9031. }
  9032. //退房时间
  9033. if (doc.Range.Bookmarks["COut"] != null)
  9034. {
  9035. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9036. Bookmark mark = doc.Range.Bookmarks["COut"];
  9037. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9038. }
  9039. //客户名称
  9040. if (doc.Range.Bookmarks["GName"] != null)
  9041. {
  9042. string guestName = "";
  9043. string[] clients = new string[] { };
  9044. if (hr.GuestName.Contains(","))
  9045. {
  9046. clients = hr.GuestName.Split(",");
  9047. }
  9048. else
  9049. {
  9050. clients = new string[] { hr.GuestName };
  9051. }
  9052. List<int> clientIds_int = new List<int>();
  9053. if (clients.Length > 0)
  9054. {
  9055. foreach (var item in clients)
  9056. {
  9057. if (item.IsNumeric())
  9058. {
  9059. clientIds_int.Add(int.Parse(item));
  9060. }
  9061. }
  9062. }
  9063. if (clientIds_int.Count > 0)
  9064. {
  9065. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9066. foreach (var client in _clientDatas)
  9067. {
  9068. //男
  9069. if (client.Sex == 0) guestName += $"Mr.";
  9070. //女
  9071. else if (client.Sex == 1) guestName += $"Ms.";
  9072. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9073. {
  9074. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9075. }
  9076. //guestName += $"{client.Pinyin},";
  9077. }
  9078. if (guestName.Length > 0)
  9079. {
  9080. guestName = guestName.Substring(0, guestName.Length - 1);
  9081. }
  9082. }
  9083. else
  9084. {
  9085. guestName = hr.GuestName;
  9086. }
  9087. Bookmark mark = doc.Range.Bookmarks["GName"];
  9088. mark.Text = guestName;
  9089. }
  9090. //房间介绍
  9091. if (doc.Range.Bookmarks["ROOM"] != null)
  9092. {
  9093. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9094. mark.Text = hr.RoomExplanation;
  9095. }
  9096. //报价描述
  9097. if (doc.Range.Bookmarks["NOTE"] != null)
  9098. {
  9099. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9100. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9101. if (ss != null)
  9102. mark.Text = ss.Name;
  9103. }
  9104. //入住时间
  9105. if (doc.Range.Bookmarks["CheckIn"] != null)
  9106. {
  9107. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9108. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9109. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9110. }
  9111. //退房时间
  9112. if (doc.Range.Bookmarks["CheckOut"] != null)
  9113. {
  9114. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9115. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9116. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9117. }
  9118. //日期
  9119. if (doc.Range.Bookmarks["DT"] != null)
  9120. {
  9121. Bookmark mark = doc.Range.Bookmarks["DT"];
  9122. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9123. }
  9124. //名称
  9125. if (doc.Range.Bookmarks["VName"] != null)
  9126. {
  9127. Bookmark mark = doc.Range.Bookmarks["VName"];
  9128. mark.Text = hr.HotelName;
  9129. }
  9130. //号码
  9131. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9132. {
  9133. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9134. mark.Text = hr.CheckNumber;
  9135. }
  9136. #endregion
  9137. strFileName += "VOUCHER.doc";
  9138. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9139. doc.Save(fileDir);
  9140. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9141. return Ok(JsonView(true, "操作成功!", Url));
  9142. }
  9143. else
  9144. {
  9145. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9146. }
  9147. }
  9148. else
  9149. {
  9150. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9151. }
  9152. }
  9153. catch (Exception ex)
  9154. {
  9155. return Ok(JsonView(false, ex.Message));
  9156. }
  9157. }
  9158. /// <summary>
  9159. /// 酒店预订
  9160. /// 生成VOUCHER
  9161. /// 2024.05.06 之后版本
  9162. /// </summary>
  9163. /// <param name="_dto"></param>
  9164. /// <returns></returns>
  9165. [HttpPost]
  9166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9167. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9168. {
  9169. #region 参数验证
  9170. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9171. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9172. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9173. #region 团组操作权限验证 76 酒店预定模块
  9174. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9175. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9176. #endregion
  9177. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9178. #region 页面操作权限验证
  9179. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9180. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9181. #endregion
  9182. #endregion
  9183. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9184. //判断数据是否完整
  9185. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9186. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9187. string strFileName = "HotelStatement/";
  9188. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9189. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9190. #region 数据处理
  9191. List<int> guestIds = new List<int>();
  9192. int index = 0;
  9193. foreach (var item in hrDtas)
  9194. {
  9195. if (item.GuestName.Contains(","))
  9196. {
  9197. string[] guestIdArr = item.GuestName.Split(',');
  9198. foreach (var guestIdStr in guestIdArr)
  9199. {
  9200. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9201. if (guestBool)
  9202. {
  9203. guestIds.Add(guestId);
  9204. }
  9205. }
  9206. }
  9207. else guestNames += item.GuestName;
  9208. var voucherInfo = new HotelVoucherInfoView()
  9209. {
  9210. HotelName = item.HotelName,
  9211. CheckInDate = item.CheckInDate,
  9212. CheckOutDate = item.CheckOutDate,
  9213. ConfirmationNumber = item.DetermineNo.Trim(),
  9214. RoomType = item.RoomExplanation
  9215. };
  9216. vouchers.Add(voucherInfo);
  9217. }
  9218. if (guestIds.Count > 0)
  9219. {
  9220. guestIds = guestIds.Distinct().ToList();
  9221. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9222. if (guestDatas.Count > 0)
  9223. {
  9224. guestNames = "";
  9225. foreach (var guest in guestDatas)
  9226. {
  9227. string guestName = "";
  9228. if (guest.Sex == 0) guestName += @"MR.";
  9229. else if (guest.Sex == 1) guestName += @"MS.";
  9230. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9231. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9232. guestNames += @$"{guestName.Trim()}、";
  9233. }
  9234. if (guestNames.Length > 0)
  9235. {
  9236. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9237. }
  9238. }
  9239. }
  9240. #endregion
  9241. //载入模板
  9242. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9243. Document doc = new Document(sss);
  9244. DocumentBuilder builder = new DocumentBuilder(doc);
  9245. if (doc.Range.Bookmarks["GuestName"] != null)
  9246. {
  9247. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9248. mark.Text = guestNames;
  9249. }
  9250. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9251. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9252. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9253. for (int i = 1; i <= vouchers.Count; i++)
  9254. {
  9255. HotelVoucherInfoView hviv = vouchers[i - 1];
  9256. builder.MoveToCell(0, i, 0, 0);
  9257. builder.Write(hviv.HotelName);
  9258. builder.MoveToCell(0, i, 1, 0);
  9259. builder.Write(hviv.CheckInDate);
  9260. builder.MoveToCell(0, i, 2, 0);
  9261. builder.Write(hviv.CheckOutDate);
  9262. builder.MoveToCell(0, i, 3, 0);
  9263. builder.Write(hviv.RoomType);
  9264. builder.MoveToCell(0, i, 4, 0);
  9265. builder.Write(hviv.ConfirmationNumber);
  9266. }
  9267. //删除多余行
  9268. int currRowIndex = vouchers.Count + 1;
  9269. int delRows = 21 - currRowIndex;
  9270. if (delRows > 0)
  9271. {
  9272. for (int i = 0; i < delRows; i++)
  9273. {
  9274. table.Rows.RemoveAt(currRowIndex);
  9275. //cultivateRowIndex++;
  9276. }
  9277. }
  9278. strFileName += "VOUCHER.docx";
  9279. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9280. doc.Save(fileDir);
  9281. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9282. return Ok(JsonView(true, "操作成功!", Url));
  9283. }
  9284. /// <summary>
  9285. /// 酒店预订
  9286. /// 生成 预定成本 Excel
  9287. /// </summary>
  9288. /// <param name="_dto"></param>
  9289. /// <returns></returns>
  9290. [HttpPost]
  9291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9292. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9293. {
  9294. #region 参数验证
  9295. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9296. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9297. if (!vadalitorRes.IsValid)
  9298. {
  9299. var errors = new StringBuilder();
  9300. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9301. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9302. }
  9303. #region 团组操作权限验证 76 酒店预定模块
  9304. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9305. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9306. #endregion
  9307. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9308. #region 页面操作权限验证
  9309. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9310. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9311. #endregion
  9312. #endregion
  9313. decimal _rate = 1.00M;
  9314. string _currency = "";
  9315. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9316. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9317. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9318. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9319. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9320. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9321. {
  9322. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9323. }
  9324. _currency = _GroupCostParameter.Currency;
  9325. bool isIntType = int.TryParse(_currency, out int currId);
  9326. if (isIntType)
  9327. {
  9328. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9329. }
  9330. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9331. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9332. if (currInfo == null)
  9333. {
  9334. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9335. }
  9336. if (!_currency.ToUpper().Equals("CNY"))
  9337. {
  9338. _rate = _GroupCostParameter.Rate;
  9339. }
  9340. _rate = currInfo.Rate;
  9341. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9342. string strFileName = "HotelStatement/";
  9343. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9344. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9345. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9346. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9347. #region 数据处理
  9348. foreach (var item in hrDtas)
  9349. {
  9350. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9351. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9352. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9353. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9354. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9355. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  9356. string singleRoomFeeStr = string.Empty,
  9357. doubleRoomFeeStr = string.Empty,
  9358. suiteRoomFeeStr = string.Empty,
  9359. otherRoomFeeStr = string.Empty,
  9360. payMoneyStr = string.Empty,
  9361. cardPriceStr = string.Empty;
  9362. if (roomCurr.Equals(_currency))
  9363. {
  9364. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9365. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9366. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9367. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9368. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9369. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9370. }
  9371. else
  9372. {
  9373. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9374. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9375. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9376. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9377. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9378. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9379. }
  9380. string breakfastPriceStr = string.Empty,
  9381. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9382. governmentRentStr = string.Empty,
  9383. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9384. cityTaxStrStr = string.Empty,
  9385. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9386. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9387. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9388. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9389. int payDId = roomInfo?.PayDId ?? 0;
  9390. pcfds.Add(new HotelReservations_PCFD_View()
  9391. {
  9392. City = item.City,
  9393. HotelName = item.HotelName,
  9394. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9395. // SingleRoomCount = item.SingleRoomCount,
  9396. SingleRoomPrice = singleRoomFeeStr,
  9397. // DoubleRoomCount = item.DoubleRoomCount,
  9398. DoubleRoomPrice = doubleRoomFeeStr,
  9399. //SuiteRoomCount = item.SuiteRoomCount,
  9400. SuiteRoomPrice = suiteRoomFeeStr,
  9401. OtherRoomPrice = otherRoomFeeStr,
  9402. //OtherRoomCount = item.OtherRoomCount,
  9403. BreakfastPrice = breakfastPriceStr,
  9404. GovernmentRent = governmentRentStr,
  9405. CityTax = cityTaxStrStr,
  9406. RoomExplanation = item.RoomExplanation,
  9407. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  9408. PayTime = roomInfo?.ConsumptionDate,
  9409. BankNo = roomInfo?.BankNo,
  9410. PayMoney = payMoneyStr,
  9411. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9412. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  9413. CardPrice = cardPriceStr,
  9414. Remark = ccpInfo.Remark
  9415. });
  9416. }
  9417. #endregion
  9418. //载入模板
  9419. WorkbookDesigner designer = new WorkbookDesigner();
  9420. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9421. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9422. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9423. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9424. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9425. designer.SetDataSource("Opertor", userInfo.CnName);
  9426. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9427. dt.TableName = "ViewMyHotelReservations";
  9428. designer.SetDataSource(dt);
  9429. designer.Process();
  9430. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9431. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9432. designer.Workbook.Save(serverPath);
  9433. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9434. #region 删除指定行
  9435. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9436. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9437. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9438. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9439. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9440. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9441. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9442. cssIndex = dt.Columns["CityTax"].Ordinal,
  9443. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9444. remarkIndex = dt.Columns["Remark"].Ordinal;
  9445. //删除指定列
  9446. foreach (DataRow item in dt.Rows)
  9447. {
  9448. string singleStr = item["SingleRoomPrice"].ToString();
  9449. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9450. if (containsDigitButNotZero1) singleDel = false;
  9451. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9452. string doubleStr = item["DoubleRoomPrice"].ToString();
  9453. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9454. if (containsDigitButNotZero2) doubleDel = false;
  9455. string suiteStr = item["SuiteRoomPrice"].ToString();
  9456. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9457. if (containsDigitButNotZero3) suiteDel = false;
  9458. string otherStr = item["OtherRoomPrice"].ToString();
  9459. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9460. if (containsDigitButNotZero4) otherDel = false;
  9461. string zcStr = item["BreakfastPrice"].ToString();
  9462. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9463. if (containsDigitButNotZero5) zcDel = false;
  9464. string dsStr = item["GovernmentRent"].ToString();
  9465. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9466. if (containsDigitButNotZero6) dsDel = false;
  9467. string cssStr = item["CityTax"].ToString();
  9468. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9469. if (containsDigitButNotZero7) cssDel = false;
  9470. string cpStr = item["ConsumptionPatterns"].ToString();
  9471. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9472. string remarkStr = item["Remark"].ToString();
  9473. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9474. }
  9475. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9476. DeleteColumn(serverPath, cpIndex, cpDel);
  9477. DeleteColumn(serverPath, dsIndex, dsDel);
  9478. DeleteColumn(serverPath, cssIndex, cssDel);
  9479. DeleteColumn(serverPath, zcIndex, zcDel);
  9480. DeleteColumn(serverPath, otherIndex, otherDel);
  9481. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9482. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9483. DeleteColumn(serverPath, singleIndex, singleDel);
  9484. #endregion
  9485. //只保留第一个表格
  9486. DeleteSheet(serverPath);
  9487. return Ok(JsonView(true, "操作成功", url = rst));
  9488. }
  9489. /// <summary>
  9490. /// 删除指定列
  9491. /// </summary>
  9492. /// <param name="file"></param>
  9493. /// <param name="columnIndex"></param>
  9494. /// <param name="isDel"></param>
  9495. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9496. {
  9497. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9498. //wb.Save(file);
  9499. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9500. if (sheet1 != null)
  9501. {
  9502. if (isDel)
  9503. {
  9504. Cells cells = sheet1.Cells;
  9505. cells.DeleteColumn(columnIndex);
  9506. }
  9507. }
  9508. wb.Save(file);
  9509. }
  9510. /// <summary>
  9511. /// 删除sheet
  9512. /// </summary>
  9513. /// <param name="file"></param>
  9514. /// <param name="sheetName"></param>
  9515. private void DeleteSheet(string file, string sheetName = "")
  9516. {
  9517. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9518. //wb.Save(file);
  9519. List<string> sheets = new List<string>();
  9520. foreach (var item in wb.Worksheets)
  9521. {
  9522. sheets.Add(item.Name);
  9523. }
  9524. if (sheets.Count > 0)
  9525. {
  9526. sheets.RemoveAt(0);//不删除第一个sheet
  9527. foreach (var item in sheets)
  9528. {
  9529. wb.Worksheets.RemoveAt(item);
  9530. }
  9531. }
  9532. wb.Save(file);
  9533. }
  9534. /// <summary>
  9535. /// 酒店预订
  9536. /// 确认单
  9537. /// </summary>
  9538. /// <param name="_dto"></param>
  9539. /// <returns></returns>
  9540. [HttpPost]
  9541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9542. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9543. {
  9544. try
  9545. {
  9546. #region 参数验证
  9547. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9548. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9549. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9550. #region 团组操作权限验证 76 酒店预定模块
  9551. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9552. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9553. #endregion
  9554. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9555. #region 页面操作权限验证
  9556. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9557. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9558. #endregion
  9559. #endregion
  9560. //团组信息
  9561. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9562. //酒店数据
  9563. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9564. if (listhoteldata.Count < 0)
  9565. {
  9566. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9567. }
  9568. //利datatable存储
  9569. DataTable dt = new DataTable();
  9570. dt.Columns.Add("CheckInDate", typeof(string));
  9571. dt.Columns.Add("City", typeof(string));
  9572. dt.Columns.Add("Hotel", typeof(string));
  9573. dt.Columns.Add("Room", typeof(string));
  9574. for (int i = 0; i < listhoteldata.Count; i++)
  9575. {
  9576. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9577. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9578. while (dayStart < dayEnd)
  9579. {
  9580. string temp = "";
  9581. DataRow row = dt.NewRow();
  9582. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9583. row["City"] = listhoteldata[i].City;
  9584. row["Hotel"] = listhoteldata[i].HotelName;
  9585. if (listhoteldata[i].SingleRoomCount > 0)
  9586. {
  9587. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9588. }
  9589. if (listhoteldata[i].DoubleRoomCount > 0)
  9590. {
  9591. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9592. }
  9593. if (listhoteldata[i].SuiteRoomCount > 0)
  9594. {
  9595. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9596. }
  9597. if (listhoteldata[i].OtherRoomCount > 0)
  9598. {
  9599. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9600. }
  9601. row["Room"] = temp;
  9602. dt.Rows.Add(row);
  9603. dayStart = dayStart.AddDays(1);
  9604. }
  9605. }
  9606. Dictionary<string, string> dic = new Dictionary<string, string>();
  9607. dic.Add("Dele", di.TeamName);
  9608. dic.Add("City", di.VisitCountry);
  9609. //模板路径
  9610. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9611. //载入模板
  9612. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9613. DocumentBuilder builder = new DocumentBuilder(doc);
  9614. foreach (var key in dic.Keys)
  9615. {
  9616. builder.MoveToBookmark(key);
  9617. builder.Write(dic[key]);
  9618. }
  9619. //获取word里所有表格
  9620. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9621. //获取所填表格的序数
  9622. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9623. var rowStart = tableOne.Rows[0]; //获取第1行
  9624. //循环赋值
  9625. for (int i = 0; i < dt.Rows.Count; i++)
  9626. {
  9627. builder.MoveToCell(0, i + 1, 0, 0);
  9628. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9629. builder.MoveToCell(0, i + 1, 1, 0);
  9630. builder.Write(dt.Rows[i]["City"].ToString());
  9631. builder.MoveToCell(0, i + 1, 2, 0);
  9632. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9633. builder.MoveToCell(0, i + 1, 3, 0);
  9634. builder.Write(dt.Rows[i]["Room"].ToString());
  9635. }
  9636. //删除多余行
  9637. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9638. {
  9639. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9640. }
  9641. string strFileName = di.TeamName + "酒店确认单.doc";
  9642. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9643. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9644. return Ok(JsonView(true, "成功", url));
  9645. }
  9646. catch (Exception ex)
  9647. {
  9648. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9649. }
  9650. }
  9651. #endregion
  9652. #region 团组状态
  9653. /// <summary>
  9654. /// 团组状态列表 Page
  9655. /// </summary>
  9656. /// <param name="dto">团组列表请求dto</param>
  9657. /// <returns></returns>
  9658. [HttpPost]
  9659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9660. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9661. {
  9662. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9663. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9664. {
  9665. string sqlWhere = string.Empty;
  9666. if (dto.IsSure == 0) //未完成
  9667. {
  9668. sqlWhere += string.Format(@" And IsSure = 0");
  9669. }
  9670. else if (dto.IsSure == 1) //已完成
  9671. {
  9672. sqlWhere += string.Format(@" And IsSure = 1");
  9673. }
  9674. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9675. {
  9676. string tj = dto.SearchCriteria;
  9677. 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}%')",
  9678. tj, tj, tj, tj, tj);
  9679. }
  9680. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9681. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9682. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9683. From (
  9684. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9685. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9686. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9687. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9688. From Grp_DelegationInfo gdi
  9689. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9690. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9691. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9692. Where gdi.IsDel = 0 {0}
  9693. ) temp ", sqlWhere);
  9694. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9695. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9696. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9697. }
  9698. else
  9699. {
  9700. return Ok(JsonView(false, "查询失败"));
  9701. }
  9702. }
  9703. /// <summary>
  9704. /// 团组状态
  9705. /// 设置操作完成
  9706. /// </summary>
  9707. /// <param name="dto">团组列表请求dto</param>
  9708. /// <returns></returns>
  9709. [HttpPost]
  9710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9711. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9712. {
  9713. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9714. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9715. {
  9716. Id = dto.Id,
  9717. IsSure = 1
  9718. };
  9719. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9720. .UpdateColumns(it => new { it.IsSure })
  9721. .WhereColumns(it => new { it.Id })
  9722. .ExecuteCommandAsync();
  9723. if (result > 0)
  9724. {
  9725. return Ok(JsonView(true, "操作完成!"));
  9726. }
  9727. return Ok(JsonView(false, "操作失败!"));
  9728. }
  9729. #endregion
  9730. #region 保险费用录入
  9731. /// <summary>
  9732. /// 根据团组Id查询保险费用列表
  9733. /// </summary>
  9734. /// <param name="dto"></param>
  9735. /// <returns></returns>
  9736. [HttpPost]
  9737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9738. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9739. {
  9740. try
  9741. {
  9742. Result groupData = await _customersRep.CustomersByDiId(dto);
  9743. if (groupData.Code != 0)
  9744. {
  9745. return Ok(JsonView(false, groupData.Msg));
  9746. }
  9747. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9748. }
  9749. catch (Exception ex)
  9750. {
  9751. return Ok(JsonView(false, ex.Message));
  9752. }
  9753. }
  9754. /// <summary>
  9755. /// 根据保险费用Id查询保险费用详细
  9756. /// </summary>
  9757. /// <param name="dto"></param>
  9758. /// <returns></returns>
  9759. [HttpPost]
  9760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9761. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9762. {
  9763. try
  9764. {
  9765. Result groupData = await _customersRep.CustomersById(dto);
  9766. if (groupData.Code != 0)
  9767. {
  9768. return Ok(JsonView(false, groupData.Msg));
  9769. }
  9770. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9771. }
  9772. catch (Exception ex)
  9773. {
  9774. return Ok(JsonView(false, ex.Message));
  9775. }
  9776. }
  9777. /// <summary>
  9778. /// 保险费用录入页面初始化绑定
  9779. /// </summary>
  9780. /// <param name="dto"></param>
  9781. /// <returns></returns>
  9782. [HttpPost]
  9783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9784. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9785. {
  9786. try
  9787. {
  9788. Result groupData = await _customersRep.CustomersInitialize(dto);
  9789. if (groupData.Code != 0)
  9790. {
  9791. return Ok(JsonView(false, groupData.Msg));
  9792. }
  9793. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9794. }
  9795. catch (Exception ex)
  9796. {
  9797. return Ok(JsonView(false, ex.Message));
  9798. }
  9799. }
  9800. /// <summary>
  9801. /// 保险费用操作(Status:1.新增,2.修改)
  9802. /// </summary>
  9803. /// <param name="dto"></param>
  9804. /// <returns></returns>
  9805. [HttpPost]
  9806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9807. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9808. {
  9809. try
  9810. {
  9811. Result groupData = await _customersRep.OpCustomers(dto);
  9812. if (groupData.Code != 0)
  9813. {
  9814. return Ok(JsonView(false, groupData.Msg));
  9815. }
  9816. #region 应用推送
  9817. try
  9818. {
  9819. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9820. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9821. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9822. }
  9823. catch (Exception ex)
  9824. {
  9825. }
  9826. #endregion
  9827. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9828. }
  9829. catch (Exception ex)
  9830. {
  9831. return Ok(JsonView(false, ex.Message));
  9832. }
  9833. }
  9834. /// <summary>
  9835. /// 保险文件上传
  9836. /// </summary>
  9837. /// <param name="file"></param>
  9838. /// <returns></returns>
  9839. [HttpPost]
  9840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9841. public async Task<IActionResult> UploadCus(IFormFile file)
  9842. {
  9843. try
  9844. {
  9845. if (file != null)
  9846. {
  9847. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9848. //文件名称
  9849. string projectFileName = file.FileName;
  9850. //上传的文件的路径
  9851. string filePath = "";
  9852. if (!Directory.Exists(fileDir))
  9853. {
  9854. Directory.CreateDirectory(fileDir);
  9855. }
  9856. //上传的文件的路径
  9857. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9858. using (FileStream fs = System.IO.File.Create(filePath))
  9859. {
  9860. file.CopyTo(fs);
  9861. fs.Flush();
  9862. }
  9863. return Ok(JsonView(true, "上传成功!", projectFileName));
  9864. }
  9865. else
  9866. {
  9867. return Ok(JsonView(false, "上传失败!"));
  9868. }
  9869. }
  9870. catch (Exception ex)
  9871. {
  9872. return Ok(JsonView(false, "程序错误!"));
  9873. throw;
  9874. }
  9875. }
  9876. /// <summary>
  9877. /// 保险删除指定文件
  9878. /// </summary>
  9879. /// <param name="dto"></param>
  9880. /// <returns></returns>
  9881. [HttpPost]
  9882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9883. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9884. {
  9885. try
  9886. {
  9887. string filePath = "";
  9888. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9889. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9890. //int id = 0;
  9891. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9892. // 删除该文件
  9893. try
  9894. {
  9895. System.IO.File.Delete(filePath);
  9896. 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()
  9897. {
  9898. Attachment = "",
  9899. }).ExecuteCommandAsync();
  9900. if (result != 0)
  9901. {
  9902. return Ok(JsonView(true, "成功!"));
  9903. }
  9904. else
  9905. {
  9906. return Ok(JsonView(false, "失败!"));
  9907. }
  9908. }
  9909. catch (Exception)
  9910. {
  9911. 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()
  9912. {
  9913. Attachment = "",
  9914. }).ExecuteCommandAsync();
  9915. if (result != 0)
  9916. {
  9917. return Ok(JsonView(true, "成功!"));
  9918. }
  9919. else
  9920. {
  9921. return Ok(JsonView(false, "失败!"));
  9922. }
  9923. }
  9924. }
  9925. catch (Exception ex)
  9926. {
  9927. return Ok(JsonView(false, "程序错误!"));
  9928. throw;
  9929. }
  9930. }
  9931. /// <summary>
  9932. /// 保险费用操作(删除)
  9933. /// </summary>
  9934. /// <param name="dto"></param>
  9935. /// <returns></returns>
  9936. [HttpPost]
  9937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9938. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9939. {
  9940. try
  9941. {
  9942. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9943. if (!res)
  9944. {
  9945. return Ok(JsonView(false, "删除失败"));
  9946. }
  9947. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9948. {
  9949. IsDel = 1,
  9950. DeleteUserId = dto.DeleteUserId,
  9951. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9952. }).ExecuteCommandAsync();
  9953. return Ok(JsonView(true, "删除成功!"));
  9954. }
  9955. catch (Exception ex)
  9956. {
  9957. return Ok(JsonView(false, "程序错误!"));
  9958. throw;
  9959. }
  9960. }
  9961. #endregion
  9962. #region 接团客户名单 PageId 104
  9963. /// <summary>
  9964. /// 接团客户名单
  9965. /// 迁移数据(慎用!)
  9966. /// </summary>
  9967. /// <param name="dto"></param>
  9968. /// <returns></returns>
  9969. [HttpPost]
  9970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9971. public async Task<IActionResult> PostTourClientListChange()
  9972. {
  9973. try
  9974. {
  9975. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9976. //var groupClinetData1
  9977. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9978. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9979. int updateCount = 0;
  9980. if (oldOAClientList.Count > 0)
  9981. {
  9982. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9983. _sqlSugar.BeginTran();
  9984. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9985. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9986. foreach (var item in oldOAClientList)
  9987. {
  9988. int comId = 0;
  9989. string format = "yyyy-MM-dd HH:mm:ss";
  9990. string data11 = "1990-01-01 00:00";
  9991. var data1 = IsValidDate(item.OPdate, format);
  9992. if (data1) data11 = item.OPdate;
  9993. //客户公司验证
  9994. if (!string.IsNullOrEmpty(item.Company))
  9995. {
  9996. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9997. if (clientComInfo == null) // add
  9998. {
  9999. var addInfo = new Crm_CustomerCompany()
  10000. {
  10001. CompanyAbbreviation = "",
  10002. CompanyFullName = item.Company,
  10003. Address = "",
  10004. PostCodes = "",
  10005. LastedOpUserId = item.OPer,
  10006. LastedOpDt = Convert.ToDateTime(data11),
  10007. CreateUserId = item.OPer,
  10008. CreateTime = Convert.ToDateTime(data11),
  10009. IsDel = 0
  10010. };
  10011. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10012. if (comId1 > 0) comId = comId1;
  10013. }
  10014. else comId = clientComInfo.Id;
  10015. }
  10016. //客户人员验证
  10017. int clientId = 0;
  10018. string name = item.LastName + item.Name;
  10019. if (!string.IsNullOrEmpty(name))
  10020. {
  10021. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10022. if (clientInfo == null)
  10023. {
  10024. DateTime? dateTime = null;
  10025. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10026. if (isDt) dateTime = birthDayDt;
  10027. var addInfo1 = new Crm_DeleClient()
  10028. {
  10029. CrmCompanyId = comId,
  10030. DiId = -1,
  10031. LastName = item.LastName,
  10032. FirstName = item.Name,
  10033. OldName = "",
  10034. Pinyin = item.Pinyin,
  10035. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10036. Marriage = 0,
  10037. Phone = item.Phone,
  10038. Job = item.Job,
  10039. BirthDay = dateTime
  10040. };
  10041. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10042. if (clientId1 > 0) clientId = clientId1;
  10043. }
  10044. else clientId = clientInfo.Id;
  10045. }
  10046. if (clientId < 1)
  10047. {
  10048. continue;
  10049. }
  10050. int airType = 0;
  10051. if (item.AirType == "超经舱") airType = 459;
  10052. else if (item.AirType == "公务舱") airType = 458;
  10053. else if (item.AirType == "经济舱") airType = 460;
  10054. else if (item.AirType == "其他") airType = 565;
  10055. else if (item.AirType == "头等舱") airType = 457;
  10056. var _TourClientListEntity = new Grp_TourClientList()
  10057. {
  10058. DiId = item.Diid,
  10059. ClientId = clientId,
  10060. CreateUserId = item.OPer,
  10061. CreateTime = Convert.ToDateTime(data11),
  10062. Remark = item.Remark,
  10063. IsDel = item.Isdel,
  10064. ShippingSpaceTypeId = airType,
  10065. ShippingSpaceSpecialNeeds = item.AirRemark,
  10066. HotelSpecialNeeds = item.RoomType
  10067. };
  10068. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10069. if (_TourClientList > 0)
  10070. {
  10071. updateCount++;
  10072. }
  10073. }
  10074. _sqlSugar.CommitTran();
  10075. }
  10076. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10077. }
  10078. catch (Exception ex)
  10079. {
  10080. _sqlSugar.RollbackTran();
  10081. return Ok(JsonView(false, ex.Message));
  10082. }
  10083. return Ok(JsonView(true));
  10084. }
  10085. private bool IsValidDate(string dateString, string format)
  10086. {
  10087. DateTime dateValue;
  10088. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10089. return valid;
  10090. }
  10091. /// <summary>
  10092. /// 接团客户名单
  10093. /// 根据团组Id查询List
  10094. /// </summary>
  10095. /// <param name="dto"></param>
  10096. /// <returns></returns>
  10097. [HttpPost]
  10098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10099. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10100. {
  10101. #region 参数验证
  10102. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10103. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10104. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10105. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10106. #region 页面操作权限验证
  10107. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10108. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10109. #endregion
  10110. #endregion
  10111. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10112. if (viewData.Code != 0)
  10113. {
  10114. return Ok(JsonView(false, viewData.Msg));
  10115. }
  10116. return Ok(JsonView(viewData.Data));
  10117. }
  10118. /// <summary>
  10119. /// 接团客户名单
  10120. /// 基础数据 Init
  10121. /// </summary>
  10122. /// <param name="_dto"></param>
  10123. /// <returns></returns>
  10124. [HttpPost]
  10125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10126. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10127. {
  10128. #region 参数验证
  10129. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10130. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10131. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10132. #region 页面操作权限验证
  10133. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10134. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10135. #endregion
  10136. #endregion
  10137. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10138. if (viewData.Code != 0)
  10139. {
  10140. return Ok(JsonView(false, viewData.Msg));
  10141. }
  10142. return Ok(JsonView(viewData.Data));
  10143. }
  10144. /// <summary>
  10145. /// 接团客户名单
  10146. /// 根据 Id查询 Details
  10147. /// </summary>
  10148. /// <param name="_dto"></param>
  10149. /// <returns></returns>
  10150. [HttpPost]
  10151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10152. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10153. {
  10154. #region 参数验证
  10155. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10156. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10157. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10158. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10159. #region 页面操作权限验证
  10160. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10161. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10162. #endregion
  10163. #endregion
  10164. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10165. if (viewData.Code != 0)
  10166. {
  10167. return Ok(JsonView(false, viewData.Msg));
  10168. }
  10169. return Ok(JsonView(viewData.Data));
  10170. }
  10171. /// <summary>
  10172. /// 接团客户名单
  10173. /// Add Or Edit
  10174. /// </summary>
  10175. /// <param name="_dto"></param>
  10176. /// <returns></returns>
  10177. [HttpPost]
  10178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10179. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10180. {
  10181. #region 参数验证
  10182. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10183. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10184. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10185. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10186. #region 页面操作权限验证
  10187. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10188. if (_dto.Id == 0) //添加
  10189. {
  10190. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10191. }
  10192. else if (_dto.Id >= 0) //修改
  10193. {
  10194. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10195. }
  10196. #endregion
  10197. #endregion
  10198. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10199. if (viewData.Code != 0)
  10200. {
  10201. return Ok(JsonView(false, viewData.Msg));
  10202. }
  10203. return Ok(JsonView(true));
  10204. }
  10205. /// <summary>
  10206. /// 接团客户名单
  10207. /// AddMultiple(添加多个)
  10208. /// </summary>
  10209. /// <param name="_dto"></param>
  10210. /// <returns></returns>
  10211. [HttpPost]
  10212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10213. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10214. {
  10215. #region 参数验证
  10216. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10217. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10218. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10219. #region 页面操作权限验证
  10220. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10221. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10222. #endregion
  10223. #endregion
  10224. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10225. if (viewData.Code != 0)
  10226. {
  10227. return Ok(JsonView(false, viewData.Msg));
  10228. }
  10229. return Ok(JsonView(true));
  10230. }
  10231. /// <summary>
  10232. /// 接团客户名单
  10233. /// Del
  10234. /// </summary>
  10235. /// <param name="_dto"></param>
  10236. /// <returns></returns>
  10237. [HttpPost]
  10238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10239. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10240. {
  10241. #region 参数验证
  10242. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10243. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10244. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10245. #region 页面操作权限验证
  10246. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10247. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10248. #endregion
  10249. #endregion
  10250. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10251. if (viewData.Code != 0)
  10252. {
  10253. return Ok(JsonView(false, viewData.Msg));
  10254. }
  10255. return Ok(JsonView(true));
  10256. }
  10257. /// <summary>
  10258. /// 接团客户名单
  10259. /// 文件下载 客户名单
  10260. /// </summary>
  10261. /// <param name="_dto"></param>
  10262. /// <returns></returns>
  10263. [HttpPost]
  10264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10265. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10266. {
  10267. #region 参数验证
  10268. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10269. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10270. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10271. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10272. #region 页面操作权限验证
  10273. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10274. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10275. #endregion
  10276. #endregion
  10277. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10278. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10279. From Grp_TourClientList tcl
  10280. Left Join
  10281. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10282. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10283. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10284. From Crm_DeleClient dc
  10285. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10286. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10287. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10288. Where dc.IsDel = 0) temp
  10289. On temp.DcId =tcl.ClientId
  10290. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10291. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10292. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10293. //载入模板
  10294. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10295. if (_dto.Language == 1)
  10296. {
  10297. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10298. }
  10299. //载入模板
  10300. var doc = new Document(tempPath);
  10301. DocumentBuilder builder = new DocumentBuilder(doc);
  10302. //获取word里所有表格
  10303. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10304. //获取所填表格的序数
  10305. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10306. var rowStart = tableOne.Rows[0]; //获取第1行
  10307. if (_dto.Language == 0)
  10308. {
  10309. //循环赋值
  10310. for (int i = 0; i < DcList.Count; i++)
  10311. {
  10312. builder.MoveToCell(0, i + 1, 0, 0);
  10313. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10314. builder.MoveToCell(0, i + 1, 1, 0);
  10315. int sex = DcList[i].Sex;
  10316. string sexStr = string.Empty;
  10317. if (sex == 0) sexStr = "男";
  10318. else if (sex == 1) sexStr = "女";
  10319. else sexStr = "未设置";
  10320. builder.Write(sexStr);
  10321. builder.MoveToCell(0, i + 1, 2, 0);
  10322. string birthDay = DcList[i].BirthDay;
  10323. string birthDayStr = string.Empty;
  10324. if (!string.IsNullOrEmpty(birthDay))
  10325. {
  10326. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10327. }
  10328. builder.Write(birthDayStr);
  10329. builder.MoveToCell(0, i + 1, 3, 0);
  10330. string company = "";
  10331. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10332. {
  10333. company = DcList[i].CompanyFullName.ToString();
  10334. }
  10335. builder.Write(company);
  10336. builder.MoveToCell(0, i + 1, 4, 0);
  10337. builder.Write(DcList[i].Job);
  10338. }
  10339. }
  10340. else if (_dto.Language == 1)
  10341. {
  10342. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10343. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10344. List<string> transArrayStr = new List<string>();
  10345. string transStrRes1 = "";
  10346. for (int i = 0; i < DcList.Count; i++)
  10347. {
  10348. var dc = DcList[i];
  10349. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  10350. if (dc.Job.Equals("暂无")) dc.Job = "-";
  10351. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  10352. if (DcList.Count - 1 == i) transStrRes1 += str1;
  10353. else transStrRes1 += $"{str1}|";
  10354. }
  10355. //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";
  10356. string transStrRes = "";
  10357. if (transStrRes1.Length > 0 )
  10358. {
  10359. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  10360. }
  10361. //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
  10362. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  10363. //List<string> transArray = new List<string> { };
  10364. List<TranslateInfo> transArray = new List<TranslateInfo>();
  10365. if (transStrRes.Contains("|"))
  10366. {
  10367. string[] transArray1 = transStrRes.Split('|');
  10368. if (transArray1.Length > 0)
  10369. {
  10370. foreach (var item in transArray1)
  10371. {
  10372. if (item.Contains("&"))
  10373. {
  10374. string[] transArray2 = item.Split('&');
  10375. int index = 0;
  10376. string companyName = "", job = "";
  10377. if (transArray2.Length > 0)
  10378. {
  10379. bool success = int.TryParse(transArray2[0].Trim(), out index);
  10380. if (1 < transArray2.Length) companyName = transArray2[1];
  10381. if (2 < transArray2.Length) job = transArray2[2];
  10382. }
  10383. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  10384. }
  10385. }
  10386. }
  10387. }
  10388. //循环赋值
  10389. for (int i = 0; i < DcList.Count; i++)
  10390. {
  10391. string PYName = "";
  10392. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10393. {
  10394. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10395. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10396. PYName = PY_First + " " + PY_Last;
  10397. }
  10398. else
  10399. {
  10400. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10401. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10402. PYName = PY_First + " " + PY_Last;
  10403. }
  10404. builder.MoveToCell(0, i + 1, 0, 0);
  10405. builder.Write(PYName);
  10406. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10407. builder.MoveToCell(0, i + 1, 1, 0);
  10408. builder.Write(sex);
  10409. DateTime birthDt;
  10410. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10411. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  10412. builder.MoveToCell(0, i + 1, 2, 0);
  10413. builder.Write(birthday);
  10414. string company = string.Empty,job = string.Empty;
  10415. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  10416. if (dcTransInfo != null)
  10417. {
  10418. company = dcTransInfo.CompanyName;
  10419. job = dcTransInfo.Job;
  10420. }
  10421. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10422. {
  10423. //查询对照表
  10424. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10425. if (tempCec != null)
  10426. {
  10427. company = tempCec.enName;
  10428. }
  10429. //翻译
  10430. else
  10431. {
  10432. }
  10433. }
  10434. builder.MoveToCell(0, i + 1, 3, 0);
  10435. builder.Write(company);
  10436. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10437. {
  10438. //查询对照表
  10439. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10440. if (tempPec != null)
  10441. {
  10442. job = tempPec.enName;
  10443. }
  10444. //翻译
  10445. else
  10446. {
  10447. }
  10448. }
  10449. builder.MoveToCell(0, i + 1, 4, 0);
  10450. builder.Write(job);
  10451. }
  10452. }
  10453. //删除多余行
  10454. while (tableOne.Rows.Count > DcList.Count + 1)
  10455. {
  10456. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10457. }
  10458. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10459. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10460. doc.Save(fileDir);
  10461. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10462. return Ok(JsonView(true, "操作成功!", Url));
  10463. }
  10464. private class TranslateInfo
  10465. {
  10466. public int Index { get; set; }
  10467. public string CompanyName { get; set; }
  10468. public string Job { get; set; }
  10469. }
  10470. #endregion
  10471. #region 团组倒推表
  10472. /// <summary>
  10473. /// 倒推表基础数据
  10474. /// Init
  10475. /// </summary>
  10476. /// <param name="dto"></param>
  10477. /// <returns></returns>
  10478. [HttpPost]
  10479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10480. public async Task<IActionResult> PostInvertedListInit()
  10481. {
  10482. var viewData = await _invertedListRep._Init();
  10483. if (viewData.Code != 0)
  10484. {
  10485. return Ok(JsonView(false, viewData.Msg));
  10486. }
  10487. return Ok(JsonView(viewData.Data));
  10488. }
  10489. /// <summary>
  10490. /// 倒推表
  10491. /// Info
  10492. /// </summary>
  10493. /// <param name="dto"></param>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10498. {
  10499. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10500. if (viewData.Code != 0)
  10501. {
  10502. return Ok(JsonView(false, viewData.Msg));
  10503. }
  10504. return Ok(JsonView(viewData.Data));
  10505. }
  10506. /// <summary>
  10507. /// 倒推表
  10508. /// Create
  10509. /// </summary>
  10510. /// <param name="dto"></param>
  10511. /// <returns></returns>
  10512. [HttpPost]
  10513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10514. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10515. {
  10516. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10517. if (viewData.Code != 0)
  10518. {
  10519. return Ok(JsonView(false, viewData.Msg));
  10520. }
  10521. return Ok(JsonView(viewData.Data));
  10522. }
  10523. /// <summary>
  10524. /// 倒推表
  10525. /// Update
  10526. /// </summary>
  10527. /// <param name="dto"></param>
  10528. /// <returns></returns>
  10529. [HttpPost]
  10530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10531. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10532. {
  10533. var viewData = await _invertedListRep._Update(dto);
  10534. if (viewData.Code != 0)
  10535. {
  10536. return Ok(JsonView(false, viewData.Msg));
  10537. }
  10538. return Ok(JsonView(viewData.Data));
  10539. }
  10540. /// <summary>
  10541. /// 倒推表
  10542. /// File Download
  10543. /// </summary>
  10544. /// <param name="dto"></param>
  10545. /// <returns></returns>
  10546. [HttpPost]
  10547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10548. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10549. {
  10550. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10551. if (info2.Code != 0)
  10552. {
  10553. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10554. }
  10555. var info1 = info2.Data as InvertedListInfoView;
  10556. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10557. string teamName = "";
  10558. if (info != null) teamName = info.TeamName;
  10559. //载入模板
  10560. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10561. DocumentBuilder builder = new DocumentBuilder(doc);
  10562. //利用键值对存放数据
  10563. Dictionary<string, string> dic = new Dictionary<string, string>();
  10564. dic.Add("TeamName", teamName);
  10565. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10566. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10567. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10568. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10569. dic.Add("SQRemark", info1.ApprovalRemark);
  10570. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10571. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10572. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10573. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10574. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10575. dic.Add("QZRemark", info1.VisaInformationRemark);
  10576. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10577. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10578. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10579. dic.Add("CQRemark", info1.IssueVisaRemark);
  10580. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10581. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10582. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10583. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10584. #region 填充word模板书签内容
  10585. foreach (var key in dic.Keys)
  10586. {
  10587. builder.MoveToBookmark(key);
  10588. builder.Write(dic[key]);
  10589. }
  10590. #endregion
  10591. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10592. string fileName = $"{teamName}团出行准备流程表.doc";
  10593. string filePath = fileDir + $@"InvertedList/{fileName}";
  10594. doc.Save(filePath);
  10595. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10596. return Ok(JsonView(true, "操作成功!", Url));
  10597. }
  10598. #endregion
  10599. #region 三公签证费用(签证费、代办费)
  10600. /// <summary>
  10601. /// 三公签证费用(签证费、代办费)
  10602. /// List
  10603. /// </summary>
  10604. /// <returns></returns>
  10605. [HttpPost]
  10606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10607. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10608. {
  10609. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10610. if (_view.Code != 0)
  10611. {
  10612. return Ok(JsonView(false, _view.Msg));
  10613. }
  10614. return Ok(JsonView(true, "操作成功!", _view.Data));
  10615. }
  10616. /// <summary>
  10617. /// 三公签证费用(签证费、代办费)
  10618. /// Add Or Update
  10619. /// </summary>
  10620. /// <returns></returns>
  10621. [HttpPost]
  10622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10623. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10624. {
  10625. var _view = await _visaFeeInfoRep._Update(_dto);
  10626. if (_view.Code != 0)
  10627. {
  10628. return Ok(JsonView(false, _view.Msg));
  10629. }
  10630. return Ok(JsonView(true, _view.Msg));
  10631. }
  10632. #endregion
  10633. #region 酒店询价
  10634. /// <summary>
  10635. /// 酒店询价
  10636. /// Init
  10637. /// </summary>
  10638. /// <param name="dto"></param>
  10639. /// <returns></returns>
  10640. [HttpPost]
  10641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10642. public async Task<IActionResult> PostHotelInquiryInit()
  10643. {
  10644. var res = await _hotelInquiryRep._Init();
  10645. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10646. return Ok(JsonView(true, res.Msg, res.Data));
  10647. }
  10648. /// <summary>
  10649. /// 酒店询价
  10650. /// page Item
  10651. /// </summary>
  10652. /// <param name="_dto"></param>
  10653. /// <returns></returns>
  10654. [HttpPost]
  10655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10656. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10657. {
  10658. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10659. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10660. var view = res.Data as PageDataViewBase;
  10661. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10662. }
  10663. /// <summary>
  10664. /// 酒店询价
  10665. /// info
  10666. /// </summary>
  10667. /// <param name="_dto"></param>
  10668. /// <returns></returns>
  10669. [HttpPost]
  10670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10671. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10672. {
  10673. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10674. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10675. return Ok(JsonView(true, res.Msg, res.Data));
  10676. }
  10677. /// <summary>
  10678. /// 酒店询价
  10679. /// Add Or Edit
  10680. /// </summary>
  10681. /// <param name="_dto"></param>
  10682. /// <returns></returns>
  10683. [HttpPost]
  10684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10685. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10686. {
  10687. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10688. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10689. return Ok(JsonView(true, res.Msg, res.Data));
  10690. }
  10691. /// <summary>
  10692. /// 酒店询价
  10693. /// Del
  10694. /// </summary>
  10695. /// <param name="_dto"></param>
  10696. /// <returns></returns>
  10697. [HttpPost]
  10698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10699. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10700. {
  10701. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10702. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10703. return Ok(JsonView(true, res.Msg, res.Data));
  10704. }
  10705. #endregion
  10706. #region 下载匹配op行程单
  10707. /// <summary>
  10708. /// 匹配op行程单
  10709. /// Init
  10710. /// </summary>
  10711. /// <param name="dto">团组列表请求dto</param>
  10712. /// <returns></returns>
  10713. [HttpPost]
  10714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10715. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10716. {
  10717. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10718. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10719. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10720. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10721. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10722. .Where(it => it.IsDel == 0)
  10723. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10724. .OrderByDescending(it => it.CreateUserId)
  10725. .ToList();
  10726. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  10727. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10728. var diids = groupInfos.Select(it => it.Id).ToList();
  10729. List<string> countrys = new List<string>();
  10730. foreach (var item in country)
  10731. {
  10732. var data = _groupRepository.FormartTeamName(item);
  10733. var dataArray = _groupRepository.GroupSplitCountry(data);
  10734. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10735. }
  10736. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10737. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10738. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10739. foreach (var item in areaItem)
  10740. {
  10741. string areaStr = item.Value;
  10742. if (!string.IsNullOrEmpty(areaStr))
  10743. {
  10744. string[] str1 = areaStr.Split("-");
  10745. if (str1.Length > 0)
  10746. {
  10747. areaArray.AddRange(str1);
  10748. }
  10749. }
  10750. }
  10751. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10752. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10753. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10754. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10755. .ToList();
  10756. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10757. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10758. .Where(it => countriesIds.Contains(it.Id))
  10759. .Select(it => new { it.Id, Name = it.Name_CN })
  10760. .ToList();
  10761. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  10762. .Select(it => it.TeamName).ToList();
  10763. stopwatch.Stop();
  10764. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  10765. }
  10766. ///// <summary>
  10767. ///// 匹配op行程单
  10768. ///// Init 查询区域数据
  10769. ///// </summary>
  10770. ///// <param name="dto">团组列表请求dto</param>
  10771. ///// <returns></returns>
  10772. //[HttpPost]
  10773. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10774. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10775. //{
  10776. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10777. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10778. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10779. // if (string.IsNullOrEmpty(countriesDataStr))
  10780. // {
  10781. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10782. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10783. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10784. // }
  10785. // else
  10786. // {
  10787. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10788. // }
  10789. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10790. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10791. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10792. // List<dynamic> childList = new List<dynamic>();
  10793. // int parentId = dto.CountriesId;
  10794. // if (provinceData.Count > 1)
  10795. // {
  10796. // foreach (var item1 in provinceData)
  10797. // {
  10798. // List<dynamic> childList1 = new List<dynamic>();
  10799. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10800. // foreach (var item2 in citiesData1)
  10801. // {
  10802. // List<dynamic> childList2 = new List<dynamic>();
  10803. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10804. // foreach (var item3 in countiesData1)
  10805. // {
  10806. // childList2.Add(new
  10807. // {
  10808. // id = item3.Id,
  10809. // parentId = item2.Id,
  10810. // level = "district",
  10811. // name = item3.Name_CN,
  10812. // });
  10813. // }
  10814. // childList1.Add(new
  10815. // {
  10816. // id = item2.Id,
  10817. // parentId = item1.Id,
  10818. // level = "city",
  10819. // name = item2.Name_CN,
  10820. // childList = childList2
  10821. // });
  10822. // }
  10823. // childList.Add(new
  10824. // {
  10825. // id = item1.Id,
  10826. // parentId = parentId,
  10827. // level = "province",
  10828. // name = item1.Name_CN,
  10829. // childList = childList1
  10830. // });
  10831. // }
  10832. // //城市
  10833. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10834. // foreach (var item2 in citiesData2)
  10835. // {
  10836. // List<dynamic> childList22 = new List<dynamic>();
  10837. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10838. // foreach (var item3 in countiesData1)
  10839. // {
  10840. // childList22.Add(new
  10841. // {
  10842. // id = item3.Id,
  10843. // parentId = item2.Id,
  10844. // level = "district",
  10845. // name = item3.Name_CN,
  10846. // });
  10847. // }
  10848. // childList.Add(new
  10849. // {
  10850. // id = item2.Id,
  10851. // parentId = parentId,
  10852. // level = "city",
  10853. // name = item2.Name_CN,
  10854. // childList = childList22
  10855. // });
  10856. // }
  10857. // }
  10858. // else
  10859. // {
  10860. // foreach (var item2 in citiesData)
  10861. // {
  10862. // string cname = item2.Name_CN;
  10863. // List<dynamic> childList1 = new List<dynamic>();
  10864. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10865. // foreach (var item3 in countiesData1)
  10866. // {
  10867. // childList1.Add(new
  10868. // {
  10869. // Id = item3.Id,
  10870. // parentId = item2.Id,
  10871. // level = "district",
  10872. // name = item3.Name_CN
  10873. // });
  10874. // }
  10875. // childList.Add(new
  10876. // {
  10877. // id = item2.Id,
  10878. // parentId = parentId,
  10879. // level = "city",
  10880. // name = item2.Name_CN,
  10881. // childList = childList1
  10882. // });
  10883. // }
  10884. // }
  10885. // stopwatch.Stop();
  10886. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10887. //}
  10888. /// <summary>
  10889. /// 匹配op行程单
  10890. /// 接团信息列表 Page
  10891. /// </summary>
  10892. /// <param name="dto">团组列表请求dto</param>
  10893. /// <returns></returns>
  10894. [HttpPost]
  10895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10896. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10897. {
  10898. var swatch = new Stopwatch();
  10899. swatch.Start();
  10900. #region 参数验证
  10901. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10902. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10903. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10904. #region 页面操作权限验证
  10905. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10906. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10907. #endregion
  10908. #endregion
  10909. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10910. {
  10911. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10912. string sqlWhere = "";
  10913. if (!string.IsNullOrEmpty(dto.Country))
  10914. {
  10915. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10916. }
  10917. if (!string.IsNullOrEmpty(dto.Area))
  10918. {
  10919. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10920. }
  10921. if (!string.IsNullOrEmpty(dto.TeamName))
  10922. {
  10923. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10924. }
  10925. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10926. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10927. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10928. swatch.Stop();
  10929. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10930. }
  10931. else
  10932. {
  10933. return Ok(JsonView(false, "查询失败"));
  10934. }
  10935. }
  10936. /// <summary>
  10937. /// 匹配op行程单
  10938. /// 行程单下载
  10939. /// </summary>
  10940. /// <param name="dto">团组列表请求dto</param>
  10941. /// <returns></returns>
  10942. [HttpPost]
  10943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10944. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10945. {
  10946. #region 参数验证
  10947. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10948. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10949. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10950. #region 页面操作权限验证
  10951. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10952. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10953. #endregion
  10954. #endregion
  10955. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10956. {
  10957. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  10958. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10959. }
  10960. else
  10961. {
  10962. return Ok(JsonView(false, "下载失败!"));
  10963. }
  10964. }
  10965. #endregion
  10966. #region 国家信息 数据 注释
  10967. //[HttpPost]
  10968. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10969. //{
  10970. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10971. // foreach (var item in dto)
  10972. // {
  10973. // infos.Add(new Grp_GroupsTaskAssignment()
  10974. // {
  10975. // DIId = item,
  10976. // CTId = 82,
  10977. // UId = 248,
  10978. // IsEnable = 1,
  10979. // CreateUserId = 233,
  10980. // CreateTime = DateTime.Now,
  10981. // IsDel = 0
  10982. // });
  10983. // infos.Add(new Grp_GroupsTaskAssignment()
  10984. // {
  10985. // DIId = item,
  10986. // CTId = 82,
  10987. // UId = 286,
  10988. // IsEnable = 1,
  10989. // CreateUserId = 233,
  10990. // CreateTime = DateTime.Now,
  10991. // IsDel = 0
  10992. // });
  10993. // }
  10994. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10995. // return Ok("操作成功");
  10996. //}
  10997. //public class paramJsonDto
  10998. //{
  10999. // public List<CountriesInfo> str { get; set; }
  11000. //}
  11001. //[HttpPost]
  11002. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11003. //{
  11004. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11005. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11006. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11007. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11008. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11009. // _sqlSugar.BeginTran();
  11010. // int countitiesIndex = 0;
  11011. // foreach (var item in dto.str)
  11012. // {
  11013. // dynamic data = item.c;
  11014. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11015. // if (data != null)
  11016. // {
  11017. // countitiesIndex++;
  11018. // foreach (var item1 in data)
  11019. // {
  11020. // string cnname = item1.cn;
  11021. // string enname = item1.en;
  11022. // Sys_Cities provinceInfo = new Sys_Cities()
  11023. // {
  11024. // CountriesId = countriesId,
  11025. // Name_CN = cnname,
  11026. // Name_EN = enname,
  11027. // ParentId = 0,
  11028. // IsCapital = 1,
  11029. // CreateUserId = 208,
  11030. // CreateTime = DateTime.Now,
  11031. // IsDel = 0
  11032. // };
  11033. // if (item1.lv == "province") //省份
  11034. // {
  11035. // provinceInfo.Level = 1;
  11036. // int provinceId = 0;
  11037. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11038. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11039. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11040. // var data1 = item1.c;
  11041. // foreach (var item2 in data1)
  11042. // {
  11043. // if (item2.lv == "city")
  11044. // {
  11045. // string citycnname = item2.cn;
  11046. // string cityenname = item2.en;
  11047. // Sys_Cities cityInfo = new Sys_Cities()
  11048. // {
  11049. // CountriesId = countriesId,
  11050. // ParentId = provinceId,
  11051. // Level = 2,
  11052. // Name_CN = citycnname,
  11053. // Name_EN = cityenname,
  11054. // IsCapital = 1,
  11055. // CreateUserId = 208,
  11056. // CreateTime = DateTime.Now,
  11057. // IsDel = 0
  11058. // };
  11059. // if (item2.c != null)
  11060. // {
  11061. // int cityId = 0;
  11062. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11063. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11064. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11065. // foreach (var item3 in item2.c)
  11066. // {
  11067. // if (item3.lv == "district")
  11068. // {
  11069. // var districtInfo = new Sys_Cities()
  11070. // {
  11071. // CountriesId = countriesId,
  11072. // Name_CN = item3.cn,
  11073. // Name_EN = item3.en,
  11074. // Level = 3,
  11075. // ParentId = cityId,
  11076. // IsCapital = 1,
  11077. // CreateUserId = 208,
  11078. // CreateTime = DateTime.Now,
  11079. // IsDel = 0
  11080. // };
  11081. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11082. // //{
  11083. // districts.Add(districtInfo);
  11084. // //}
  11085. // }
  11086. // }
  11087. // }
  11088. // else
  11089. // {
  11090. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11091. // //{
  11092. // cities.Add(cityInfo);
  11093. // //}
  11094. // }
  11095. // }
  11096. // }
  11097. // }
  11098. // else if (item1.lv == "city")//城市
  11099. // {
  11100. // provinceInfo.Level = 2;
  11101. // if (item1.c != null)
  11102. // {
  11103. // int cityId = 0;
  11104. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11105. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11106. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11107. // foreach (var item3 in item1.c)
  11108. // {
  11109. // if (item3.lv == "district")
  11110. // {
  11111. // var districtInfo = new Sys_Cities()
  11112. // {
  11113. // CountriesId = countriesId,
  11114. // Name_CN = item3.cn,
  11115. // Name_EN = item3.en,
  11116. // Level = 3,
  11117. // ParentId = cityId,
  11118. // IsCapital = 1,
  11119. // CreateUserId = 208,
  11120. // CreateTime = DateTime.Now,
  11121. // IsDel = 0
  11122. // };
  11123. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11124. // //{
  11125. // districts.Add(districtInfo);
  11126. // //}
  11127. // }
  11128. // }
  11129. // }
  11130. // else
  11131. // {
  11132. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11133. // //{
  11134. // cities.Add(provinceInfo);
  11135. // //}
  11136. // }
  11137. // }
  11138. // }
  11139. // }
  11140. // }
  11141. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11142. // cities = cities.Distinct().ToList();
  11143. // districts = districts.Distinct().ToList();
  11144. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11145. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11146. // cities.AddRange(districts);
  11147. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11148. // //_sqlSugar.RollbackTran();
  11149. // _sqlSugar.CommitTran();
  11150. // return Ok(JsonView(false, "操作成功!"));
  11151. //}
  11152. //[HttpPost]
  11153. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11154. //{
  11155. // List<CountitiesInfo> infos = dto.MyProperty;
  11156. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11157. // _sqlSugar.BeginTran();
  11158. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11159. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11160. // foreach (var item in infos)
  11161. // {
  11162. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11163. // if (countryInfo != null)
  11164. // {
  11165. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11166. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11167. // if (cityInfo1 != null)
  11168. // {
  11169. // cityInfo1.IsCapital = 0;
  11170. // cityInfos.Add(cityInfo1);
  11171. // }
  11172. // }
  11173. // }
  11174. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11175. // .UpdateColumns(it => it.IsCapital)
  11176. // .WhereColumns(it => it.Id)
  11177. // .ExecuteCommand();
  11178. // //_sqlSugar.RollbackTran();
  11179. // _sqlSugar.CommitTran();
  11180. // return Ok(JsonView(false, "操作成功!"));
  11181. //}
  11182. //public class CounrtiesDto
  11183. //{
  11184. // public List<CountitiesInfo> MyProperty { get; set; }
  11185. //}
  11186. //public class CountitiesInfo
  11187. //{
  11188. // /// <summary>
  11189. // /// 圣约翰
  11190. // /// </summary>
  11191. // public string capital_name_chinese { get; set; }
  11192. // /// <summary>
  11193. // ///
  11194. // /// </summary>
  11195. // public string capital_name { get; set; }
  11196. // /// <summary>
  11197. // ///
  11198. // /// </summary>
  11199. // public string country_type { get; set; }
  11200. // /// <summary>
  11201. // /// 安提瓜和巴布达
  11202. // /// </summary>
  11203. // public string country_name_chinese { get; set; }
  11204. // /// <summary>
  11205. // /// 安提瓜和巴布达
  11206. // /// </summary>
  11207. // public string country_name_chinese_short { get; set; }
  11208. // /// <summary>
  11209. // /// 安提瓜和巴布达
  11210. // /// </summary>
  11211. // public string country_name_chinese_UN { get; set; }
  11212. // /// <summary>
  11213. // ///
  11214. // /// </summary>
  11215. // public string country_name_english_abbreviation { get; set; }
  11216. // /// <summary>
  11217. // ///
  11218. // /// </summary>
  11219. // public string country_name_english_formal { get; set; }
  11220. // /// <summary>
  11221. // ///
  11222. // /// </summary>
  11223. // public string country_name_english_UN { get; set; }
  11224. // /// <summary>
  11225. // ///
  11226. // /// </summary>
  11227. // public string continent_name { get; set; }
  11228. // /// <summary>
  11229. // ///
  11230. // /// </summary>
  11231. // public string subregion_name { get; set; }
  11232. // /// <summary>
  11233. // ///
  11234. // /// </summary>
  11235. // public string country_code2 { get; set; }
  11236. // /// <summary>
  11237. // ///
  11238. // /// </summary>
  11239. // public string country_code3 { get; set; }
  11240. // /// <summary>
  11241. // ///
  11242. // /// </summary>
  11243. // public string phone_code { get; set; }
  11244. //}
  11245. //public class CountriesInfo : BasicInfo
  11246. //{
  11247. // public List<CitiesInfo> c { get; set; }
  11248. //}
  11249. //public class CitiesInfo : BasicInfo
  11250. //{
  11251. // public List<AreaInfo> c { get; set; }
  11252. //}
  11253. //public class AreaInfo : BasicInfo
  11254. //{
  11255. // public List<AreaInfo> c { get; set; }
  11256. //}
  11257. //public class BasicInfo
  11258. //{
  11259. // public string code { get; set; }
  11260. // public string cn { get; set; }
  11261. // public string lv { get; set; }
  11262. // public string en { get; set; }
  11263. //}
  11264. #endregion
  11265. #region 查看邀请方
  11266. /// <summary>
  11267. /// 查看邀请方
  11268. /// 邀请方信息 Init
  11269. /// </summary>
  11270. /// <param name="dto"></param>
  11271. /// <returns></returns>
  11272. [HttpPost]
  11273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11274. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11275. {
  11276. string sqlWhere = string.Empty;
  11277. if (!string.IsNullOrEmpty(dto.Search))
  11278. {
  11279. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11280. }
  11281. string sql = string.Format($@"Select
  11282. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11283. Id,
  11284. UnitName
  11285. From Res_InvitationOfficialActivityData
  11286. Where IsDel = 0
  11287. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11288. RefAsync<int> total = 0;
  11289. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11290. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11291. }
  11292. /// <summary>
  11293. /// 查看邀请方
  11294. /// 国家信息 Init
  11295. /// </summary>
  11296. /// <param name="dto"></param>
  11297. /// <returns></returns>
  11298. [HttpPost]
  11299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11300. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11301. {
  11302. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11303. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11304. var diids = groupInfos.Select(it => it.Id).ToList();
  11305. List<string> countrys = new List<string>();
  11306. foreach (var item in country)
  11307. {
  11308. var data = _groupRepository.FormartTeamName(item);
  11309. var dataArray = _groupRepository.GroupSplitCountry(data);
  11310. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11311. }
  11312. countrys = countrys.Distinct().ToList();
  11313. for (int i = 0; i < countrys.Count; i++)
  11314. {
  11315. string item = countrys[i];
  11316. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11317. {
  11318. countrys.Remove(item);
  11319. i--;
  11320. }
  11321. }
  11322. RefAsync<int> total = 0;
  11323. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11324. .Where(it => countrys.Contains(it.Name_CN))
  11325. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11326. .Select(it => new { id = it.Id, name = it.Name_CN })
  11327. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11328. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11329. }
  11330. /// <summary>
  11331. /// 查看邀请方
  11332. /// 城市信息 Init
  11333. /// </summary>
  11334. /// <param name="dto"></param>
  11335. /// <returns></returns>
  11336. [HttpPost]
  11337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11338. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11339. {
  11340. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11341. RefAsync<int> total = 0;
  11342. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11343. .Where(it => it.CountriesId == dto.CountiesId)
  11344. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11345. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  11346. .Select(it => new { id = it.Id, name = it.Name_CN })
  11347. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11348. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11349. }
  11350. /// <summary>
  11351. /// 查看邀请方
  11352. /// 团组名称 Init
  11353. /// </summary>
  11354. /// <param name="dto"></param>
  11355. /// <returns></returns>
  11356. [HttpPost]
  11357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11358. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  11359. {
  11360. var watch = new Stopwatch();
  11361. watch.Start();
  11362. RefAsync<int> total = 0;
  11363. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  11364. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  11365. .Where((oa, di) => oa.IsDel == 0)
  11366. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  11367. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  11368. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  11369. .Distinct()
  11370. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11371. watch.Stop();
  11372. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  11373. }
  11374. /// <summary>
  11375. /// 查看邀请方
  11376. /// 团组 & 邀请方信息
  11377. /// </summary>
  11378. /// <param name="dto"></param>
  11379. /// <returns></returns>
  11380. [HttpPost]
  11381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11382. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  11383. {
  11384. var watch = new Stopwatch();
  11385. watch.Start();
  11386. RefAsync<int> total = 0;
  11387. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  11388. .AS("Grp_DelegationInfo")
  11389. .Includes(x => x.InvitingInfos)
  11390. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  11391. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  11392. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  11393. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  11394. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  11395. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  11396. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11397. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  11398. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  11399. infos.ForEach(x =>
  11400. {
  11401. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  11402. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  11403. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  11404. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  11405. });
  11406. watch.Stop();
  11407. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  11408. }
  11409. #endregion
  11410. #region 报批行程
  11411. /// <summary>
  11412. /// 报批行程初始化
  11413. /// </summary>
  11414. /// <param name="dto"></param>
  11415. /// <returns></returns>
  11416. [HttpPost]
  11417. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11418. {
  11419. const int chiNumber = 5;
  11420. var jw = JsonView(false);
  11421. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11422. var group = groupList.First();
  11423. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11424. group = groupList.First(x => x.Id == diid);
  11425. if (group == null)
  11426. {
  11427. jw.Msg = "暂无团组!";
  11428. return Ok(jw);
  11429. }
  11430. var data = new
  11431. {
  11432. groupList = groupList.Select(x => new
  11433. {
  11434. x.TeamName,
  11435. x.Id
  11436. }),
  11437. content = new ArrayList(),
  11438. groupInfo = new
  11439. {
  11440. group.VisitDays,
  11441. group.TourCode,
  11442. group.VisitPNumber,
  11443. group.TeamName,
  11444. group.Id,
  11445. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  11446. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  11447. },
  11448. };
  11449. var resultArr = new ArrayList();
  11450. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11451. if (content.Count == 0)
  11452. {
  11453. var stay = "-";
  11454. var cityPath = "-";
  11455. //添加城市路径以及住宿地
  11456. //黑屏代码数据
  11457. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11458. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11459. {
  11460. jw = JsonView(true, "黑屏代码有误!", data);
  11461. return Ok(jw);
  11462. }
  11463. foreach (DataRow row in dtBlack.Rows)
  11464. {
  11465. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11466. {
  11467. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  11468. return Ok(jw);
  11469. }
  11470. }
  11471. //黑屏代码获取时间区间
  11472. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11473. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11474. _sqlSugar.BeginTran();
  11475. for (int i = 0; i < timeArr.Count; i++)
  11476. {
  11477. stay = "-";
  11478. cityPath = "-";
  11479. DateTime NewData = DateTime.Parse(timeArr[i]);
  11480. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11481. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11482. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11483. if (tbSelect.Length > 0)
  11484. {
  11485. List<string> threeCodeStr = new List<string>();
  11486. foreach (var item in tbSelect)
  11487. {
  11488. var threeCode = item["Three"].ToString() ?? "";
  11489. if (threeCode.Length == 6)
  11490. {
  11491. var start = threeCode.Substring(0, 3);
  11492. var end = threeCode.Substring(3, 3);
  11493. if (threeCodeStr.Count == 0)
  11494. {
  11495. threeCodeStr.Add(start);
  11496. threeCodeStr.Add(end);
  11497. }
  11498. else
  11499. {
  11500. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11501. {
  11502. threeCodeStr.Add(end);
  11503. }
  11504. else
  11505. {
  11506. threeCodeStr.Add(start);
  11507. threeCodeStr.Add(end);
  11508. }
  11509. }
  11510. }
  11511. }
  11512. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11513. var last = threeCodeStr.Last();
  11514. foreach (var item in threeCodeStr)
  11515. {
  11516. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11517. if (item.Equals(last))
  11518. {
  11519. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11520. }
  11521. }
  11522. cityPath = cityPath.Trim('-');
  11523. }
  11524. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11525. appro.Diid = diid ?? -1;
  11526. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11527. appro.Id = thisId;
  11528. appro.CreateUserId = dto.UserId;
  11529. appro.CreateTime = DateTime.Now;
  11530. content.Add(appro);
  11531. }
  11532. _sqlSugar.CommitTran();
  11533. }
  11534. foreach (var x in content)
  11535. {
  11536. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11537. if (chiList.Count < chiNumber)
  11538. {
  11539. for (int i = chiList.Count; i < chiNumber; i++)
  11540. {
  11541. chiList.Add(new Grp_ApprovalTravelDetails());
  11542. }
  11543. }
  11544. resultArr.Add(new
  11545. {
  11546. x.Id,
  11547. x.Date,
  11548. x.Diid,
  11549. chiList = chiList.Select(x1 => new
  11550. {
  11551. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11552. x1.Details,
  11553. x1.ParentId,
  11554. x1.Id
  11555. })
  11556. });
  11557. }
  11558. data = data with
  11559. {
  11560. content = resultArr,
  11561. };
  11562. jw = JsonView(true, "获取成功!", data);
  11563. return Ok(jw);
  11564. }
  11565. /// <summary>
  11566. /// 报批行程删除
  11567. /// </summary>
  11568. /// <param name="dto"></param>
  11569. /// <returns></returns>
  11570. [HttpPost]
  11571. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11572. {
  11573. var jw = JsonView(false);
  11574. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11575. if (group == null)
  11576. {
  11577. jw.Msg = "团组参数有误!";
  11578. return Ok(jw);
  11579. }
  11580. try
  11581. {
  11582. _sqlSugar.BeginTran();
  11583. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  11584. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11585. {
  11586. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11587. DeleteUserId = dto.uesrId,
  11588. IsDel = 1
  11589. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11590. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11591. {
  11592. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11593. DeleteUserId = dto.uesrId,
  11594. IsDel = 1
  11595. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11596. _sqlSugar.CommitTran();
  11597. jw = JsonView(true, "删除成功");
  11598. }
  11599. catch (Exception ex)
  11600. {
  11601. jw = JsonView(false, ex.Message);
  11602. }
  11603. return Ok(jw);
  11604. }
  11605. /// <summary>
  11606. /// 报批行程保存
  11607. /// </summary>
  11608. /// <param name="dto"></param>
  11609. /// <returns></returns>
  11610. [HttpPost]
  11611. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11612. {
  11613. var jw = JsonView(false);
  11614. var Find = dto.Arr.Find(x => x.id == 0);
  11615. if (Find != null)
  11616. {
  11617. jw.Msg = "生成的ID为0!";
  11618. return Ok(jw);
  11619. }
  11620. foreach (var item in dto.Arr)
  11621. {
  11622. foreach (var chi in item.chiList)
  11623. {
  11624. if (chi.parentId == 0)
  11625. {
  11626. chi.parentId = item.id;
  11627. }
  11628. }
  11629. }
  11630. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11631. _sqlSugar.BeginTran();
  11632. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  11633. {
  11634. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11635. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  11636. {
  11637. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11638. DeleteUserId = dto.UserId,
  11639. IsDel = 1
  11640. }).ExecuteCommand();
  11641. }
  11642. try
  11643. {
  11644. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11645. {
  11646. CreateTime = DateTime.Now,
  11647. CreateUserId = dto.UserId,
  11648. Details = x.details,
  11649. ParentId = x.parentId,
  11650. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11651. Remark = "",
  11652. IsDel = 0
  11653. }).ToList()).ExecuteCommand();
  11654. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11655. {
  11656. Id = x.id,
  11657. Details = x.details,
  11658. ParentId = x.parentId,
  11659. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11660. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  11661. {
  11662. Details = x.Details,
  11663. ParentId = x.ParentId,
  11664. Time = x.Time
  11665. }).ExecuteCommand();
  11666. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11667. {
  11668. Id = x.id,
  11669. Date = x.date,
  11670. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11671. {
  11672. Date = x.Date
  11673. }).ExecuteCommand();
  11674. _sqlSugar.CommitTran();
  11675. jw = JsonView(true, "保存成功!");
  11676. }
  11677. catch (Exception ex)
  11678. {
  11679. _sqlSugar.RollbackTran();
  11680. jw = JsonView(false, "保存失败!" + ex.Message);
  11681. }
  11682. return Ok(jw);
  11683. }
  11684. /// <summary>
  11685. /// 报批行程生成
  11686. /// </summary>
  11687. /// <param name="dto"></param>
  11688. /// <returns></returns>
  11689. [HttpPost]
  11690. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11691. {
  11692. var jw = JsonView(false);
  11693. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11694. if (group == null)
  11695. {
  11696. jw.Msg = "暂无该团组!";
  11697. return Ok(jw);
  11698. }
  11699. //黑屏代码数据
  11700. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11701. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11702. {
  11703. jw.Msg = "黑屏代码有误!";
  11704. return Ok(jw);
  11705. }
  11706. foreach (DataRow row in dtBlack.Rows)
  11707. {
  11708. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11709. {
  11710. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11711. return Ok(jw);
  11712. }
  11713. }
  11714. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11715. var resultArr = new ArrayList();
  11716. if (officialActivitiesArr.Count == 0)
  11717. {
  11718. jw.Msg = "暂无公务出访信息!";
  11719. return Ok(jw);
  11720. }
  11721. try
  11722. {
  11723. _sqlSugar.BeginTran();
  11724. DeleteApprovalJourney(new
  11725. Domain.Dtos.Groups.DeleteApprovalJourney
  11726. {
  11727. Diid = dto.Diid,
  11728. uesrId = dto.Userid
  11729. });
  11730. var stay = "-";
  11731. var cityPath = "-";
  11732. //添加城市路径以及住宿地
  11733. //黑屏代码获取时间区间
  11734. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11735. var empty = "【未收入该三字码!请机票同事录入】";
  11736. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11737. for (int i = 0; i < timeArr.Count; i++)
  11738. {
  11739. stay = "-";
  11740. cityPath = "-";
  11741. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11742. DateTime NewData = DateTime.Parse(timeArr[i]);
  11743. 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();
  11744. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11745. if (tbSelect.Length > 0)
  11746. {
  11747. List<string> threeCodeStr = new List<string>();
  11748. bool isTrade = false;
  11749. string trip = string.Empty;
  11750. var rowLast = tbSelect.Last();
  11751. var rowFirst = tbSelect.First();
  11752. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11753. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11754. var takeOffTime = DateTime.Parse(timeArr[i]);
  11755. var fallToTime = DateTime.Parse(timeArr[i]);
  11756. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11757. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11758. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11759. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11760. foreach (var item in tbSelect)
  11761. {
  11762. var start = string.Empty;
  11763. var end = string.Empty;
  11764. var threeCode = item["Three"].ToString() ?? "";
  11765. if (threeCode.Length == 6)
  11766. {
  11767. start = threeCode.Substring(0, 3);
  11768. end = threeCode.Substring(3, 3);
  11769. if (threeCodeStr.Count == 0)
  11770. {
  11771. threeCodeStr.Add(start);
  11772. threeCodeStr.Add(end);
  11773. }
  11774. else
  11775. {
  11776. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11777. {
  11778. threeCodeStr.Add(end);
  11779. }
  11780. else
  11781. {
  11782. threeCodeStr.Add(start);
  11783. threeCodeStr.Add(end);
  11784. }
  11785. }
  11786. }
  11787. //处理机票信息
  11788. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11789. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11790. if (start_Object == null)
  11791. {
  11792. start_Object = new Res_ThreeCode()
  11793. {
  11794. AirPort = empty,
  11795. AirPort_En = empty,
  11796. City = empty,
  11797. Country = empty,
  11798. Four = empty,
  11799. Three = empty,
  11800. };
  11801. }
  11802. if (end_Object == null)
  11803. {
  11804. end_Object = new Res_ThreeCode()
  11805. {
  11806. AirPort = empty,
  11807. AirPort_En = empty,
  11808. City = empty,
  11809. Country = empty,
  11810. Four = empty,
  11811. Three = empty,
  11812. };
  11813. }
  11814. //机型判断
  11815. string airModel = item["AirModel"].ToString();
  11816. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11817. string flightTime = item["FlightTime"].ToString();
  11818. if (flightTime!.Contains(":"))
  11819. {
  11820. flightTime = flightTime.Replace(":", "小时");
  11821. flightTime += "分钟";
  11822. }
  11823. if (flightTime.Contains("H"))
  11824. {
  11825. flightTime = flightTime.Replace("H", "小时");
  11826. }
  11827. if (flightTime.Contains("M"))
  11828. {
  11829. flightTime = flightTime.Replace("M", "分钟");
  11830. }
  11831. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  11832. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  11833. {
  11834. flightTime = flightDataTime.Hour > 0
  11835. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  11836. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  11837. ? flightDataTime.Minute.ToString() + "分钟" : "";
  11838. }
  11839. //航班号
  11840. string flightcode = item["Fliagtcode"].ToString();
  11841. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11842. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11843. if (aircompany == null)
  11844. {
  11845. aircompany = new Res_AirCompany
  11846. {
  11847. CnName = hsEmpty,
  11848. EnName = hsEmpty,
  11849. ShortCode = hsEmpty,
  11850. };
  11851. }
  11852. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11853. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11854. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11855. if (isTrade)
  11856. {
  11857. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  11858. }
  11859. else
  11860. {
  11861. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11862. }
  11863. }
  11864. chiarr.Add(new Grp_ApprovalTravelDetails
  11865. {
  11866. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  11867. CreateTime = DateTime.Now,
  11868. CreateUserId = dto.Userid,
  11869. ParentId = 0,
  11870. Details = trip
  11871. });
  11872. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11873. var last = threeCodeStr.Last();
  11874. foreach (var item in threeCodeStr)
  11875. {
  11876. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11877. if (item.Equals(last))
  11878. {
  11879. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11880. }
  11881. }
  11882. cityPath = cityPath.Trim('-');
  11883. }
  11884. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11885. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11886. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11887. appro.Diid = dto.Diid;
  11888. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11889. appro.Id = thisId;
  11890. appro.CreateUserId = dto.Userid;
  11891. appro.CreateTime = DateTime.Now;
  11892. foreach (var item in gwinfo)
  11893. {
  11894. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11895. chi.Details = "拜访" + item.Client;
  11896. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  11897. {
  11898. chi.Details += "," + item.ReqSample;
  11899. }
  11900. chi.ParentId = thisId;
  11901. chi.Time = item.Time;
  11902. chiarr.Add(chi);
  11903. }
  11904. if (chiarr.Count < 5)
  11905. {
  11906. for (int j = chiarr.Count; j < 5; j++)
  11907. {
  11908. chiarr.Add(new
  11909. Grp_ApprovalTravelDetails());
  11910. }
  11911. }
  11912. resultArr.Add(new
  11913. {
  11914. appro.Id,
  11915. appro.Date,
  11916. appro.Diid,
  11917. chiList = chiarr.Select(x1 => new
  11918. {
  11919. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11920. x1.Details,
  11921. x1.ParentId,
  11922. x1.Id
  11923. })
  11924. });
  11925. }
  11926. _sqlSugar.CommitTran();
  11927. jw = JsonView(true, "生成成功!", resultArr);
  11928. }
  11929. catch (Exception ex)
  11930. {
  11931. jw.Code = 400;
  11932. jw.Msg = "生成失败!" + ex.Message;
  11933. }
  11934. return Ok(jw);
  11935. }
  11936. /// <summary>
  11937. /// 报批行程word导出
  11938. /// </summary>
  11939. /// <param name="dto"></param>
  11940. /// <returns></returns>
  11941. [HttpPost]
  11942. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11943. {
  11944. var jw = JsonView(false);
  11945. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11946. if (group == null)
  11947. {
  11948. jw.Msg = "暂无该团组!";
  11949. return Ok(jw);
  11950. }
  11951. //模板路径
  11952. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  11953. //载入模板
  11954. Document doc = new Document(tempPath);
  11955. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11956. //获取所填表格的序数
  11957. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11958. Aspose.Words.Tables.Row titleRowClone = null;
  11959. Aspose.Words.Tables.Row CenterRowClone = null;
  11960. int index = 0;
  11961. int indexChi = 0;
  11962. int SetIndex = 0;
  11963. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11964. //获取数据,放到datatable
  11965. foreach (var item in ApprovalTravelArr)
  11966. {
  11967. if (index > 0)
  11968. {
  11969. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11970. tableOne.AppendChild(titleRowClone);
  11971. }
  11972. var textTime = item.Date;
  11973. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11974. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11975. SetIndex++;
  11976. if (ChiRep.Count > 0)
  11977. {
  11978. foreach (var itemChi in ChiRep)
  11979. {
  11980. var txtTime = itemChi.Time;
  11981. var txtDetail = itemChi.Details;
  11982. if (indexChi > 0)
  11983. {
  11984. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11985. tableOne.AppendChild(CenterRowClone);
  11986. }
  11987. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11988. {
  11989. SetCells(tableOne, doc, SetIndex, 0, "");
  11990. SetCells(tableOne, doc, SetIndex, 1, "");
  11991. indexChi++;
  11992. SetIndex++;
  11993. break;
  11994. }
  11995. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11996. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11997. indexChi++;
  11998. SetIndex++;
  11999. }
  12000. }
  12001. else
  12002. {
  12003. if (indexChi > 0)
  12004. {
  12005. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12006. tableOne.AppendChild(CenterRowClone);
  12007. }
  12008. SetCells(tableOne, doc, SetIndex, 0, "");
  12009. SetCells(tableOne, doc, SetIndex, 1, "");
  12010. indexChi++;
  12011. SetIndex++;
  12012. }
  12013. index++;
  12014. }
  12015. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12016. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12017. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12018. jw.Code = 200;
  12019. jw.Msg = "";
  12020. return Ok(jw);
  12021. }
  12022. private string intToString(int numberVal)
  12023. {
  12024. string numberval = numberVal.ToString();
  12025. Dictionary<char, string> Number = new Dictionary<char, string>();
  12026. Number.Add('1', "一");
  12027. Number.Add('2', "二");
  12028. Number.Add('3', "三");
  12029. Number.Add('4', "四");
  12030. Number.Add('5', "五");
  12031. Number.Add('6', "六");
  12032. Number.Add('7', "七");
  12033. Number.Add('8', "八");
  12034. Number.Add('9', "九");
  12035. string stringNumberVal = string.Empty;
  12036. for (int i = 0; i < numberval.Length; i++)
  12037. {
  12038. if (i == 0)
  12039. {
  12040. stringNumberVal += Number[numberval[i]];
  12041. }
  12042. else if (i >= 1)
  12043. {
  12044. if (numberval[i] == '0')
  12045. {
  12046. stringNumberVal = "十";
  12047. }
  12048. else
  12049. {
  12050. stringNumberVal += "十" + Number[numberval[i]];
  12051. }
  12052. }
  12053. }
  12054. return stringNumberVal;
  12055. }
  12056. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12057. {
  12058. //获取table中的某个单元格,从0开始
  12059. Cell lshCell = table.Rows[rows].Cells[cells];
  12060. //将单元格中段落移除
  12061. foreach (Node item in lshCell.Paragraphs)
  12062. {
  12063. lshCell.Paragraphs.Remove(item);
  12064. }
  12065. if (val.Contains("\r\n"))
  12066. {
  12067. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12068. foreach (var item in spArr)
  12069. {
  12070. //新建一个段落
  12071. Paragraph p = new Paragraph(doc);
  12072. var r = new Run(doc, item);
  12073. //把设置的值赋给之前新建的段落
  12074. p.AppendChild(r);
  12075. //将此段落加到单元格内
  12076. lshCell.AppendChild(p);
  12077. }
  12078. }
  12079. else
  12080. {
  12081. //新建一个段落
  12082. Paragraph p = new Paragraph(doc);
  12083. var r = new Run(doc, val);
  12084. //把设置的值赋给之前新建的段落
  12085. p.AppendChild(r);
  12086. //将此段落加到单元格内
  12087. lshCell.AppendChild(p);
  12088. }
  12089. }
  12090. [HttpPost]
  12091. public async Task<IActionResult> ServerHttp(string paramStr)
  12092. {
  12093. paramStr = paramStr.TrimEnd('\'');
  12094. paramStr = paramStr.TrimStart('\'');
  12095. JsonView jw = JsonView(false);
  12096. JObject param = JObject.Parse(paramStr);
  12097. if (!param.ContainsKey("url"))
  12098. {
  12099. jw.Msg = "url null";
  12100. return Ok(jw);
  12101. }
  12102. string url = param["url"]!.ToString();
  12103. var methon = "get";
  12104. Dictionary<string, string> bodyValues = null;
  12105. Dictionary<string, string> headValues = null;
  12106. if (param.ContainsKey("methon"))
  12107. {
  12108. methon = param["methon"]!.ToString();
  12109. }
  12110. if (param.ContainsKey("header"))
  12111. {
  12112. var header = param["header"]!.ToString();
  12113. JObject headerJobject = JObject.Parse(header);
  12114. headValues = new Dictionary<string, string>();
  12115. foreach (JProperty item in headerJobject.Properties())
  12116. {
  12117. var value = item.Value.ToString();
  12118. var head = item.Path;
  12119. headValues.Add(head, value);
  12120. }
  12121. }
  12122. if (param.ContainsKey("body"))
  12123. {
  12124. var body = param["body"]!.ToString();
  12125. bodyValues = new Dictionary<string, string>();
  12126. JObject bodyJobject = JObject.Parse(body);
  12127. foreach (JProperty item in bodyJobject.Properties())
  12128. {
  12129. var value = item.Value.ToString();
  12130. var head = item.Path;
  12131. bodyValues.Add(head, value);
  12132. }
  12133. }
  12134. HttpClient client = new HttpClient();
  12135. string responseString = string.Empty;
  12136. if (param.ContainsKey("isJson"))
  12137. {
  12138. }
  12139. if (headValues != null)
  12140. {
  12141. foreach (var item in headValues.Keys)
  12142. {
  12143. client.DefaultRequestHeaders.Add(item, headValues[item]);
  12144. }
  12145. }
  12146. try
  12147. {
  12148. if (methon == "get")
  12149. {
  12150. responseString = await client.GetStringAsync(url);
  12151. }
  12152. else if (methon == "post")
  12153. {
  12154. if (bodyValues == null)
  12155. {
  12156. jw.Msg = "methon post body null";
  12157. return Ok(jw);
  12158. }
  12159. // 数据转化为 key=val 格式
  12160. var content = new FormUrlEncodedContent(bodyValues);
  12161. var response = await client.PostAsync(url, content);
  12162. // 获取数据
  12163. responseString = await response.Content.ReadAsStringAsync();
  12164. }
  12165. else
  12166. {
  12167. jw.Msg = "methon error";
  12168. }
  12169. jw = JsonView(true, "success", responseString);
  12170. }
  12171. catch (Exception ex)
  12172. {
  12173. jw.Msg = "error " + ex.Message;
  12174. jw.Data = ex.StackTrace;
  12175. }
  12176. finally
  12177. {
  12178. client.Dispose();
  12179. }
  12180. return Ok(jw);
  12181. }
  12182. #endregion
  12183. // /// <summary>
  12184. // ///
  12185. // /// </summary>
  12186. // /// <param name="_dto"></param>
  12187. // /// <returns></returns>
  12188. // [HttpPost]
  12189. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12190. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12191. // {
  12192. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12193. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  12194. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  12195. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12196. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  12197. // dic_psg.Add("客人", 974);
  12198. // dic_psg.Add("司机", 975);
  12199. // dic_psg.Add("导游", 976);
  12200. // dic_psg.Add("公司内部人员", 977);
  12201. // dic_psg.Add("司机/导游/公司内部人员", 978);
  12202. // foreach (var item in list_visa)
  12203. // {
  12204. // Grp_VisaInfo temp = new Grp_VisaInfo();
  12205. // temp.Id = item.Id;
  12206. // temp.DIId = item.DIId;
  12207. // temp.VisaClient = item.VisaClient;
  12208. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  12209. // temp.VisaCurrency = item.VisaCurrency;
  12210. // temp.IsThird = item.IsThird;
  12211. // if (dic_psg.ContainsKey(item.PassengerType))
  12212. // {
  12213. // temp.PassengerType = dic_psg[item.PassengerType];
  12214. // }
  12215. // else {
  12216. // temp.PassengerType = -1;
  12217. // }
  12218. // temp.VisaNumber = item.VisaNumber;
  12219. // temp.VisaFreeNumber = item.VisaFreeNumber;
  12220. // temp.CreateUserId = item.Operators;
  12221. // DateTime dt_ct;
  12222. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  12223. // if (b_ct)
  12224. // {
  12225. // temp.CreateTime = dt_ct;
  12226. // }
  12227. // else
  12228. // {
  12229. // temp.CreateTime = DateTime.Now;
  12230. // }
  12231. // temp.DeleteTime = "";
  12232. // temp.DeleteUserId = 0;
  12233. // temp.Remark = item.Remark;
  12234. // if (string.IsNullOrEmpty(temp.Remark)) {
  12235. // temp.Remark = "";
  12236. // }
  12237. // temp.IsDel = item.IsDel;
  12238. // temp.VisaDescription = item.VisaAttachment;
  12239. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  12240. //([Id]
  12241. // ,[DIId]
  12242. // ,[VisaClient]
  12243. // ,[VisaPrice]
  12244. // ,[VisaCurrency]
  12245. // ,[IsThird]
  12246. // ,[PassengerType]
  12247. // ,[VisaNumber]
  12248. // ,[VisaFreeNumber]
  12249. // ,[CreateUserId]
  12250. // ,[CreateTime]
  12251. // ,[DeleteTime]
  12252. // ,[DeleteUserId]
  12253. // ,[Remark]
  12254. // ,[IsDel]
  12255. // ,[visaDescription])
  12256. // VALUES
  12257. // ({0},{1},'{2}',{3},{4}
  12258. //,{5},{6},{7},{8},{9}
  12259. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  12260. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  12261. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  12262. //);
  12263. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  12264. // }
  12265. // return Ok(JsonView(true, "操作成功!"));
  12266. // }
  12267. /// <summary>
  12268. /// 123132123
  12269. /// </summary>
  12270. /// <param name="_dto"></param>
  12271. /// <returns></returns>
  12272. [HttpPost]
  12273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12274. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12275. {
  12276. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12277. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  12278. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  12279. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12280. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  12281. dicDetail.Add(789, 1034);
  12282. dicDetail.Add(790, 1035);
  12283. dicDetail.Add(791, 1036);
  12284. dicDetail.Add(792, 1037);
  12285. dicDetail.Add(793, 1038);
  12286. dicDetail.Add(794, 1039);
  12287. dicDetail.Add(795, 1040);
  12288. dicDetail.Add(796, 1041);
  12289. dicDetail.Add(797, 1042);
  12290. dicDetail.Add(798, 1043);
  12291. dicDetail.Add(801, 1044);
  12292. dicDetail.Add(802, 1045);
  12293. dicDetail.Add(803, 1046);
  12294. Dictionary<int, int> dic = new Dictionary<int, int>();
  12295. dic.Add(806, 1027);
  12296. dic.Add(807, 1028);
  12297. dic.Add(808, 1029);
  12298. dic.Add(809, 1030);
  12299. dic.Add(810, 1031);
  12300. dic.Add(811, 1032);
  12301. dic.Add(812, 1033);
  12302. foreach (var item in list_visa)
  12303. {
  12304. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  12305. temp.Coefficient = item.coefficient;
  12306. DateTime dtCrt;
  12307. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  12308. if (b1)
  12309. {
  12310. temp.CreateTime = dtCrt;
  12311. }
  12312. else
  12313. {
  12314. temp.CreateTime = DateTime.Now;
  12315. }
  12316. temp.CreateUserId = item.Operators;
  12317. temp.DeleteTime = "";
  12318. temp.DeleteUserId = 0;
  12319. temp.DiId = int.Parse(item.DIID);
  12320. temp.FilePath = item.FilePath;
  12321. temp.IsDel = item.IsDel;
  12322. temp.Price = item.Price;
  12323. temp.PriceCount = 1;
  12324. temp.PriceCurrency = item.Currency;
  12325. int detailId = 0;
  12326. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  12327. {
  12328. detailId = dicDetail[item.PriceTypeDetail];
  12329. }
  12330. temp.PriceDetailType = detailId;
  12331. temp.PriceDt = DateTime.Now;
  12332. temp.PriceName = item.PriceName;
  12333. temp.PriceSum = item.Price;
  12334. int tid = 0;
  12335. if (dic.ContainsKey(item.PriceType))
  12336. {
  12337. tid = dic[item.PriceType];
  12338. }
  12339. temp.PriceType = tid;
  12340. temp.Remark = item.Remark;
  12341. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  12342. }
  12343. return Ok(JsonView(true, "操作成功!"));
  12344. }
  12345. }
  12346. }