GroupsController.cs 763 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using EyeSoft.Collections.Generic;
  7. using EyeSoft.IO;
  8. using Microsoft.AspNetCore.SignalR;
  9. using MySqlX.XDevAPI.Relational;
  10. using NPOI.HSSF.UserModel;
  11. using NPOI.SS.Format;
  12. using NPOI.SS.UserModel;
  13. using NPOI.SS.Util;
  14. using NPOI.XSSF.UserModel;
  15. using OASystem.API.OAMethodLib;
  16. using OASystem.API.OAMethodLib.File;
  17. using OASystem.API.OAMethodLib.Hub.HubClients;
  18. using OASystem.API.OAMethodLib.Hub.Hubs;
  19. using OASystem.API.OAMethodLib.JuHeAPI;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.Dtos.CRM;
  22. using OASystem.Domain.Dtos.FileDto;
  23. using OASystem.Domain.Dtos.Financial;
  24. using OASystem.Domain.Dtos.Groups;
  25. using OASystem.Domain.Entities.Customer;
  26. using OASystem.Domain.Entities.Financial;
  27. using OASystem.Domain.Entities.Groups;
  28. using OASystem.Domain.ViewModels;
  29. using OASystem.Domain.ViewModels.Groups;
  30. using OASystem.Domain.ViewModels.Statistics;
  31. using OASystem.Infrastructure.Repositories.Financial;
  32. using OASystem.Infrastructure.Repositories.Groups;
  33. using OfficeOpenXml;
  34. using Org.BouncyCastle.Asn1.Ocsp;
  35. using Quartz.Util;
  36. using SqlSugar;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Data.OleDb;
  41. using System.Diagnostics;
  42. using System.Globalization;
  43. using System.IO;
  44. using System.IO.Compression;
  45. using System.Net.Http;
  46. using System.Reflection.PortableExecutable;
  47. using System.Security.Cryptography;
  48. using Ubiety.Dns.Core;
  49. using static NPOI.POIFS.Crypt.CryptoFunctions;
  50. using static OASystem.API.OAMethodLib.JWTHelper;
  51. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  52. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  53. using Bookmark = Aspose.Words.Bookmark;
  54. using Cell = Aspose.Words.Tables.Cell;
  55. using Table = Aspose.Words.Tables.Table;
  56. namespace OASystem.API.Controllers
  57. {
  58. /// <summary>
  59. /// 团组相关
  60. /// </summary>
  61. //[Authorize]
  62. [Route("api/[controller]/[action]")]
  63. public class GroupsController : ControllerBase
  64. {
  65. private readonly ILogger<GroupsController> _logger;
  66. private readonly GrpScheduleRepository _grpScheduleRep;
  67. private readonly IMapper _mapper;
  68. private readonly DelegationInfoRepository _groupRepository;
  69. private readonly TaskAssignmentRepository _taskAssignmentRep;
  70. private readonly AirTicketResRepository _airTicketResRep;
  71. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  72. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  73. private readonly DelegationEnDataRepository _delegationEnDataRep;
  74. private readonly DelegationVisaRepository _delegationVisaRep;
  75. private readonly VisaPriceRepository _visaPriceRep;
  76. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  77. private readonly HotelPriceRepository _hotelPriceRep;
  78. private readonly CustomersRepository _customersRep;
  79. private readonly MessageRepository _message;
  80. private readonly SqlSugarClient _sqlSugar;
  81. private readonly TourClientListRepository _tourClientListRep;
  82. private readonly TeamRateRepository _teamRateRep;
  83. #region 成本相关
  84. private readonly CheckBoxsRepository _checkBoxs;
  85. private readonly GroupCostRepository _GroupCostRepository;
  86. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  87. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  88. #endregion
  89. private readonly SetDataRepository _setDataRep;
  90. private string url;
  91. private string path;
  92. private readonly EnterExitCostRepository _enterExitCostRep;
  93. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  94. private readonly UsersRepository _usersRep;
  95. private readonly IJuHeApiService _juHeApi;
  96. private readonly InvertedListRepository _invertedListRep;
  97. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  98. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  99. private readonly ThreeCodeRepository _threeCodeRepository;
  100. private readonly HotelInquiryRepository _hotelInquiryRep;
  101. private readonly FeeAuditRepository _feeAuditRep;
  102. private readonly VisaCommissionRepository _visaCommissionRep;
  103. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  104. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  105. public GroupsController(
  106. ILogger<GroupsController> logger,
  107. IMapper mapper,
  108. IHubContext<ChatHub, IChatClient> hubContext,
  109. SqlSugarClient sqlSugar,
  110. GrpScheduleRepository grpScheduleRep,
  111. DelegationInfoRepository groupRepository,
  112. TaskAssignmentRepository taskAssignmentRep,
  113. AirTicketResRepository airTicketResRep,
  114. DecreasePaymentsRepository decreasePaymentsRep,
  115. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  116. DelegationEnDataRepository delegationEnDataRep,
  117. EnterExitCostRepository enterExitCostRep,
  118. DelegationVisaRepository delegationVisaRep,
  119. MessageRepository message,
  120. VisaPriceRepository visaPriceRep,
  121. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  122. CheckBoxsRepository checkBoxs,
  123. GroupCostRepository GroupCostRepository,
  124. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  125. GroupCostParameterRepository GroupCostParameterRepository,
  126. HotelPriceRepository hotelPriceRep,
  127. CustomersRepository customersRep,
  128. SetDataRepository setDataRep,
  129. TourClientListRepository tourClientListRep,
  130. TeamRateRepository teamRateRep,
  131. UsersRepository usersRep, IJuHeApiService juHeApi,
  132. InvertedListRepository invertedListRep,
  133. VisaFeeInfoRepository visaFeeInfoRep,
  134. TicketBlackCodeRepository ticketBlackCodeRep,
  135. HotelInquiryRepository hotelInquiryRep,
  136. ThreeCodeRepository threeCodeRepository,
  137. FeeAuditRepository feeAuditRep,
  138. VisaCommissionRepository visaCommissionRep,
  139. ForeignReceivablesRepository ffrRep,
  140. OpinionaireRepository opinionaireRep
  141. )
  142. {
  143. _logger = logger;
  144. _mapper = mapper;
  145. _grpScheduleRep = grpScheduleRep;
  146. _groupRepository = groupRepository;
  147. _taskAssignmentRep = taskAssignmentRep;
  148. _airTicketResRep = airTicketResRep;
  149. _sqlSugar = sqlSugar;
  150. url = AppSettingsHelper.Get("ExcelBaseUrl");
  151. path = AppSettingsHelper.Get("ExcelBasePath");
  152. if (!System.IO.Directory.Exists(path))
  153. {
  154. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  155. }
  156. _decreasePaymentsRep = decreasePaymentsRep;
  157. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  158. _delegationEnDataRep = delegationEnDataRep;
  159. _enterExitCostRep = enterExitCostRep;
  160. _delegationVisaRep = delegationVisaRep;
  161. _message = message;
  162. _visaPriceRep = visaPriceRep;
  163. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  164. _checkBoxs = checkBoxs;
  165. _GroupCostRepository = GroupCostRepository;
  166. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  167. _GroupCostParameterRepository = GroupCostParameterRepository;
  168. _hotelPriceRep = hotelPriceRep;
  169. _customersRep = customersRep;
  170. _setDataRep = setDataRep;
  171. _tourClientListRep = tourClientListRep;
  172. _teamRateRep = teamRateRep;
  173. _hubContext = hubContext;
  174. _usersRep = usersRep;
  175. _juHeApi = juHeApi;
  176. _invertedListRep = invertedListRep;
  177. _visaFeeInfoRep = visaFeeInfoRep;
  178. _ticketBlackCodeRep = ticketBlackCodeRep;
  179. _hotelInquiryRep = hotelInquiryRep;
  180. _threeCodeRepository = threeCodeRepository;
  181. _feeAuditRep = feeAuditRep;
  182. _visaCommissionRep = visaCommissionRep;
  183. _ffrRep = ffrRep;
  184. _opinionaireRep = opinionaireRep;
  185. }
  186. #region 流程管控
  187. /// <summary>
  188. /// 获取团组流程管控信息
  189. /// </summary>
  190. /// <param name="paras">参数Json字符串</param>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  195. {
  196. if (string.IsNullOrEmpty(_jsonDto.Paras))
  197. {
  198. return Ok(JsonView(false, "参数为空"));
  199. }
  200. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  201. if (_ScheduleDto != null)
  202. {
  203. if (_ScheduleDto.SearchType == 2)//获取列表
  204. {
  205. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  206. return Ok(JsonView(_grpScheduleViewList));
  207. }
  208. else//获取对象
  209. {
  210. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  211. if (_grpScheduleView != null)
  212. {
  213. return Ok(JsonView(_grpScheduleView));
  214. }
  215. }
  216. }
  217. else
  218. {
  219. return Ok(JsonView(false, "参数反序列化失败"));
  220. }
  221. return Ok(JsonView(false, "暂无数据!"));
  222. }
  223. /// <summary>
  224. /// 修改团组流程管控详细表数据
  225. /// </summary>
  226. /// <param name="paras"></param>
  227. /// <returns></returns>
  228. [HttpPost]
  229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  230. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  231. {
  232. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  233. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  234. .SetColumns(it => it.Duty == _detail.Duty)
  235. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  236. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  237. .SetColumns(it => it.JobContent == _detail.JobContent)
  238. .SetColumns(it => it.Remark == _detail.Remark)
  239. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  240. .Where(s => s.Id == dto.Id)
  241. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  242. .ExecuteCommandAsync();
  243. if (result > 0)
  244. {
  245. return Ok(JsonView(true, "保存成功!"));
  246. }
  247. return Ok(JsonView(false, "保存失败!"));
  248. }
  249. /// <summary>
  250. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  251. /// </summary>
  252. /// <param name="dto"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  257. {
  258. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  259. _detail.IsDel = 1;
  260. _detail.DeleteUserId = dto.Duty;
  261. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  262. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  263. .SetColumns(it => it.IsDel == _detail.IsDel)
  264. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  265. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  266. .Where(it => it.Id == dto.Id)
  267. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  268. //.WhereColumns(s => s.Id == dto.Id)
  269. .ExecuteCommandAsync();
  270. if (result > 0)
  271. {
  272. return Ok(JsonView(true, "删除成功!"));
  273. }
  274. return Ok(JsonView(false, "删除失败!"));
  275. }
  276. /// <summary>
  277. /// 增加团组流程管控详细表数据
  278. /// </summary>
  279. /// <param name="dto"></param>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  284. {
  285. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  286. if (DateTime.Now < _detail.ExpectBeginDt)
  287. {
  288. _detail.StepStatus = 0;
  289. }
  290. else
  291. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  292. _detail.StepStatus = 1;
  293. }
  294. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  295. if (result > 0)
  296. {
  297. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  298. return Ok(JsonView(true, "添加成功!", _result));
  299. }
  300. return Ok(JsonView(false, "添加失败!"));
  301. }
  302. #endregion
  303. #region 团组基本信息
  304. /// <summary>
  305. /// 接团信息列表
  306. /// </summary>
  307. /// <param name="dto">团组列表请求dto</param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  312. {
  313. var groupData = await _groupRepository.GetGroupList(dto);
  314. if (groupData.Code != 0)
  315. {
  316. return Ok(JsonView(false, groupData.Msg));
  317. }
  318. return Ok(JsonView(groupData.Data));
  319. }
  320. /// <summary>
  321. /// 分页查询团组列表
  322. /// </summary>
  323. /// <param name="dto"></param>
  324. /// <returns></returns>
  325. [HttpPost]
  326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  327. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  328. {
  329. var watch = new Stopwatch();
  330. watch.Start();
  331. RefAsync<int> total = 0;
  332. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  333. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  334. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  335. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  336. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  337. .Distinct()
  338. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  339. watch.Stop();
  340. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  341. }
  342. /// <summary>
  343. /// 接团信息列表 Page
  344. /// </summary>
  345. /// <param name="dto">团组列表请求dto</param>
  346. /// <returns></returns>
  347. [HttpPost]
  348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  349. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  350. {
  351. #region 参数验证
  352. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  353. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  354. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  355. #region 页面操作权限验证
  356. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  357. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  358. #endregion
  359. #endregion
  360. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  361. {
  362. string sqlWhere = string.Empty;
  363. if (dto.IsSure == 0) //未完成
  364. {
  365. sqlWhere += string.Format(@" And IsSure = 0");
  366. }
  367. else if (dto.IsSure == 1) //已完成
  368. {
  369. sqlWhere += string.Format(@" And IsSure = 1");
  370. }
  371. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  372. {
  373. string tj = dto.SearchCriteria;
  374. 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}%')",
  375. tj, tj, tj, tj, tj);
  376. }
  377. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  378. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  379. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  380. JietuanOperator,IsSure,CreateTime,IsBid
  381. From (
  382. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  383. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  384. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  385. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  386. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  387. From Grp_DelegationInfo gdi
  388. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  389. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  390. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  391. Where gdi.IsDel = 0 {0}
  392. ) temp", sqlWhere);
  393. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  394. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  395. #region 处理所属部门
  396. /*
  397. * 1.sq 和 gyy 等显示 市场部
  398. * 2.王鸽和主管及张总还有管理员号统一国交部
  399. * 2-1. 4 管理员 ,21 张海麟
  400. */
  401. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  402. List<int> userIds1 = new List<int>() { 4, 21 };
  403. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  404. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  405. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  406. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  407. .ToList();
  408. foreach (var item in _DelegationList)
  409. {
  410. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  411. }
  412. #endregion
  413. var _view = new
  414. {
  415. PageFuncAuth = pageFunAuthView,
  416. Data = _DelegationList
  417. };
  418. return Ok(JsonView(true, "查询成功!", _view, total));
  419. }
  420. else
  421. {
  422. return Ok(JsonView(false, "查询失败"));
  423. }
  424. }
  425. /// <summary>
  426. /// 团组列表
  427. /// </summary>
  428. /// <returns></returns>
  429. [HttpPost]
  430. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  431. {
  432. #region 参数验证
  433. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  434. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  435. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  436. #region 页面操作权限验证
  437. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  438. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  439. #endregion
  440. #endregion
  441. if (dto.PortType != 1 && dto.PortType != 2)
  442. {
  443. return Ok(JsonView(false, "查询失败!"));
  444. }
  445. string orderbyStr = "order by gdi.CreateTime Desc";
  446. string sqlWhere = string.Empty;
  447. if (dto.IsSure == 0) //未完成
  448. {
  449. sqlWhere += string.Format(@" And IsSure = 0");
  450. }
  451. else if (dto.IsSure == 1) //已完成
  452. {
  453. sqlWhere += string.Format(@" And IsSure = 1");
  454. }
  455. //团组类型
  456. if (dto.TeamDid > 0)
  457. {
  458. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  459. }
  460. //团组名称
  461. if (!string.IsNullOrEmpty(dto.TeamName))
  462. {
  463. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  464. }
  465. //客户名称
  466. if (!string.IsNullOrEmpty(dto.ClientName))
  467. {
  468. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  469. }
  470. //客户单位
  471. if (!string.IsNullOrEmpty(dto.ClientUnit))
  472. {
  473. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  474. }
  475. //出访时间
  476. if (!string.IsNullOrEmpty(dto.visitDataTime))
  477. {
  478. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  479. orderbyStr = "order by gdi.VisitDate";
  480. }
  481. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  482. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  483. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  484. JietuanOperator,IsSure,CreateTime
  485. From (
  486. Select row_number() over({0}) as Row_Number,
  487. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  488. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  489. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  490. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  491. From Grp_DelegationInfo gdi
  492. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  493. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  494. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  495. Where gdi.IsDel = 0 {1}
  496. ) temp ", orderbyStr, sqlWhere);
  497. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  498. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  499. #region 处理所属部门
  500. /*
  501. * 1.sq 和 gyy 等显示 市场部
  502. * 2.王鸽和主管及张总还有管理员号统一国交部
  503. * 2-1. 4 管理员 ,21 张海麟
  504. */
  505. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  506. List<int> userIds1 = new List<int>() { 4, 21 };
  507. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  508. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  509. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  510. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  511. .ToList();
  512. foreach (var item in _DelegationList)
  513. {
  514. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  515. }
  516. #endregion
  517. var _view = new
  518. {
  519. PageFuncAuth = pageFunAuthView,
  520. Data = _DelegationList
  521. };
  522. return Ok(JsonView(true, "查询成功!", _view, total));
  523. }
  524. /// <summary>
  525. /// 接团信息详情
  526. /// </summary>
  527. /// <param name="dto">团组info请求dto</param>
  528. /// <returns></returns>
  529. [HttpPost]
  530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  531. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  532. {
  533. var groupData = await _groupRepository.GetGroupInfo(dto);
  534. if (groupData.Code != 0)
  535. {
  536. return Ok(JsonView(false, groupData.Msg));
  537. }
  538. return Ok(JsonView(groupData.Data));
  539. }
  540. /// <summary>
  541. /// 接团信息 编辑添加
  542. /// 基础信息数据源
  543. /// </summary>
  544. /// <param name="dto"></param>
  545. /// <returns></returns>
  546. [HttpPost]
  547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  548. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  549. {
  550. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  551. if (groupData.Code != 0)
  552. {
  553. return Ok(JsonView(false, groupData.Msg));
  554. }
  555. return Ok(JsonView(groupData.Data));
  556. }
  557. /// <summary>
  558. /// 接团信息 操作(增改)
  559. /// </summary>
  560. /// <param name="dto"></param>
  561. /// <returns></returns>
  562. [HttpPost]
  563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  564. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  565. {
  566. try
  567. {
  568. decimal ffrPrice = 0.00M;
  569. DateTime? visitDt = null;
  570. if (dto.Status == 2)
  571. {
  572. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  573. if (groupInfo != null)
  574. {
  575. ffrPrice = groupInfo.PaymentMoney;
  576. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  577. }
  578. }
  579. var groupData = await _groupRepository.GroupOperation(dto);
  580. if (groupData.Code != 0)
  581. {
  582. return Ok(JsonView(false, groupData.Msg));
  583. }
  584. int diId = 0;
  585. //添加时 默认加入团组汇率
  586. if (dto.Status == 1) //添加
  587. {
  588. diId = groupData.Data;
  589. //添加默认币种
  590. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  591. //默认分配权限
  592. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  593. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  594. var _managerIds = new List<int>() { 22, 32, 21 };
  595. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  596. if (userIds.Count > 0)
  597. {
  598. userIds.Add(208);
  599. //创建团组管控
  600. GroupStepForDelegation.CreateWorkStep(diId);
  601. //发送消息
  602. string groupName = dto.TeamName;
  603. string createGroupUser = string.Empty;
  604. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  605. if (userInfo != null) createGroupUser = userInfo.CnName;
  606. string title = $"系统通知";
  607. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  608. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  609. }
  610. //默认创建倒推表
  611. await _invertedListRep._Create(dto.UserId, diId);
  612. }
  613. else if (dto.Status == 2)
  614. {
  615. diId = dto.Id;
  616. }
  617. #region 签证人员团组时间通知
  618. #region 计算出访起止时间
  619. var startTime = new DateTime();
  620. var endTime = new DateTime();
  621. if (DateTime.TryParse(dto.VisitDate, out startTime))
  622. {
  623. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  624. }
  625. #endregion
  626. if (diId > 0)
  627. {
  628. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  629. }
  630. #endregion
  631. #region 团组操作默认添加/修改收款账单
  632. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  633. {
  634. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  635. .Where(x => x.IsDel == 0 &&
  636. x.Diid == diId &&
  637. x.Remark.Equals("预付款")
  638. )
  639. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  640. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  641. .FirstAsync();
  642. ffrInfo = new Fin_ForeignReceivables()
  643. {
  644. Diid = diId,
  645. PriceName = dto.ClientUnit,
  646. Price = dto.PaymentMoney,
  647. Count = 1,
  648. Unit = $"元",
  649. ItemSumPrice = dto.PaymentMoney,
  650. Rate = 1.0000M,
  651. Currency = 836,
  652. AddingWay = 0,
  653. CreateUserId = dto.UserId,
  654. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  655. Remark = $"预付款"
  656. };
  657. if (ffrInfo == null) //Add
  658. {
  659. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  660. }
  661. else //修改
  662. {
  663. await _sqlSugar.Updateable(ffrInfo)
  664. .UpdateColumns(x => new
  665. {
  666. x.PriceName,
  667. x.Price,
  668. x.ItemSumPrice,
  669. x.CreateTime,
  670. x.CreateUserId
  671. })
  672. .WhereColumns(x => x.Id)
  673. .ExecuteCommandAsync();
  674. }
  675. }
  676. #endregion
  677. return Ok(JsonView(true, "操作成功!", diId));
  678. }
  679. catch (Exception ex)
  680. {
  681. Logs("[response]" + JsonConvert.SerializeObject(dto));
  682. Logs(ex.Message);
  683. return Ok(JsonView(false, ex.Message));
  684. }
  685. }
  686. /// <summary>
  687. /// 接团流程操作(增改)
  688. /// 安卓端使用 建团时添加客户名单
  689. /// </summary>
  690. /// <param name="dto"></param>
  691. /// <returns></returns>
  692. [HttpPost]
  693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  694. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  695. {
  696. try
  697. {
  698. #region 参数验证
  699. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  700. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  701. #region 页面操作权限验证
  702. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  703. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  704. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  705. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  706. #endregion
  707. #endregion
  708. _sqlSugar.BeginTran();
  709. decimal ffrPrice = 0.00M;
  710. DateTime? visitDt = null;
  711. if (dto.Status == 2)
  712. {
  713. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  714. if (groupInfo != null)
  715. {
  716. ffrPrice = groupInfo.PaymentMoney;
  717. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  718. }
  719. }
  720. var _dto = new GroupOperationDto();
  721. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  722. var groupData = await _groupRepository.GroupOperation(_dto);
  723. if (groupData.Code != 0)
  724. {
  725. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  726. }
  727. int diId = 0;
  728. //添加时 默认加入团组汇率
  729. if (dto.Status == 1) //添加
  730. {
  731. diId = groupData.Data;
  732. //添加默认币种
  733. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  734. //默认分配权限
  735. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  736. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  737. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  738. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  739. if (userIds.Count > 0)
  740. {
  741. userIds.Add(208);
  742. //创建团组管控
  743. GroupStepForDelegation.CreateWorkStep(diId);
  744. //发送消息
  745. string groupName = dto.TeamName;
  746. string createGroupUser = string.Empty;
  747. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  748. if (userInfo != null) createGroupUser = userInfo.CnName;
  749. string title = $"系统通知";
  750. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  751. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  752. }
  753. #region 应用推送
  754. try
  755. {
  756. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  757. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  758. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  759. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  760. {
  761. List<string> userList = new List<string>() { users.QiyeChatUserId };
  762. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  763. }
  764. }
  765. catch (Exception ex)
  766. {
  767. }
  768. #endregion
  769. //默认创建倒推表
  770. await _invertedListRep._Create(dto.UserId, diId);
  771. }
  772. if (dto.Status == 2)
  773. {
  774. diId = dto.Id;
  775. if (diId == 0)
  776. {
  777. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  778. }
  779. }
  780. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  781. if (viewData.Code != 0)
  782. {
  783. _sqlSugar.RollbackTran();
  784. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  785. }
  786. #region 团组操作默认添加/修改收款账单
  787. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  788. {
  789. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  790. .Where(x => x.IsDel == 0 &&
  791. x.Diid == diId &&
  792. x.Remark.Equals("预付款")
  793. )
  794. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  795. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  796. .FirstAsync();
  797. ffrInfo = new Fin_ForeignReceivables()
  798. {
  799. Diid = diId,
  800. PriceName = dto.ClientUnit,
  801. Price = dto.PaymentMoney,
  802. Count = 1,
  803. Unit = $"元",
  804. ItemSumPrice = dto.PaymentMoney,
  805. Rate = 1.0000M,
  806. Currency = 836,
  807. AddingWay = 0,
  808. CreateUserId = dto.UserId,
  809. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  810. Remark = $"预付款"
  811. };
  812. if (ffrInfo == null) //Add
  813. {
  814. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  815. }
  816. else //修改
  817. {
  818. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  819. .UpdateColumns(x => new
  820. {
  821. x.PriceName,
  822. x.Price,
  823. x.ItemSumPrice,
  824. x.CreateTime,
  825. x.CreateUserId
  826. })
  827. .WhereColumns(x => x.Id)
  828. .ExecuteCommandAsync();
  829. }
  830. }
  831. #endregion
  832. #region 签证人员团组时间通知
  833. #region 计算出访起止时间
  834. var startTime = new DateTime();
  835. var endTime = new DateTime();
  836. if (DateTime.TryParse(dto.VisitDate, out startTime))
  837. {
  838. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  839. }
  840. #endregion
  841. if (diId > 0)
  842. {
  843. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  844. }
  845. #endregion
  846. _sqlSugar.CommitTran();
  847. return Ok(JsonView(true, "添加成功"));
  848. }
  849. catch (Exception ex)
  850. {
  851. _sqlSugar.RollbackTran();
  852. return Ok(JsonView(false, ex.Message));
  853. }
  854. }
  855. /// <summary>
  856. /// 接团信息 操作(删除)
  857. /// </summary>
  858. /// <param name="dto"></param>
  859. /// <returns></returns>
  860. [HttpPost]
  861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  862. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  863. {
  864. try
  865. {
  866. var groupData = await _groupRepository.GroupDel(dto);
  867. if (groupData.Code != 0)
  868. {
  869. return Ok(JsonView(false, groupData.Msg));
  870. }
  871. return Ok(JsonView(true));
  872. }
  873. catch (Exception ex)
  874. {
  875. Logs("[response]" + JsonConvert.SerializeObject(dto));
  876. Logs(ex.Message);
  877. return Ok(JsonView(false, ex.Message));
  878. }
  879. }
  880. /// <summary>
  881. /// 获取团组销售报价号
  882. /// 团组添加时 使用
  883. /// </summary>
  884. /// <returns></returns>
  885. [HttpPost]
  886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  887. public async Task<IActionResult> GetGroupSalesQuoteNo()
  888. {
  889. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  890. if (groupData.Code != 0)
  891. {
  892. return Ok(JsonView(false, groupData.Msg));
  893. }
  894. object salesQuoteNo = new
  895. {
  896. SalesQuoteNo = groupData.Data
  897. };
  898. return Ok(JsonView(salesQuoteNo));
  899. }
  900. /// <summary>
  901. /// 设置确认出团
  902. /// </summary>
  903. /// <param name="dto"></param>
  904. /// <returns></returns>
  905. [HttpPost]
  906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  907. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  908. {
  909. var groupData = await _groupRepository.ConfirmationGroup(dto);
  910. if (groupData.Code != 0)
  911. {
  912. return Ok(JsonView(false, groupData.Msg));
  913. }
  914. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  915. #region OA消息推送
  916. try
  917. {
  918. string groupName = groupInfo.TeamName;
  919. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  920. List<int> userIds = new List<int>();
  921. listUser.ForEach(s => userIds.Add(s.Id));
  922. string title = $"系统通知";
  923. string content = $"团组[{groupName}]已确认出团!";
  924. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  925. }
  926. catch (Exception ex)
  927. {
  928. }
  929. #endregion
  930. #region 应用推送
  931. try
  932. {
  933. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  934. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  935. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  936. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  937. {
  938. List<string> userList = new List<string>() { users.QiyeChatUserId };
  939. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  940. }
  941. }
  942. catch (Exception ex)
  943. {
  944. }
  945. #endregion
  946. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  947. return Ok(JsonView(true, "操作成功!", groupData.Data));
  948. }
  949. /// <summary>
  950. /// 获取团组名称data And 签证国别Data
  951. /// </summary>
  952. /// <param name="dto"></param>
  953. /// <returns></returns>
  954. [HttpPost]
  955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  956. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  957. {
  958. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  959. if (groupData.Code != 0)
  960. {
  961. return Ok(JsonView(false, groupData.Msg));
  962. }
  963. return Ok(JsonView(groupData.Data));
  964. }
  965. /// <summary>
  966. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  967. /// </summary>
  968. /// <returns></returns>
  969. [HttpPost]
  970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  971. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  972. {
  973. try
  974. {
  975. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  976. if (groupData.Code != 0)
  977. {
  978. return Ok(JsonView(false, groupData.Msg));
  979. }
  980. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  981. }
  982. catch (Exception ex)
  983. {
  984. return Ok(JsonView(false, "程序错误!"));
  985. throw;
  986. }
  987. }
  988. /// <summary>
  989. /// 团组清单 Excel
  990. /// </summary>
  991. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  992. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  993. /// <returns></returns>
  994. [HttpGet]
  995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  996. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  997. {
  998. DateTime _beginDt, _endDt;
  999. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1000. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1001. if (!beginBool && !endBool)
  1002. {
  1003. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1004. }
  1005. string sql = string.Format(@"
  1006. SELECT
  1007. ROW_NUMBER,
  1008. Id,
  1009. SalesQuoteNo,
  1010. TourCode,
  1011. TeamTypeId,
  1012. TeamType,
  1013. TeamLevId,
  1014. TeamLev,
  1015. TeamName,
  1016. ClientName,
  1017. ClientUnit,
  1018. VisitDate,
  1019. VisitDays,
  1020. VisitPNumber,
  1021. JietuanOperatorId,
  1022. JietuanOperator,
  1023. IsSure,
  1024. CreateTime,
  1025. IsBid
  1026. FROM
  1027. (
  1028. SELECT
  1029. ROW_NUMBER() OVER(
  1030. ORDER BY
  1031. gdi.CreateTime Desc
  1032. ) AS ROW_NUMBER,
  1033. gdi.Id,
  1034. SalesQuoteNo,
  1035. TourCode,
  1036. ssd.Id TeamTypeId,
  1037. ssd.Name TeamType,
  1038. ssd1.Id TeamLevId,
  1039. ssd1.Name TeamLev,
  1040. TeamName,
  1041. ClientName,
  1042. ClientUnit,
  1043. VisitDate,
  1044. VisitDays,
  1045. VisitPNumber,
  1046. JietuanOperator JietuanOperatorId,
  1047. su.CnName JietuanOperator,
  1048. IsSure,
  1049. gdi.CreateTime,
  1050. gdi.IsBid
  1051. FROM
  1052. Grp_DelegationInfo gdi
  1053. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1054. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1055. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1056. WHERE
  1057. gdi.IsDel = 0
  1058. AND gdi.IsBid = 0
  1059. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1060. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1061. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1062. #region 处理所属部门
  1063. /*
  1064. * 1.sq 和 gyy 等显示 市场部
  1065. * 2.王鸽和主管及张总还有管理员号统一国交部
  1066. * 2-1. 4 管理员 ,21 张海麟
  1067. */
  1068. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1069. List<int> userIds1 = new List<int>() { 4, 21 };
  1070. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1071. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1072. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1073. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1074. .ToListAsync();
  1075. foreach (var item in groupList)
  1076. {
  1077. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1078. }
  1079. #endregion
  1080. #region Excel
  1081. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1082. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1083. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1084. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1085. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1086. //载入模板
  1087. WorkbookDesigner designer = new WorkbookDesigner();
  1088. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1089. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1090. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1091. dt.TableName = "GroupList";
  1092. designer.SetDataSource(dt);
  1093. designer.Process();
  1094. if (!Directory.Exists(savePath))
  1095. {
  1096. Directory.CreateDirectory(savePath);
  1097. }
  1098. string serverPath = $"{savePath}{fileName}";
  1099. designer.Workbook.Save(serverPath);
  1100. string rst = $"{servicePath}{ftpPath}{fileName}";
  1101. #endregion
  1102. return Ok(JsonView(true, "操作成功!", rst));
  1103. }
  1104. #endregion
  1105. #region 团组&签证
  1106. /// <summary>
  1107. /// 根据团组Id获取签证客户信息List
  1108. /// </summary>
  1109. /// <param name="dto">请求dto</param>
  1110. /// <returns></returns>
  1111. [HttpPost]
  1112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1113. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1114. {
  1115. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1116. if (groupData.Code != 0)
  1117. {
  1118. return Ok(JsonView(false, groupData.Msg));
  1119. }
  1120. return Ok(JsonView(groupData.Data));
  1121. }
  1122. /// <summary>
  1123. /// IOS获取团组签证拍照上传进度01(团组列表)
  1124. /// </summary>
  1125. /// <param name="dto">请求dto</param>
  1126. /// <returns></returns>
  1127. [HttpPost]
  1128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1129. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1130. {
  1131. if (dto == null)
  1132. {
  1133. return Ok(JsonView(false, "参数为空"));
  1134. }
  1135. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1136. return Ok(JsonView(visaList));
  1137. }
  1138. /// <summary>
  1139. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1140. /// </summary>
  1141. /// <returns></returns>
  1142. [HttpPost]
  1143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1144. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1145. {
  1146. if (dto == null)
  1147. {
  1148. return Ok(JsonView(false, "请求错误:"));
  1149. }
  1150. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1151. return Ok(JsonView(list));
  1152. }
  1153. /// <summary>
  1154. /// IOS获取团组签证拍照上传进度03(相册)
  1155. /// </summary>
  1156. /// <returns></returns>
  1157. [HttpPost]
  1158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1159. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1160. {
  1161. if (dto == null)
  1162. {
  1163. return Ok(JsonView(false, "请求错误:"));
  1164. }
  1165. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1166. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1167. list.ForEach(s => s.url = url);
  1168. return Ok(JsonView(list));
  1169. }
  1170. /// <summary>
  1171. /// IOS获取团组签证拍照上传进度04(图片上传)
  1172. /// </summary>
  1173. /// <param name="dto"></param>
  1174. /// <returns></returns>
  1175. [HttpPost]
  1176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1177. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1178. {
  1179. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1180. //if (!string.IsNullOrEmpty(result))
  1181. //{
  1182. //}
  1183. //else {
  1184. // return Ok(JsonView(false, "上传失败"));
  1185. //}
  1186. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1187. int sucNum = 0;
  1188. try
  1189. {
  1190. foreach (var item in dto.base64DataList)
  1191. {
  1192. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1193. string result = decodeBase64ToImage(item, imageName);
  1194. if (!string.IsNullOrEmpty(result))
  1195. {
  1196. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1197. pic.CreateUserId = dto.CreateUserId;
  1198. pic.PicName = imageName;
  1199. pic.PicPath = result;
  1200. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1201. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1202. if (insertResult > 0)
  1203. {
  1204. sucNum++;
  1205. }
  1206. }
  1207. }
  1208. }
  1209. catch (Exception ex)
  1210. {
  1211. return Ok(JsonView(false, ex.Message));
  1212. }
  1213. string msg = string.Format(@"成功上传{0}张", sucNum);
  1214. return Ok(JsonView(true, msg));
  1215. }
  1216. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1217. {
  1218. string filename = "";//声明一个string类型的相对路径
  1219. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1220. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1221. try//会有异常抛出,try,catch一下
  1222. {
  1223. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1224. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1225. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1226. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1227. //文件名称
  1228. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1229. //上传的文件的路径
  1230. string filePath = "";
  1231. if (!Directory.Exists(fileDir))
  1232. {
  1233. Directory.CreateDirectory(fileDir);
  1234. }
  1235. //上传的文件的路径
  1236. filePath = fileDir + filename;
  1237. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1238. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1239. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1240. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1241. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1242. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1243. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1244. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1245. bitmap.Dispose();
  1246. }
  1247. catch (Exception e)
  1248. {
  1249. string massage = e.Message;
  1250. Logs("IOS图片上传Error:" + massage);
  1251. //filename = e.Message;
  1252. }
  1253. return filename;//返回相对路径
  1254. }
  1255. /// <summary>
  1256. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1257. /// </summary>
  1258. /// <param name="dto"></param>
  1259. /// <returns></returns>
  1260. [HttpPost]
  1261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1262. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1263. {
  1264. if (dto == null)
  1265. {
  1266. return Ok(JsonView(false, "请求错误:"));
  1267. }
  1268. string msg = "参数错误";
  1269. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1270. {
  1271. try
  1272. {
  1273. //_delegationVisaRep.BeginTran();
  1274. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1275. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1276. .Where(s => s.Id == dto.visaProgressCustomerId)
  1277. .ExecuteCommandAsync();
  1278. if (updCount > 0 && dto.publishCode == 1)
  1279. {
  1280. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1281. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1282. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1283. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1284. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1285. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1286. if (groupData == null)
  1287. {
  1288. _delegationVisaRep.RollbackTran();
  1289. }
  1290. string title = string.Format(@"[签证进度更新]");
  1291. string content = string.Format(@"测试文本");
  1292. bool rst = await _message.AddMsg(new MessageDto()
  1293. {
  1294. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1295. IssuerId = dto.publisher,
  1296. Title = title,
  1297. Content = content,
  1298. ReleaseTime = DateTime.Now,
  1299. UIdList = new List<int> {
  1300. 234
  1301. }
  1302. });
  1303. if (rst)
  1304. {
  1305. return Ok(JsonView(true, "发送通知成功"));
  1306. }
  1307. }
  1308. //_delegationVisaRep.CommitTran();
  1309. }
  1310. catch (Exception)
  1311. {
  1312. //_delegationVisaRep.RollbackTran();
  1313. }
  1314. }
  1315. return Ok(JsonView(true, msg));
  1316. }
  1317. #endregion
  1318. #region 团组任务分配
  1319. /// <summary>
  1320. /// 团组任务分配初始化
  1321. /// </summary>
  1322. /// <param name="dto"></param>
  1323. /// <returns></returns>
  1324. [HttpPost]
  1325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1326. public async Task<IActionResult> GetTaskAssignmen()
  1327. {
  1328. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1329. if (groupData.Code != 0)
  1330. {
  1331. return Ok(JsonView(false, groupData.Msg));
  1332. }
  1333. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1334. }
  1335. /// <summary>
  1336. /// 团组任务分配查询
  1337. /// </summary>
  1338. /// <param name="dto"></param>
  1339. /// <returns></returns>
  1340. [HttpPost]
  1341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1342. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1343. {
  1344. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1345. if (groupData.Code != 0)
  1346. {
  1347. return Ok(JsonView(false, groupData.Msg));
  1348. }
  1349. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1350. }
  1351. /// <summary>
  1352. /// 团组任务分配操作
  1353. /// </summary>
  1354. /// <param name="dto"></param>
  1355. /// <returns></returns>
  1356. [HttpPost]
  1357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1358. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1359. {
  1360. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1361. if (groupData.Code != 0)
  1362. {
  1363. return Ok(JsonView(false, groupData.Msg));
  1364. }
  1365. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1366. }
  1367. /// <summary>
  1368. /// 团组任务分配
  1369. /// 批量分配
  1370. /// 查询团组
  1371. /// </summary>
  1372. /// <param name="dto"></param>
  1373. /// <returns></returns>
  1374. [HttpPost]
  1375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1376. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1377. {
  1378. //参数验证
  1379. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1380. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1381. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1382. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1383. }
  1384. /// <summary>
  1385. /// 团组任务分配
  1386. /// 批量分配
  1387. /// </summary>
  1388. /// <param name="dto"></param>
  1389. /// <returns></returns>
  1390. [HttpPost]
  1391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1392. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1393. {
  1394. //参数验证
  1395. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1396. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1397. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1398. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1399. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1400. }
  1401. #endregion
  1402. #region 团组费用审核
  1403. /// <summary>
  1404. /// 费用审核
  1405. /// 团组列表 Page
  1406. /// </summary>
  1407. /// <param name="_dto">团组列表请求dto</param>
  1408. /// <returns></returns>
  1409. [HttpPost]
  1410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1411. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1412. {
  1413. #region 参数验证
  1414. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1415. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1416. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1417. #region 页面操作权限验证
  1418. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1419. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1420. #endregion
  1421. #endregion
  1422. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1423. {
  1424. string sqlWhere = string.Empty;
  1425. if (_dto.IsSure == 0) //未完成
  1426. {
  1427. sqlWhere += string.Format(@" And IsSure = 0");
  1428. }
  1429. else if (_dto.IsSure == 1) //已完成
  1430. {
  1431. sqlWhere += string.Format(@" And IsSure = 1");
  1432. }
  1433. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1434. {
  1435. string tj = _dto.SearchCriteria;
  1436. 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}%')",
  1437. tj, tj, tj, tj, tj);
  1438. }
  1439. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1440. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1441. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1442. From (
  1443. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1444. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1445. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1446. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1447. From Grp_DelegationInfo gdi
  1448. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1449. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1450. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1451. Where gdi.IsDel = 0 {0}
  1452. ) temp ", sqlWhere);
  1453. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1454. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1455. var _view = new
  1456. {
  1457. PageFuncAuth = pageFunAuthView,
  1458. Data = _DelegationList
  1459. };
  1460. return Ok(JsonView(true, "查询成功!", _view, total));
  1461. }
  1462. else
  1463. {
  1464. return Ok(JsonView(false, "查询失败"));
  1465. }
  1466. }
  1467. /// <summary>
  1468. /// 获取团组费用审核
  1469. /// </summary>
  1470. /// <param name="paras">参数Json字符串</param>
  1471. /// <returns></returns>
  1472. [HttpPost]
  1473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1474. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1475. {
  1476. try
  1477. {
  1478. #region 参数验证
  1479. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1480. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1481. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1482. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1483. #region 页面操作权限验证
  1484. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1485. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1486. #endregion
  1487. #endregion
  1488. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1489. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1490. #region 费用清单
  1491. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1492. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1493. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1494. List<Grp_CreditCardPayment> entityList = _groupRepository
  1495. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1496. .Where(exp.ToExpression())
  1497. .ToList();
  1498. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1499. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1500. /*
  1501. * 76://酒店预订
  1502. */
  1503. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1504. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1505. .ToListAsync();
  1506. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1507. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1508. .ToListAsync();
  1509. /*
  1510. * 79://车/导游地接
  1511. */
  1512. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1513. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1514. .ToListAsync();
  1515. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1516. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1517. .ToListAsync();
  1518. /*
  1519. * 80: //签证
  1520. */
  1521. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1522. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1523. .ToListAsync();
  1524. /*
  1525. *81: //邀请/公务活动
  1526. */
  1527. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1528. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1529. .ToListAsync();
  1530. /*
  1531. * 82: //团组客户保险
  1532. */
  1533. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1534. /*
  1535. * Lable = 85 机票预订
  1536. */
  1537. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1538. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1539. .ToListAsync();
  1540. /*
  1541. * 85 机票预定
  1542. */
  1543. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1544. /*
  1545. * 98 其他款项
  1546. */
  1547. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1548. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1549. .ToListAsync();
  1550. /*
  1551. * 285:收款退还
  1552. */
  1553. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1554. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1555. .ToListAsync();
  1556. /*
  1557. * 1015: //超支费用
  1558. */
  1559. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1560. /*
  1561. * 币种信息
  1562. */
  1563. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1564. /*
  1565. * 车/导游地接 费用类型
  1566. */
  1567. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1568. /*
  1569. * 车/导游地接 费用类型
  1570. */
  1571. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1572. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1573. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1574. /*
  1575. * 用户信息
  1576. */
  1577. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1578. /*
  1579. * 费用模块
  1580. */
  1581. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1582. string priceModule = string.Empty;
  1583. if (sdPriceName != null)
  1584. {
  1585. priceModule = sdPriceName.Name;
  1586. }
  1587. /*
  1588. * 成本信息
  1589. */
  1590. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1591. decimal _groupRate = 0.0000M;
  1592. string _groupCurrencyCode = "-";
  1593. if (groupCost != null)
  1594. {
  1595. _groupRate = groupCost.Rate;
  1596. if (int.TryParse(groupCost.Currency, out int _currency))
  1597. {
  1598. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1599. }
  1600. else _groupCurrencyCode = groupCost.Currency;
  1601. }
  1602. string costContentSql = $"Select * From Grp_GroupCost";
  1603. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1604. //处理日期为空的天数
  1605. for (int i = 0; i < groupCostDetails.Count; i++)
  1606. if (i != 0)
  1607. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1608. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1609. /*
  1610. * 处理详情数据
  1611. */
  1612. foreach (var entity in entityList)
  1613. {
  1614. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1615. _detail.Id = entity.Id;
  1616. _detail.PriceName = priceModule;
  1617. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1618. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1619. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1620. //处理金额
  1621. if (entity.CTable == 1015)
  1622. {
  1623. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1624. if (czInfo != null)
  1625. {
  1626. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1627. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1628. }
  1629. }
  1630. /*
  1631. * 应付款金额
  1632. */
  1633. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1634. string PaymentCurrency_WaitPay = "Unknown";
  1635. string hotelCurrncyCode = "Unknown";
  1636. string hotelCurrncyName = "Unknown";
  1637. if (sdPaymentCurrency_WaitPay != null)
  1638. {
  1639. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1640. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1641. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1642. if (hotelCurrncyCode.Equals("CNY"))
  1643. {
  1644. entity.DayRate = 1.0000M;
  1645. }
  1646. }
  1647. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1648. /*
  1649. * 此次付款金额
  1650. */
  1651. decimal CurrPayStr = 0.00M,
  1652. OriginalCurrPay = 0.00M;
  1653. if (entity.PayPercentage == 0)
  1654. {
  1655. if (entity.PayThenMoney != 0)
  1656. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1657. }
  1658. else
  1659. {
  1660. if (entity.PayMoney != 0)
  1661. {
  1662. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1663. }
  1664. }
  1665. if (_dto.Label == 79)
  1666. {
  1667. string original = string.Empty;
  1668. if (hotelCurrncyCode.Equals("CNY"))
  1669. {
  1670. OriginalCurrPay = CurrPayStr;
  1671. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1672. }
  1673. else
  1674. {
  1675. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1676. //760 EUR(7600.00 CNY)
  1677. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1678. }
  1679. }
  1680. else
  1681. {
  1682. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1683. }
  1684. /*
  1685. * 剩余尾款
  1686. */
  1687. decimal BalanceStr = 0;
  1688. if (CurrPayStr != 0)
  1689. {
  1690. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1691. BalanceStr = 0;
  1692. else
  1693. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1694. }
  1695. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1696. /*
  1697. * Bus名称
  1698. */
  1699. _detail.BusName = "待增加";
  1700. /*
  1701. *费用所属
  1702. */
  1703. switch (entity.CTable)
  1704. {
  1705. case 76://酒店预订
  1706. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1707. if (hotelReservations != null)
  1708. {
  1709. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1710. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1711. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1712. string roomFeeStr = "", roomFeestr1 = "";
  1713. //是否比较房型价格
  1714. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1715. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1716. roomFeeStr += $"<br/>";
  1717. if (hotelReservations.SingleRoomPrice > 0)
  1718. {
  1719. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1720. __isSingle = true;
  1721. }
  1722. if (hotelReservations.DoubleRoomPrice > 0)
  1723. {
  1724. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1725. __isDouble = true;
  1726. }
  1727. if (hotelReservations.SuiteRoomPrice > 0)
  1728. {
  1729. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1730. __isSuite = true;
  1731. }
  1732. if (hotelReservations.OtherRoomPrice > 0)
  1733. {
  1734. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1735. __isOther = true;
  1736. }
  1737. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1738. else roomFeeStr += " 0.00 * 0";
  1739. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1740. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1741. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1742. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1743. /*
  1744. * 费用类型
  1745. * 1:房费
  1746. * 2:早餐
  1747. * 3:地税
  1748. * 4:城市税
  1749. * </summary>
  1750. */
  1751. //地税
  1752. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1753. if (governmentRentData != null)
  1754. {
  1755. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1756. governmentRentFee = governmentRentData.Price;
  1757. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1758. if (governmentRentCurrData != null)
  1759. {
  1760. governmentRentCode = governmentRentCurrData.Name;
  1761. governmentRentName = $"({governmentRentCurrData.Remark})";
  1762. }
  1763. }
  1764. //城市税
  1765. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1766. if (cityTaxData != null)
  1767. {
  1768. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1769. cityTaxFee = cityTaxData.Price;
  1770. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1771. if (cityTaxCurrData != null)
  1772. {
  1773. cityTaxCode = cityTaxCurrData.Name;
  1774. cityTaxName = $"({cityTaxCurrData.Remark})";
  1775. }
  1776. }
  1777. //酒店早餐
  1778. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1779. if (breakfastData != null)
  1780. {
  1781. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1782. breakfastFee = breakfastData.Price;
  1783. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1784. if (breakfastCurrData != null)
  1785. {
  1786. breakfastCode = breakfastCurrData.Name;
  1787. breakfastName = $"({breakfastCurrData.Remark})";
  1788. }
  1789. }
  1790. //房间费用
  1791. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1792. if (roomData != null)
  1793. {
  1794. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1795. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1796. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1797. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1798. roomFee = roomData.Price;
  1799. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1800. if (roomCurrData != null)
  1801. {
  1802. roomCode = roomCurrData.Name;
  1803. roomName = $"({roomCurrData.Remark})";
  1804. }
  1805. }
  1806. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1807. string hotelCostStr = "";
  1808. decimal hotelCsotTotal = 0.00M;
  1809. if (groupCost != null)
  1810. {
  1811. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1812. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1813. }
  1814. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1815. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1816. string hotelCost_day = "";
  1817. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1818. foreach (var item in hotelCostDetails1)
  1819. {
  1820. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1821. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1822. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1823. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1824. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1825. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1826. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1827. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1828. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1829. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1830. hotelCost_day += @$"<br/>";
  1831. }
  1832. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1833. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1834. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1835. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1836. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1837. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1838. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1839. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1840. $"房间说明: {hotelReservations.Remark} <br/>" +
  1841. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1842. $"{hotelBreakfastStr}" +
  1843. $"{hotelGovernmentRentStr}" +
  1844. $"{hotelCityTaxStr}";
  1845. _detail.PriceNameContent = hotelReservations.HotelName;
  1846. }
  1847. break;
  1848. case 79://车/导游地接
  1849. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1850. if (touristGuideGroundReservations != null)
  1851. {
  1852. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1853. {
  1854. _detail.BusName = touristGuideGroundReservations.BusName;
  1855. }
  1856. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1857. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1858. //if (isInt)
  1859. //{
  1860. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1861. // if (cityInfo != null)
  1862. // {
  1863. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1864. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1865. // if (carFeeItem != null)
  1866. // {
  1867. // nameContent += $@"({carFeeItem.Name})";
  1868. // }
  1869. // _detail.PriceNameContent = nameContent;
  1870. // }
  1871. //}
  1872. //else
  1873. //{
  1874. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1875. //}
  1876. var touristGuideGroundReservationsContents =
  1877. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1878. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1879. foreach (var item in touristGuideGroundReservationsContents)
  1880. {
  1881. string typeName = "Unknown";
  1882. string carCurrencyCode = "Unknown";
  1883. string carCurrencyName = "Unknown";
  1884. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1885. if (carTypeData != null) typeName = carTypeData.Name;
  1886. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1887. if (currencyData != null)
  1888. {
  1889. carCurrencyCode = currencyData.Name;
  1890. carCurrencyName = currencyData.Remark;
  1891. }
  1892. //op、成本 币种是否一致
  1893. bool IsCurrencyAgreement = false;
  1894. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1895. string opCostStr = string.Empty;
  1896. decimal opCostTypePrice = 0.00M;
  1897. #region 处理成本各项费用
  1898. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1899. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1900. if (opCost.Count > 0)
  1901. {
  1902. switch (item.SId)
  1903. {
  1904. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1905. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1906. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1907. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1908. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1909. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1910. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1911. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1912. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1913. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1914. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1915. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1916. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1917. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1918. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1919. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1920. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1921. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1922. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1923. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1924. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1925. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1926. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1927. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1928. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1929. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1930. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1931. }
  1932. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1933. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1934. }
  1935. #endregion
  1936. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1937. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1938. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1939. $"{opTypeStr} {opCostStr}<br/>" +
  1940. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1941. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1942. }
  1943. _detail.PriceMsgContent = priceMsg;
  1944. }
  1945. break;
  1946. case 80: //签证
  1947. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1948. if (visaInfo != null)
  1949. {
  1950. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1951. _detail.PriceNameContent = visaInfo.VisaDescription;
  1952. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1953. }
  1954. break;
  1955. case 81: //邀请/公务活动
  1956. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1957. if (_ioa != null)
  1958. {
  1959. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1960. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1961. sendCurrName = "Unknown", //快递费用币种 Name
  1962. sendCurrCode = "Unknown", //快递费用币种 Code
  1963. eventsCurrName = "Unknown", //公务活动费币种 Name
  1964. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1965. translateCurrName = "Unknown", //公务翻译费 Name
  1966. translateCurrCode = "Unknown"; //公务翻译费 Code
  1967. #region 处理费用币种
  1968. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1969. if (inviteCurrData != null)
  1970. {
  1971. inviteCurrName = inviteCurrData.Remark;
  1972. inviteCurrCode = inviteCurrData.Name;
  1973. }
  1974. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1975. if (sendCurrData != null)
  1976. {
  1977. sendCurrName = sendCurrData.Remark;
  1978. sendCurrCode = sendCurrData.Name;
  1979. }
  1980. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1981. if (eventsCurrData != null)
  1982. {
  1983. eventsCurrName = eventsCurrData.Remark;
  1984. eventsCurrCode = eventsCurrData.Name;
  1985. }
  1986. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1987. if (translateCurrData != null)
  1988. {
  1989. translateCurrName = translateCurrData.Remark;
  1990. translateCurrCode = translateCurrData.Name;
  1991. }
  1992. #endregion
  1993. _detail.PriceNameContent = _ioa.InviterArea;
  1994. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1995. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1996. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1997. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1998. $@"备注:" + _ioa.Remark + "<br/>";
  1999. }
  2000. break;
  2001. case 82: //团组客户保险
  2002. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2003. if (customers != null)
  2004. {
  2005. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2006. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2007. }
  2008. break;
  2009. case 85: //机票预订
  2010. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2011. if (jpRes != null)
  2012. {
  2013. string FlightsDescription = jpRes.FlightsDescription;
  2014. string PriceDescription = jpRes.PriceDescription;
  2015. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2016. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2017. }
  2018. break;
  2019. case 98://其他款项
  2020. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2021. if (gdpRes != null)
  2022. {
  2023. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2024. _detail.PriceNameContent = gdpRes.PriceName;
  2025. }
  2026. break;
  2027. case 285://收款退还
  2028. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2029. if (refundAndOtherMoney != null)
  2030. {
  2031. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2032. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2033. }
  2034. break;
  2035. case 751://酒店早餐
  2036. break;
  2037. case 1015://超支费用
  2038. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2039. if (groupExtraCost != null)
  2040. {
  2041. _detail.PriceNameContent = groupExtraCost.PriceName;
  2042. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2043. }
  2044. break;
  2045. default:
  2046. break;
  2047. }
  2048. /*
  2049. * 申请人
  2050. */
  2051. string operatorName = " - ";
  2052. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2053. if (_opUser != null)
  2054. {
  2055. operatorName = _opUser.CnName;
  2056. }
  2057. _detail.OperatorName = operatorName;
  2058. /*
  2059. * 审核人
  2060. */
  2061. string auditOperatorName = "Unknown";
  2062. if (entity.AuditGMOperate == 0)
  2063. auditOperatorName = " - ";
  2064. else if (entity.AuditGMOperate == 4)
  2065. auditOperatorName = "自动审核";
  2066. else
  2067. {
  2068. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2069. if (_adUser != null)
  2070. {
  2071. auditOperatorName = _adUser.CnName;
  2072. }
  2073. }
  2074. _detail.AuditOperatorName = auditOperatorName;
  2075. /*
  2076. * 超预算比例
  2077. */
  2078. string overBudgetStr = "";
  2079. if (entity.ExceedBudget == -1)
  2080. overBudgetStr = sdPriceName.Name + "尚无预算";
  2081. else if (entity.ExceedBudget == 0)
  2082. {
  2083. if (entity.CTable == 76 || entity.CTable == 79)
  2084. {
  2085. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2086. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2087. }
  2088. else
  2089. {
  2090. overBudgetStr = "未超预算";
  2091. }
  2092. }
  2093. else
  2094. overBudgetStr = entity.ExceedBudget.ToString("P");
  2095. _detail.OverBudget = overBudgetStr;
  2096. /*
  2097. * 已审核金额
  2098. */
  2099. decimal auditFee = 0.00M;
  2100. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2101. /*
  2102. * 费用总计
  2103. */
  2104. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2105. {
  2106. CurrencyId = entity.PaymentCurrency,
  2107. CurrencyName = PaymentCurrency_WaitPay,
  2108. AmountPayable = entity.PayMoney,
  2109. ThisPayment = OriginalCurrPay,
  2110. BalancePayment = BalanceStr,
  2111. AuditedFunds = auditFee
  2112. });
  2113. _detail.IsAuditGM = entity.IsAuditGM;
  2114. detailList.Add(_detail);
  2115. }
  2116. #endregion
  2117. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2118. /*
  2119. * 下方描述处理
  2120. */
  2121. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2122. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2123. if (ccpCurrencyPrice != null)
  2124. {
  2125. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2126. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2127. }
  2128. else
  2129. {
  2130. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2131. }
  2132. string amountPayableStr = string.Format(@"应付款总金额: ");
  2133. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2134. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2135. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2136. foreach (var item in nonDuplicat)
  2137. {
  2138. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2139. if (strs.Count > 0)
  2140. {
  2141. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2142. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2143. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2144. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2145. //单独处理此次付款金额
  2146. if (item.CurrencyId == 836) //人民币
  2147. {
  2148. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2149. }
  2150. else
  2151. {
  2152. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2153. }
  2154. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2155. //单独处理已审核费用
  2156. if (item.CurrencyId == 836) //人民币
  2157. {
  2158. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2159. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2160. }
  2161. else
  2162. {
  2163. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2164. }
  2165. }
  2166. }
  2167. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2168. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2169. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2170. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2171. var _view1 = new
  2172. {
  2173. PageFuncAuth = pageFunAuthView,
  2174. Data = _view
  2175. };
  2176. return Ok(JsonView(_view1));
  2177. }
  2178. catch (Exception ex)
  2179. {
  2180. return Ok(JsonView(false, ex.Message));
  2181. }
  2182. }
  2183. /// <summary>
  2184. /// 费用审核
  2185. /// 修改团组费用审核状态
  2186. /// </summary>
  2187. /// <param name="_dto">参数Json字符串</param>
  2188. /// <returns></returns>
  2189. [HttpPost]
  2190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2191. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2192. {
  2193. #region 参数验证
  2194. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2195. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2196. #endregion
  2197. #region 页面操作权限验证
  2198. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2199. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2200. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2201. #endregion
  2202. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2203. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2204. DateTime dtNow = DateTime.Now;
  2205. _groupRepository.BeginTran();
  2206. int rst = 0;
  2207. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2208. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2209. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2210. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2211. List<dynamic> msgDatas = new List<dynamic>();
  2212. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2213. foreach (var item in idList)
  2214. {
  2215. int CreditId = int.Parse(item);
  2216. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2217. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2218. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2219. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2220. .Where(s => s.Id == CreditId)
  2221. .ExecuteCommandAsync();
  2222. if (result < 1)
  2223. {
  2224. rst = -1;
  2225. _groupRepository.RollbackTran();
  2226. return Ok(JsonView(false, "操作失败并回滚!"));
  2227. }
  2228. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2229. if (creditData != null)
  2230. {
  2231. #region 应用通知配置
  2232. try
  2233. {
  2234. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2235. }
  2236. catch (Exception ex)
  2237. {
  2238. }
  2239. #endregion
  2240. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2241. string groupNameStr = string.Empty;
  2242. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2243. if (groupData != null) groupNameStr = groupData.TeamName;
  2244. string creditTypeStr = string.Empty;
  2245. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2246. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2247. string creditCurrency = string.Empty;
  2248. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2249. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2250. if (creditCurrency.Equals("CNY"))
  2251. {
  2252. creditData.DayRate = 1.0000M;
  2253. }
  2254. if (creditData.PayPercentage == 0.00M)
  2255. {
  2256. creditData.PayPercentage = 100M;
  2257. }
  2258. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2259. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2260. string msgContent = "";
  2261. if (creditCurrency.Equals("CNY"))
  2262. {
  2263. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2264. }
  2265. else
  2266. {
  2267. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2268. }
  2269. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2270. }
  2271. }
  2272. if (rst == 0)
  2273. {
  2274. _groupRepository.CommitTran();
  2275. foreach (var item in msgDatas)
  2276. {
  2277. //发送消息
  2278. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2279. }
  2280. #region 应用推送
  2281. try
  2282. {
  2283. foreach (var ccpId in dic_ccp_user.Keys)
  2284. {
  2285. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2286. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2287. }
  2288. }
  2289. catch (Exception)
  2290. {
  2291. }
  2292. #endregion
  2293. return Ok(JsonView(true, "操作成功!"));
  2294. }
  2295. return Ok(JsonView(false, "操作失败!"));
  2296. }
  2297. #endregion
  2298. #region 机票费用录入
  2299. /// <summary>
  2300. /// 机票录入当前登录人可操作团组
  2301. /// </summary>
  2302. /// <param name="dto"></param>
  2303. /// <returns></returns>
  2304. [HttpPost]
  2305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2306. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2307. {
  2308. try
  2309. {
  2310. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2311. if (groupData.Code != 0)
  2312. {
  2313. return Ok(JsonView(false, groupData.Msg));
  2314. }
  2315. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2316. }
  2317. catch (Exception ex)
  2318. {
  2319. return Ok(JsonView(false, "程序错误!"));
  2320. throw;
  2321. }
  2322. }
  2323. /// <summary>
  2324. /// 机票费用录入列表
  2325. /// </summary>
  2326. /// <param name="dto"></param>
  2327. /// <returns></returns>
  2328. [HttpPost]
  2329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2330. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2331. {
  2332. try
  2333. {
  2334. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2335. if (groupData.Code != 0)
  2336. {
  2337. return Ok(JsonView(false, groupData.Msg));
  2338. }
  2339. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2340. }
  2341. catch (Exception ex)
  2342. {
  2343. return Ok(JsonView(false, ex.Message));
  2344. throw;
  2345. }
  2346. }
  2347. /// <summary>
  2348. /// 根据id查询费用录入信息
  2349. /// </summary>
  2350. /// <param name="dto"></param>
  2351. /// <returns></returns>
  2352. [HttpPost]
  2353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2354. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2355. {
  2356. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2357. if (groupData.Code != 0)
  2358. {
  2359. return Ok(JsonView(false, groupData.Msg));
  2360. }
  2361. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2362. }
  2363. /// <summary>
  2364. /// 机票费用录入操作(Status:1.新增,2.修改)
  2365. /// </summary>
  2366. /// <param name="dto"></param>
  2367. /// <returns></returns>
  2368. [HttpPost]
  2369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2370. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2371. {
  2372. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2373. if (groupData.Code != 0)
  2374. {
  2375. return Ok(JsonView(false, groupData.Msg));
  2376. }
  2377. #region 应用推送
  2378. try
  2379. {
  2380. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2381. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2382. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2383. //2024-10-21 新增LZ UID
  2384. var userIds = new List<int>() { 21 };
  2385. string title = $"系统通知";
  2386. string content = "";
  2387. var diId = dto.AirTicketResOpData.DiId;
  2388. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2389. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2390. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2391. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2392. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2393. await GeneralMethod.iOS_PushNotifications("051", $"机票费用审核", "", content);
  2394. }
  2395. catch (Exception ex)
  2396. {
  2397. }
  2398. #endregion
  2399. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2400. }
  2401. /// <summary>
  2402. /// 根据舱位类型查询接团客户名单信息
  2403. /// </summary>
  2404. /// <param name="dto"></param>
  2405. /// <returns></returns>
  2406. [HttpPost]
  2407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2408. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2409. {
  2410. try
  2411. {
  2412. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2413. if (crm_Groups.Count != 0)
  2414. {
  2415. List<dynamic> Customer = new List<dynamic>();
  2416. foreach (var item in crm_Groups)
  2417. {
  2418. var data = new
  2419. {
  2420. Id = item.Id,
  2421. Pinyin = item.Pinyin,
  2422. Name = item.LastName + item.FirstName
  2423. };
  2424. Customer.Add(data);
  2425. }
  2426. return Ok(JsonView(true, "查询成功!", Customer));
  2427. }
  2428. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2429. }
  2430. catch (Exception ex)
  2431. {
  2432. return Ok(JsonView(false, "程序错误!"));
  2433. throw;
  2434. }
  2435. }
  2436. /// <summary>
  2437. /// 根据团号获取客户信息
  2438. /// </summary>
  2439. /// <param name="dto"></param>
  2440. /// <returns></returns>
  2441. [HttpPost]
  2442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2443. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2444. {
  2445. var jw = JsonView(false);
  2446. if (dto.DIID < 1)
  2447. {
  2448. jw.Msg += "请输入正确的diid";
  2449. return Ok(jw);
  2450. }
  2451. var arr = getSimplClientList(dto.DIID);
  2452. jw = JsonView(true, "获取成功!", arr);
  2453. return Ok(jw);
  2454. }
  2455. private List<SimplClientInfo> getSimplClientList(int diId)
  2456. {
  2457. 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);
  2458. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2459. return arr;
  2460. }
  2461. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2462. {
  2463. string result = origin;
  2464. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2465. {
  2466. string[] temparr = origin.Split(',');
  2467. string fistrStr = temparr[0];
  2468. int count = temparr.Count();
  2469. int tempId;
  2470. bool success = int.TryParse(fistrStr, out tempId);
  2471. if (success)
  2472. {
  2473. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2474. if (tempInfo != null)
  2475. {
  2476. if (count > 1)
  2477. {
  2478. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2479. }
  2480. else
  2481. {
  2482. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2483. }
  2484. }
  2485. }
  2486. }
  2487. return result;
  2488. }
  2489. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2490. {
  2491. string result = origin;
  2492. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2493. {
  2494. string[] temparr = origin.Split(',');
  2495. result = "";
  2496. foreach (var item in temparr)
  2497. {
  2498. int tempId;
  2499. bool success = int.TryParse(item, out tempId);
  2500. if (success)
  2501. {
  2502. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2503. if (tempInfo != null)
  2504. {
  2505. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2506. }
  2507. }
  2508. }
  2509. }
  2510. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2511. return result;
  2512. }
  2513. /// <summary>
  2514. /// 机票费用录入,删除
  2515. /// </summary>
  2516. /// <param name="dto"></param>
  2517. /// <returns></returns>
  2518. [HttpPost]
  2519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2520. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2521. {
  2522. try
  2523. {
  2524. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2525. if (res)
  2526. {
  2527. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2528. {
  2529. IsDel = 1,
  2530. DeleteUserId = dto.DeleteUserId,
  2531. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2532. }).ExecuteCommandAsync();
  2533. return Ok(JsonView(true, "删除成功!"));
  2534. }
  2535. return Ok(JsonView(false, "删除失败!"));
  2536. }
  2537. catch (Exception ex)
  2538. {
  2539. return Ok(JsonView(false, "程序错误!"));
  2540. throw;
  2541. }
  2542. }
  2543. /// <summary>
  2544. /// 导出机票录入报表
  2545. /// </summary>
  2546. /// <param name="dto"></param>
  2547. /// <returns></returns>
  2548. [HttpPost]
  2549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2550. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2551. {
  2552. try
  2553. {
  2554. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2555. if (groupData.Code != 0)
  2556. {
  2557. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2558. }
  2559. else
  2560. {
  2561. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2562. if (AirTicketReservations.Count != 0)
  2563. {
  2564. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2565. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2566. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2567. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2568. WorkbookDesigner designer = new WorkbookDesigner();
  2569. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2570. decimal countCost = 0;
  2571. foreach (var item in AirTicketReservations)
  2572. {
  2573. #region 处理客人姓名
  2574. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2575. item.ClientName = clientNames;
  2576. #endregion
  2577. if (item.BankType == "其他")
  2578. {
  2579. item.BankNo = "--";
  2580. }
  2581. else
  2582. {
  2583. if (!string.IsNullOrEmpty(item.BankType))
  2584. {
  2585. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2586. }
  2587. }
  2588. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2589. item.Price = System.Decimal.Round(item.Price, 2);
  2590. countCost += Convert.ToDecimal(item.Price);
  2591. }
  2592. designer.SetDataSource("Export", AirTicketReservations);
  2593. designer.SetDataSource("ExportDiCode", diCode);
  2594. designer.SetDataSource("ExportDiName", diName);
  2595. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2596. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2597. designer.Process();
  2598. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2599. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2600. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2601. return Ok(JsonView(true, "成功", url = rst));
  2602. }
  2603. else
  2604. {
  2605. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2606. }
  2607. }
  2608. }
  2609. catch (Exception ex)
  2610. {
  2611. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2612. throw;
  2613. }
  2614. }
  2615. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2616. /// <summary>
  2617. /// 行程单导出
  2618. /// </summary>
  2619. /// <param name="dto"></param>
  2620. /// <returns></returns>
  2621. [HttpPost]
  2622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2623. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2624. {
  2625. try
  2626. {
  2627. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2628. if (groupData.Code != 0)
  2629. {
  2630. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2631. }
  2632. else
  2633. {
  2634. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2635. if (dto.Language == "CN")
  2636. {
  2637. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2638. DocumentBuilder builder = new DocumentBuilder(doc);
  2639. int tableIndex = 0;//表格索引
  2640. //得到文档中的第一个表格
  2641. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2642. foreach (var item in _AirTicketReservations)
  2643. {
  2644. #region 处理固定数据
  2645. string[] FlightsCode = item.FlightsCode.Split('/');
  2646. if (FlightsCode.Length != 0)
  2647. {
  2648. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2649. if (_AirCompany != null)
  2650. {
  2651. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2652. }
  2653. else
  2654. {
  2655. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2656. }
  2657. }
  2658. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2659. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2660. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2661. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2662. string name = "";
  2663. foreach (string clientName in nameArray)
  2664. {
  2665. if (!name.Contains(clientName))
  2666. {
  2667. name += clientName + ",";
  2668. }
  2669. }
  2670. if (!string.IsNullOrWhiteSpace(name))
  2671. {
  2672. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2673. }
  2674. else
  2675. {
  2676. table.Range.Bookmarks["ClientName"].Text = "--";
  2677. }
  2678. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2679. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2680. table.Range.Bookmarks["JointTicket"].Text = "--";
  2681. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2682. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2683. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2684. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2685. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2686. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2687. #endregion
  2688. #region 循环数据处理
  2689. List<AirInfo> airs = new List<AirInfo>();
  2690. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2691. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2692. for (int i = 0; i < FlightsCode.Length; i++)
  2693. {
  2694. AirInfo air = new AirInfo();
  2695. string[] tempstr = DayArray[i]
  2696. .Replace("\r\n", string.Empty)
  2697. .Replace("\\r\\n", string.Empty)
  2698. .TrimStart().TrimEnd()
  2699. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2700. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2701. string starCity = "";
  2702. if (star_Three != null)
  2703. {
  2704. starCity = star_Three.AirPort;
  2705. }
  2706. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2707. string EndCity = "";
  2708. if (End_Three != null)
  2709. {
  2710. EndCity = End_Three.AirPort;
  2711. }
  2712. air.Destination = starCity + "/" + EndCity;
  2713. air.Flight = FlightsCode[i];
  2714. air.SeatingClass = item.CTypeName;
  2715. string dateTime = tempstr[2];
  2716. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2717. air.FlightDate = DateTemp;
  2718. air.DepartureTime = tempstr[5];
  2719. air.LandingTime = tempstr[6];
  2720. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2721. air.TicketStatus = "--";
  2722. air.Luggage = "--";
  2723. air.DepartureTerminal = "--";
  2724. air.LandingTerminal = "--";
  2725. airs.Add(air);
  2726. }
  2727. int row = 13;
  2728. for (int i = 0; i < airs.Count; i++)
  2729. {
  2730. if (airs.Count > 2)
  2731. {
  2732. for (int j = 0; j < airs.Count - 2; j++)
  2733. {
  2734. var CopyRow = table.Rows[12].Clone(true);
  2735. table.Rows.Add(CopyRow);
  2736. }
  2737. }
  2738. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2739. int index = 0;
  2740. foreach (PropertyInfo property in properties)
  2741. {
  2742. string value = property.GetValue(airs[i]).ToString();
  2743. Cell ishcel0 = table.Rows[row].Cells[index];
  2744. Paragraph p = new Paragraph(doc);
  2745. string s = value;
  2746. p.AppendChild(new Run(doc, s));
  2747. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2748. ishcel0.AppendChild(p);
  2749. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2750. index++;
  2751. }
  2752. row++;
  2753. }
  2754. #endregion
  2755. Paragraph lastParagraph = new Paragraph(doc);
  2756. //第一个表格末尾加段落
  2757. table.ParentNode.InsertAfter(lastParagraph, table);
  2758. //复制第一个表格
  2759. Table cloneTable = (Table)table.Clone(true);
  2760. //在文档末尾段落后面加入复制的表格
  2761. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2762. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2763. {
  2764. int rownewsIndex = 13;
  2765. for (int i = 0; i < 2; i++)
  2766. {
  2767. var CopyRow = table.Rows[12].Clone(true);
  2768. table.Rows.RemoveAt(13);
  2769. table.Rows.Add(CopyRow);
  2770. rownewsIndex++;
  2771. }
  2772. }
  2773. else
  2774. {
  2775. table.Rows.RemoveAt(12);
  2776. }
  2777. cloneTable.Rows.RemoveAt(12);
  2778. }
  2779. if (_AirTicketReservations.Count != 0)
  2780. {
  2781. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2782. if (FlightsCode.Length != 0)
  2783. {
  2784. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2785. if (_AirCompany != null)
  2786. {
  2787. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2788. }
  2789. else
  2790. {
  2791. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2792. }
  2793. }
  2794. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2795. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2796. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2797. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2798. string name = "";
  2799. foreach (string clientName in nameArray)
  2800. {
  2801. if (!name.Contains(clientName))
  2802. {
  2803. name += clientName + ",";
  2804. }
  2805. }
  2806. if (!string.IsNullOrWhiteSpace(name))
  2807. {
  2808. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2809. }
  2810. else
  2811. {
  2812. table.Range.Bookmarks["ClientName"].Text = "--";
  2813. }
  2814. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2815. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2816. table.Range.Bookmarks["JointTicket"].Text = "--";
  2817. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2818. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2819. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2820. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2821. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2822. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2823. }
  2824. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2825. //保存合并后的文档
  2826. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2827. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2828. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2829. return Ok(JsonView(true, "成功!", rst));
  2830. }
  2831. else
  2832. {
  2833. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2834. DocumentBuilder builder = new DocumentBuilder(doc);
  2835. int tableIndex = 0;//表格索引
  2836. //得到文档中的第一个表格
  2837. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2838. List<string> texts = new List<string>();
  2839. foreach (var item in _AirTicketReservations)
  2840. {
  2841. string[] FlightsCode = item.FlightsCode.Split('/');
  2842. if (FlightsCode.Length != 0)
  2843. {
  2844. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2845. if (_AirCompany != null)
  2846. {
  2847. if (!transDic.ContainsKey(_AirCompany.CnName))
  2848. {
  2849. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2850. }
  2851. }
  2852. else
  2853. {
  2854. if (!transDic.ContainsKey("--"))
  2855. {
  2856. transDic.Add("--", "--");
  2857. }
  2858. }
  2859. }
  2860. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2861. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2862. string name = "";
  2863. foreach (string clientName in nameArray)
  2864. {
  2865. name += clientName + ",";
  2866. }
  2867. if (!texts.Contains(name))
  2868. {
  2869. texts.Add(name);
  2870. }
  2871. List<AirInfo> airs = new List<AirInfo>();
  2872. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2873. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2874. for (int i = 0; i < FlightsCode.Length; i++)
  2875. {
  2876. AirInfo air = new AirInfo();
  2877. string[] tempstr = DayArray[i]
  2878. .Replace("\r\n", string.Empty)
  2879. .Replace("\\r\\n", string.Empty)
  2880. .TrimStart().TrimEnd()
  2881. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2882. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2883. if (star_Three != null)
  2884. {
  2885. if (!transDic.ContainsKey(star_Three.AirPort))
  2886. {
  2887. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2888. }
  2889. }
  2890. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2891. if (End_Three != null)
  2892. {
  2893. if (!transDic.ContainsKey(End_Three.AirPort))
  2894. {
  2895. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2896. }
  2897. }
  2898. if (!texts.Contains(item.CTypeName))
  2899. {
  2900. texts.Add(item.CTypeName);
  2901. }
  2902. }
  2903. }
  2904. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2905. if (transData.Count > 0)
  2906. {
  2907. foreach (TranslateResult item in transData)
  2908. {
  2909. if (!transDic.ContainsKey(item.Query))
  2910. {
  2911. transDic.Add(item.Query, item.Translation);
  2912. }
  2913. }
  2914. }
  2915. foreach (var item in _AirTicketReservations)
  2916. {
  2917. #region 处理固定数据
  2918. string[] FlightsCode = item.FlightsCode.Split('/');
  2919. if (FlightsCode.Length != 0)
  2920. {
  2921. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2922. if (_AirCompany != null)
  2923. {
  2924. string str = "--";
  2925. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2926. if (!string.IsNullOrEmpty(translateResult))
  2927. {
  2928. str = translateResult;
  2929. str = _airTicketResRep.Processing(str);
  2930. }
  2931. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2932. }
  2933. else
  2934. {
  2935. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2936. }
  2937. }
  2938. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2939. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2940. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2941. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2942. string names = "";
  2943. foreach (string clientName in nameArray)
  2944. {
  2945. names += clientName + ",";
  2946. }
  2947. if (!string.IsNullOrWhiteSpace(names))
  2948. {
  2949. string str = "--";
  2950. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2951. if (!string.IsNullOrEmpty(translateResult))
  2952. {
  2953. str = translateResult;
  2954. str = _airTicketResRep.Processing(str);
  2955. }
  2956. table.Range.Bookmarks["ClientName"].Text = str;
  2957. }
  2958. else
  2959. {
  2960. table.Range.Bookmarks["ClientName"].Text = "--";
  2961. }
  2962. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2963. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2964. table.Range.Bookmarks["JointTicket"].Text = "--";
  2965. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2966. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2967. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2968. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2969. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2970. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2971. #endregion
  2972. #region 循环数据处理
  2973. List<AirInfo> airs = new List<AirInfo>();
  2974. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2975. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2976. for (int i = 0; i < FlightsCode.Length; i++)
  2977. {
  2978. AirInfo air = new AirInfo();
  2979. string[] tempstr = DayArray[i]
  2980. .Replace("\r\n", string.Empty)
  2981. .Replace("\\r\\n", string.Empty)
  2982. .TrimStart().TrimEnd()
  2983. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2984. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2985. string starCity = "";
  2986. if (star_Three != null)
  2987. {
  2988. string str2 = "--";
  2989. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2990. if (!string.IsNullOrEmpty(translateResult2))
  2991. {
  2992. str2 = translateResult2;
  2993. str2 = _airTicketResRep.Processing(str2);
  2994. }
  2995. starCity = str2;
  2996. }
  2997. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2998. string EndCity = "";
  2999. if (End_Three != null)
  3000. {
  3001. string str1 = "--";
  3002. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3003. if (!string.IsNullOrEmpty(translateResult1))
  3004. {
  3005. str1 = translateResult1;
  3006. str1 = _airTicketResRep.Processing(str1);
  3007. }
  3008. EndCity = str1;
  3009. }
  3010. air.Destination = starCity + "/" + EndCity;
  3011. air.Flight = FlightsCode[i];
  3012. string str = "--";
  3013. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3014. if (!string.IsNullOrEmpty(translateResult))
  3015. {
  3016. str = translateResult;
  3017. str = _airTicketResRep.Processing(str);
  3018. }
  3019. air.SeatingClass = str;
  3020. string dateTime = tempstr[2];
  3021. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3022. air.FlightDate = DateTemp;
  3023. air.DepartureTime = tempstr[5];
  3024. air.LandingTime = tempstr[6];
  3025. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3026. air.TicketStatus = "--";
  3027. air.Luggage = "--";
  3028. air.DepartureTerminal = "--";
  3029. air.LandingTerminal = "--";
  3030. airs.Add(air);
  3031. }
  3032. int row = 13;
  3033. for (int i = 0; i < airs.Count; i++)
  3034. {
  3035. if (airs.Count > 2)
  3036. {
  3037. for (int j = 0; j < airs.Count - 2; j++)
  3038. {
  3039. var CopyRow = table.Rows[12].Clone(true);
  3040. table.Rows.Add(CopyRow);
  3041. }
  3042. }
  3043. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3044. int index = 0;
  3045. foreach (PropertyInfo property in properties)
  3046. {
  3047. string value = property.GetValue(airs[i]).ToString();
  3048. Cell ishcel0 = table.Rows[row].Cells[index];
  3049. Paragraph p = new Paragraph(doc);
  3050. string s = value;
  3051. p.AppendChild(new Run(doc, s));
  3052. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3053. ishcel0.AppendChild(p);
  3054. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3055. //ishcel0.CellFormat.VerticalAlignment=
  3056. index++;
  3057. }
  3058. row++;
  3059. }
  3060. #endregion
  3061. Paragraph lastParagraph = new Paragraph(doc);
  3062. //第一个表格末尾加段落
  3063. table.ParentNode.InsertAfter(lastParagraph, table);
  3064. //复制第一个表格
  3065. Table cloneTable = (Table)table.Clone(true);
  3066. //在文档末尾段落后面加入复制的表格
  3067. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3068. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3069. {
  3070. int rownewsIndex = 13;
  3071. for (int i = 0; i < 2; i++)
  3072. {
  3073. var CopyRow = table.Rows[12].Clone(true);
  3074. table.Rows.RemoveAt(13);
  3075. table.Rows.Add(CopyRow);
  3076. rownewsIndex++;
  3077. }
  3078. }
  3079. else
  3080. {
  3081. table.Rows.RemoveAt(12);
  3082. }
  3083. cloneTable.Rows.RemoveAt(12);
  3084. }
  3085. if (_AirTicketReservations.Count != 0)
  3086. {
  3087. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3088. if (FlightsCode.Length != 0)
  3089. {
  3090. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3091. if (_AirCompany != null)
  3092. {
  3093. string str = "--";
  3094. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3095. if (!string.IsNullOrEmpty(translateResult))
  3096. {
  3097. str = translateResult;
  3098. str = _airTicketResRep.Processing(str);
  3099. }
  3100. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3101. }
  3102. else
  3103. {
  3104. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3105. }
  3106. }
  3107. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3108. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3109. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3110. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3111. string names = "";
  3112. foreach (string clientName in nameArray)
  3113. {
  3114. names += clientName + ",";
  3115. }
  3116. if (!string.IsNullOrWhiteSpace(names))
  3117. {
  3118. string str = "--";
  3119. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3120. if (!string.IsNullOrEmpty(translateResult))
  3121. {
  3122. str = translateResult;
  3123. str = _airTicketResRep.Processing(str);
  3124. }
  3125. table.Range.Bookmarks["ClientName"].Text = str;
  3126. }
  3127. else
  3128. {
  3129. table.Range.Bookmarks["ClientName"].Text = "--";
  3130. }
  3131. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3132. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3133. table.Range.Bookmarks["JointTicket"].Text = "--";
  3134. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3135. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3136. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3137. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3138. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3139. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3140. }
  3141. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3142. //保存合并后的文档
  3143. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3144. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3145. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3146. return Ok(JsonView(true, "成功!", rst));
  3147. }
  3148. }
  3149. }
  3150. catch (Exception ex)
  3151. {
  3152. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3153. throw;
  3154. }
  3155. }
  3156. #endregion
  3157. #region 团组增减款项 --> 其他款项
  3158. /// <summary>
  3159. /// 团组增减款项下拉框绑定
  3160. /// </summary>
  3161. /// <param name="dto"></param>
  3162. /// <returns></returns>
  3163. [HttpPost]
  3164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3165. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3166. {
  3167. #region 参数验证
  3168. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3169. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3170. #endregion
  3171. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3172. }
  3173. /// <summary>
  3174. /// 根据团组Id查询团组增减款项
  3175. /// </summary>
  3176. /// <param name="dto"></param>
  3177. /// <returns></returns>
  3178. [HttpPost]
  3179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3180. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3181. {
  3182. #region 参数验证
  3183. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3184. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3185. #endregion
  3186. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3187. }
  3188. /// <summary>
  3189. /// 团组增减款项操作(Status:1.新增,2.修改)
  3190. /// </summary>
  3191. /// <param name="dto"></param>
  3192. /// <returns></returns>
  3193. [HttpPost]
  3194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3195. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3196. {
  3197. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3198. if (groupData.Code != 200)
  3199. {
  3200. return Ok(JsonView(false, groupData.Msg));
  3201. }
  3202. #region 应用推送
  3203. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3204. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3205. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3206. //2024-10-21 新增LZ UID
  3207. var userIds = new List<int>() { 21 };
  3208. string title = $"系统通知";
  3209. string content = "";
  3210. var diId = dto.DiId;
  3211. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3212. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3213. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3214. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3215. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3216. await GeneralMethod.iOS_PushNotifications("051", $"其他款项费用审核", "", content);
  3217. #endregion
  3218. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3219. }
  3220. /// <summary>
  3221. /// 团组增减款项操作 删除
  3222. /// </summary>
  3223. /// <param name="dto"></param>
  3224. /// <returns></returns>
  3225. [HttpPost]
  3226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3227. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3228. {
  3229. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3230. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3231. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3232. if (res.Code == 0)
  3233. {
  3234. return Ok(JsonView(true, "删除成功!"));
  3235. }
  3236. return Ok(JsonView(false, "删除失败!"));
  3237. }
  3238. /// <summary>
  3239. /// 根据团组增减款项Id查询
  3240. /// </summary>
  3241. /// <param name="dto"></param>
  3242. /// <returns></returns>
  3243. [HttpPost]
  3244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3245. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3246. {
  3247. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3248. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3249. }
  3250. /// <summary>
  3251. /// 查询供应商名称
  3252. /// </summary>
  3253. /// <param name="dto"></param>
  3254. /// <returns></returns>
  3255. [HttpPost]
  3256. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3257. {
  3258. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3259. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3260. ?? new List<Grp_DecreasePayments>();
  3261. dbResult = dbResult.Distinct(new
  3262. ProductComparer()).ToList();
  3263. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3264. {
  3265. x.Id,
  3266. x.SupplierAddress,
  3267. x.SupplierArea,
  3268. x.SupplierContact,
  3269. x.SupplierContactNumber,
  3270. x.SupplierEmail,
  3271. x.SupplierName,
  3272. x.SupplierSocialAccount,
  3273. x.SupplierTypeId,
  3274. }).ToList());
  3275. return Ok(jw);
  3276. }
  3277. /// <summary>
  3278. /// 团组增减款项 OTA匹配
  3279. /// </summary>
  3280. /// <param name="file"></param>
  3281. /// <returns></returns>
  3282. [HttpPost]
  3283. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3284. {
  3285. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3286. string fileName = file.FileName;
  3287. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3288. {
  3289. return Ok(JsonView(false, "请上传Excel文件!"));
  3290. }
  3291. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3292. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3293. if (!Directory.Exists(path))
  3294. {
  3295. Directory.CreateDirectory(path);
  3296. }
  3297. var filePath = @$"{path}/{fileName}";
  3298. //保存文件
  3299. using (FileStream fs = System.IO.File.Create(filePath))
  3300. {
  3301. file.CopyTo(fs);
  3302. fs.Flush();
  3303. }
  3304. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3305. //读取ExcelFile
  3306. DataTable dt = ConvertExcelToDataTable(filePath);
  3307. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3308. dt.TableName = "TB";
  3309. //修改table列名
  3310. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3311. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3312. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3313. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3314. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3315. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3316. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3317. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3318. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3319. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3320. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3321. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3322. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3323. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3324. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3325. var otaOrderNos = new List<string>();
  3326. foreach (DataRow item in dt.Rows)
  3327. {
  3328. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3329. }
  3330. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3331. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3332. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3333. .Select((dp, di) => new
  3334. {
  3335. dp.PriceName,
  3336. dp.OTAOrderNo,
  3337. dp.FeeTotal,
  3338. di.TeamName,
  3339. })
  3340. .ToListAsync();
  3341. foreach (DataRow item in dt.Rows)
  3342. {
  3343. var otaOrderNo = item["OTAOrderNo"].ToString();
  3344. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3345. if (oaData == null) continue;
  3346. item["GroupName"] = oaData.TeamName;
  3347. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3348. }
  3349. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3350. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3351. List<DataTable> datas = new List<DataTable>();
  3352. datas.Add(dt);
  3353. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3354. return Ok(JsonView(true, "操作成功", new { url = url }));
  3355. }
  3356. #region
  3357. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3358. {
  3359. // 创建Workbook对象
  3360. Workbook workbook = new Workbook(excelFilePath);
  3361. // 获取第一个工作表
  3362. Worksheet worksheet = workbook.Worksheets[0];
  3363. // 将工作表转换为DataTable
  3364. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3365. return dataTable;
  3366. }
  3367. #endregion
  3368. #endregion
  3369. #region 文件上传、删除
  3370. /// <summary>
  3371. /// region 文件上传 可以带参数
  3372. /// </summary>
  3373. /// <param name="file"></param>
  3374. /// <returns></returns>
  3375. [HttpPost]
  3376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3377. public async Task<IActionResult> UploadProject(IFormFile file)
  3378. {
  3379. //var TypeName = Request.Headers["TypeName"].ToString();
  3380. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3381. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3382. ////文件名称
  3383. //string projectFileName = file.FileName;
  3384. ////上传的文件的路径
  3385. //string filePath = $"{fileDir}/{projectFileName}";
  3386. //if (TypeName == "A")//A代表团组增减款项
  3387. //{
  3388. // filePath = fileDir + $@"\团组增减款项相关文件";
  3389. // if (!Directory.Exists(filePath))
  3390. // {
  3391. // Directory.CreateDirectory(filePath);
  3392. // }
  3393. // //上传的文件的路径
  3394. // filePath += $@"\{projectFileName}";
  3395. //}
  3396. //else if (TypeName == "B")//B代表商邀相关文件
  3397. //{
  3398. // //上传的文件的路径
  3399. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3400. // if (!Directory.Exists(filePath))
  3401. // {
  3402. // Directory.CreateDirectory(filePath);
  3403. // }
  3404. // //上传的文件的路径
  3405. // filePath = $@"\{projectFileName}";
  3406. //}
  3407. //try
  3408. //{
  3409. // using (FileStream fs = System.IO.File.Create(filePath))
  3410. // {
  3411. // file.CopyTo(fs);
  3412. // fs.Flush();
  3413. // }
  3414. //}
  3415. //catch (Exception ex)
  3416. //{
  3417. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3418. //}
  3419. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3420. try
  3421. {
  3422. var TypeName = Request.Headers["TypeName"].ToString();
  3423. if (file != null)
  3424. {
  3425. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3426. //文件名称
  3427. string projectFileName = file.FileName;
  3428. //上传的文件的路径
  3429. string filePath = $"{fileDir}/{projectFileName}";
  3430. if (TypeName == "A")//A代表团组增减款项
  3431. {
  3432. if (!Directory.Exists(fileDir))
  3433. {
  3434. Directory.CreateDirectory(fileDir);
  3435. }
  3436. //上传的文件的路径
  3437. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3438. }
  3439. else if (TypeName == "B")//B代表商邀相关文件
  3440. {
  3441. if (!Directory.Exists(fileDir))
  3442. {
  3443. Directory.CreateDirectory(fileDir);
  3444. }
  3445. //上传的文件的路径
  3446. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3447. }
  3448. using (FileStream fs = System.IO.File.Create(filePath))
  3449. {
  3450. file.CopyTo(fs);
  3451. fs.Flush();
  3452. }
  3453. return Ok(JsonView(true, "上传成功!", projectFileName));
  3454. }
  3455. else
  3456. {
  3457. return Ok(JsonView(false, "上传失败!"));
  3458. }
  3459. }
  3460. catch (Exception ex)
  3461. {
  3462. return Ok(JsonView(false, "程序错误!"));
  3463. }
  3464. }
  3465. /// <summary>
  3466. /// 删除指定文件
  3467. /// </summary>
  3468. /// <param name="dto"></param>
  3469. /// <returns></returns>
  3470. [HttpPost]
  3471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3472. public async Task<IActionResult> DelFile(DelFileDto dto)
  3473. {
  3474. try
  3475. {
  3476. var TypeName = Request.Headers["TypeName"].ToString();
  3477. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3478. string filePath = "";
  3479. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3480. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3481. int id = 0;
  3482. if (TypeName == "A")
  3483. {
  3484. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3485. // 删除该文件
  3486. System.IO.File.Delete(filePath);
  3487. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3488. .Where(a => a.Id == dto.Id)
  3489. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3490. .ExecuteCommandAsync();
  3491. }
  3492. else if (TypeName == "B")
  3493. {
  3494. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3495. // 删除该文件
  3496. System.IO.File.Delete(filePath);
  3497. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3498. if (info != null)
  3499. {
  3500. string[] files = new string[] { };
  3501. if (!string.IsNullOrEmpty(info.Attachment))
  3502. {
  3503. try
  3504. {
  3505. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3506. }
  3507. catch (Exception)
  3508. {
  3509. files = new List<string>() { info.Attachment }.ToArray();
  3510. }
  3511. }
  3512. if (files.Length > 0)
  3513. {
  3514. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3515. string filePath2 = string.Empty;
  3516. if (files1.Length > 0)
  3517. {
  3518. filePath2 = JsonConvert.SerializeObject(files1);
  3519. }
  3520. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3521. .Where(a => a.Id == dto.Id)
  3522. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3523. .ExecuteCommandAsync();
  3524. }
  3525. }
  3526. }
  3527. if (id != 0)
  3528. {
  3529. return Ok(JsonView(true, "成功!"));
  3530. }
  3531. else
  3532. {
  3533. return Ok(JsonView(false, "失败!"));
  3534. }
  3535. }
  3536. catch (Exception ex)
  3537. {
  3538. return Ok(JsonView(false, "程序错误!"));
  3539. throw;
  3540. }
  3541. }
  3542. /// <summary>
  3543. /// 文件上传多个文件 可以带参数
  3544. /// </summary>
  3545. /// <param name="file"></param>
  3546. /// <returns></returns>
  3547. [HttpPost]
  3548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3549. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3550. {
  3551. try
  3552. {
  3553. var TypeName = Request.Headers["TypeName"].ToString();
  3554. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3555. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3556. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3557. var filePahts = new List<string>();
  3558. foreach (var file in files)
  3559. {
  3560. //文件名称
  3561. string projectFileName = file.FileName;
  3562. //上传的文件的路径
  3563. string filePath = $"{fileDir}/{projectFileName}";
  3564. if (TypeName == "A")//A代表团组增减款项
  3565. {
  3566. if (!Directory.Exists(fileDir))
  3567. {
  3568. Directory.CreateDirectory(fileDir);
  3569. }
  3570. //上传的文件的路径
  3571. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3572. }
  3573. else if (TypeName == "B")//B代表商邀相关文件
  3574. {
  3575. if (!Directory.Exists(fileDir))
  3576. {
  3577. Directory.CreateDirectory(fileDir);
  3578. }
  3579. //上传的文件的路径
  3580. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3581. }
  3582. using (FileStream fs = System.IO.File.Create(filePath))
  3583. {
  3584. file.CopyTo(fs);
  3585. fs.Flush();
  3586. }
  3587. filePahts.Add(projectFileName);
  3588. }
  3589. return Ok(JsonView(true, "上传成功!", filePahts));
  3590. }
  3591. catch (Exception ex)
  3592. {
  3593. return Ok(JsonView(false, "程序错误!"));
  3594. }
  3595. }
  3596. #endregion
  3597. #region 商邀费用录入
  3598. /// <summary>
  3599. /// 根据团组Id查询商邀费用列表
  3600. /// </summary>
  3601. /// <param name="dto"></param>
  3602. /// <returns></returns>
  3603. [HttpPost]
  3604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3605. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3606. {
  3607. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3608. if (groupData.Code != 0)
  3609. {
  3610. return Ok(JsonView(false, groupData.Msg));
  3611. }
  3612. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3613. }
  3614. /// <summary>
  3615. /// 商邀费用列表
  3616. /// 下载文件
  3617. /// </summary>
  3618. /// <param name="dto"></param>
  3619. /// <returns></returns>
  3620. [HttpGet("{id}")]
  3621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3622. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3623. {
  3624. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3625. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3626. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3627. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3628. var filePaths = new List<string>();
  3629. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3630. try
  3631. {
  3632. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3633. }
  3634. catch (Exception ex)
  3635. {
  3636. filePaths.Add(info.Attachment);
  3637. }
  3638. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3639. for (int i = 0; i < filePaths.Count; i++)
  3640. {
  3641. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3642. }
  3643. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3644. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3645. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3646. {
  3647. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3648. {
  3649. foreach (string filePath in filePaths)
  3650. {
  3651. if (System.IO.File.Exists(filePath))
  3652. {
  3653. // 获取文件名
  3654. string fileName = Path.GetFileName(filePath);
  3655. // 将文件添加到ZIP归档中
  3656. zipArchive.CreateEntryFromFile(filePath, fileName);
  3657. }
  3658. }
  3659. }
  3660. }
  3661. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3662. }
  3663. /// <summary>
  3664. /// 商邀费用 Info Page 基础数据源
  3665. /// </summary>
  3666. /// <param name="dto"></param>
  3667. /// <returns></returns>
  3668. [HttpPost]
  3669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3670. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3671. {
  3672. try
  3673. {
  3674. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3675. if (groupData.Code != 0)
  3676. {
  3677. return Ok(JsonView(false, groupData.Msg));
  3678. }
  3679. return Ok(JsonView(true, "操作成功", groupData.Data));
  3680. }
  3681. catch (Exception ex)
  3682. {
  3683. return Ok(JsonView(false, ex.Message));
  3684. throw;
  3685. }
  3686. }
  3687. /// <summary>
  3688. /// 根据商邀费用ID查询C表和商邀费用数据
  3689. /// </summary>
  3690. /// <param name="dto"></param>
  3691. /// <returns></returns>
  3692. [HttpPost]
  3693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3694. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3695. {
  3696. try
  3697. {
  3698. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3699. if (groupData.Code != 0)
  3700. {
  3701. return Ok(JsonView(false, groupData.Msg));
  3702. }
  3703. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3704. }
  3705. catch (Exception ex)
  3706. {
  3707. return Ok(JsonView(false, ex.Message));
  3708. throw;
  3709. }
  3710. }
  3711. /// <summary>
  3712. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3713. /// </summary>
  3714. /// <param name="dto"></param>
  3715. /// <returns></returns>
  3716. [HttpPost]
  3717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3718. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3719. {
  3720. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3721. if (groupData.Code != 0)
  3722. {
  3723. return Ok(JsonView(false, groupData.Msg));
  3724. }
  3725. #region 应用推送
  3726. try
  3727. {
  3728. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3729. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3730. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3731. //2024-10-21 新增LZ UID
  3732. var userIds = new List<int>() { 21 };
  3733. string title = $"系统通知";
  3734. string content = "";
  3735. var diId = dto.DiId;
  3736. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3737. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3738. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3739. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3740. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3741. await GeneralMethod.iOS_PushNotifications("051", $"商邀费用审核", "", content);
  3742. }
  3743. catch (Exception ex)
  3744. {
  3745. }
  3746. #endregion
  3747. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3748. }
  3749. /// <summary>
  3750. /// 商邀删除
  3751. /// </summary>
  3752. /// <param name="dto"></param>
  3753. /// <returns></returns>
  3754. [HttpPost]
  3755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3756. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3757. {
  3758. try
  3759. {
  3760. _sqlSugar.BeginTran();
  3761. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3762. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3763. {
  3764. IsDel = 1,
  3765. DeleteUserId = dto.DeleteUserId,
  3766. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3767. })
  3768. .Where(it => it.Id == dto.Id)
  3769. .ExecuteCommand();
  3770. if (res1 > 0)
  3771. {
  3772. int _diId = 0;
  3773. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3774. if (_ioaInfo != null)
  3775. {
  3776. _diId = _ioaInfo.DiId;
  3777. }
  3778. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3779. .SetColumns(a => new Grp_CreditCardPayment()
  3780. {
  3781. IsDel = 1,
  3782. DeleteUserId = dto.DeleteUserId,
  3783. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3784. })
  3785. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3786. .ExecuteCommand();
  3787. if (res2 > 0)
  3788. {
  3789. _sqlSugar.CommitTran();
  3790. return Ok(JsonView(true, "删除成功!"));
  3791. }
  3792. }
  3793. _sqlSugar.RollbackTran();
  3794. return Ok(JsonView(false, "删除失败"));
  3795. }
  3796. catch (Exception ex)
  3797. {
  3798. _sqlSugar.RollbackTran();
  3799. return Ok(JsonView(false, ex.Message));
  3800. }
  3801. }
  3802. /// <summary>
  3803. /// 团组模块文件上传
  3804. /// </summary>
  3805. /// <param name="dto"></param>
  3806. /// <returns></returns>
  3807. [HttpPost]
  3808. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3809. {
  3810. var jw = JsonView(false);
  3811. long M = 1024 * 1024;
  3812. if (dto.Files == null || dto.Files.Count == 0)
  3813. {
  3814. jw.Msg = "无文件信息!";
  3815. return Ok(jw);
  3816. }
  3817. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3818. {
  3819. jw.Msg = "文件大小超过20M!";
  3820. return Ok(jw);
  3821. }
  3822. //var nameSp = dto.File.FileName.Split(".");
  3823. //if (nameSp.Length < 2)
  3824. //{
  3825. // jw.Msg = "拓展名称有误!";
  3826. // return Ok(jw);
  3827. //}
  3828. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3829. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3830. //{
  3831. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3832. // return Ok(jw);
  3833. //}
  3834. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3835. if (Ctable == null)
  3836. {
  3837. jw.Msg = "Ctable指向有误!";
  3838. return Ok(jw);
  3839. }
  3840. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3841. if (groupInfo == null)
  3842. {
  3843. jw.Msg = "团组信息不存在!";
  3844. return Ok(jw);
  3845. }
  3846. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3847. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3848. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3849. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3850. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3851. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3852. try
  3853. {
  3854. if (!Directory.Exists(fileBase))
  3855. {
  3856. Directory.CreateDirectory(fileBase);
  3857. }
  3858. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3859. foreach (var fileStream in dto.Files)
  3860. {
  3861. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3862. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3863. {
  3864. Cid = dto.Cid,
  3865. CreateTime = DateTime.Now,
  3866. CreateUserId = dto.Userid,
  3867. Ctable = dto.Ctable,
  3868. Diid = dto.Diid,
  3869. IsDel = 0,
  3870. FilePath = saveFilePath,
  3871. FileName = fileStream.FileName
  3872. };
  3873. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3874. {
  3875. fileStream.CopyTo(fs);
  3876. fs.Flush();
  3877. }
  3878. saveArr.Add(file);
  3879. }
  3880. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3881. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3882. jw = JsonView(true, "保存成功!", new
  3883. {
  3884. count = addResult,
  3885. filesName = saveArr.Select(x => x.FileName)
  3886. });
  3887. }
  3888. catch (Exception ex)
  3889. {
  3890. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3891. {
  3892. count = 0,
  3893. filesName = new string[0],
  3894. });
  3895. }
  3896. return Ok(jw);
  3897. }
  3898. /// <summary>
  3899. /// 查询各模块已保存文件
  3900. /// </summary>
  3901. /// <param name="dto"></param>
  3902. /// <returns></returns>
  3903. [HttpPost]
  3904. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3905. {
  3906. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3907. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3908. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3909. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3910. {
  3911. expression = Expressionable.Create<Grp_GroupModelFile>()
  3912. .And(x => visaIds.Contains(x.CreateUserId));
  3913. }
  3914. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3915. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3916. .Where(expression.ToExpression())
  3917. .ToList();
  3918. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3919. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3920. {
  3921. x.FileName,
  3922. x.Id,
  3923. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3924. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3925. })));
  3926. }
  3927. /// <summary>
  3928. /// 下载该团组下的所有文件
  3929. /// </summary>
  3930. /// <param name="dto"></param>
  3931. /// <returns></returns>
  3932. [HttpPost]
  3933. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3934. {
  3935. var jw = JsonView(false);
  3936. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3937. if (groupInfo == null)
  3938. {
  3939. jw.Msg = "团组信息不存在!";
  3940. return Ok(jw);
  3941. }
  3942. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3943. var isModule = Convert.ToBoolean(dto.isModule);
  3944. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3945. IOOperatorHelper io = new IOOperatorHelper();
  3946. if (isModule)
  3947. {
  3948. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3949. foreach (var moduleArr in moduleGroup)
  3950. {
  3951. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3952. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3953. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3954. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3955. foreach (var item in moduleArr)
  3956. {
  3957. if (System.IO.File.Exists(item.FilePath))
  3958. {
  3959. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3960. {
  3961. byte[] bytes = new byte[fileStream.Length];
  3962. fileStream.Read(bytes, 0, bytes.Length);
  3963. fileStream.Close();
  3964. Stream stream = new MemoryStream(bytes);
  3965. chiZips.Add(item.FileName, stream);
  3966. }
  3967. }
  3968. }
  3969. if (chiZips.Count > 0)
  3970. {
  3971. var byts = io.ConvertZipStream(chiZips);
  3972. Stream stream = new MemoryStream(byts);
  3973. Zips.Add(key.Name + "_.zip", stream);
  3974. }
  3975. }
  3976. }
  3977. else
  3978. {
  3979. foreach (var item in dbQuery)
  3980. {
  3981. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3982. {
  3983. byte[] bytes = new byte[fileStream.Length];
  3984. fileStream.Read(bytes, 0, bytes.Length);
  3985. fileStream.Close();
  3986. Stream stream = new MemoryStream(bytes);
  3987. while (Zips.Keys.Contains(item.FileName))
  3988. {
  3989. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3990. }
  3991. Zips.Add(item.FileName, stream);
  3992. }
  3993. }
  3994. }
  3995. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3996. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3997. if (Zips.Count > 0)
  3998. {
  3999. var byts = io.ConvertZipStream(Zips);
  4000. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4001. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4002. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4003. }
  4004. else
  4005. {
  4006. jw.Msg = "暂无生成文件!";
  4007. }
  4008. return Ok(jw);
  4009. }
  4010. /// <summary>
  4011. /// 下载该团组下此模块的所有文件
  4012. /// </summary>
  4013. /// <param name="dto"></param>
  4014. /// <returns></returns>
  4015. [HttpPost]
  4016. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4017. {
  4018. var jw = JsonView(false);
  4019. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4020. if (groupInfo == null)
  4021. {
  4022. jw.Msg = "团组信息不存在!";
  4023. return Ok(jw);
  4024. }
  4025. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4026. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4027. && x.IsDel == 0);
  4028. if (key == null)
  4029. {
  4030. jw.Msg = "Ctable指向错误!";
  4031. return Ok(jw);
  4032. }
  4033. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4034. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4035. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4036. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4037. IOOperatorHelper io = new IOOperatorHelper();
  4038. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4039. foreach (var item in dbQuery)
  4040. {
  4041. if (System.IO.File.Exists(item.FilePath))
  4042. {
  4043. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4044. {
  4045. byte[] bytes = new byte[fileStream.Length];
  4046. fileStream.Read(bytes, 0, bytes.Length);
  4047. fileStream.Close();
  4048. Stream stream = new MemoryStream(bytes);
  4049. while (Zips.Keys.Contains(item.FileName))
  4050. {
  4051. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4052. }
  4053. Zips.Add(item.FileName, stream);
  4054. }
  4055. }
  4056. }
  4057. if (Zips.Count > 0)
  4058. {
  4059. var byts = io.ConvertZipStream(Zips);
  4060. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4061. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4062. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4063. }
  4064. else
  4065. {
  4066. jw.Msg = "暂无生成文件!";
  4067. }
  4068. return Ok(jw);
  4069. }
  4070. /// <summary>
  4071. /// 删除该团组下的指定文件
  4072. /// </summary>
  4073. /// <param name="dto"></param>
  4074. /// <returns></returns>
  4075. [HttpPost]
  4076. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4077. {
  4078. var jw = JsonView(false);
  4079. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4080. if (sing == null)
  4081. {
  4082. jw.Msg = "暂无";
  4083. return Ok(jw);
  4084. }
  4085. if (System.IO.File.Exists(sing.FilePath))
  4086. {
  4087. try
  4088. {
  4089. System.IO.File.Delete(sing.FilePath);
  4090. }
  4091. catch (Exception ex)
  4092. {
  4093. jw.Msg = "删除失败!" + ex.Message;
  4094. return Ok(jw);
  4095. }
  4096. }
  4097. sing.IsDel = 1;
  4098. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4099. sing.DeleteUserId = dto.UserId;
  4100. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4101. jw = JsonView(true, "删除成功!");
  4102. return Ok(jw);
  4103. }
  4104. #endregion
  4105. #region 团组英文资料
  4106. /// <summary>
  4107. /// 查询团组英文所有资料
  4108. /// </summary>
  4109. /// <param name="dto"></param>
  4110. /// <returns></returns>
  4111. [HttpPost]
  4112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4113. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4114. {
  4115. try
  4116. {
  4117. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4118. if (groupData.Code != 0)
  4119. {
  4120. return Ok(JsonView(false, groupData.Msg));
  4121. }
  4122. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4123. }
  4124. catch (Exception ex)
  4125. {
  4126. return Ok(JsonView(false, "程序错误!"));
  4127. throw;
  4128. }
  4129. }
  4130. /// <summary>
  4131. /// 团组英文资料操作(Status:1.新增,2.修改)
  4132. /// </summary>
  4133. /// <param name="dto"></param>
  4134. /// <returns></returns>
  4135. [HttpPost]
  4136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4137. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4138. {
  4139. try
  4140. {
  4141. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4142. if (groupData.Code != 0)
  4143. {
  4144. return Ok(JsonView(false, groupData.Msg));
  4145. }
  4146. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4147. }
  4148. catch (Exception ex)
  4149. {
  4150. return Ok(JsonView(false, "程序错误!"));
  4151. throw;
  4152. }
  4153. }
  4154. /// <summary>
  4155. /// 团组英文资料Id查询数据
  4156. /// </summary>
  4157. /// <param name="dto"></param>
  4158. /// <returns></returns>
  4159. [HttpPost]
  4160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4161. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4162. {
  4163. try
  4164. {
  4165. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4166. if (_DelegationEnData != null)
  4167. {
  4168. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4169. }
  4170. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4171. }
  4172. catch (Exception ex)
  4173. {
  4174. return Ok(JsonView(false, "程序错误!"));
  4175. throw;
  4176. }
  4177. }
  4178. /// <summary>
  4179. /// 团组英文资料删除
  4180. /// </summary>
  4181. /// <param name="dto"></param>
  4182. /// <returns></returns>
  4183. [HttpPost]
  4184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4185. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4186. {
  4187. try
  4188. {
  4189. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4190. if (!res)
  4191. {
  4192. return Ok(JsonView(false, "删除失败"));
  4193. }
  4194. return Ok(JsonView(true, "删除成功!"));
  4195. }
  4196. catch (Exception ex)
  4197. {
  4198. return Ok(JsonView(false, "程序错误!"));
  4199. throw;
  4200. }
  4201. }
  4202. #endregion
  4203. #region 导出邀请函
  4204. /// <summary>
  4205. /// 导出邀请函页面初始化
  4206. /// </summary>
  4207. /// <param name="dto"></param>
  4208. /// <returns></returns>
  4209. [HttpPost]
  4210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4211. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4212. {
  4213. try
  4214. {
  4215. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4216. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4217. if (dto.DiId == 0)
  4218. {
  4219. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4220. }
  4221. else
  4222. {
  4223. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4224. }
  4225. return Ok(JsonView(true, "查询成功!", new
  4226. {
  4227. deleClient = crm_Deles,
  4228. delegations = grp_Delegations
  4229. }));
  4230. }
  4231. catch (Exception ex)
  4232. {
  4233. return Ok(JsonView(false, "程序错误!"));
  4234. throw;
  4235. }
  4236. }
  4237. /// <summary>
  4238. /// 导出邀请函
  4239. /// </summary>
  4240. /// <param name="dto"></param>
  4241. /// <returns></returns>
  4242. [HttpPost]
  4243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4244. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4245. {
  4246. #region 参数验证
  4247. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4248. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4249. #endregion
  4250. try
  4251. {
  4252. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4253. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4254. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4255. From Grp_TourClientList tcl
  4256. Left Join
  4257. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4258. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4259. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4260. From Crm_DeleClient dc
  4261. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4262. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4263. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4264. Where dc.IsDel = 0) temp
  4265. On temp.DcId =tcl.ClientId
  4266. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4267. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4268. List<string> texts = new List<string>();
  4269. if (datas.Count != 0)
  4270. {
  4271. foreach (TourClientListDetailsView item in datas)
  4272. {
  4273. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4274. {
  4275. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4276. }
  4277. else
  4278. {
  4279. string name = item.LastName + item.FirstName;
  4280. texts.Add(name);
  4281. }
  4282. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4283. {
  4284. if (!transDic.ContainsKey(item.Job))
  4285. {
  4286. texts.Add(item.Job);
  4287. }
  4288. }
  4289. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4290. {
  4291. texts.Add(item.CompanyFullName);
  4292. }
  4293. }
  4294. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4295. if (transData.Count > 0)
  4296. {
  4297. foreach (TranslateResult item in transData)
  4298. {
  4299. if (!transDic.ContainsKey(item.Query))
  4300. {
  4301. transDic.Add(item.Query, item.Translation);
  4302. }
  4303. }
  4304. }
  4305. List<GuestList> list = new List<GuestList>();
  4306. foreach (TourClientListDetailsView dele in datas)
  4307. {
  4308. GuestList guestList = new GuestList();
  4309. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4310. {
  4311. guestList.Name = dele.Pinyin;
  4312. }
  4313. else
  4314. {
  4315. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4316. guestList.Name = Name;
  4317. }
  4318. if (dele.Sex == 0)
  4319. {
  4320. guestList.Sex = "Male";
  4321. }
  4322. else if (dele.Sex == 1)
  4323. {
  4324. guestList.Sex = "Female";
  4325. }
  4326. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4327. if (!string.IsNullOrEmpty(dele.Job))
  4328. {
  4329. guestList.Job = dele.Job;
  4330. }
  4331. list.Add(guestList);
  4332. }
  4333. //载入模板
  4334. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4335. DocumentBuilder builder = new DocumentBuilder(doc);
  4336. //获取word里所有表格
  4337. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4338. //获取所填表格的序数
  4339. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4340. var rowStart = tableOne.Rows[0]; //获取第1行
  4341. //循环赋值
  4342. for (int i = 0; i < list.Count; i++)
  4343. {
  4344. builder.MoveToCell(0, i + 1, 0, 0);
  4345. builder.Write(list[i].Name.ToString());
  4346. builder.MoveToCell(0, i + 1, 1, 0);
  4347. builder.Write(list[i].Sex.ToString());
  4348. builder.MoveToCell(0, i + 1, 2, 0);
  4349. builder.Write(list[i].DOB.ToString());
  4350. builder.MoveToCell(0, i + 1, 3, 0);
  4351. builder.Write(list[i].Job.ToString());
  4352. }
  4353. //删除多余行
  4354. while (tableOne.Rows.Count > list.Count + 1)
  4355. {
  4356. tableOne.Rows.RemoveAt(list.Count + 1);
  4357. }
  4358. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4359. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4360. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4361. doc.Save(filePath);
  4362. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4363. return Ok(JsonView(true, "操作成功!", Url));
  4364. }
  4365. else
  4366. {
  4367. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4368. }
  4369. }
  4370. catch (Exception ex)
  4371. {
  4372. return Ok(JsonView(false, ex.Message));
  4373. throw;
  4374. }
  4375. }
  4376. #endregion
  4377. #region 团组经理模块 出入境费用
  4378. ///// <summary>
  4379. ///// 团组模块 - 出入境费用
  4380. ///// </summary>
  4381. ///// <returns></returns>
  4382. //[HttpPost]
  4383. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4384. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4385. //{
  4386. // try
  4387. // {
  4388. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4389. // if (data.Code != 0)
  4390. // {
  4391. // return Ok(JsonView(false, data.Msg));
  4392. // }
  4393. // return Ok(JsonView(true, "查询成功!"));
  4394. // }
  4395. // catch (Exception ex)
  4396. // {
  4397. // return Ok(JsonView(false, ex.Message));
  4398. // throw;
  4399. // }
  4400. //}
  4401. /// <summary>
  4402. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4403. /// </summary>
  4404. /// <returns></returns>
  4405. [HttpPost]
  4406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4407. public async Task<IActionResult> SetDayAndCostAreaChange()
  4408. {
  4409. try
  4410. {
  4411. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4412. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4413. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4414. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4415. foreach (var item in unite) //处理交集数据
  4416. {
  4417. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4418. }
  4419. foreach (var item in merge) //处理差集数据
  4420. {
  4421. int nationalTravelFeeId = 0;
  4422. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4423. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4424. else
  4425. {
  4426. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4427. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4428. }
  4429. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4430. }
  4431. //只更新dayAndCost 的 nationalTravelFeeId;
  4432. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4433. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4434. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4435. }
  4436. catch (Exception ex)
  4437. {
  4438. return Ok(JsonView(false, ex.Message));
  4439. throw;
  4440. }
  4441. }
  4442. /// <summary>
  4443. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4444. /// </summary>
  4445. /// <returns></returns>
  4446. [HttpPost]
  4447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4448. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4449. {
  4450. try
  4451. {
  4452. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4453. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4454. //SetDataInfoView
  4455. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4456. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4457. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4458. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4459. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4460. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4461. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4462. //默认币种显示
  4463. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4464. {
  4465. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4466. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4467. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4468. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4469. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4470. };
  4471. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4472. if (_currencyRate.Count > 0)
  4473. {
  4474. foreach (var item in _currencyInfos)
  4475. {
  4476. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4477. if (rateInfo != null)
  4478. {
  4479. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4480. rate1 *= 1.035M;
  4481. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4482. }
  4483. }
  4484. }
  4485. return Ok(JsonView(true, "查询成功!", new
  4486. {
  4487. GroupNameData = groupNameData.Data,
  4488. CurrencyData = _CurrencyData,
  4489. WordTypeData = _WordTypeData,
  4490. ExcelTypeData = _ExcelTypeData,
  4491. CurrencyInit = _currencyInfos
  4492. }));
  4493. }
  4494. catch (Exception ex)
  4495. {
  4496. return Ok(JsonView(false, ex.Message));
  4497. throw;
  4498. }
  4499. }
  4500. /// <summary>
  4501. /// 团组模块 - 出入境费用
  4502. /// 实时汇率 tips
  4503. /// 签证费用 tips
  4504. /// </summary>
  4505. /// <returns></returns>
  4506. [HttpPost]
  4507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4508. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4509. {
  4510. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4511. //默认币种显示
  4512. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4513. {
  4514. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4515. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4516. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4517. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4518. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4519. };
  4520. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4521. List<dynamic> reteInfos = new List<dynamic>();
  4522. if (_currencyRate.Count > 0)
  4523. {
  4524. foreach (var item in _currencyInfos)
  4525. {
  4526. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4527. if (rateInfo != null)
  4528. {
  4529. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4530. decimal rate1 = item.Rate;
  4531. rate1 *= 1.03M;
  4532. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4533. reteInfos.Add(new
  4534. {
  4535. currCode = item.CurrencyCode,
  4536. currName = item.CurrencyName,
  4537. rate = rate2,
  4538. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4539. });
  4540. }
  4541. }
  4542. }
  4543. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4544. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4545. return Ok(JsonView(true, "查询成功!", new
  4546. {
  4547. //GroupNameData = groupNameData.Data,
  4548. visaData = visaData.Data,
  4549. airData = airData.Data,
  4550. reteInfos = reteInfos
  4551. }));
  4552. }
  4553. /// <summary>
  4554. /// 团组模块 - 出入境费用 - Info
  4555. /// </summary>
  4556. /// <returns></returns>
  4557. [HttpPost]
  4558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4559. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4560. {
  4561. try
  4562. {
  4563. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4564. if (data.Code != 0)
  4565. {
  4566. return Ok(JsonView(false, data.Msg));
  4567. }
  4568. return Ok(JsonView(true, "查询成功!", data.Data));
  4569. }
  4570. catch (Exception ex)
  4571. {
  4572. return Ok(JsonView(false, ex.Message));
  4573. }
  4574. }
  4575. /// <summary>
  4576. /// 团组模块 - 出入境费用 - Add And Update
  4577. /// </summary>
  4578. /// <returns></returns>
  4579. [HttpPost]
  4580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4581. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4582. {
  4583. try
  4584. {
  4585. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4586. if (data.Code != 0)
  4587. {
  4588. return Ok(JsonView(false, data.Msg));
  4589. }
  4590. //生成默认文件pdf并且通知人员
  4591. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4592. {
  4593. DiId = dto.DiId,
  4594. ExportType = 1,
  4595. SubTypeId = 1005
  4596. }, "pdf");
  4597. //发送通知
  4598. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4599. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4600. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4601. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4602. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4603. //汇率信息记录
  4604. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4605. return Ok(JsonView(true, data.Msg, data.Data));
  4606. }
  4607. catch (Exception ex)
  4608. {
  4609. return Ok(JsonView(false, ex.Message));
  4610. }
  4611. }
  4612. /// <summary>
  4613. /// 团组模块 - 出入境费用 - Confirm 费用
  4614. /// </summary>
  4615. /// <returns></returns>
  4616. [HttpPost]
  4617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4618. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4619. {
  4620. //TODO:测试完毕需把对应的用户ID更改
  4621. //1、数据表添加字段
  4622. //2、更改字段接口()
  4623. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4624. //3、确认成功 给财务发送消息
  4625. if (_view.Code == 200)
  4626. {
  4627. if (dto.Type == 1)
  4628. {
  4629. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4630. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4631. }
  4632. }
  4633. return Ok(_view);
  4634. }
  4635. /// <summary>
  4636. /// 团组模块 - 出入境费用 - File downlaod
  4637. /// </summary>
  4638. /// <param name="dto"></param>
  4639. /// <returns></returns>
  4640. [HttpPost]
  4641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4642. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4643. {
  4644. try
  4645. {
  4646. if (dto.DiId < 1)
  4647. {
  4648. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4649. }
  4650. if (dto.ExportType < 1)
  4651. {
  4652. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4653. }
  4654. if (dto.SubTypeId < 1)
  4655. {
  4656. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4657. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4658. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4659. 3 团组成员名单 1 团组成员名单", ""));
  4660. }
  4661. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4662. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4663. if (_EnterExitCosts == null)
  4664. {
  4665. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4666. }
  4667. //数据源
  4668. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4669. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4670. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4671. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4672. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4673. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4674. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4675. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4676. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4677. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4678. .Select((tcl, dc, cc) => new
  4679. {
  4680. Name = dc.LastName + dc.FirstName,
  4681. Sex = dc.Sex,
  4682. Birthday = dc.BirthDay,
  4683. Company = cc.CompanyFullName,
  4684. Job = dc.Job
  4685. })
  4686. .ToList();
  4687. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4688. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4689. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4690. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4691. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4692. if (dto.ExportType == 1) //明细表
  4693. {
  4694. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4695. {
  4696. //获取模板
  4697. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4698. //载入模板
  4699. Document doc = new Document(tempPath);
  4700. DocumentBuilder builder = new DocumentBuilder(doc);
  4701. //利用键值对存放数据
  4702. Dictionary<string, string> dic = new Dictionary<string, string>();
  4703. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4704. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4705. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4706. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4707. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4708. //境内费用(其他费用)
  4709. if (_EnterExitCosts.ChoiceOne == 1)
  4710. {
  4711. string row1_1 = "";
  4712. if (_EnterExitCosts.Visa > 0)
  4713. {
  4714. //insidePayTotal += _EnterExitCosts.Visa;
  4715. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4716. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4717. {
  4718. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4719. }
  4720. }
  4721. string row1_2 = "";
  4722. if (_EnterExitCosts.YiMiao > 0)
  4723. {
  4724. //insidePayTotal += _EnterExitCosts.YiMiao;
  4725. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4726. }
  4727. if (_EnterExitCosts.HeSuan > 0)
  4728. {
  4729. //insidePayTotal += _EnterExitCosts.HeSuan;
  4730. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4731. }
  4732. if (_EnterExitCosts.Service > 0)
  4733. {
  4734. //insidePayTotal += _EnterExitCosts.Service;
  4735. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4736. }
  4737. string row1_3 = "";
  4738. if (_EnterExitCosts.Safe > 0)
  4739. {
  4740. //insidePayTotal += _EnterExitCosts.Safe;
  4741. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4742. }
  4743. if (_EnterExitCosts.Ticket > 0)
  4744. {
  4745. //insidePayTotal += _EnterExitCosts.Ticket;
  4746. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4747. }
  4748. string row1 = "";
  4749. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4750. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4751. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4752. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4753. dic.Add("Row1Str", row1);
  4754. }
  4755. string airTotalStr = string.Empty,
  4756. airPriceStr = string.Empty;
  4757. //经济舱
  4758. if (_EnterExitCosts.SumJJC == 1)
  4759. {
  4760. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4761. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4762. }
  4763. //公务舱
  4764. if (_EnterExitCosts.SumGWC == 1)
  4765. {
  4766. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4767. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4768. }
  4769. //头等舱
  4770. if (_EnterExitCosts.SumTDC == 1)
  4771. {
  4772. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4773. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4774. }
  4775. dic.Add("AirTotalStr", airTotalStr);
  4776. dic.Add("AirPriceStr", airPriceStr);
  4777. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4778. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4779. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4780. int table1Row = 0,
  4781. table2Row = 0,
  4782. table3Row = 0,
  4783. table4Row = 0;
  4784. //住宿费
  4785. if (_EnterExitCosts.ChoiceThree == 1)
  4786. {
  4787. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4788. table1Row = dac1.Count;
  4789. #region 填充word表格内容
  4790. for (int i = 0; i < dac1.Count; i++)
  4791. {
  4792. Grp_DayAndCost dac = dac1[i];
  4793. if (dac == null) continue;
  4794. builder.MoveToCell(0, i, 0, 0);
  4795. builder.Write("第" + dac.Days.ToString() + "晚:");
  4796. builder.MoveToCell(0, i, 1, 0);
  4797. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4798. //builder.Write(dac.Place == null ? "" : dac.Place);
  4799. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4800. builder.MoveToCell(0, i, 2, 0);
  4801. builder.Write("费用标准:");
  4802. string curr = "";
  4803. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4804. if (currData != null)
  4805. {
  4806. curr = currData.Name;
  4807. }
  4808. builder.MoveToCell(0, i, 3, 0);
  4809. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4810. builder.MoveToCell(0, i, 4, 0);
  4811. builder.Write("费用小计:");
  4812. builder.MoveToCell(0, i, 5, 0);
  4813. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4814. }
  4815. #endregion
  4816. }
  4817. else dic.Add("SubZS", "0.00");
  4818. //删除多余行
  4819. while (table1.Rows.Count > table1Row)
  4820. {
  4821. table1.Rows.RemoveAt(table1Row);
  4822. }
  4823. //伙食费
  4824. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4825. if (_EnterExitCosts.ChoiceFour == 1)
  4826. {
  4827. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4828. table2Row = dac2.Count;
  4829. #region 填充word表格内容
  4830. for (int i = 0; i < dac2.Count; i++)
  4831. {
  4832. Grp_DayAndCost dac = dac2[i];
  4833. if (dac == null) continue;
  4834. builder.MoveToCell(1, i, 0, 0);
  4835. builder.Write("第" + dac.Days.ToString() + "天:");
  4836. builder.MoveToCell(1, i, 1, 0);
  4837. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4838. builder.MoveToCell(1, i, 2, 0);
  4839. builder.Write("费用标准:");
  4840. string curr = "";
  4841. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4842. if (currData != null)
  4843. {
  4844. curr = currData.Name;
  4845. }
  4846. builder.MoveToCell(1, i, 3, 0);
  4847. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4848. builder.MoveToCell(1, i, 4, 0);
  4849. builder.Write("费用小计:");
  4850. builder.MoveToCell(1, i, 5, 0);
  4851. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4852. }
  4853. #endregion
  4854. }
  4855. else dic.Add("SubHS", "0.00");
  4856. //删除多余行
  4857. while (table2.Rows.Count > table2Row)
  4858. {
  4859. table2.Rows.RemoveAt(table2Row);
  4860. }
  4861. //公杂费
  4862. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4863. if (_EnterExitCosts.ChoiceFive == 1)
  4864. {
  4865. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4866. table3Row = dac3.Count;
  4867. #region 填充word表格内容
  4868. for (int i = 0; i < dac3.Count; i++)
  4869. {
  4870. Grp_DayAndCost dac = dac3[i];
  4871. if (dac == null) continue;
  4872. builder.MoveToCell(2, i, 0, 0);
  4873. builder.Write("第" + dac.Days.ToString() + "天:");
  4874. builder.MoveToCell(2, i, 1, 0);
  4875. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4876. builder.MoveToCell(2, i, 2, 0);
  4877. builder.Write("费用标准:");
  4878. string curr = "";
  4879. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4880. if (currData != null)
  4881. {
  4882. curr = currData.Name;
  4883. }
  4884. builder.MoveToCell(2, i, 3, 0);
  4885. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4886. builder.MoveToCell(2, i, 4, 0);
  4887. builder.Write("费用小计:");
  4888. builder.MoveToCell(2, i, 5, 0);
  4889. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4890. }
  4891. //删除多余行
  4892. while (table3.Rows.Count > table3Row)
  4893. {
  4894. table3.Rows.RemoveAt(table3Row);
  4895. }
  4896. #endregion
  4897. }
  4898. else dic.Add("SubGZF", "0.00");
  4899. //删除多余行
  4900. while (table3.Rows.Count > table3Row)
  4901. {
  4902. table3.Rows.RemoveAt(table3Row);
  4903. }
  4904. //培训费
  4905. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4906. if (_EnterExitCosts.ChoiceSix == 1)
  4907. {
  4908. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4909. dic.Add("SubPX", pxStr);
  4910. table4Row = dac4.Count;
  4911. #region 填充word表格内容
  4912. for (int i = 0; i < dac4.Count; i++)
  4913. {
  4914. Grp_DayAndCost dac = dac4[i];
  4915. if (dac == null) continue;
  4916. builder.MoveToCell(3, i, 0, 0);
  4917. builder.Write("第" + dac.Days.ToString() + "天:");
  4918. builder.MoveToCell(3, i, 1, 0);
  4919. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4920. builder.MoveToCell(3, i, 2, 0);
  4921. builder.Write("费用标准:");
  4922. string curr = "";
  4923. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4924. if (currData != null)
  4925. {
  4926. curr = currData.Name;
  4927. }
  4928. builder.MoveToCell(3, i, 3, 0);
  4929. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4930. builder.MoveToCell(3, i, 4, 0);
  4931. builder.Write("费用小计:");
  4932. builder.MoveToCell(3, i, 5, 0);
  4933. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4934. }
  4935. #endregion
  4936. }
  4937. //else dic.Add("SubPX","0.00");
  4938. //删除多余行
  4939. while (table4.Rows.Count > table4Row)
  4940. {
  4941. table4.Rows.RemoveAt(table4Row);
  4942. }
  4943. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4944. decimal subJJC = 0.00M,
  4945. subGWC = 0.00M,
  4946. subTDC = 0.00M;
  4947. //经济舱
  4948. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4949. //公务舱
  4950. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4951. //头等舱
  4952. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4953. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4954. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4955. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4956. #region 填充word模板书签内容
  4957. foreach (var key in dic.Keys)
  4958. {
  4959. builder.MoveToBookmark(key);
  4960. builder.Write(dic[key]);
  4961. }
  4962. #endregion
  4963. //文件名
  4964. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4965. AsposeHelper.removewatermark_v2180();
  4966. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4967. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4968. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  4969. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  4970. }
  4971. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4972. {
  4973. //获取模板
  4974. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4975. //载入模板
  4976. Document doc = new Document(tempPath);
  4977. DocumentBuilder builder = new DocumentBuilder(doc);
  4978. Dictionary<string, string> dic = new Dictionary<string, string>();
  4979. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4980. {
  4981. List<string> list = new List<string>();
  4982. try
  4983. {
  4984. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4985. foreach (var item in spilitArr)
  4986. {
  4987. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4988. var depCode = spDotandEmpty[2].Substring(0, 3);
  4989. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4990. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4991. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4992. list.Add(depName);
  4993. list.Add(arrName);
  4994. }
  4995. list = list.Distinct().ToList();
  4996. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4997. }
  4998. catch (Exception)
  4999. {
  5000. dic.Add("ReturnCode", "行程录入不正确!");
  5001. }
  5002. }
  5003. else
  5004. {
  5005. dic.Add("ReturnCode", "未录入行程!");
  5006. }
  5007. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5008. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5009. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5010. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5011. {
  5012. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5013. dic.Add("Day", sp.Days.ToString());
  5014. }
  5015. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5016. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5017. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5018. //dic.Add("Names", Names);
  5019. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5020. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5021. decimal dac1totalPrice = 0.00M;
  5022. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5023. foreach (var dac in dac1)
  5024. {
  5025. if (dac.SubTotal == 0.00M)
  5026. {
  5027. continue;
  5028. }
  5029. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5030. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5031. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5032. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5033. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5034. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5035. builder.Write(currency);//币种
  5036. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5037. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5038. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5039. builder.Write("");//人数
  5040. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5041. builder.Write("");//天数
  5042. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5043. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5044. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5045. decimal rate = 0.00M;
  5046. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5047. builder.Write(rate.ToString("#0.0000"));//汇率
  5048. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5049. decimal rbmPrice = dac.SubTotal;
  5050. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5051. accommodationStartIndex++;
  5052. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5053. }
  5054. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5055. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5056. {
  5057. table1.Rows.RemoveAt(i - 1);
  5058. foodandotherStartIndex--;
  5059. }
  5060. if (dac2.Count == dac3.Count)//国家 币种 金额
  5061. {
  5062. for (int i = 0; i < dac2.Count; i++)
  5063. {
  5064. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5065. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5066. }
  5067. }
  5068. decimal dac2totalPrice = 0.00M;
  5069. foreach (var dac in dac2)
  5070. {
  5071. if (dac.SubTotal == 0)
  5072. {
  5073. continue;
  5074. }
  5075. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5076. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5077. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5078. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5079. builder.Write(currency);//币种
  5080. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5081. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5082. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5083. builder.Write("");//人数
  5084. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5085. builder.Write("");//天数
  5086. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5087. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5088. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5089. decimal rate = 0.00M;
  5090. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5091. builder.Write(rate.ToString("#0.0000"));//汇率
  5092. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5093. decimal rbmPrice = dac.SubTotal;
  5094. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5095. foodandotherStartIndex++;
  5096. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5097. }
  5098. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5099. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5100. {
  5101. table1.Rows.RemoveAt(i - 1);
  5102. }
  5103. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5104. string otherFeeStr = "";
  5105. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5106. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5107. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5108. if (otherFeeStr.Length > 0)
  5109. {
  5110. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5111. otherFeeStr = $"({otherFeeStr})";
  5112. dic.Add("OtherFeeStr", otherFeeStr);
  5113. }
  5114. //总计
  5115. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5116. //国际旅费
  5117. string outsideAir = string.Empty;
  5118. string allPriceAir = string.Empty;
  5119. if (_EnterExitCosts.SumJJC == 1)
  5120. {
  5121. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5122. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5123. }
  5124. if (_EnterExitCosts.SumGWC == 1)
  5125. {
  5126. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5127. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5128. }
  5129. if (_EnterExitCosts.SumTDC == 1)
  5130. {
  5131. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5132. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5133. }
  5134. dic.Add("InTravelPrice", $"({outsideAir})");
  5135. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5136. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5137. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5138. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5139. foreach (var key in dic.Keys)
  5140. {
  5141. builder.MoveToBookmark(key);
  5142. builder.Write(dic[key]);
  5143. }
  5144. //模板文件名
  5145. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5146. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5147. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5148. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5149. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5150. }
  5151. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5152. {
  5153. //获取模板
  5154. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5155. //载入模板
  5156. WorkbookDesigner designer = new WorkbookDesigner();
  5157. designer.Workbook = new Workbook(tempPath);
  5158. Dictionary<string, string> dic = new Dictionary<string, string>();
  5159. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5160. {
  5161. List<string> list = new List<string>();
  5162. try
  5163. {
  5164. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5165. foreach (var item in spilitArr)
  5166. {
  5167. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5168. var depCode = spDotandEmpty[2].Substring(0, 3);
  5169. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5170. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5171. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5172. list.Add(depName);
  5173. list.Add(arrName);
  5174. }
  5175. list = list.Distinct().ToList();
  5176. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5177. }
  5178. catch (Exception)
  5179. {
  5180. dic.Add("ReturnCode", "行程录入不正确!");
  5181. }
  5182. }
  5183. else
  5184. {
  5185. dic.Add("ReturnCode", "未录入行程!");
  5186. }
  5187. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5188. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5189. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5190. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5191. {
  5192. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5193. dic.Add("Day", sp.Days.ToString());
  5194. }
  5195. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5196. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5197. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5198. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5199. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5200. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5201. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5202. designer.SetDataSource("Name", Names);
  5203. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5204. designer.SetDataSource("Day", dic["Day"] + "天");
  5205. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5206. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5207. int startIndex = 10;
  5208. const int startIndexcopy = 10;
  5209. if (dac2.Count == dac3.Count)//国家 币种 金额
  5210. {
  5211. for (int i = 0; i < dac2.Count; i++)
  5212. {
  5213. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5214. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5215. }
  5216. }
  5217. DataTable dtdac1 = new DataTable();
  5218. List<string> place = new List<string>();
  5219. dtdac1.Columns.AddRange(new DataColumn[] {
  5220. new DataColumn(){ ColumnName = "city"},
  5221. new DataColumn(){ ColumnName = "curr"},
  5222. new DataColumn(){ ColumnName = "criterion"},
  5223. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5224. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5225. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5226. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5227. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5228. });
  5229. DataTable dtdac2 = new DataTable();
  5230. dtdac2.Columns.AddRange(new DataColumn[] {
  5231. new DataColumn(){ ColumnName = "city"},
  5232. new DataColumn(){ ColumnName = "curr"},
  5233. new DataColumn(){ ColumnName = "criterion"},
  5234. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5235. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5236. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5237. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5238. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5239. });
  5240. dtdac1.TableName = "tb1";
  5241. dtdac2.TableName = "tb2";
  5242. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5243. foreach (var item in dac1)
  5244. {
  5245. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5246. if (place.Contains(item.Place))
  5247. {
  5248. continue;
  5249. }
  5250. DataRow row = dtdac1.NewRow();
  5251. row["city"] = item.Place;
  5252. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5253. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5254. row["curr"] = currency;
  5255. row["rate"] = rate.ToString("#0.0000");
  5256. row["criterion"] = item.Cost.ToString("#0.00");
  5257. row["number"] = 1;
  5258. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5259. //row["costRMB"] = rbmPrice;
  5260. dtdac1.Rows.Add(row);
  5261. place.Add(item.Place);
  5262. }
  5263. place = new List<string>();
  5264. foreach (var item in dac2)
  5265. {
  5266. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5267. if (place.Contains(item.Place))
  5268. {
  5269. continue;
  5270. }
  5271. DataRow row = dtdac2.NewRow();
  5272. row["city"] = item.Place;
  5273. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5274. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5275. row["curr"] = currency;
  5276. row["rate"] = rate.ToString("#0.0000");
  5277. row["criterion"] = item.Cost.ToString("#0.00");
  5278. row["number"] = 1;
  5279. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5280. //row["cost"] = item.SubTotal;
  5281. //row["costRMB"] = rbmPrice;
  5282. dtdac2.Rows.Add(row);
  5283. place.Add(item.Place);
  5284. //dac2totalPrice += rbmPrice;
  5285. }
  5286. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5287. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5288. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5289. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5290. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5291. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5292. string cell4Str1 = string.Empty;
  5293. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5294. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5295. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5296. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5297. string cellStr = $" 5.其他费用(";
  5298. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5299. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5300. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5301. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5302. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5303. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5304. if (cellStr.Length > 8)
  5305. {
  5306. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5307. }
  5308. cellStr += ")";
  5309. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5310. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5311. decimal pxFee = dac4.Sum(it => it.Cost);
  5312. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5313. string celllastStr1 = "";
  5314. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5315. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5316. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5317. celllastStr1 += $",国际旅费 元";
  5318. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5319. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5320. designer.SetDataSource("cell4Str", cell4Str);
  5321. designer.SetDataSource("cellStr", cellStr);
  5322. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5323. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5324. designer.SetDataSource("celllastStr", celllastStr);
  5325. Workbook wb = designer.Workbook;
  5326. var sheet = wb.Worksheets[0];
  5327. //绑定datatable数据集
  5328. designer.SetDataSource(dtdac1);
  5329. designer.SetDataSource(dtdac2);
  5330. designer.Process();
  5331. var rowStart = dtdac1.Rows.Count;
  5332. while (rowStart > 0)
  5333. {
  5334. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5335. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5336. startIndex++;
  5337. rowStart--;
  5338. }
  5339. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5340. startIndex += 1; //总计行
  5341. rowStart = dtdac2.Rows.Count;
  5342. while (rowStart > 0)
  5343. {
  5344. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5345. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5346. startIndex++;
  5347. rowStart--;
  5348. }
  5349. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5350. wb.CalculateFormula(true);
  5351. //模板文件名
  5352. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5353. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5354. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5355. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5356. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5357. }
  5358. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5359. {
  5360. //获取模板
  5361. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5362. //载入模板
  5363. Document doc = new Document(tempPath);
  5364. DocumentBuilder builder = new DocumentBuilder(doc);
  5365. Dictionary<string, string> dic = new Dictionary<string, string>();
  5366. dic.Add("GroupName", _DelegationInfo.TeamName);
  5367. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5368. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5369. string missionLeaderJob = "";//负责人job
  5370. int groupNumber = 0; //团人数
  5371. if (DeleClientList.Count > 0)
  5372. {
  5373. missionLeader = DeleClientList[0]?.Name ?? "";
  5374. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5375. }
  5376. dic.Add("MissionLeader", missionLeader); //团负责人
  5377. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5378. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5379. #region MyRegion
  5380. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5381. //{
  5382. // List<string> list = new List<string>();
  5383. // try
  5384. // {
  5385. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5386. // foreach (var item in spilitArr)
  5387. // {
  5388. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5389. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5390. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5391. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5392. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5393. // list.Add(depName);
  5394. // list.Add(arrName);
  5395. // }
  5396. // list = list.Distinct().ToList();
  5397. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5398. // }
  5399. // catch (Exception)
  5400. // {
  5401. // dic.Add("ReturnCode", "行程录入不正确!");
  5402. // }
  5403. //}
  5404. //else
  5405. //{
  5406. // dic.Add("ReturnCode", "未录入行程!");
  5407. //}
  5408. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5409. dic.Add("ReturnCode", string.Join("、", countrys));
  5410. #endregion
  5411. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5412. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5413. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5414. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5415. //{
  5416. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5417. // dic.Add("Day", sp.Days.ToString());
  5418. //}
  5419. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5420. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5421. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5422. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5423. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5424. //培训人员名单
  5425. int cultivateRowIndex = 7;
  5426. foreach (var item in DeleClientList)
  5427. {
  5428. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5429. builder.Write(item.Name);
  5430. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5431. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5432. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5433. string birthDay = "";
  5434. if (item.Birthday != null)
  5435. {
  5436. DateTime dt = Convert.ToDateTime(item.Birthday);
  5437. birthDay = $"{dt.Year}.{dt.Month}";
  5438. }
  5439. builder.Write(birthDay);
  5440. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5441. builder.Write(item.Company);
  5442. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5443. builder.Write(item.Job);
  5444. cultivateRowIndex++;
  5445. }
  5446. //删除多余行
  5447. //cultivateRowIndex -= 2;
  5448. int delRows = 10 + 7 - cultivateRowIndex;
  5449. if (delRows > 0)
  5450. {
  5451. for (int i = 0; i < delRows; i++)
  5452. {
  5453. table1.Rows.RemoveAt(cultivateRowIndex);
  5454. //cultivateRowIndex++;
  5455. }
  5456. }
  5457. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5458. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5459. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5460. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5461. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5462. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5463. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5464. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5465. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5466. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5467. //其他费用
  5468. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5469. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5470. //其他费用合计
  5471. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5472. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5473. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5474. //公务舱合计
  5475. //国际旅费
  5476. string outsideJJ = "";
  5477. string allPriceJJ = "";
  5478. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5479. {
  5480. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5481. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5482. }
  5483. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5484. {
  5485. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5486. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5487. }
  5488. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5489. {
  5490. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5491. dic.Add("AirFeeTotal", airFeeTotalStr);
  5492. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5493. dic.Add("FeeTotal", feeTotalStr);
  5494. }
  5495. foreach (var key in dic.Keys)
  5496. {
  5497. builder.MoveToBookmark(key);
  5498. builder.Write(dic[key]);
  5499. }
  5500. //模板文件名
  5501. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5502. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5503. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5504. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5505. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5506. }
  5507. }
  5508. else if (dto.ExportType == 2) //表格
  5509. {
  5510. //利用键值对存放数据
  5511. Dictionary<string, string> dic = new Dictionary<string, string>();
  5512. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5513. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5514. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5515. dic.Add("Day", sp.Days.ToString());
  5516. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5517. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5518. {
  5519. //获取模板
  5520. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5521. //载入模板
  5522. Document doc = new Document(tempPath);
  5523. DocumentBuilder builder = new DocumentBuilder(doc);
  5524. dic.Add("TeamName", _DelegationInfo.TeamName);
  5525. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5526. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5527. string missionLeaderName = "",
  5528. missionLeaderJob = "";
  5529. if (DeleClientList.Count > 0)
  5530. {
  5531. missionLeaderName = DeleClientList[0].Name;
  5532. missionLeaderJob = DeleClientList[0].Job;
  5533. }
  5534. dic.Add("MissionLeaderName", missionLeaderName);
  5535. dic.Add("MissionLeaderJob", missionLeaderJob);
  5536. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5537. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5538. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5539. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5540. int rowCount = 10;//总人数行
  5541. int startRowIndex = 7; //起始行
  5542. for (int i = 0; i < DeleClientList.Count; i++)
  5543. {
  5544. builder.MoveToCell(0, startRowIndex, 0, 0);
  5545. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5546. builder.MoveToCell(0, startRowIndex, 1, 0);
  5547. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5548. builder.Write(sex);//性别
  5549. builder.MoveToCell(0, startRowIndex, 2, 0);
  5550. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5551. builder.MoveToCell(0, startRowIndex, 3, 0);
  5552. builder.Write(DeleClientList[i].Company);//工作单位
  5553. builder.MoveToCell(0, startRowIndex, 4, 0);
  5554. builder.Write(DeleClientList[i].Job);//职务及级别
  5555. builder.MoveToCell(0, startRowIndex, 5, 0);
  5556. builder.Write("");//人员属性
  5557. builder.MoveToCell(0, startRowIndex, 6, 0);
  5558. builder.Write("");//上次出国时间
  5559. startRowIndex++;
  5560. }
  5561. int nullRow = rowCount - DeleClientList.Count;//空行
  5562. for (int i = 0; i < nullRow; i++)
  5563. {
  5564. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5565. }
  5566. foreach (var key in dic.Keys)
  5567. {
  5568. builder.MoveToBookmark(key);
  5569. builder.Write(dic[key]);
  5570. }
  5571. //模板文件名
  5572. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5573. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5574. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5575. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5576. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5577. }
  5578. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5579. {
  5580. //获取模板
  5581. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5582. //载入模板
  5583. Document doc = new Document(tempPath);
  5584. DocumentBuilder builder = new DocumentBuilder(doc);
  5585. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5586. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5587. dic.Add("Names", Names);
  5588. int accommodationRows = 12, foodandotherRows = 12;
  5589. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5590. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5591. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5592. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5593. int accommodationStartIndex = 6;
  5594. decimal dac1totalPrice = 0.00M;
  5595. foreach (var dac in dac1)
  5596. {
  5597. if (dac.SubTotal == 0)
  5598. {
  5599. continue;
  5600. }
  5601. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5602. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5603. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5604. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5605. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5606. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5607. builder.Write(currency);//币种
  5608. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5609. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5610. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5611. builder.Write("");//人数
  5612. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5613. builder.Write("");//天数
  5614. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5615. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5616. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5617. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5618. builder.Write(rate.ToString("#0.0000"));//汇率
  5619. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5620. decimal rbmPrice = rate * dac.SubTotal;
  5621. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5622. accommodationStartIndex++;
  5623. dac1totalPrice += rbmPrice;
  5624. }
  5625. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5626. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5627. builder.Write("小计");
  5628. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5629. builder.Write(dac1totalPrice.ToString("#0.00"));
  5630. accommodationStartIndex++;
  5631. int nullRow = accommodationRows - dac1.Count;
  5632. //删除空行
  5633. //if (nullRow > 0)
  5634. //{
  5635. // int rowIndex = accommodationStartIndex;
  5636. // for (int i = 0; i < nullRow; i++)
  5637. // {
  5638. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5639. // row.Remove();
  5640. // rowIndex++;
  5641. // }
  5642. //}
  5643. if (dac2.Count == dac3.Count)//国家 币种 金额
  5644. {
  5645. for (int i = 0; i < dac2.Count; i++)
  5646. {
  5647. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5648. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5649. }
  5650. }
  5651. int foodandotherStartIndex = 19;//
  5652. decimal dac2totalPrice = 0.00M;
  5653. foreach (var dac in dac2)
  5654. {
  5655. if (dac.SubTotal == 0)
  5656. {
  5657. continue;
  5658. }
  5659. //foodandotherStartIndex = 12;
  5660. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5661. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5662. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5663. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5664. builder.Write(currency);//币种
  5665. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5666. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5667. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5668. builder.Write("");//人数
  5669. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5670. builder.Write("");//天数
  5671. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5672. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5673. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5674. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5675. builder.Write(rate.ToString("#0.0000"));//汇率
  5676. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5677. decimal rbmPrice = rate * dac.SubTotal;
  5678. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5679. foodandotherStartIndex++;
  5680. dac2totalPrice += rbmPrice;
  5681. }
  5682. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5683. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5684. //删除空行
  5685. //if (dac2.Count < foodandotherRows)
  5686. //{
  5687. // while (table2.Rows.Count > dac2.Count)
  5688. // {
  5689. // table2.Rows.RemoveAt(dac2.Count);
  5690. // }
  5691. //}
  5692. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5693. string otherFeeStr = "";
  5694. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5695. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5696. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5697. if (otherFeeStr.Length > 0)
  5698. {
  5699. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5700. otherFeeStr = $"({otherFeeStr})";
  5701. dic.Add("OtherFeeStr", otherFeeStr);
  5702. }
  5703. foreach (var key in dic.Keys)
  5704. {
  5705. builder.MoveToBookmark(key);
  5706. builder.Write(dic[key]);
  5707. }
  5708. //模板文件名
  5709. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5710. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5711. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5712. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5713. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5714. }
  5715. }
  5716. else if (dto.ExportType == 3)
  5717. {
  5718. if (dto.SubTypeId == 1) //团组成员名单
  5719. {
  5720. if (DeleClientList.Count < 1)
  5721. {
  5722. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5723. }
  5724. //获取模板
  5725. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5726. //载入模板
  5727. Document doc = new Document(tempPath);
  5728. DocumentBuilder builder = new DocumentBuilder(doc);
  5729. //获取word里所有表格
  5730. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5731. //获取所填表格的序数
  5732. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5733. var rowStart = tableOne.Rows[0]; //获取第1行
  5734. //循环赋值
  5735. for (int i = 0; i < DeleClientList.Count; i++)
  5736. {
  5737. builder.MoveToCell(0, i + 1, 0, 0);
  5738. builder.Write(DeleClientList[i].Name);
  5739. builder.MoveToCell(0, i + 1, 1, 0);
  5740. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5741. builder.Write(sex);
  5742. builder.MoveToCell(0, i + 1, 2, 0);
  5743. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5744. builder.MoveToCell(0, i + 1, 3, 0);
  5745. builder.Write(DeleClientList[i].Company);
  5746. builder.MoveToCell(0, i + 1, 4, 0);
  5747. builder.Write(DeleClientList[i].Job);
  5748. }
  5749. //删除多余行
  5750. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5751. {
  5752. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5753. }
  5754. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5755. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5756. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5757. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5758. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5759. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5760. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5761. }
  5762. }
  5763. return Ok(JsonView(400, "操作失败!", ""));
  5764. }
  5765. catch (Exception ex)
  5766. {
  5767. return Ok(JsonView(400, ex.Message, ""));
  5768. }
  5769. }
  5770. /// <summary>
  5771. /// 获取三公费用标准city
  5772. /// </summary>
  5773. /// <param name="placeData"></param>
  5774. /// <param name="nationalTravelFeeId"></param>
  5775. /// <returns></returns>
  5776. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5777. {
  5778. string _city = string.Empty;
  5779. if (placeData.Count < 1) return _city;
  5780. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5781. if (data == null) return _city;
  5782. string country = data.Country;
  5783. string city = data.City;
  5784. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5785. else _city = city;
  5786. return _city;
  5787. }
  5788. /// <summary>
  5789. /// 团组模块 - 出入境费用 - 明细表导出
  5790. /// </summary>
  5791. /// <returns></returns>
  5792. [HttpPost]
  5793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5794. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5795. {
  5796. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5797. if (data.Code != 0)
  5798. {
  5799. return Ok(JsonView(false, data.Msg));
  5800. }
  5801. return Ok(JsonView(true, data.Msg, data.Data));
  5802. }
  5803. /// <summary>
  5804. /// 团组模块 - 出入境费用 - 一键清空
  5805. /// </summary>
  5806. /// <returns></returns>
  5807. [HttpPost]
  5808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5809. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5810. {
  5811. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5812. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5813. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5814. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5815. if (_view.Code == 0)
  5816. {
  5817. return Ok(JsonView(true, "操作成功"));
  5818. }
  5819. return Ok(JsonView(false, "操作失败"));
  5820. }
  5821. /// <summary>
  5822. /// 团组模块 - 出入境费用 - 子项删除
  5823. /// </summary>
  5824. /// <returns></returns>
  5825. [HttpPost]
  5826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5827. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5828. {
  5829. try
  5830. {
  5831. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5832. if (data.Code != 0)
  5833. {
  5834. return Ok(JsonView(false, data.Msg));
  5835. }
  5836. return Ok(JsonView(true, "操作成功!", data.Data));
  5837. }
  5838. catch (Exception ex)
  5839. {
  5840. return Ok(JsonView(false, ex.Message));
  5841. }
  5842. }
  5843. /// <summary>
  5844. /// 团组模块 - 出入境国家费用标准 List
  5845. /// </summary>
  5846. /// <returns></returns>
  5847. [HttpPost]
  5848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5849. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5850. {
  5851. try
  5852. {
  5853. Stopwatch sw = new Stopwatch();
  5854. sw.Start();
  5855. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5856. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5857. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5858. Where gntf.Isdel = 0");
  5859. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5860. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5861. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5862. //foreach (var item in nationalTravel)
  5863. //{
  5864. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5865. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5866. // if (otherData != null)
  5867. // {
  5868. // cityData.Remove(otherData);
  5869. // cityData.Add(otherData);
  5870. // }
  5871. // nationalTravelFeeData1.Add(new
  5872. // {
  5873. // Country = item.Country,
  5874. // CityData = cityData
  5875. // });
  5876. //}
  5877. sw.Stop();
  5878. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5879. }
  5880. catch (Exception ex)
  5881. {
  5882. return Ok(JsonView(false, ex.Message));
  5883. throw;
  5884. }
  5885. }
  5886. /// <summary>
  5887. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5888. /// </summary>
  5889. /// <returns></returns>
  5890. [HttpPost]
  5891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5892. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5893. {
  5894. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5895. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5896. List<string> countryData = new List<string>();
  5897. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5898. countryData = countryData.Distinct().ToList();
  5899. List<dynamic> dataSource = new List<dynamic>();
  5900. foreach (var item in countryData)
  5901. {
  5902. List<string> cityData1 = new List<string>();
  5903. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5904. var countryData2 = new
  5905. {
  5906. CountryName = item,
  5907. CityData = cityData1
  5908. };
  5909. dataSource.Add(countryData2);
  5910. }
  5911. return Ok(JsonView(true, "查询成功!", dataSource));
  5912. }
  5913. /// <summary>
  5914. /// 团组模块 - 出入境国家费用标准 Page List
  5915. /// </summary>
  5916. /// <returns></returns>
  5917. [HttpPost]
  5918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5919. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5920. {
  5921. int portId = dto.PortType;
  5922. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5923. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5924. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5925. string whereSql = string.Empty;
  5926. if (!string.IsNullOrEmpty(dto.Country))
  5927. {
  5928. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5929. }
  5930. if (!string.IsNullOrEmpty(dto.City))
  5931. {
  5932. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5933. }
  5934. string pageSql = string.Format(@"Select * From (
  5935. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5936. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5937. From Grp_NationalTravelFee gntf
  5938. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5939. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5940. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5941. RefAsync<int> total = 0;
  5942. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5943. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5944. }
  5945. /// <summary>
  5946. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5947. /// </summary>
  5948. /// <returns></returns>
  5949. [HttpPost]
  5950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5951. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5952. {
  5953. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5954. int portId = dto.PortType;
  5955. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5956. string whereSql = string.Empty;
  5957. if (!string.IsNullOrEmpty(dto.Country))
  5958. {
  5959. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5960. }
  5961. if (!string.IsNullOrEmpty(dto.City))
  5962. {
  5963. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5964. }
  5965. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5966. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5967. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5968. From Grp_NationalTravelFee gntf
  5969. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5970. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5971. Where gntf.Isdel = 0 {0} ", whereSql);
  5972. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5973. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5974. }
  5975. /// <summary>
  5976. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5977. /// </summary>
  5978. /// <returns></returns>
  5979. [HttpPost]
  5980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5981. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5982. {
  5983. try
  5984. {
  5985. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5986. if (data.Code != 0)
  5987. {
  5988. return Ok(JsonView(false, data.Msg));
  5989. }
  5990. return Ok(JsonView(true, "操作成功!", data.Data));
  5991. }
  5992. catch (Exception ex)
  5993. {
  5994. return Ok(JsonView(false, ex.Message));
  5995. }
  5996. }
  5997. /// <summary>
  5998. /// 团组模块 - 出入境国家费用标准 - Del
  5999. /// </summary>
  6000. /// <returns></returns>
  6001. [HttpPost]
  6002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6003. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6004. {
  6005. try
  6006. {
  6007. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6008. {
  6009. Id = dto.Id,
  6010. DeleteUserId = dto.DeleteUserId,
  6011. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6012. IsDel = 1
  6013. };
  6014. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6015. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6016. .WhereColumns(it => new { it.Id })
  6017. .ExecuteCommandAsync();
  6018. if (delStatus <= 0)
  6019. {
  6020. return Ok(JsonView(false, "删除失败!"));
  6021. }
  6022. return Ok(JsonView(true, "操作成功!"));
  6023. }
  6024. catch (Exception ex)
  6025. {
  6026. return Ok(JsonView(false, ex.Message));
  6027. }
  6028. }
  6029. /// <summary>
  6030. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6031. /// 注:Get 请求Headers 加 Token
  6032. /// </summary>
  6033. /// <param name="groupId"></param>
  6034. /// <returns></returns>
  6035. [HttpGet("{groupId}")]
  6036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6037. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6038. {
  6039. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6040. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6041. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6042. data.ForEach(x =>
  6043. {
  6044. x.CreateUserId = _currUserInfo.UserId;
  6045. });
  6046. if (data.Count > 0)
  6047. {
  6048. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6049. if (add > 0)
  6050. {
  6051. return Ok(JsonView(true, "操作成功!"));
  6052. }
  6053. }
  6054. return Ok(JsonView(false, "未操作!"));
  6055. }
  6056. #endregion
  6057. #region 签证费用录入
  6058. /// <summary>
  6059. /// 根据diid查询签证费用列表
  6060. /// </summary>
  6061. /// <param name="dto"></param>
  6062. /// <returns></returns>
  6063. [HttpPost]
  6064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6065. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6066. {
  6067. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6068. if (groupData.Code != 0)
  6069. {
  6070. return Ok(JsonView(false, groupData.Msg));
  6071. }
  6072. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6073. }
  6074. /// <summary>
  6075. /// 根据签证费用Id查询单条数据及c表数据
  6076. /// </summary>
  6077. /// <param name="dto"></param>
  6078. /// <returns></returns>
  6079. [HttpPost]
  6080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6081. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6082. {
  6083. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6084. if (groupData.Code != 0)
  6085. {
  6086. return Ok(JsonView(false, groupData.Msg));
  6087. }
  6088. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6089. }
  6090. /// <summary>
  6091. /// 签证费用删除
  6092. /// </summary>
  6093. /// <param name="dto"></param>
  6094. /// <returns></returns>
  6095. [HttpPost]
  6096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6097. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6098. {
  6099. _sqlSugar.BeginTran();
  6100. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6101. if (!res)
  6102. {
  6103. _sqlSugar.RollbackTran();
  6104. return Ok(JsonView(false, "删除失败"));
  6105. }
  6106. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6107. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6108. .SetColumns(a => new Grp_CreditCardPayment()
  6109. {
  6110. IsDel = 1,
  6111. DeleteUserId = dto.DeleteUserId,
  6112. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6113. })
  6114. .ExecuteCommand();
  6115. if (resSub < 1)
  6116. {
  6117. _sqlSugar.RollbackTran();
  6118. return Ok(JsonView(false, "删除失败"));
  6119. }
  6120. _sqlSugar.CommitTran();
  6121. return Ok(JsonView(true, "删除成功!"));
  6122. }
  6123. /// <summary>
  6124. /// 签证费用录入下拉框初始化
  6125. /// </summary>
  6126. /// <returns></returns>
  6127. [HttpPost]
  6128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6129. public async Task<IActionResult> VisaPriceAddSelect()
  6130. {
  6131. //支付方式
  6132. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6133. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6134. //币种
  6135. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6136. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6137. //乘客类型
  6138. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6139. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6140. //卡类型
  6141. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6142. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6143. //代办费类型
  6144. var agencyFeeTypeData = new List<dynamic>() {
  6145. new { id = 0 , Text = "未选择" },
  6146. new { id = 1 , Text = "小公务" },
  6147. new { id = 2 , Text = "大公务" },
  6148. };
  6149. //签证费用标准国家Data
  6150. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  6151. var data = new
  6152. {
  6153. Payment = _Payment,
  6154. CurrencyList = _CurrencyList,
  6155. PassengerType = _PassengerType,
  6156. BankCard = _BankCard,
  6157. AgencyFeeType = agencyFeeTypeData,
  6158. CountryFeeData = visaCountryFeeData
  6159. };
  6160. return Ok(JsonView(true, "查询成功!", data));
  6161. }
  6162. /// <summary>
  6163. /// 签证费用录入操作(Status:1.新增,2.修改)
  6164. /// </summary>
  6165. /// <param name="dto"></param>
  6166. /// <returns></returns>
  6167. [HttpPost]
  6168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6169. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6170. {
  6171. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6172. if (groupData.Code != 0)
  6173. {
  6174. return Ok(JsonView(false, groupData.Msg));
  6175. }
  6176. #region 应用推送
  6177. try
  6178. {
  6179. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6180. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6181. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6182. //2024-10-21 新增LZ UID
  6183. var userIds = new List<int>() { 21 };
  6184. string title = $"系统通知";
  6185. string content = "";
  6186. var diId = dto.DiId;
  6187. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6188. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6189. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6190. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6191. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6192. await GeneralMethod.iOS_PushNotifications("051", $"签证费用审核", "", content);
  6193. }
  6194. catch (Exception ex)
  6195. {
  6196. }
  6197. #endregion
  6198. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6199. }
  6200. #endregion
  6201. #region 签证提成录入
  6202. /// <summary>
  6203. /// 签证提成录入
  6204. /// 基础数据
  6205. /// </summary>
  6206. /// <param name="_dto"></param>
  6207. /// <returns></returns>
  6208. [HttpGet]
  6209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6210. public async Task<IActionResult> VisaCommissionInit()
  6211. {
  6212. return Ok(await _visaCommissionRep.Init());
  6213. }
  6214. /// <summary>
  6215. /// 签证提成录入
  6216. /// Item
  6217. /// </summary>
  6218. /// <param name="_dto"></param>
  6219. /// <returns></returns>
  6220. [HttpPost]
  6221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6222. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6223. {
  6224. var validator = new VisaCommissionItemDtoValidator();
  6225. var validatorRes = await validator.ValidateAsync(_dto);
  6226. if (!validatorRes.IsValid)
  6227. {
  6228. StringBuilder sb = new StringBuilder();
  6229. foreach (var item in validatorRes.Errors)
  6230. {
  6231. sb.AppendLine(item.ErrorMessage);
  6232. }
  6233. return Ok(JsonView(false, sb.ToString()));
  6234. }
  6235. return Ok(await _visaCommissionRep.Item(_dto));
  6236. }
  6237. /// <summary>
  6238. /// 签证提成录入
  6239. /// Save
  6240. /// </summary>
  6241. /// <param name="_dto"></param>
  6242. /// <returns></returns>
  6243. [HttpPost]
  6244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6245. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6246. {
  6247. //参数验证
  6248. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6249. foreach (var item in _dto.Items)
  6250. {
  6251. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6252. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6253. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6254. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6255. }
  6256. return Ok(await _visaCommissionRep.Save(_dto));
  6257. }
  6258. /// <summary>
  6259. /// 签证提成录入
  6260. /// Create
  6261. /// </summary>
  6262. /// <param name="_dto"></param>
  6263. /// <returns></returns>
  6264. [HttpPost]
  6265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6266. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6267. {
  6268. var validator = new VisaCommissionCreateDtoValidator();
  6269. var validatorRes = await validator.ValidateAsync(_dto);
  6270. if (!validatorRes.IsValid)
  6271. {
  6272. StringBuilder sb = new StringBuilder();
  6273. foreach (var item in validatorRes.Errors)
  6274. {
  6275. sb.AppendLine(item.ErrorMessage);
  6276. }
  6277. return Ok(JsonView(false, sb.ToString()));
  6278. }
  6279. return Ok(await _visaCommissionRep.Create(_dto));
  6280. }
  6281. /// <summary>
  6282. /// 签证提成录入
  6283. /// Put(编辑)
  6284. /// </summary>
  6285. /// <param name="id"></param>
  6286. /// <param name="_dto"></param>
  6287. /// <returns></returns>
  6288. [HttpPut]
  6289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6290. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6291. {
  6292. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6293. var validator = new VisaCommissionCreateDtoValidator();
  6294. var validatorRes = await validator.ValidateAsync(_dto);
  6295. if (!validatorRes.IsValid)
  6296. {
  6297. StringBuilder sb = new StringBuilder();
  6298. foreach (var item in validatorRes.Errors)
  6299. {
  6300. sb.AppendLine(item.ErrorMessage);
  6301. }
  6302. return Ok(JsonView(false, sb.ToString()));
  6303. }
  6304. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6305. }
  6306. /// <summary>
  6307. /// 签证提成录入
  6308. /// Del
  6309. /// </summary>
  6310. /// <param name="id"></param>
  6311. /// <param name="currUserId"></param>
  6312. /// <returns></returns>
  6313. [HttpPost]
  6314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6315. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6316. {
  6317. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6318. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6319. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6320. }
  6321. #endregion
  6322. #region op费用录入
  6323. /// <summary>
  6324. /// 根据diid查询op费用列表
  6325. /// </summary>
  6326. /// <param name="dto"></param>
  6327. /// <returns></returns>
  6328. [HttpPost]
  6329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6330. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6331. {
  6332. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6333. if (groupData.Code != 0)
  6334. {
  6335. return Ok(JsonView(false, groupData.Msg));
  6336. }
  6337. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6338. }
  6339. /// <summary>
  6340. /// 根据op费用Id查询单条数据及c表数据
  6341. /// </summary>
  6342. /// <param name="dto"></param>
  6343. /// <returns></returns>
  6344. [HttpPost]
  6345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6346. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6347. {
  6348. try
  6349. {
  6350. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6351. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6352. var data = new
  6353. {
  6354. CarTouristGuideGround = _groupData,
  6355. CreditCardPayment = _creditCardPayment
  6356. };
  6357. return Ok(JsonView(true, "查询成功!", data));
  6358. }
  6359. catch (Exception ex)
  6360. {
  6361. return Ok(JsonView(false, "程序错误!"));
  6362. }
  6363. }
  6364. /// <summary>
  6365. /// op费用删除
  6366. /// </summary>
  6367. /// <param name="dto"></param>
  6368. /// <returns></returns>
  6369. [HttpPost]
  6370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6371. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6372. {
  6373. try
  6374. {
  6375. _sqlSugar.BeginTran();
  6376. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6377. if (!res)
  6378. {
  6379. return Ok(JsonView(false, "删除失败"));
  6380. }
  6381. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6382. {
  6383. IsDel = 1,
  6384. DeleteUserId = dto.DeleteUserId,
  6385. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6386. }).ExecuteCommandAsync();
  6387. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6388. {
  6389. IsDel = 1,
  6390. DeleteUserId = dto.DeleteUserId,
  6391. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6392. }).ExecuteCommandAsync();
  6393. #region 删除超支相关数据
  6394. //删除导入的超支数据
  6395. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6396. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6397. {
  6398. IsDel = 1,
  6399. DeleteUserId = dto.DeleteUserId,
  6400. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6401. }).ExecuteCommand();
  6402. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6403. {
  6404. IsDel = 1,
  6405. DeleteUserId = dto.DeleteUserId,
  6406. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6407. }).ExecuteCommand();
  6408. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6409. {
  6410. IsDel = 1,
  6411. DeleteUserId = dto.DeleteUserId,
  6412. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6413. }).ExecuteCommand();
  6414. #endregion
  6415. _sqlSugar.CommitTran();
  6416. return Ok(JsonView(true, "删除成功!"));
  6417. }
  6418. catch (Exception ex)
  6419. {
  6420. _sqlSugar.RollbackTran();
  6421. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6422. }
  6423. }
  6424. /// <summary>
  6425. /// op费用录入操作(Status:1.新增,2.修改)
  6426. /// </summary>
  6427. /// <param name="dto"></param>
  6428. /// <returns></returns>
  6429. [HttpPost]
  6430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6431. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6432. {
  6433. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6434. if (groupData.Code != 0)
  6435. {
  6436. return Ok(JsonView(false, groupData.Msg));
  6437. }
  6438. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6439. }
  6440. /// <summary>
  6441. /// 填写费用详细页面初始化绑定
  6442. /// </summary>
  6443. /// <param name="dto"></param>
  6444. /// <returns></returns>
  6445. [HttpPost]
  6446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6447. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6448. {
  6449. try
  6450. {
  6451. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6452. if (groupData.Code != 0)
  6453. {
  6454. return Ok(JsonView(false, groupData.Msg));
  6455. }
  6456. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6457. }
  6458. catch (Exception ex)
  6459. {
  6460. return Ok(JsonView(false, ex.Message));
  6461. }
  6462. }
  6463. /// <summary>
  6464. /// 根据op费用Id查询详细数据
  6465. /// </summary>
  6466. /// <param name="dto"></param>
  6467. /// <returns></returns>
  6468. [HttpPost]
  6469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6470. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6471. {
  6472. try
  6473. {
  6474. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6475. if (groupData.Code != 0)
  6476. {
  6477. return Ok(JsonView(false, groupData.Msg));
  6478. }
  6479. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6480. }
  6481. catch (Exception ex)
  6482. {
  6483. return Ok(JsonView(false, ex.Message));
  6484. }
  6485. }
  6486. /// <summary>
  6487. /// OP费用录入填写详情
  6488. /// </summary>
  6489. /// <param name="dto"></param>
  6490. /// <returns></returns>
  6491. [HttpPost]
  6492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6493. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6494. {
  6495. try
  6496. {
  6497. #region 参数校验
  6498. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6499. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6500. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6501. #endregion
  6502. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6503. if (groupData.Code != 0)
  6504. {
  6505. return Ok(JsonView(false, groupData.Msg));
  6506. }
  6507. //自动审核
  6508. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6509. #region 应用推送
  6510. try
  6511. {
  6512. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6513. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6514. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6515. //2024-10-21 新增LZ UID
  6516. var userIds = new List<int>() { 21 };
  6517. string title = $"系统通知";
  6518. var diId = dto.DiId;
  6519. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6520. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6521. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6522. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6523. await GeneralMethod.iOS_PushNotifications("051", "OP费用审核", "", content);
  6524. }
  6525. catch (Exception ex)
  6526. {
  6527. }
  6528. #endregion
  6529. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6530. }
  6531. catch (Exception ex)
  6532. {
  6533. return Ok(JsonView(false, ex.Message));
  6534. }
  6535. }
  6536. /// <summary>
  6537. /// 获取三公详细所有城市
  6538. /// </summary>
  6539. /// <returns></returns>
  6540. [HttpGet]
  6541. public IActionResult OpCarCityResult()
  6542. {
  6543. var jw = JsonView(false);
  6544. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6545. {
  6546. x.Id,
  6547. x.Country,
  6548. x.City,
  6549. }).ToList();
  6550. if (data.Count > 0)
  6551. {
  6552. jw = JsonView(true, "获取成功!", data);
  6553. }
  6554. else
  6555. {
  6556. jw.Msg = "城市数据为空!";
  6557. jw.Data = new string[0];
  6558. }
  6559. return Ok(jw);
  6560. }
  6561. /// <summary>
  6562. /// 导出地接费用明细
  6563. /// </summary>
  6564. /// <param name="dto"></param>
  6565. /// <returns></returns>
  6566. [HttpPost]
  6567. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6568. {
  6569. var jw = JsonView(false);
  6570. if (dto.Diid < 1)
  6571. {
  6572. jw.Msg = "请输入正确的diid!";
  6573. return Ok(jw);
  6574. }
  6575. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6576. if (group == null)
  6577. {
  6578. jw.Msg = "未找到团组信息!";
  6579. return Ok(jw);
  6580. }
  6581. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6582. if (localGuideArr.Count == 0)
  6583. {
  6584. jw.Msg = "该团组暂无地接信息!";
  6585. return Ok(jw);
  6586. }
  6587. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6588. var overspendSoure = new Dictionary<int, int>
  6589. {
  6590. { 91, 982 }, //车
  6591. { 92 , 1059} ,//导游
  6592. { 994 , 1073}, //翻译
  6593. { 988 , 1074 }, //早餐
  6594. { 93 , 1075 }, //午餐
  6595. { 989 , 1076 }, //晚餐
  6596. };
  6597. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6598. foreach (var groupArr in localGroup)
  6599. {
  6600. var keyValue = groupArr.Key;
  6601. if (int.TryParse(keyValue, out int cityid))
  6602. {
  6603. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6604. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6605. }
  6606. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6607. foreach (var item in groupArr)
  6608. {
  6609. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6610. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6611. new Grp_CarTouristGuideGroundReservationsContentExtend
  6612. {
  6613. Count = a.Count,
  6614. CreateTime = a.CreateTime,
  6615. CreateUserId = a.CreateUserId,
  6616. CTGGRId = a.CTGGRId,
  6617. Currency = a.Currency,
  6618. DatePrice = a.DatePrice,
  6619. DeleteTime = a.DeleteTime,
  6620. DeleteUserId = a.DeleteUserId,
  6621. DiId = a.DiId,
  6622. Id = a.Id,
  6623. IsDel = a.IsDel,
  6624. Price = a.Price,
  6625. PriceContent = a.PriceContent,
  6626. Remark = a.Remark,
  6627. SId = a.SId,
  6628. SidName = b.Name,
  6629. Units = a.Units,
  6630. }
  6631. ).ToList();
  6632. if (content.Count > 0)
  6633. {
  6634. contentArr.Add(content);
  6635. }
  6636. }
  6637. //open excel
  6638. //set excel
  6639. //save excel
  6640. try
  6641. {
  6642. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6643. IWorkbook workbook;
  6644. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6645. {
  6646. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6647. }
  6648. else
  6649. {
  6650. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6651. }
  6652. ISheet sheet = workbook.GetSheetAt(0);
  6653. var rowStartIndex = 2;
  6654. var clounmCount = 10;
  6655. var initStyleRow = sheet.GetRow(2);
  6656. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6657. //var overspendArrDetail =
  6658. var existsId = new List<CarCompare>();
  6659. var lastElem = arr.Last();
  6660. var thisSid = -1;
  6661. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6662. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6663. {
  6664. Name = "未知币种!",
  6665. Remark = "未知币种!",
  6666. };
  6667. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6668. Action cloneRowFn = () =>
  6669. {
  6670. rowStartIndex++;
  6671. var cloneRow = sheet.CreateRow(rowStartIndex);
  6672. // 复制样式
  6673. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6674. {
  6675. ICell sourceCell = initStyleRow.GetCell(i);
  6676. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6677. // 确保单元格存在样式
  6678. if (sourceCell.CellStyle != null)
  6679. {
  6680. targetCell.CellStyle = sourceCell.CellStyle;
  6681. }
  6682. }
  6683. };
  6684. var mergeRow = () =>
  6685. {
  6686. for (int i = 2; i < sheet.LastRowNum; i++)
  6687. {
  6688. var row = sheet.GetRow(i);
  6689. var cellFirst = row.GetCell(0);
  6690. var thisIndex = i + 1;
  6691. while (thisIndex < sheet.LastRowNum)
  6692. {
  6693. var nextRow = sheet.GetRow(thisIndex);
  6694. var nextCellFirst = nextRow.GetCell(0);
  6695. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6696. {
  6697. thisIndex++;
  6698. }
  6699. else
  6700. {
  6701. break;
  6702. }
  6703. }
  6704. thisIndex--;
  6705. if (thisIndex != i)
  6706. {
  6707. //合并row
  6708. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6709. i, // 起始行索引(0-based)
  6710. thisIndex, // 结束行索引(0-based)
  6711. 0, // 起始列索引(0-based)
  6712. 0 // 结束列索引(0-based)
  6713. );
  6714. sheet.AddMergedRegion(cellRangeAddress);
  6715. i = thisIndex;
  6716. }
  6717. }
  6718. };
  6719. var chaoshiNumber = 0;
  6720. var totalNumber = 0.00M;
  6721. string lastStr = "";
  6722. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6723. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6724. {
  6725. b.IsAuditGM,
  6726. x.Id,
  6727. x.Area,
  6728. b.PayPercentage,
  6729. b.PayMoney,
  6730. }).ToList();
  6731. string yesPayment = "", noPayment = "";
  6732. foreach (var item in queryCarArrByCityAndDiid)
  6733. {
  6734. if (item.IsAuditGM == 1)
  6735. {
  6736. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6737. }
  6738. else
  6739. {
  6740. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6741. }
  6742. }
  6743. lastStr = yesPayment + noPayment;
  6744. foreach (var item in arr)
  6745. {
  6746. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6747. {
  6748. if (thisSid != item.SId)
  6749. {
  6750. if (thisSid == -1)
  6751. {
  6752. thisSid = item.SId;
  6753. }
  6754. else
  6755. {
  6756. //合并小计行
  6757. //创建合并区域的实例
  6758. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6759. rowStartIndex, // 起始行索引(0-based)
  6760. rowStartIndex, // 结束行索引(0-based)
  6761. 0, // 起始列索引(0-based)
  6762. 3 // 结束列索引(0-based)
  6763. );
  6764. sheet.AddMergedRegion(cellRangeAddress);
  6765. var CellStyle = workbook.CreateCellStyle();
  6766. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6767. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6768. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6769. for (int i = 0; i <= clounmCount; i++)
  6770. {
  6771. if (i > 6)
  6772. {
  6773. var CellStyle1 = workbook.CreateCellStyle();
  6774. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6775. IFont Font = workbook.CreateFont(); // 创建字体
  6776. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6777. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6778. CellStyle1.SetFont(Font);
  6779. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6780. }
  6781. else
  6782. {
  6783. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6784. }
  6785. }
  6786. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6787. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6788. //超时合计
  6789. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6790. //超时数
  6791. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6792. //超时合计费用
  6793. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6794. thisSid = item.SId;
  6795. cloneRowFn();
  6796. chaoshiNumber = 0;
  6797. totalNumber = 0;
  6798. }
  6799. }
  6800. IRow row = sheet.GetRow(rowStartIndex);
  6801. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6802. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6803. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6804. if (isOpenOverspendSoure)
  6805. {
  6806. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6807. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6808. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6809. }
  6810. for (int i = 0; i <= clounmCount; i++)
  6811. {
  6812. var cell = row.GetCell(i);
  6813. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6814. if (cell == null)
  6815. {
  6816. cell = row.CreateCell(i);
  6817. }
  6818. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6819. fontRed.CloneStyleFrom(cell.CellStyle);
  6820. IFont Font = workbook.CreateFont(); // 创建字体
  6821. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6822. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6823. fontRed.SetFont(Font);
  6824. byte[] rgb = new byte[3] { 255, 242, 204 };
  6825. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6826. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6827. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6828. if (workbook is XSSFWorkbook)
  6829. {
  6830. BackgroundColor255_242_204.FillForegroundColor = 0;
  6831. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6832. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6833. }
  6834. else
  6835. {
  6836. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6837. }
  6838. if (i == 1 || i > 6)
  6839. {
  6840. if (i > 6)
  6841. {
  6842. fontRed.FillForegroundColor = 0;
  6843. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6844. fontRed.FillPattern = FillPattern.SolidForeground;
  6845. }
  6846. cell.CellStyle = fontRed;
  6847. }
  6848. if (i > 2 && i < 7)
  6849. {
  6850. cell.CellStyle = BackgroundColor255_242_204;
  6851. }
  6852. cell.SetCellValue(setCellValue); //写入单元格
  6853. }
  6854. if (overspendSoure.ContainsKey(thisSid))
  6855. {
  6856. var overspendId = overspendSoure[thisSid];
  6857. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6858. }
  6859. cloneRowFn();
  6860. existsId.Add(new CarCompare
  6861. {
  6862. DataPrice = item.DatePrice.ObjToDate(),
  6863. Sid = item.SId
  6864. });
  6865. }
  6866. if (item.Equals(lastElem))
  6867. {
  6868. //合并小计行
  6869. //创建合并区域的实例
  6870. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6871. rowStartIndex, // 起始行索引(0-based)
  6872. rowStartIndex, // 结束行索引(0-based)
  6873. 0, // 起始列索引(0-based)
  6874. 3 // 结束列索引(0-based)
  6875. );
  6876. sheet.AddMergedRegion(cellRangeAddress);
  6877. var CellStyle = workbook.CreateCellStyle();
  6878. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6879. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6880. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6881. for (int i = 0; i <= clounmCount; i++)
  6882. {
  6883. if (i > 6)
  6884. {
  6885. var CellStyle1 = workbook.CreateCellStyle();
  6886. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6887. IFont Font = workbook.CreateFont(); // 创建字体
  6888. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6889. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6890. CellStyle1.SetFont(Font);
  6891. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6892. }
  6893. else
  6894. {
  6895. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6896. }
  6897. }
  6898. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6899. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6900. //超时合计
  6901. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6902. //超时数
  6903. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6904. //超时合计费用
  6905. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6906. cloneRowFn();
  6907. // 创建合并区域的实例
  6908. cellRangeAddress = new CellRangeAddress(
  6909. rowStartIndex, // 起始行索引(0-based)
  6910. rowStartIndex, // 结束行索引(0-based)
  6911. 0, // 起始列索引(0-based)
  6912. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6913. );
  6914. // 添加合并区域
  6915. sheet.AddMergedRegion(cellRangeAddress);
  6916. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6917. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6918. }
  6919. }
  6920. mergeRow();
  6921. // 保存修改后的Excel文件到新文件
  6922. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6923. // new FileStream(newFilePath, FileMode.CreateNew)
  6924. using (var stream = new MemoryStream())
  6925. {
  6926. workbook.Write(stream, true);
  6927. stream.Flush();
  6928. stream.Seek(0, SeekOrigin.Begin);
  6929. MemoryStream memoryStream = new MemoryStream();
  6930. stream.CopyTo(memoryStream);
  6931. memoryStream.Seek(0, SeekOrigin.Begin);
  6932. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6933. }
  6934. workbook.Close();
  6935. workbook.Dispose();
  6936. }
  6937. catch (Exception ex)
  6938. {
  6939. jw.Msg = "出现异常!" + ex.Message;
  6940. return Ok(jw);
  6941. }
  6942. }
  6943. if (Zips.Count > 0)
  6944. {
  6945. IOOperatorHelper io = new IOOperatorHelper();
  6946. var byts = io.ConvertZipStream(Zips);
  6947. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6948. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6949. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6950. }
  6951. else
  6952. {
  6953. jw.Msg = "暂无生成文件!";
  6954. }
  6955. return Ok(jw);
  6956. }
  6957. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6958. {
  6959. string outStr = string.Empty;
  6960. switch (i)
  6961. {
  6962. case 0:
  6963. outStr = arr[0].SidName;
  6964. break;
  6965. case 1:
  6966. outStr = arr[0].DataPriceStr;
  6967. break;
  6968. case 2:
  6969. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6970. break;
  6971. case 4:
  6972. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6973. break;
  6974. case 7:
  6975. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6976. {
  6977. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6978. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6979. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6980. }
  6981. break;
  6982. case 8:
  6983. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6984. {
  6985. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6986. }
  6987. break;
  6988. case 9:
  6989. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6990. {
  6991. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6992. }
  6993. break;
  6994. case 10:
  6995. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6996. {
  6997. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6998. }
  6999. break;
  7000. }
  7001. return outStr;
  7002. }
  7003. #region OP行程单
  7004. /// <summary>
  7005. /// OP行程单初始化
  7006. /// </summary>
  7007. /// <param name="dto"></param>
  7008. /// <returns></returns>
  7009. [HttpPost]
  7010. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7011. {
  7012. var jw = JsonView(false);
  7013. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7014. var group = groupList.First();
  7015. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7016. if (group == null)
  7017. {
  7018. jw.Msg = "暂无团组!";
  7019. return Ok(jw);
  7020. }
  7021. group = groupList.Find(x => x.Id == diid);
  7022. if (group == null)
  7023. {
  7024. jw.Msg = "请输入正确的团组ID!";
  7025. return Ok(jw);
  7026. }
  7027. string city = string.Empty;
  7028. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7029. if (blackCode.Count > 0)
  7030. {
  7031. var black = blackCode.First();
  7032. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7033. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7034. if (blackSp.Length > 0)
  7035. {
  7036. try
  7037. {
  7038. var cityArrCode = new List<string>(20);
  7039. foreach (var item in blackSp)
  7040. {
  7041. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7042. var IndexSelect = itemSp[2];
  7043. var cityArrCodeLength = cityArrCode.Count - 1;
  7044. var startCity = IndexSelect.Substring(0, 3);
  7045. if (cityArrCodeLength > 0)
  7046. {
  7047. var arrEndCity = cityArrCode[cityArrCodeLength];
  7048. if (arrEndCity != startCity)
  7049. {
  7050. cityArrCode.Add(startCity.ToUpper());
  7051. }
  7052. }
  7053. else
  7054. {
  7055. cityArrCode.Add(startCity.ToUpper());
  7056. }
  7057. var endCity = IndexSelect.Substring(3, 3);
  7058. cityArrCode.Add(endCity.ToUpper());
  7059. }
  7060. var cityThree = string.Empty;
  7061. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7062. cityThree = cityThree.TrimEnd(',');
  7063. if (string.IsNullOrWhiteSpace(cityThree))
  7064. {
  7065. throw new
  7066. Exception("error");
  7067. }
  7068. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7069. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7070. foreach (var item in cityArrCode)
  7071. {
  7072. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7073. if (find != null)
  7074. {
  7075. city += find.City + "/";
  7076. }
  7077. else
  7078. {
  7079. city += item + "三字码未收入/";
  7080. }
  7081. }
  7082. city = city.TrimEnd('/');
  7083. }
  7084. catch (Exception e)
  7085. {
  7086. city = "黑屏代码格式不正确!";
  7087. }
  7088. }
  7089. }
  7090. else
  7091. {
  7092. city = "未录入黑屏代码";
  7093. }
  7094. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7095. {
  7096. Date = x.Date,
  7097. Days = x.Days,
  7098. Diffgroup = x.Diffgroup,
  7099. Diid = x.Diid,
  7100. Traffic_First = x.Traffic_First,
  7101. Traffic_Second = x.Traffic_Second,
  7102. Trip = x.Trip,
  7103. WeekDay = x.WeekDay,
  7104. Id = x.Id
  7105. }).ToList();
  7106. jw.Data = new
  7107. {
  7108. groupList = groupList.Select(x => new
  7109. {
  7110. x.Id,
  7111. x.TeamName,
  7112. x.TourCode
  7113. }).ToList(),
  7114. groupInfo = new
  7115. {
  7116. group.VisitDays,
  7117. group.TourCode,
  7118. group.VisitPNumber,
  7119. group.TeamName,
  7120. city
  7121. },
  7122. OpTravelList
  7123. };
  7124. jw.Code = 200;
  7125. jw.Msg = "操作成功!";
  7126. return Ok(jw);
  7127. }
  7128. /// <summary>
  7129. /// 删除团组行程单
  7130. /// </summary>
  7131. /// <returns></returns>
  7132. [HttpPost]
  7133. public IActionResult DelTravel(DelOpTravelDto dto)
  7134. {
  7135. var jw = JsonView(false);
  7136. if (dto.UserId <= 0 || dto.Diid <= 0)
  7137. {
  7138. jw.Msg = "请输入正确的参数!";
  7139. return Ok(jw);
  7140. }
  7141. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7142. .SetColumns(x => new Grp_TravelList
  7143. {
  7144. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7145. DeleteUserId = dto.UserId,
  7146. IsDel = 1,
  7147. }).ExecuteCommand();
  7148. jw = JsonView(true);
  7149. return Ok(jw);
  7150. }
  7151. /// <summary>
  7152. /// 行程单保存
  7153. /// </summary>
  7154. /// <returns></returns>
  7155. [HttpPost]
  7156. public IActionResult TravelSave(TravelSaveDto dto)
  7157. {
  7158. var jw = JsonView(false);
  7159. if (dto.Arr.Count > 0)
  7160. {
  7161. try
  7162. {
  7163. _sqlSugar.BeginTran();
  7164. foreach (var item in dto.Arr)
  7165. {
  7166. if (item.Id == 0)
  7167. {
  7168. throw new Exception("请传入正确的Id");
  7169. }
  7170. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7171. .SetColumns(x => new Grp_TravelList
  7172. {
  7173. Trip = item.Trip
  7174. }).ExecuteCommand();
  7175. }
  7176. _sqlSugar.CommitTran();
  7177. jw = JsonView(true);
  7178. }
  7179. catch (Exception ex)
  7180. {
  7181. _sqlSugar.RollbackTran();
  7182. jw.Msg = "程序异常!" + ex.Message;
  7183. }
  7184. }
  7185. else
  7186. {
  7187. jw.Msg = "请传入正确的参数!";
  7188. }
  7189. return Ok(jw);
  7190. }
  7191. /// <summary>
  7192. /// 导出行程单
  7193. /// </summary>
  7194. /// <param name="dto"></param>
  7195. /// <returns></returns>
  7196. [HttpPost]
  7197. public IActionResult ExportTravel(ExportTravelDto dto)
  7198. {
  7199. var jw = JsonView(false);
  7200. jw.Data = "";
  7201. int diid = 0;
  7202. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7203. if (Find == null)
  7204. {
  7205. jw.Msg = "请选择正确的团组!";
  7206. return Ok(jw);
  7207. }
  7208. else
  7209. {
  7210. diid = Find.Id;
  7211. }
  7212. //数据源
  7213. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7214. DataTable dtBlack = null;
  7215. try
  7216. {
  7217. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7218. }
  7219. catch (Exception)
  7220. {
  7221. jw.Msg = "机票黑屏代码有误!";
  7222. return Ok(jw);
  7223. }
  7224. string CityStr = string.Empty;
  7225. if (dtBlack.Rows.Count == 0)
  7226. {
  7227. jw.Msg = "机票黑屏代码有误!";
  7228. return Ok(jw);
  7229. }
  7230. else
  7231. {
  7232. foreach (DataRow row in dtBlack.Rows)
  7233. {
  7234. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7235. {
  7236. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7237. return Ok(jw);
  7238. }
  7239. }
  7240. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7241. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7242. }
  7243. //创建数据源Table
  7244. DataTable dtSource = new DataTable();
  7245. dtSource.Columns.Add("Days", typeof(string));
  7246. dtSource.Columns.Add("Date", typeof(string));
  7247. dtSource.Columns.Add("Week", typeof(string));
  7248. dtSource.Columns.Add("Traffic", typeof(string));
  7249. dtSource.Columns.Add("Trip", typeof(string));
  7250. //获取数据,放到datatable
  7251. foreach (var item in _travelList)
  7252. {
  7253. DataRow dr = dtSource.NewRow();
  7254. dr["Days"] = item.Days;
  7255. dr["Date"] = item.Date;
  7256. dr["Week"] = item.WeekDay;
  7257. dr["Traffic"] = item.Traffic_First
  7258. + "\r\n"
  7259. + item.Traffic_Second;
  7260. dr["Trip"] = item.Trip;
  7261. dtSource.Rows.Add(dr);
  7262. }
  7263. Dictionary<string, string> dic = new Dictionary<string, string>();
  7264. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7265. dic.Add("City", CityStr);
  7266. dic.Add("Days", Find.VisitDays.ToString());
  7267. dic.Add("DeleCode", Find.TourCode);
  7268. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7269. //模板路径
  7270. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7271. //载入模板
  7272. Document doc = null;
  7273. DocumentBuilder builder = null;
  7274. try
  7275. {
  7276. //载入模板
  7277. doc = new Document(tempPath);
  7278. builder = new DocumentBuilder(doc);
  7279. }
  7280. catch (Exception)
  7281. {
  7282. jw.Msg = "模板位置不存在!";
  7283. return Ok(jw);
  7284. }
  7285. foreach (var key in dic.Keys)
  7286. {
  7287. Bookmark bookmark = doc.Range.Bookmarks[key];
  7288. if (bookmark != null)
  7289. {
  7290. builder.MoveToBookmark(key);
  7291. builder.Write(dic[key]);
  7292. }
  7293. }
  7294. //获取word里所有表格
  7295. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7296. //获取所填表格的序数
  7297. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7298. try
  7299. {
  7300. //循环赋值
  7301. for (int i = 0; i < dtSource.Rows.Count; i++)
  7302. {
  7303. builder.MoveToCell(0, i + 1, 0, 0);
  7304. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7305. builder.MoveToCell(0, i + 1, 1, 0);
  7306. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7307. builder.MoveToCell(0, i + 1, 2, 0);
  7308. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7309. var trip = dtSource.Rows[i]["Trip"].ToString();
  7310. builder.MoveToCell(0, i + 1, 3, 0);
  7311. builder.Write(trip);
  7312. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7313. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7314. // 获取特定索引的段落
  7315. Paragraph paragraph = (Paragraph)paragraphs[0];
  7316. Run run = paragraph.Runs[0];
  7317. Aspose.Words.Font font = run.Font;
  7318. font.Name = "黑体";
  7319. //设置双休红色
  7320. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7321. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7322. paragraph = (Paragraph)paragraphs[1];
  7323. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7324. {
  7325. run = paragraph.Runs[0];
  7326. font = run.Font;
  7327. font.Color = Color.Red;
  7328. }
  7329. }
  7330. }
  7331. catch (Exception ex)
  7332. {
  7333. }
  7334. //删除多余行
  7335. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7336. {
  7337. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7338. }
  7339. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7340. if (!Directory.Exists(savePath))
  7341. {
  7342. try
  7343. {
  7344. Directory.CreateDirectory(savePath);
  7345. }
  7346. catch
  7347. {
  7348. }
  7349. }
  7350. string path = savePath + Find.TeamName + "出访日程";
  7351. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7352. try
  7353. {
  7354. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7355. string postfix = ".docx";
  7356. if (dto.IsPDF == 1)
  7357. {
  7358. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7359. postfix = ".pdf";
  7360. }
  7361. doc.Save(path + postfix, saveFormat);
  7362. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7363. }
  7364. catch (Exception)
  7365. {
  7366. jw = JsonView(false);
  7367. }
  7368. return Ok(jw);
  7369. }
  7370. /// <summary>
  7371. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7372. /// </summary>
  7373. /// <param name="num"></param>
  7374. /// <returns></returns>
  7375. string GetNum(string num)
  7376. {
  7377. string str = "";
  7378. switch (num)
  7379. {
  7380. case "1":
  7381. str = "一";
  7382. break;
  7383. case "2":
  7384. str = "二";
  7385. break;
  7386. case "3":
  7387. str = "三";
  7388. break;
  7389. case "4":
  7390. str = "四";
  7391. break;
  7392. case "5":
  7393. str = "五";
  7394. break;
  7395. case "6":
  7396. str = "六";
  7397. break;
  7398. case "7":
  7399. str = "七";
  7400. break;
  7401. case "8":
  7402. str = "八";
  7403. break;
  7404. case "9":
  7405. str = "九";
  7406. break;
  7407. case "10":
  7408. str = "十";
  7409. break;
  7410. case "11":
  7411. str = "十一";
  7412. break;
  7413. case "12":
  7414. str = "十二";
  7415. break;
  7416. case "一":
  7417. str = "1";
  7418. break;
  7419. case "二":
  7420. str = "2";
  7421. break;
  7422. case "三":
  7423. str = "3";
  7424. break;
  7425. case "四":
  7426. str = "4";
  7427. break;
  7428. case "五":
  7429. str = "5";
  7430. break;
  7431. case "六":
  7432. str = "6";
  7433. break;
  7434. case "七":
  7435. str = "7";
  7436. break;
  7437. case "八":
  7438. str = "8";
  7439. break;
  7440. case "九":
  7441. str = "9";
  7442. break;
  7443. case "十":
  7444. str = "10";
  7445. break;
  7446. case "十一":
  7447. str = "11";
  7448. break;
  7449. case "十二":
  7450. str = "12";
  7451. break;
  7452. }
  7453. return str;
  7454. }
  7455. #endregion
  7456. #endregion
  7457. #region 团组成本
  7458. /// <summary>
  7459. /// 团组成本数据初始化
  7460. /// </summary>
  7461. /// <param name="dto"></param>
  7462. /// <returns></returns>
  7463. [HttpPost]
  7464. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7465. {
  7466. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7467. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7468. WHEN COUNT(*) >= 0 THEN 'True'
  7469. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7470. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7471. ").ToList(); //团组列表
  7472. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7473. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7474. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7475. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7476. if (groupinfoValue != null)
  7477. {
  7478. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7479. var spArr = new string[1] { countryArr };
  7480. if (countryArr.Contains("|"))
  7481. {
  7482. spArr = countryArr.Split("|");
  7483. }
  7484. else if (countryArr.Contains("、"))
  7485. {
  7486. spArr = countryArr.Split("、");
  7487. }
  7488. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7489. {
  7490. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7491. if (dbQueryCountry != null)
  7492. {
  7493. visaCountryInfoArr.Add(dbQueryCountry);
  7494. }
  7495. }
  7496. }
  7497. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7498. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7499. var create = _GroupCostRepository.
  7500. CreateGroupCostByBlackCode(dto.Diid);
  7501. if (groupCost.Count == 0 && create.Code == 0)
  7502. {
  7503. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7504. }
  7505. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7506. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7507. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7508. groupCostMap = groupCostMap.Select(x =>
  7509. {
  7510. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7511. {
  7512. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7513. }
  7514. return x;
  7515. }).ToList();
  7516. //GroupCostParameter.Add(new
  7517. // Grp_GroupCostParameter());
  7518. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7519. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7520. return Ok(JsonView(new
  7521. {
  7522. groupList,
  7523. groupInfo,
  7524. groupChecks,
  7525. groupCost = groupCostMap,
  7526. hotelNumber,
  7527. GroupCostParameter = GroupCostParameterMap,
  7528. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7529. {
  7530. x.VisaCountry,
  7531. x.VisaPrice,
  7532. x.Id,
  7533. }).ToList(),
  7534. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7535. blackCodeIsTrue = create.Code == 0 ? true : false,
  7536. hotelIsTrue = hotelIsTrue,
  7537. }));
  7538. }
  7539. /// <summary>
  7540. /// 团组成本信息保存
  7541. /// </summary>
  7542. /// <param name="dto"></param>
  7543. /// <returns></returns>
  7544. [HttpPost]
  7545. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7546. {
  7547. if (dto.Diid <= 0 || dto.Userid <= 0)
  7548. {
  7549. return Ok(JsonView(false));
  7550. }
  7551. JsonView jw = null;
  7552. bool isTrue = false;
  7553. #region 复制团组成本
  7554. //if (dto.Diid == 2581)
  7555. //{
  7556. // dto.Diid = 2599;
  7557. // dto.CheckBoxs.ForEach(x =>
  7558. // {
  7559. // x.Diid = 2599;
  7560. // });
  7561. // dto.GroupCosts.ForEach(x =>
  7562. // {
  7563. // x.Diid = 2599;
  7564. // });
  7565. // dto.CostTypeHotelNumbers.ForEach(x =>
  7566. // {
  7567. // x.Diid = 2599;
  7568. // });
  7569. // dto.GroupCostParameters.ForEach(x =>
  7570. // {
  7571. // x.DiId = 2599;
  7572. // });
  7573. //}
  7574. #endregion
  7575. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7576. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7577. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7578. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7579. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7580. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7581. try
  7582. {
  7583. _sqlSugar.BeginTran();
  7584. isTrue = await _GroupCostRepository.
  7585. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7586. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7587. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7588. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7589. _sqlSugar.CommitTran();
  7590. jw = JsonView(true, "保存成功!", isTrue);
  7591. }
  7592. catch (Exception)
  7593. {
  7594. _sqlSugar.RollbackTran();
  7595. jw = JsonView(false);
  7596. }
  7597. return Ok(jw);
  7598. }
  7599. /// <summary>
  7600. /// 司兼导数据
  7601. /// </summary>
  7602. /// <param name="dto"></param>
  7603. /// <returns></returns>
  7604. [HttpPost]
  7605. public IActionResult GetCarGuides(CarGuidesDto dto)
  7606. {
  7607. JsonView jw = null;
  7608. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7609. jw = JsonView(true, "获取成功!", Data);
  7610. return Ok(jw);
  7611. }
  7612. /// <summary>
  7613. /// 导游数据
  7614. /// </summary>
  7615. /// <param name="dto"></param>
  7616. /// <returns></returns>
  7617. [HttpPost]
  7618. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7619. {
  7620. JsonView jw = null;
  7621. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7622. // 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
  7623. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7624. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7625. jw = JsonView(true, "获取成功!", Data);
  7626. return Ok(jw);
  7627. }
  7628. /// <summary>
  7629. /// 成本车数据
  7630. /// </summary>
  7631. /// <param name="dto"></param>
  7632. /// <returns></returns>
  7633. [HttpPost]
  7634. public IActionResult GetCarInfo(CarGuidesDto dto)
  7635. {
  7636. JsonView jw = null;
  7637. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7638. jw = JsonView(true, "获取成功!", Data);
  7639. return Ok(jw);
  7640. }
  7641. /// <summary>
  7642. /// 景点数据
  7643. /// </summary>
  7644. /// <param name="dto"></param>
  7645. /// <returns></returns>
  7646. [HttpPost]
  7647. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7648. {
  7649. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7650. return Ok(JsonView(true, "获取成功!", Data));
  7651. }
  7652. /// <summary>
  7653. /// 成本通知
  7654. /// </summary>
  7655. /// <param name="dto"></param>
  7656. /// <returns></returns>
  7657. [HttpPost]
  7658. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7659. {
  7660. if (dto.Diid < 0)
  7661. {
  7662. return Ok(JsonView(false));
  7663. }
  7664. JsonView jw = null;
  7665. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7666. if (GroupCostParameter != null)
  7667. {
  7668. int IsShare = 0;
  7669. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7670. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7671. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7672. string msg = string.Empty;
  7673. if (isTrue)
  7674. {
  7675. if (IsShare == 0)
  7676. {
  7677. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7678. }
  7679. else
  7680. {
  7681. #region 企微通知对应岗位用户
  7682. try
  7683. {
  7684. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7685. }
  7686. catch (Exception ex)
  7687. {
  7688. }
  7689. #endregion
  7690. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7691. }
  7692. jw = JsonView(isTrue, msg, new { IsShare });
  7693. }
  7694. else
  7695. {
  7696. msg = "修改失败!";
  7697. jw = JsonView(isTrue, msg);
  7698. }
  7699. }
  7700. else
  7701. {
  7702. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7703. }
  7704. return Ok(jw);
  7705. }
  7706. /// <summary>
  7707. /// 导出报价单
  7708. /// </summary>
  7709. /// <param name="dto"></param>
  7710. /// <returns></returns>
  7711. [HttpPost]
  7712. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7713. {
  7714. if (dto.Diid == 0)
  7715. {
  7716. return Ok(JsonView(false, "请传递团组id"));
  7717. }
  7718. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7719. if (deleInfo.Code != 0)
  7720. {
  7721. return Ok(JsonView(false, "团组信息查询失败!"));
  7722. }
  7723. var di = deleInfo.Data as DelegationInfoWebView;
  7724. if (di != null)
  7725. {
  7726. di.TeamName = di.TeamName.Replace("|", "、");
  7727. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7728. //文件名
  7729. string strFileName = di.TeamName + "-收款账单.doc";
  7730. //获取模板
  7731. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7732. //载入模板
  7733. Document doc = new Document(tmppath);
  7734. decimal TotalPrice = 0.00M;
  7735. string itemStr = string.Empty;
  7736. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7737. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7738. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7739. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7740. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7741. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7742. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7743. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7744. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7745. foreach (var cost in groupCostType)
  7746. {
  7747. var List = cost.ToList();
  7748. if (cost.Key == "A")
  7749. {
  7750. foreach (var ListItem in List)
  7751. {
  7752. if (ListItem.number > 0)
  7753. {
  7754. if (ListItem.code.Contains("TBR"))
  7755. {
  7756. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7757. }
  7758. else
  7759. {
  7760. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7761. }
  7762. TotalPrice += (ListItem.number * ListItem.price);
  7763. }
  7764. }
  7765. }
  7766. else
  7767. {
  7768. itemStr = itemStr.Insert(0, "A段\r\n");
  7769. itemStr += "B段\r\n";
  7770. foreach (var ListItem in List)
  7771. {
  7772. if (ListItem.number > 0)
  7773. {
  7774. if (ListItem.code.Contains("TBR"))
  7775. {
  7776. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7777. }
  7778. else
  7779. {
  7780. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7781. }
  7782. TotalPrice += (ListItem.number * ListItem.price);
  7783. }
  7784. }
  7785. }
  7786. }
  7787. #region 替换Word模板书签内容
  7788. Dictionary<string, string> marks = new Dictionary<string, string>();
  7789. marks.Add("To", di.ClientUnit);//付款方
  7790. marks.Add("ToTel", di.TellPhone);//付款方电话
  7791. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7792. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7793. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7794. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7795. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7796. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7797. marks.Add("PayItemContent", itemStr);//详细信息
  7798. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7799. #endregion
  7800. ////注
  7801. //if (doc.Range.Bookmarks["Attention"] != null)
  7802. //{
  7803. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7804. // mark.Text = frList[0].Attention;
  7805. //}
  7806. foreach (var item in marks.Keys)
  7807. {
  7808. if (doc.Range.Bookmarks[item] != null)
  7809. {
  7810. Bookmark mark = doc.Range.Bookmarks[item];
  7811. mark.Text = marks[item];
  7812. }
  7813. }
  7814. byte[] bytes = null;
  7815. using (MemoryStream stream = new MemoryStream())
  7816. {
  7817. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7818. bytes = stream.ToArray();
  7819. }
  7820. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7821. return Ok(JsonView(true, "", new
  7822. {
  7823. Data = bytes,
  7824. strFileName,
  7825. }));
  7826. }
  7827. else
  7828. {
  7829. return Ok(JsonView(false, "团组信息不存在!"));
  7830. }
  7831. }
  7832. /// <summary>
  7833. /// 导出团组成本
  7834. /// </summary>
  7835. /// <param name="dto"></param>
  7836. /// <returns></returns>
  7837. [HttpPost]
  7838. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7839. {
  7840. var jw = JsonView(false);
  7841. if (dto.Diid == 0)
  7842. {
  7843. return Ok(JsonView(false, "请传递团组id"));
  7844. }
  7845. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7846. if (deleInfo.Code != 0)
  7847. {
  7848. return Ok(JsonView(false, "团组信息查询失败!"));
  7849. }
  7850. var di = deleInfo.Data as DelegationInfoWebView;
  7851. if (di == null)
  7852. {
  7853. return Ok(JsonView(false, "团组信息查询失败!"));
  7854. }
  7855. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7856. WorkbookDesigner designer = new WorkbookDesigner();
  7857. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7858. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7859. for (int i = 0; i < List_GC.Count; i++)
  7860. {
  7861. GroupCost_Excel gc = new GroupCost_Excel();
  7862. gc.Id = List_GC[i].Id;
  7863. gc.Diid = List_GC[i].Diid.ToString();
  7864. gc.DAY = List_GC[i].DAY;
  7865. string week = "";
  7866. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7867. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7868. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7869. gc.ITIN = List_GC[i].ITIN;
  7870. gc.CarType = List_GC[i].CarType;
  7871. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7872. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7873. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7874. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7875. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7876. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7877. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7878. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7879. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7880. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7881. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7882. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7883. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7884. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7885. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7886. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7887. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7888. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7889. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7890. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7891. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7892. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7893. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7894. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7895. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7896. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7897. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7898. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7899. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7900. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7901. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7902. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7903. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7904. List_GC1.Add(gc);
  7905. }
  7906. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7907. dt.TableName = "TB";
  7908. //报表标题等不用dt的值
  7909. designer.SetDataSource("TeamName", dto.title.TeamName);
  7910. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7911. designer.SetDataSource("Tax", dto.title.Tax);
  7912. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7913. designer.SetDataSource("Currency", dto.title.Currency);
  7914. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7915. designer.SetDataSource("Rate", dto.title.Rate);
  7916. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7917. var Aparams = hotels.Find(x => x.Type == "Default");
  7918. if (Aparams == null)
  7919. {
  7920. return Ok(jw);
  7921. }
  7922. //酒店数量
  7923. var txtSGRNumber = Aparams.SGR.ToString();
  7924. var txtTBRNumber = Aparams.TBR.ToString();
  7925. var txtJSESNumber = Aparams.JSES.ToString();
  7926. var txtSUITENumbe = Aparams.SUITE.ToString();
  7927. if (dto.costType == "B")
  7928. {
  7929. Aparams = hotels.Find(x => x.Type == "A");
  7930. var Bparams = hotels.Find(x => x.Type == "B");
  7931. if (Aparams == null || Bparams == null)
  7932. {
  7933. return Ok(jw);
  7934. }
  7935. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7936. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7937. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7938. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7939. }
  7940. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7941. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7942. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7943. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7944. var ws = designer.Workbook.Worksheets[0];
  7945. int Row = List_GC.Count;
  7946. int startIndex = 11;
  7947. int HideRows = 0;
  7948. List<int> hideRowsList = new List<int>();
  7949. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7950. #region A段left数据
  7951. var left = dto.leftInfo.Find(x => x.Type == "A");
  7952. if (left == null)
  7953. {
  7954. return Ok(jw);
  7955. }
  7956. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7957. if (leftBindData != null)
  7958. {
  7959. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7960. designer.SetDataSource("VisaRS", leftBindData.rs);
  7961. designer.SetDataSource("VisaXS", leftBindData.xs);
  7962. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7963. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7964. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7965. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7966. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7967. }
  7968. else
  7969. {
  7970. hideRowsList.Add(Row + startIndex + HideRows);
  7971. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7972. }
  7973. HideRows += 2;
  7974. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7975. if (leftBindData != null)
  7976. {
  7977. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7978. designer.SetDataSource("BXRS", leftBindData.rs);
  7979. designer.SetDataSource("BXXS", leftBindData.xs);
  7980. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7981. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7982. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7983. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7984. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7985. }
  7986. else
  7987. {
  7988. hideRowsList.Add(Row + startIndex + HideRows);
  7989. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7990. }
  7991. HideRows += 2;
  7992. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7993. if (leftBindData != null)
  7994. {
  7995. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7996. designer.SetDataSource("HSRS", leftBindData.rs);
  7997. designer.SetDataSource("HSXS", leftBindData.xs);
  7998. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7999. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8000. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8001. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8002. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8003. }
  8004. else
  8005. {
  8006. hideRowsList.Add(Row + startIndex + HideRows);
  8007. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8008. }
  8009. HideRows += 2;
  8010. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8011. if (leftBindData != null)
  8012. {
  8013. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8014. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8015. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8016. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8017. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8018. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8019. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8020. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8021. }
  8022. else
  8023. {
  8024. hideRowsList.Add(Row + startIndex + HideRows);
  8025. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8026. }
  8027. HideRows += 2;
  8028. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8029. if (leftBindData != null)
  8030. {
  8031. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8032. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8033. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8034. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8035. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8036. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8037. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8038. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8039. }
  8040. else
  8041. {
  8042. hideRowsList.Add(Row + startIndex + HideRows);
  8043. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8044. }
  8045. HideRows += 2;
  8046. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8047. if (leftBindData != null)
  8048. {
  8049. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8050. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8051. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8052. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8053. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8054. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8055. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8056. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8057. }
  8058. else
  8059. {
  8060. hideRowsList.Add(Row + startIndex + HideRows);
  8061. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8062. }
  8063. HideRows += 2;
  8064. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8065. if (leftBindData != null)
  8066. {
  8067. ////TBR
  8068. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8069. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8070. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8071. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8072. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8073. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8074. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8075. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8076. }
  8077. else
  8078. {
  8079. hideRowsList.Add(Row + startIndex + HideRows);
  8080. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8081. }
  8082. HideRows += 2;
  8083. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8084. if (leftBindData != null)
  8085. {
  8086. ////SGR
  8087. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8088. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8089. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8090. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8091. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8092. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8093. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8094. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8095. }
  8096. else
  8097. {
  8098. hideRowsList.Add(Row + startIndex + HideRows);
  8099. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8100. }
  8101. HideRows += 2;
  8102. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8103. if (leftBindData != null)
  8104. {
  8105. ////JS/ES
  8106. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8107. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8108. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8109. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8110. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8111. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8112. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8113. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8114. }
  8115. else
  8116. {
  8117. hideRowsList.Add(Row + startIndex + HideRows);
  8118. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8119. }
  8120. HideRows += 2;
  8121. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8122. if (leftBindData != null)
  8123. {
  8124. ////SUITE
  8125. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8126. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8127. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8128. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8129. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8130. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8131. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8132. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8133. }
  8134. else
  8135. {
  8136. hideRowsList.Add(Row + startIndex + HideRows);
  8137. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8138. }
  8139. HideRows += 2;
  8140. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8141. if (leftBindData != null)
  8142. {
  8143. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8144. designer.SetDataSource("DJRS", leftBindData.rs);
  8145. designer.SetDataSource("DJXS", leftBindData.xs);
  8146. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8147. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8148. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8149. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8150. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8151. }
  8152. else
  8153. {
  8154. hideRowsList.Add(Row + startIndex + HideRows);
  8155. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8156. }
  8157. HideRows += 2;
  8158. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8159. if (leftBindData != null)
  8160. {
  8161. designer.SetDataSource("HCPCB", leftBindData.cb);
  8162. designer.SetDataSource("HCPRS", leftBindData.rs);
  8163. designer.SetDataSource("HCPXS", leftBindData.xs);
  8164. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8165. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8166. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8167. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8168. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8169. }
  8170. else
  8171. {
  8172. hideRowsList.Add(Row + startIndex + HideRows);
  8173. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8174. }
  8175. HideRows += 2;
  8176. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8177. if (leftBindData != null)
  8178. {
  8179. designer.SetDataSource("CPCB", leftBindData.cb);
  8180. designer.SetDataSource("CPRS", leftBindData.rs);
  8181. designer.SetDataSource("CPXS", leftBindData.xs);
  8182. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8183. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8184. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8185. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8186. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8187. }
  8188. else
  8189. {
  8190. hideRowsList.Add(Row + startIndex + HideRows);
  8191. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8192. }
  8193. HideRows += 2;
  8194. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8195. if (leftBindData != null)
  8196. {
  8197. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8198. designer.SetDataSource("GWRS", leftBindData.rs);
  8199. designer.SetDataSource("GWXS", leftBindData.xs);
  8200. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8201. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8202. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8203. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8204. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8205. }
  8206. else
  8207. {
  8208. hideRowsList.Add(Row + startIndex + HideRows);
  8209. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8210. }
  8211. HideRows += 2;
  8212. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8213. if (leftBindData != null)
  8214. {
  8215. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8216. designer.SetDataSource("LYJRS", leftBindData.rs);
  8217. designer.SetDataSource("LYJXS", leftBindData.xs);
  8218. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8219. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8220. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8221. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8222. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8223. }
  8224. else
  8225. {
  8226. hideRowsList.Add(Row + startIndex + HideRows);
  8227. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8228. }
  8229. #endregion
  8230. #region A段Right信息
  8231. var right = dto.rightInfo.Find(x => x.Type == "A");
  8232. if (right == null)
  8233. {
  8234. return Ok(jw);
  8235. }
  8236. HideRows += 4;
  8237. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8238. if (rightBindData != null)
  8239. {
  8240. //经济舱 + 双人间 TBR
  8241. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8242. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8243. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8244. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8245. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8246. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8247. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8248. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8249. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8250. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8251. }
  8252. else
  8253. {
  8254. hideRowsList.Add(Row + startIndex + HideRows);
  8255. }
  8256. HideRows += 2;
  8257. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8258. if (rightBindData != null)
  8259. {
  8260. //经济舱 + 单人间 SGR
  8261. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8262. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8263. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8264. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8265. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8266. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8267. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8268. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8269. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8270. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8271. }
  8272. else
  8273. {
  8274. hideRowsList.Add(Row + startIndex + HideRows);
  8275. }
  8276. HideRows += 2;
  8277. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8278. if (rightBindData != null)
  8279. {
  8280. //公务舱 + 单人间 SGR
  8281. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8282. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8283. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8284. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8285. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8286. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8287. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8288. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8289. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8290. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8291. }
  8292. else
  8293. {
  8294. hideRowsList.Add(Row + startIndex + HideRows);
  8295. }
  8296. HideRows += 2;
  8297. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8298. if (rightBindData != null)
  8299. {
  8300. //公务舱 + 小套房 JSES
  8301. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8302. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8303. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8304. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8305. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8306. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8307. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8308. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8309. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8310. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8311. }
  8312. else
  8313. {
  8314. hideRowsList.Add(Row + startIndex + HideRows);
  8315. }
  8316. HideRows += 2;
  8317. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8318. if (rightBindData != null)
  8319. {
  8320. //公务舱 + 小套房 JSES
  8321. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8322. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8323. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8324. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8325. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8326. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8327. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8328. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8329. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8330. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8331. }
  8332. else
  8333. {
  8334. hideRowsList.Add(Row + startIndex + HideRows);
  8335. }
  8336. HideRows += 2;
  8337. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8338. if (rightBindData != null)
  8339. {
  8340. //经济舱 + 大套房
  8341. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8342. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8343. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8344. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8345. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8346. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8347. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8348. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8349. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8350. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8351. }
  8352. else
  8353. {
  8354. hideRowsList.Add(Row + startIndex + HideRows);
  8355. }
  8356. HideRows += 2;
  8357. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8358. if (rightBindData != null)
  8359. {
  8360. //头等舱 + 小套房 JSES
  8361. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8362. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8363. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8364. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8365. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8366. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8367. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8368. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8369. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8370. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8371. }
  8372. else
  8373. {
  8374. hideRowsList.Add(Row + startIndex + HideRows);
  8375. }
  8376. HideRows += 2;
  8377. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8378. if (rightBindData != null)
  8379. {
  8380. //头等舱 + 大套房
  8381. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8382. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8383. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8384. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8385. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8386. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8387. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8388. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8389. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8390. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8391. }
  8392. else
  8393. {
  8394. hideRowsList.Add(Row + startIndex + HideRows);
  8395. }
  8396. #endregion
  8397. #region B段标题清空
  8398. designer.SetDataSource("CostBDRCB", "");
  8399. designer.SetDataSource("CostBRS", "");
  8400. designer.SetDataSource("CostBXS", "");
  8401. designer.SetDataSource("CostBZCB", "");
  8402. designer.SetDataSource("CostBDRBJ", "");
  8403. designer.SetDataSource("CostBZBJ", "");
  8404. designer.SetDataSource("CostBDRLR", "");
  8405. designer.SetDataSource("CostBZLR", "");
  8406. designer.SetDataSource("CostBDRCBOM", "");
  8407. designer.SetDataSource("CostBRSOM", "");
  8408. designer.SetDataSource("CostBZCBOM", "");
  8409. designer.SetDataSource("CostBDRBJOM", "");
  8410. designer.SetDataSource("CostBZBJOM", "");
  8411. designer.SetDataSource("CostBDRLROM", "");
  8412. designer.SetDataSource("CostBZLROM", "");
  8413. #endregion
  8414. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8415. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8416. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8417. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8418. designer.SetDataSource("DJName", "地接(CNY)");
  8419. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8420. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8421. designer.SetDataSource("GWName", "公务(CNY)");
  8422. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8423. designer.SetDataSource("LYJName", "零用金(CNY)");
  8424. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8425. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8426. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8427. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8428. designer.SetDataSource("BXName", "保险(CNY)");
  8429. designer.SetDataSource("VisaName", "签证(CNY)");
  8430. #region B段基本数据
  8431. if (dto.costType == "B")
  8432. {
  8433. left = dto.leftInfo.Find(x => x.Type == "B");
  8434. if (left == null)
  8435. {
  8436. return Ok(jw);
  8437. }
  8438. #region B段left数据
  8439. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8440. if (leftBindData != null)
  8441. {
  8442. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8443. designer.SetDataSource("BHSRS", leftBindData.rs);
  8444. designer.SetDataSource("BHSXS", leftBindData.xs);
  8445. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8446. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8447. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8448. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8449. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8450. }
  8451. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8452. if (leftBindData != null)
  8453. {
  8454. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8455. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8456. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8457. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8458. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8459. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8460. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8461. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8462. }
  8463. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8464. if (leftBindData != null)
  8465. {
  8466. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8467. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8468. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8469. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8470. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8471. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8472. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8473. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8474. }
  8475. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8476. if (leftBindData != null)
  8477. {
  8478. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8479. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8480. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8481. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8482. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8483. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8484. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8485. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8486. }
  8487. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8488. if (leftBindData != null)
  8489. {
  8490. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8491. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8492. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8493. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8494. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8495. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8496. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8497. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8498. }
  8499. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8500. if (leftBindData != null)
  8501. {
  8502. designer.SetDataSource("BCPCB", leftBindData.cb);
  8503. designer.SetDataSource("BCPRS", leftBindData.rs);
  8504. designer.SetDataSource("BCPXS", leftBindData.xs);
  8505. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8506. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8507. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8508. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8509. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8510. }
  8511. //TBR
  8512. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8513. if (leftBindData != null)
  8514. {
  8515. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8516. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8517. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8518. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8519. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8520. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8521. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8522. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8523. }
  8524. //SGR
  8525. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8526. if (leftBindData != null)
  8527. {
  8528. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8529. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8530. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8531. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8532. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8533. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8534. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8535. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8536. }
  8537. //JS/ES
  8538. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8539. if (leftBindData != null)
  8540. {
  8541. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8542. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8543. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8544. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8545. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8546. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8547. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8548. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8549. }
  8550. //SUITE
  8551. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8552. if (leftBindData != null)
  8553. {
  8554. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8555. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8556. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8557. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8558. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8559. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8560. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8561. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8562. }
  8563. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8564. if (leftBindData != null)
  8565. {
  8566. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8567. designer.SetDataSource("BDJRS", leftBindData.rs);
  8568. designer.SetDataSource("BDJXS", leftBindData.xs);
  8569. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8570. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8571. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8572. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8573. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8574. }
  8575. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8576. if (leftBindData != null)
  8577. {
  8578. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8579. designer.SetDataSource("BGWRS", leftBindData.rs);
  8580. designer.SetDataSource("BGWXS", leftBindData.xs);
  8581. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8582. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8583. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8584. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8585. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8586. }
  8587. #region 优化方案
  8588. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8589. //excelBind.Add("零用金", new {
  8590. //cb="",
  8591. //rs="",
  8592. //xs ="",
  8593. //zcb = "",
  8594. //});
  8595. #endregion
  8596. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8597. if (leftBindData != null)
  8598. {
  8599. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8600. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8601. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8602. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8603. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8604. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8605. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8606. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8607. }
  8608. #endregion
  8609. #region B段Right信息
  8610. right = dto.rightInfo.Find(x => x.Type == "B");
  8611. if (right == null)
  8612. {
  8613. return Ok(jw);
  8614. }
  8615. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8616. if (rightBindData != null)
  8617. {
  8618. //经济舱 + 双人间 TBR
  8619. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8620. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8621. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8622. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8623. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8624. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8625. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8626. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8627. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8628. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8629. }
  8630. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8631. if (rightBindData != null)
  8632. {
  8633. //经济舱 + 单人间 SGR
  8634. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8635. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8636. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8637. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8638. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8639. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8640. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8641. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8642. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8643. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8644. }
  8645. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8646. if (rightBindData != null)
  8647. {
  8648. //公务舱 + 单人间 SGR
  8649. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8650. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8651. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8652. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8653. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8654. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8655. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8656. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8657. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8658. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8659. }
  8660. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8661. if (rightBindData != null)
  8662. {
  8663. //公务舱 + 小套房 JSES
  8664. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8665. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8666. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8667. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8668. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8669. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8670. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8671. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8672. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8673. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8674. }
  8675. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8676. if (rightBindData != null)
  8677. {
  8678. //公务舱 + 小套房 JSES
  8679. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8680. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8681. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8682. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8683. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8684. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8685. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8686. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8687. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8688. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8689. }
  8690. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8691. if (rightBindData != null)
  8692. {
  8693. //经济舱 + 大套房
  8694. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8695. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8696. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8697. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8698. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8699. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8700. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8701. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8702. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8703. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8704. }
  8705. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8706. if (rightBindData != null)
  8707. {
  8708. //头等舱 + 小套房 JSES
  8709. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8710. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8711. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8712. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8713. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8714. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8715. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8716. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8717. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8718. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8719. }
  8720. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8721. if (rightBindData != null)
  8722. {
  8723. //头等舱 + 大套房
  8724. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8725. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8726. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8727. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8728. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8729. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8730. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8731. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8732. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8733. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8734. }
  8735. #endregion
  8736. #region 标题
  8737. designer.SetDataSource("CostBDRCB", "单人成本");
  8738. designer.SetDataSource("CostBRS", "人数");
  8739. designer.SetDataSource("CostBXS", "系数");
  8740. designer.SetDataSource("CostBZCB", "总成本");
  8741. designer.SetDataSource("CostBDRBJ", "单人报价");
  8742. designer.SetDataSource("CostBZBJ", "总报价");
  8743. designer.SetDataSource("CostBDRLR", "单人利润");
  8744. designer.SetDataSource("CostBZLR", "总利润");
  8745. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8746. designer.SetDataSource("CostBRSOM", "人数");
  8747. designer.SetDataSource("CostBZCBOM", "总成本");
  8748. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8749. designer.SetDataSource("CostBZBJOM", "总报价");
  8750. designer.SetDataSource("CostBDRLROM", "单人利润");
  8751. designer.SetDataSource("CostBZLROM", "总利润");
  8752. #endregion
  8753. }
  8754. #endregion
  8755. designer.SetDataSource("TzZCB2", TzZCB2);
  8756. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8757. designer.SetDataSource("TzZLR2", TzZLR2);
  8758. string[] dataSourceKeys = new string[]
  8759. {
  8760. "VF",
  8761. "TGS",
  8762. "TGOF",
  8763. "TGM",
  8764. "TGA",
  8765. "TGTF",
  8766. "TGEF",
  8767. "CFM",
  8768. "CFOF",
  8769. "B",
  8770. "L",
  8771. "D",
  8772. "TBR",
  8773. "SGR",
  8774. "JSES",
  8775. "Suite",
  8776. "TV",
  8777. "1L",
  8778. "IF",
  8779. "EF",
  8780. "BRF",
  8781. "TE",
  8782. "TGT",
  8783. "DRVT",
  8784. "PC",
  8785. "TLF",
  8786. "ECT"
  8787. };
  8788. foreach (var item in dataSourceKeys)
  8789. {
  8790. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8791. if (find != null)
  8792. {
  8793. designer.SetDataSource(item, find.text);
  8794. }
  8795. else
  8796. {
  8797. designer.SetDataSource(item, 0);
  8798. }
  8799. }
  8800. designer.SetDataSource(dt);
  8801. //根据数据源处理生成报表内容
  8802. designer.Process();
  8803. designer.Workbook.Worksheets[0].Name = "清单";
  8804. Worksheet sheet = designer.Workbook.Worksheets[0];
  8805. foreach (var Rowindex in hideRowsList)
  8806. {
  8807. ws.Cells.HideRows(Rowindex, 2);
  8808. }
  8809. byte[] bytes = null;
  8810. string strFileName = di.TeamName + "-团组-成本.xls";
  8811. using (MemoryStream stream = new MemoryStream())
  8812. {
  8813. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8814. bytes = stream.ToArray();
  8815. }
  8816. return Ok(JsonView(true, "", new
  8817. {
  8818. Data = bytes,
  8819. strFileName,
  8820. }));
  8821. }
  8822. /// <summary>
  8823. /// 导出客户报表
  8824. /// </summary>
  8825. /// <returns></returns>
  8826. [HttpPost]
  8827. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8828. {
  8829. var jw = JsonView(false);
  8830. if (dto.Diid == 0)
  8831. {
  8832. return Ok(JsonView(false, "请传递团组id"));
  8833. }
  8834. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8835. if (deleInfo.Code != 0)
  8836. {
  8837. return Ok(JsonView(false, "团组信息查询失败!"));
  8838. }
  8839. var di = deleInfo.Data as DelegationInfoWebView;
  8840. if (di == null)
  8841. {
  8842. return Ok(JsonView(false, "团组信息查询失败!"));
  8843. }
  8844. //文件名
  8845. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8846. //获取模板
  8847. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8848. //载入模板
  8849. Document doc = new Document(tmppath);
  8850. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8851. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8852. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8853. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8854. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8855. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8856. if (AParameter == null)
  8857. {
  8858. return Ok(JsonView(false, "系数不存在!"));
  8859. }
  8860. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8861. , TzAirDesc, TzZCost;
  8862. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8863. = TzAirDesc = TzZCost = string.Empty;
  8864. TzNumber = AParameter.CostTypenumber.ToString();
  8865. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8866. CarGuides1 = dto.CarGuides1;
  8867. Meal = dto.Meal;
  8868. SubsidizedMeals = dto.SubsidizedMeals;
  8869. NightRepair = dto.NightRepair;
  8870. AttractionsTickets = dto.AttractionsTickets;
  8871. MiscellaneousFees = dto.MiscellaneousFees;
  8872. ATip = dto.ATip;
  8873. TzHotelDesc = "";
  8874. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8875. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8876. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8877. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8878. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8879. TzAirDesc = "";
  8880. TzZCost = dto.TzZCost;
  8881. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8882. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8883. var index = 1;
  8884. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8885. foreach (var item in TzHotelDescArr)
  8886. {
  8887. if (AinfoArr != null)
  8888. {
  8889. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8890. if (Ainfo != null)
  8891. {
  8892. if (int.Parse(Ainfo.rs) <= 0)
  8893. {
  8894. continue;
  8895. }
  8896. var hotelText = string.Empty;
  8897. switch (item)
  8898. {
  8899. case "SGR":
  8900. hotelText = "单人间";
  8901. break;
  8902. case "JSES":
  8903. hotelText = "小套房";
  8904. break;
  8905. case "SUITE":
  8906. hotelText = "套房";
  8907. break;
  8908. case "TBR":
  8909. hotelText = "双人间";
  8910. break;
  8911. }
  8912. if (item != "TBR")
  8913. {
  8914. 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";
  8915. }
  8916. else
  8917. {
  8918. 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";
  8919. }
  8920. index++;
  8921. }
  8922. }
  8923. }
  8924. index = 1;
  8925. foreach (var item in TzAirDescArr)
  8926. {
  8927. if (AinfoArr != null)
  8928. {
  8929. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8930. if (Ainfo != null)
  8931. {
  8932. if (int.Parse(Ainfo.rs) <= 0)
  8933. {
  8934. continue;
  8935. }
  8936. 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";
  8937. index++;
  8938. }
  8939. }
  8940. }
  8941. if (dto.costType == "B")
  8942. {
  8943. if (BParameter == null)
  8944. {
  8945. return Ok(JsonView(false, "B段系数不存在!"));
  8946. }
  8947. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8948. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8949. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8950. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8951. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8952. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8953. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8954. foreach (var item in TzHotelDescArr)
  8955. {
  8956. if (AinfoArr != null)
  8957. {
  8958. TzHotelDesc += "B段信息 \r\n";
  8959. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8960. if (Ainfo != null)
  8961. {
  8962. if (int.Parse(Ainfo.rs) <= 0)
  8963. {
  8964. continue;
  8965. }
  8966. var hotelText = string.Empty;
  8967. switch (item)
  8968. {
  8969. case "SGR":
  8970. hotelText = "单人间";
  8971. break;
  8972. case "JSES":
  8973. hotelText = "小套房";
  8974. break;
  8975. case "SUITE":
  8976. hotelText = "套房";
  8977. break;
  8978. case "TBR":
  8979. hotelText = "双人间";
  8980. break;
  8981. }
  8982. if (item != "TBR")
  8983. {
  8984. 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";
  8985. }
  8986. else
  8987. {
  8988. 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";
  8989. }
  8990. index++;
  8991. }
  8992. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8993. }
  8994. }
  8995. index = 1;
  8996. foreach (var item in TzAirDescArr)
  8997. {
  8998. if (AinfoArr != null)
  8999. {
  9000. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9001. if (Ainfo != null)
  9002. {
  9003. if (int.Parse(Ainfo.rs) <= 0)
  9004. {
  9005. continue;
  9006. }
  9007. 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";
  9008. index++;
  9009. }
  9010. }
  9011. }
  9012. }
  9013. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9014. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9015. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9016. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9017. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9018. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9019. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9020. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9021. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9022. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9023. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9024. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9025. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9026. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9027. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9028. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9029. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9030. DickeyValue.Add("TzZCost", TzZCost);
  9031. foreach (var key in DickeyValue.Keys)
  9032. {
  9033. if (doc.Range.Bookmarks[key] != null)
  9034. {
  9035. Bookmark mark = doc.Range.Bookmarks[key];
  9036. mark.Text = DickeyValue[key];
  9037. }
  9038. }
  9039. byte[] bytes = null;
  9040. string strFileName = di.TeamName + "-客户报价.doc";
  9041. using (MemoryStream stream = new MemoryStream())
  9042. {
  9043. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9044. bytes = stream.ToArray();
  9045. }
  9046. return Ok(JsonView(true, "", new
  9047. {
  9048. Data = bytes,
  9049. strFileName,
  9050. }));
  9051. }
  9052. /// <summary>
  9053. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9054. /// </summary>
  9055. /// <param name="dto"></param>
  9056. /// <returns></returns>
  9057. [HttpPost]
  9058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9059. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9060. {
  9061. try
  9062. {
  9063. #region 参数验证
  9064. if (dto.DiId < 0)
  9065. {
  9066. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9067. }
  9068. List<int> cTableIds = new List<int>() {
  9069. 76 ,//酒店预订
  9070. 77 ,//行程
  9071. 79 ,//车/导游地接
  9072. 80 ,//签证
  9073. 81 ,//邀请/公务活
  9074. 82 ,//团组客户保险
  9075. 85 ,//机票预订
  9076. 98 ,//其他款项
  9077. 285 ,//收款退还
  9078. 751 ,//酒店早餐
  9079. 1015 // 超支费用
  9080. };
  9081. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9082. {
  9083. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9084. }
  9085. #endregion
  9086. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9087. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9088. if (_GroupCostParameters.Count <= 0)
  9089. {
  9090. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9091. }
  9092. if (_GroupCostParameters[0].IsShare == 0)
  9093. {
  9094. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9095. }
  9096. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9097. //处理date为空问题
  9098. if (_GroupCosts.Count > 0)
  9099. {
  9100. for (int i = 0; i < _GroupCosts.Count; i++)
  9101. {
  9102. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9103. {
  9104. if (i > 0)
  9105. {
  9106. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9107. }
  9108. }
  9109. }
  9110. }
  9111. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9112. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9113. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9114. string currCode = "";
  9115. #region currCode 验证
  9116. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9117. if (isInt)
  9118. {
  9119. var currData = currDatas.Find(it => it.Id == intCurrency);
  9120. if (currData != null)
  9121. {
  9122. currCode = currData.Name;
  9123. }
  9124. }
  9125. else
  9126. {
  9127. currCode = _GroupCostParameters[0].Currency.Trim();
  9128. }
  9129. #endregion
  9130. //op,酒店单段模式存储
  9131. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9132. {
  9133. CurrencyCode = currCode,
  9134. Rate = _GroupCostParameters[0].Rate,
  9135. CostType = _GroupCostParameters[0].CostType,
  9136. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9137. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9138. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9139. };
  9140. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9141. if (_GroupCostParameters.Count == 2)
  9142. {
  9143. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9144. }
  9145. foreach (var item in _GroupCostParameters)
  9146. {
  9147. decimal _rate = 1;
  9148. decimal _rate1 = item.Rate;
  9149. decimal _scale = 1;
  9150. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9151. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9152. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9153. //if (userInfo != null)
  9154. //{
  9155. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9156. // {
  9157. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9158. // {
  9159. // _scale = 1.00M;
  9160. // }
  9161. // }
  9162. //}
  9163. #endregion
  9164. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9165. {
  9166. CurrencyCode = currCode,
  9167. Rate = _rate1,
  9168. CostType = item.CostType,
  9169. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9170. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9171. CostTypeNumber = item.CostTypenumber
  9172. };
  9173. if (_GroupCostParameters.Count > 1)
  9174. {
  9175. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9176. }
  9177. else
  9178. {
  9179. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9180. }
  9181. if (dto.CTable == 79)//
  9182. {
  9183. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9184. modulePromptInfo.TotalCost = item.DJCB;
  9185. }
  9186. List<string> costTypes = new List<string>() { "A", "B" };
  9187. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9188. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9189. if (_GroupCostsDuplicates.Count() == 1)
  9190. {
  9191. _GroupCostsTypeData = _GroupCosts;
  9192. }
  9193. else
  9194. {
  9195. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9196. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9197. }
  9198. /*
  9199. * 76 酒店预订
  9200. * 77 行程
  9201. * 79 车/导游地接
  9202. * 80 签证
  9203. * 81 邀请/公务活动
  9204. * 82 团组客户保险
  9205. * 85 机票预订
  9206. * 98 其他款项
  9207. * 285 收款退还
  9208. * 751 酒店早餐
  9209. * 1015 超支费用
  9210. */
  9211. switch (dto.CTable)
  9212. {
  9213. case 76: // 酒店预订
  9214. _ModuleSubPromptInfo.AddRange(
  9215. _GroupCostsTypeData.Select(it => new
  9216. {
  9217. it.DAY,
  9218. it.Date,
  9219. it.ACCON,
  9220. it.ITIN,
  9221. it.SGR,
  9222. it.TBR,
  9223. it.JS_ES,
  9224. it.Suite
  9225. })
  9226. );
  9227. break;
  9228. case 79: // 车/导游地接
  9229. _ModuleSubPromptInfo.AddRange(
  9230. _GroupCostsTypeData.Select(it => new
  9231. {
  9232. Date = it.Date, //日期
  9233. CarFee = it.CarCost * _rate * _scale, //车费用
  9234. CarType = it.CarType, //车型
  9235. DriverFee = it.CFS * _rate * _scale, //司机工资
  9236. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9237. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9238. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9239. GuideFee = it.TGS * _rate * _scale, //导游费用
  9240. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9241. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9242. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9243. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9244. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9245. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9246. Breakfast = it.B * _rate * _scale, //早餐费
  9247. Lunch = it.L * _rate * _scale, //午餐费
  9248. Dinner = it.D * _rate * _scale, //晚餐费
  9249. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9250. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9251. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9252. TicketFee = it.EF * _rate * _scale, //门票费
  9253. TicketRemark = it.EFR, //门票费描述
  9254. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9255. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9256. SpentCash = it.PC * _rate * _scale, //零用金
  9257. LeadersFee = it.TLF * _rate * _scale, //领队费
  9258. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9259. })
  9260. );
  9261. break;
  9262. case 85: // 机票
  9263. List<dynamic> datas = new List<dynamic>();
  9264. datas.Add(
  9265. new
  9266. {
  9267. AirType = "经济舱",
  9268. AirNum = item.JJCRS,
  9269. AirDRCB = item.JJCCB,
  9270. AirZCB = (item.JJCRS * item.JJCCB)
  9271. }
  9272. );
  9273. datas.Add(
  9274. new
  9275. {
  9276. AirType = "公务舱",
  9277. AirNum = item.GWCRS,
  9278. AirDRCB = item.GWCCB,
  9279. AirZCB = (item.GWCRS * item.GWCCB)
  9280. }
  9281. );
  9282. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9283. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9284. modulePromptInfo.Data = new
  9285. {
  9286. airFeeData = datas,
  9287. airInitData = initDatas
  9288. };
  9289. _ModulePromptInfos.Add(modulePromptInfo);
  9290. break;
  9291. default:
  9292. break;
  9293. }
  9294. }
  9295. if (dto.CTable != 85)
  9296. {
  9297. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9298. _ModulePromptInfos.Add(_ModulePromptInfo);
  9299. }
  9300. _view.ModulePromptInfos = _ModulePromptInfos;
  9301. return Ok(JsonView(true, "操作成功!", _view));
  9302. }
  9303. catch (Exception ex)
  9304. {
  9305. return Ok(JsonView(false, ex.Message));
  9306. }
  9307. }
  9308. /// <summary>
  9309. /// 根据黑屏代码重新生成行程
  9310. /// </summary>
  9311. /// <param name="dto"></param>
  9312. /// <returns></returns>
  9313. [HttpPost]
  9314. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9315. {
  9316. var jw = JsonView(false);
  9317. var Create = _GroupCostRepository.
  9318. CreateGroupCostByBlackCode(dto.Diid);
  9319. jw.Msg = Create.Msg;
  9320. if (Create.Code == 0)
  9321. {
  9322. jw.Code = 200;
  9323. jw.Data = new
  9324. {
  9325. groupCost = Create.Data,
  9326. blackCodeIsTrue = true
  9327. };
  9328. }
  9329. else
  9330. {
  9331. jw.Code = 400;
  9332. jw.Data = new
  9333. {
  9334. groupCost = Create.Data,
  9335. blackCodeIsTrue = false,
  9336. };
  9337. }
  9338. return Ok(jw);
  9339. }
  9340. /// <summary>
  9341. /// 成本获取OP历史车费用
  9342. /// </summary>
  9343. /// <param name="dto"></param>
  9344. /// <returns></returns>
  9345. [HttpPost]
  9346. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9347. {
  9348. var jw = JsonView(false);
  9349. try
  9350. {
  9351. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9352. //获取现有所有车的数据
  9353. if (!dto.Param.IsNullOrWhiteSpace())
  9354. {
  9355. string sql = $@"
  9356. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9357. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9358. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9359. 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
  9360. AND gctggr.ServiceEndTime is not NULL
  9361. ORDER by gctggrc.id DESC
  9362. ";
  9363. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9364. var numeberResult = await Task.Run(() =>
  9365. {
  9366. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9367. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9368. return numberArr;
  9369. });
  9370. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9371. foreach (var item in numeberResult)
  9372. {
  9373. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9374. {
  9375. Country = "数据异常!",
  9376. City = string.Empty,
  9377. };
  9378. item.Area = find.Country + " " + find.City;
  9379. }
  9380. dbResult.AddRange(numeberResult);
  9381. if (dto.Param.Contains("、"))
  9382. {
  9383. var sp = dto.Param.Split("、");
  9384. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9385. .Where(x =>
  9386. {
  9387. return System.Array.Exists(sp, e =>
  9388. {
  9389. bool where = false;
  9390. if (x.Area != null)
  9391. {
  9392. where = x.Area.Contains(e);
  9393. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9394. {
  9395. return false;
  9396. }
  9397. }
  9398. if (x.PriceName != null && !where)
  9399. {
  9400. where = x.PriceName.Contains(e);
  9401. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9402. {
  9403. return false;
  9404. }
  9405. }
  9406. return where;
  9407. });
  9408. }).ToList();
  9409. }
  9410. else
  9411. {
  9412. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9413. .Where(x =>
  9414. {
  9415. bool where = false;
  9416. if (x.Area != null)
  9417. {
  9418. where = x.Area.Contains(dto.Param);
  9419. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9420. {
  9421. return false;
  9422. }
  9423. }
  9424. if (x.PriceName != null && !where)
  9425. {
  9426. where = x.PriceName.Contains(dto.Param);
  9427. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9428. {
  9429. return false;
  9430. }
  9431. }
  9432. return where;
  9433. }
  9434. )
  9435. .ToList();
  9436. }
  9437. }
  9438. var view = dbResult.Select(x =>
  9439. {
  9440. decimal dp = 0.00M;
  9441. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9442. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9443. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9444. {
  9445. if (startB && endB)
  9446. {
  9447. var timesp = endD.Subtract(startD);
  9448. if ((timesp.Days + 1) != 0)
  9449. {
  9450. dp = x.Price / (timesp.Days + 1);
  9451. }
  9452. }
  9453. }
  9454. else
  9455. {
  9456. dp = x.Price;
  9457. }
  9458. return new
  9459. {
  9460. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9461. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9462. x.Area,
  9463. x.id,
  9464. price = x.Price.ToString("F2"),
  9465. x.PriceName,
  9466. x.PriceContent,
  9467. x.TeamName,
  9468. x.DatePrice,
  9469. dayPrice = dp.ToString("F2"),
  9470. };
  9471. }).OrderByDescending(x => x.id).ToList();
  9472. jw = JsonView(true, "获取成功!", view);
  9473. }
  9474. catch (Exception e)
  9475. {
  9476. jw = JsonView(false, e.Message);
  9477. }
  9478. return Ok(jw);
  9479. }
  9480. #endregion
  9481. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9482. /// <summary>
  9483. /// 酒店预订
  9484. /// 酒店费用列表 根据团组Id查询
  9485. /// </summary>
  9486. /// <param name="_dto"></param>
  9487. /// <returns></returns>
  9488. [HttpPost]
  9489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9490. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9491. {
  9492. #region 参数验证
  9493. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9494. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9495. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9496. #region 团组操作权限验证 76 酒店预定模块
  9497. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9498. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9499. #endregion
  9500. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9501. #region 页面操作权限验证
  9502. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9503. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9504. #endregion
  9505. #endregion
  9506. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9507. }
  9508. /// <summary>
  9509. /// 酒店预订
  9510. /// 基础数据
  9511. /// </summary>
  9512. /// <param name="_dto"></param>
  9513. /// <returns></returns>
  9514. [HttpPost]
  9515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9516. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9517. {
  9518. #region 参数验证
  9519. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9520. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9521. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9522. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9523. #region 页面操作权限验证
  9524. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9525. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9526. #endregion
  9527. #region 团组操作权限验证 76 酒店预定模块
  9528. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9529. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9530. #endregion
  9531. #endregion
  9532. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  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> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9543. {
  9544. #region 参数验证
  9545. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9546. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9547. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9548. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9549. #region 页面操作权限验证
  9550. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9551. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9552. #endregion
  9553. #region 团组操作权限验证 76 酒店预定模块
  9554. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9555. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9556. #endregion
  9557. #endregion
  9558. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9559. if (data.Code != 0)
  9560. {
  9561. return Ok(JsonView(false, data.Msg));
  9562. }
  9563. return Ok(JsonView(true, data.Msg, data.Data));
  9564. }
  9565. /// <summary>
  9566. /// 酒店预订
  9567. /// 详情
  9568. /// </summary>
  9569. /// <param name="_dto"></param>
  9570. /// <returns></returns>
  9571. [HttpPost]
  9572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9573. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9574. {
  9575. #region 参数验证
  9576. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9577. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9578. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9579. #region 团组操作权限验证 76 酒店预定模块
  9580. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9581. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9582. #endregion
  9583. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9584. #region 页面操作权限验证
  9585. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9586. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9587. #endregion
  9588. #endregion
  9589. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9590. }
  9591. /// <summary>
  9592. /// 酒店预订
  9593. /// Add Or Edit
  9594. /// </summary>
  9595. /// <param name="_dto"></param>
  9596. /// <returns></returns>
  9597. [HttpPost]
  9598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9599. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9600. {
  9601. #region 参数验证
  9602. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9603. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9604. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9605. #region 团组操作权限验证 76 酒店预定模块
  9606. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9607. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9608. #endregion
  9609. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9610. #region 页面操作权限验证
  9611. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9612. if (_dto.Id == 0) // Add
  9613. {
  9614. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9615. }
  9616. else if (_dto.Id > 1) // Edit
  9617. {
  9618. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9619. }
  9620. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9621. #endregion
  9622. #endregion
  9623. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9624. if (_view.Code != 200)
  9625. {
  9626. return Ok(_view);
  9627. }
  9628. #region 应用推送
  9629. try
  9630. {
  9631. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9632. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9633. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9634. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  9635. //2024-10-21 新增LZ UID
  9636. var userIds = new List<int>() { 21 };
  9637. string title = $"费用审核";
  9638. var diId = _dto.DiId;
  9639. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9640. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9641. string content = "";
  9642. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9643. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9644. Logs($"【iOS推送通知Exception】Start");
  9645. await GeneralMethod.iOS_PushNotifications("051", title, "", content);
  9646. Logs($"【iOS推送通知Exception】End ");
  9647. }
  9648. catch (Exception ex)
  9649. {
  9650. _logger.LogInformation($"【iOS推送通知Exception】【{ex.Message}】");
  9651. Log.Error($"【iOS推送通知Exception】【{ex.Message}】");
  9652. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  9653. }
  9654. try
  9655. {
  9656. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9657. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9658. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9659. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9660. //自动审核
  9661. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9662. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9663. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9664. //2024-10-21 新增LZ UID
  9665. var userIds = new List<int>() { 21 };
  9666. string title = $"系统通知";
  9667. var diId = _dto.DiId;
  9668. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9669. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9670. string content = "";
  9671. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9672. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9673. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9674. //await GeneralMethod.iOS_PushNotifications("051", "费用审核", "", content);
  9675. }
  9676. catch (Exception ex)
  9677. {
  9678. }
  9679. #endregion
  9680. return Ok(_view);
  9681. }
  9682. /// <summary>
  9683. /// 酒店自动审核测试
  9684. /// Add Or Edit
  9685. /// </summary>
  9686. /// <param name="_dto"></param>
  9687. /// <returns></returns>
  9688. [HttpPost]
  9689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9690. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9691. {
  9692. #region 应用推送
  9693. try
  9694. {
  9695. //自动审核
  9696. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9697. }
  9698. catch (Exception ex)
  9699. {
  9700. return Ok(JsonView(false, "操作失败"));
  9701. }
  9702. #endregion
  9703. return Ok(JsonView(false, "操作成功"));
  9704. }
  9705. /// <summary>
  9706. /// 酒店预订
  9707. /// Del
  9708. /// </summary>
  9709. /// <param name="_dto"></param>
  9710. /// <returns></returns>
  9711. [HttpPost]
  9712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9713. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9714. {
  9715. #region 参数验证
  9716. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9717. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9718. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9719. #region 团组操作权限验证 76 酒店预定模块
  9720. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9721. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9722. #endregion
  9723. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9724. #region 页面操作权限验证
  9725. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9726. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9727. #endregion
  9728. #endregion
  9729. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9730. }
  9731. /// <summary>
  9732. /// 酒店预订
  9733. /// 生成VOUCHER
  9734. /// 2024.05.06 之前版本
  9735. /// </summary>
  9736. /// <param name="_dto"></param>
  9737. /// <returns></returns>
  9738. [HttpPost]
  9739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9740. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9741. {
  9742. try
  9743. {
  9744. #region 参数验证
  9745. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9746. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9747. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9748. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9749. #region 团组操作权限验证 76 酒店预定模块
  9750. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9751. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9752. #endregion
  9753. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9754. #region 页面操作权限验证
  9755. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9756. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9757. #endregion
  9758. #endregion
  9759. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9760. //判断数据是否完整
  9761. if (hr != null)
  9762. {
  9763. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9764. {
  9765. string strFileName = "HotelStatement/";
  9766. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9767. if (dele != null)
  9768. strFileName += dele.TourCode;
  9769. //载入模板
  9770. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9771. Document doc = new Document(sss);
  9772. DocumentBuilder builder = new DocumentBuilder(doc);
  9773. #region 替换Word模板书签内容
  9774. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9775. //入住卷预定号码
  9776. if (doc.Range.Bookmarks["VNO"] != null)
  9777. {
  9778. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9779. mark.Text = hr.CheckNumber;
  9780. }
  9781. //酒店时间
  9782. if (doc.Range.Bookmarks["Date"] != null)
  9783. {
  9784. Bookmark mark = doc.Range.Bookmarks["Date"];
  9785. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9786. }
  9787. //团号
  9788. if (doc.Range.Bookmarks["TNo"] != null)
  9789. {
  9790. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9791. mark.Text = dele.TourCode;
  9792. }
  9793. //预定号码
  9794. if (doc.Range.Bookmarks["BookingId"] != null)
  9795. {
  9796. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9797. mark.Text = hr.ReservationsNo;
  9798. }
  9799. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9800. {
  9801. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9802. mark.Text = hr.DetermineNo;
  9803. }
  9804. //酒店城市
  9805. if (doc.Range.Bookmarks["City"] != null)
  9806. {
  9807. Bookmark mark = doc.Range.Bookmarks["City"];
  9808. mark.Text = hr.City;
  9809. }
  9810. //酒店名称
  9811. if (doc.Range.Bookmarks["HName"] != null)
  9812. {
  9813. Bookmark mark = doc.Range.Bookmarks["HName"];
  9814. mark.Text = hr.HotelName;
  9815. }
  9816. //酒店地址
  9817. if (doc.Range.Bookmarks["Address"] != null)
  9818. {
  9819. Bookmark mark = doc.Range.Bookmarks["Address"];
  9820. mark.Text = hr.HotelAddress;
  9821. }
  9822. //酒店电话
  9823. if (doc.Range.Bookmarks["Tel"] != null)
  9824. {
  9825. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9826. mark.Text = hr.HotelTel;
  9827. }
  9828. //酒店传真
  9829. if (doc.Range.Bookmarks["Fax"] != null)
  9830. {
  9831. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9832. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9833. {
  9834. mark.Text = hr.HotelFax;
  9835. }
  9836. }
  9837. //入住时间
  9838. if (doc.Range.Bookmarks["CIn"] != null)
  9839. {
  9840. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9841. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9842. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9843. }
  9844. //退房时间
  9845. if (doc.Range.Bookmarks["COut"] != null)
  9846. {
  9847. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9848. Bookmark mark = doc.Range.Bookmarks["COut"];
  9849. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9850. }
  9851. //客户名称
  9852. if (doc.Range.Bookmarks["GName"] != null)
  9853. {
  9854. string guestName = "";
  9855. string[] clients = new string[] { };
  9856. if (hr.GuestName.Contains(","))
  9857. {
  9858. clients = hr.GuestName.Split(",");
  9859. }
  9860. else
  9861. {
  9862. clients = new string[] { hr.GuestName };
  9863. }
  9864. List<int> clientIds_int = new List<int>();
  9865. if (clients.Length > 0)
  9866. {
  9867. foreach (var item in clients)
  9868. {
  9869. if (item.IsNumeric())
  9870. {
  9871. clientIds_int.Add(int.Parse(item));
  9872. }
  9873. }
  9874. }
  9875. if (clientIds_int.Count > 0)
  9876. {
  9877. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9878. foreach (var client in _clientDatas)
  9879. {
  9880. //男
  9881. if (client.Sex == 0) guestName += $"Mr.";
  9882. //女
  9883. else if (client.Sex == 1) guestName += $"Ms.";
  9884. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9885. {
  9886. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9887. }
  9888. //guestName += $"{client.Pinyin},";
  9889. }
  9890. if (guestName.Length > 0)
  9891. {
  9892. guestName = guestName.Substring(0, guestName.Length - 1);
  9893. }
  9894. }
  9895. else
  9896. {
  9897. guestName = hr.GuestName;
  9898. }
  9899. Bookmark mark = doc.Range.Bookmarks["GName"];
  9900. mark.Text = guestName;
  9901. }
  9902. //房间介绍
  9903. if (doc.Range.Bookmarks["ROOM"] != null)
  9904. {
  9905. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9906. mark.Text = hr.RoomExplanation;
  9907. }
  9908. //报价描述
  9909. if (doc.Range.Bookmarks["NOTE"] != null)
  9910. {
  9911. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9912. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9913. if (ss != null)
  9914. mark.Text = ss.Name;
  9915. }
  9916. //入住时间
  9917. if (doc.Range.Bookmarks["CheckIn"] != null)
  9918. {
  9919. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9920. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9921. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9922. }
  9923. //退房时间
  9924. if (doc.Range.Bookmarks["CheckOut"] != null)
  9925. {
  9926. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9927. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9928. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9929. }
  9930. //日期
  9931. if (doc.Range.Bookmarks["DT"] != null)
  9932. {
  9933. Bookmark mark = doc.Range.Bookmarks["DT"];
  9934. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9935. }
  9936. //名称
  9937. if (doc.Range.Bookmarks["VName"] != null)
  9938. {
  9939. Bookmark mark = doc.Range.Bookmarks["VName"];
  9940. mark.Text = hr.HotelName;
  9941. }
  9942. //号码
  9943. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9944. {
  9945. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9946. mark.Text = hr.CheckNumber;
  9947. }
  9948. #endregion
  9949. strFileName += "VOUCHER.doc";
  9950. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9951. doc.Save(fileDir);
  9952. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9953. return Ok(JsonView(true, "操作成功!", Url));
  9954. }
  9955. else
  9956. {
  9957. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9958. }
  9959. }
  9960. else
  9961. {
  9962. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9963. }
  9964. }
  9965. catch (Exception ex)
  9966. {
  9967. return Ok(JsonView(false, ex.Message));
  9968. }
  9969. }
  9970. /// <summary>
  9971. /// 酒店预订
  9972. /// 生成VOUCHER
  9973. /// 2024.05.06 之后版本
  9974. /// </summary>
  9975. /// <param name="_dto"></param>
  9976. /// <returns></returns>
  9977. [HttpPost]
  9978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9979. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9980. {
  9981. #region 参数验证
  9982. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9983. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9984. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9985. #region 团组操作权限验证 76 酒店预定模块
  9986. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9987. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9988. #endregion
  9989. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9990. #region 页面操作权限验证
  9991. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9992. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9993. #endregion
  9994. #endregion
  9995. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9996. //判断数据是否完整
  9997. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9998. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9999. string strFileName = "HotelStatement/";
  10000. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10001. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  10002. #region 数据处理
  10003. List<int> guestIds = new List<int>();
  10004. int index = 0;
  10005. foreach (var item in hrDtas)
  10006. {
  10007. if (item.GuestName.Contains(","))
  10008. {
  10009. string[] guestIdArr = item.GuestName.Split(',');
  10010. foreach (var guestIdStr in guestIdArr)
  10011. {
  10012. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  10013. if (guestBool)
  10014. {
  10015. guestIds.Add(guestId);
  10016. }
  10017. }
  10018. }
  10019. else guestNames += item.GuestName;
  10020. var voucherInfo = new HotelVoucherInfoView()
  10021. {
  10022. HotelName = item.HotelName,
  10023. CheckInDate = item.CheckInDate,
  10024. CheckOutDate = item.CheckOutDate,
  10025. ConfirmationNumber = item.DetermineNo.Trim(),
  10026. RoomType = item.RoomExplanation
  10027. };
  10028. vouchers.Add(voucherInfo);
  10029. }
  10030. if (guestIds.Count > 0)
  10031. {
  10032. guestIds = guestIds.Distinct().ToList();
  10033. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  10034. if (guestDatas.Count > 0)
  10035. {
  10036. guestNames = "";
  10037. foreach (var guest in guestDatas)
  10038. {
  10039. string guestName = "";
  10040. if (guest.Sex == 0) guestName += @"MR.";
  10041. else if (guest.Sex == 1) guestName += @"MS.";
  10042. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10043. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10044. guestNames += @$"{guestName.Trim()}、";
  10045. }
  10046. if (guestNames.Length > 0)
  10047. {
  10048. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10049. }
  10050. }
  10051. }
  10052. #endregion
  10053. //载入模板
  10054. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10055. Document doc = new Document(sss);
  10056. DocumentBuilder builder = new DocumentBuilder(doc);
  10057. if (doc.Range.Bookmarks["GuestName"] != null)
  10058. {
  10059. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10060. mark.Text = guestNames;
  10061. }
  10062. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10063. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10064. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10065. for (int i = 1; i <= vouchers.Count; i++)
  10066. {
  10067. HotelVoucherInfoView hviv = vouchers[i - 1];
  10068. builder.MoveToCell(0, i, 0, 0);
  10069. builder.Write(hviv.HotelName);
  10070. builder.MoveToCell(0, i, 1, 0);
  10071. builder.Write(hviv.CheckInDate);
  10072. builder.MoveToCell(0, i, 2, 0);
  10073. builder.Write(hviv.CheckOutDate);
  10074. builder.MoveToCell(0, i, 3, 0);
  10075. builder.Write(hviv.RoomType);
  10076. builder.MoveToCell(0, i, 4, 0);
  10077. builder.Write(hviv.ConfirmationNumber);
  10078. }
  10079. //删除多余行
  10080. int currRowIndex = vouchers.Count + 1;
  10081. int delRows = 21 - currRowIndex;
  10082. if (delRows > 0)
  10083. {
  10084. for (int i = 0; i < delRows; i++)
  10085. {
  10086. table.Rows.RemoveAt(currRowIndex);
  10087. //cultivateRowIndex++;
  10088. }
  10089. }
  10090. strFileName += "VOUCHER.docx";
  10091. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10092. doc.Save(fileDir);
  10093. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10094. return Ok(JsonView(true, "操作成功!", Url));
  10095. }
  10096. /// <summary>
  10097. /// 酒店预订
  10098. /// 生成VOUCHER 批量生成
  10099. /// New
  10100. /// </summary>
  10101. /// <param name="_dto"></param>
  10102. /// <returns></returns>
  10103. [HttpPost]
  10104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10105. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10106. {
  10107. #region 参数验证
  10108. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10109. if (_dto.PageId < 1) _dto.PageId = 28;
  10110. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10111. #region 团组操作权限验证 76 酒店预定模块
  10112. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10113. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10114. #endregion
  10115. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10116. #region 页面操作权限验证
  10117. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10118. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10119. #endregion
  10120. #endregion
  10121. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10122. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10123. .OrderBy(x => x.CheckInDate)
  10124. .ToListAsync();
  10125. //判断数据是否完整
  10126. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10127. string strFileName = "HotelStatement/";
  10128. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10129. if (dele != null)
  10130. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10131. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10132. for (int i = 0; i < hrDtas.Count; i++)
  10133. {
  10134. string guestNames = string.Empty;
  10135. List<int> guestIds = new List<int>();
  10136. var item = hrDtas[i];
  10137. //处理客户姓名
  10138. if (item.GuestName.Contains(","))
  10139. {
  10140. string[] guestIdArr = item.GuestName.Split(',');
  10141. foreach (var guestIdStr in guestIdArr)
  10142. if (int.TryParse(guestIdStr, out int guestId))
  10143. guestIds.Add(guestId);
  10144. }
  10145. else
  10146. {
  10147. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10148. if (guestIdBool)
  10149. {
  10150. guestIds.Add(guestId);
  10151. }
  10152. //NaN
  10153. if (item.GuestName.Contains("NaN"))
  10154. {
  10155. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10156. }
  10157. }
  10158. if (guestIds.Count > 0)
  10159. {
  10160. guestIds = guestIds.Distinct().ToList();
  10161. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10162. if (guestDatas1.Count > 0)
  10163. {
  10164. guestNames = "";
  10165. foreach (var guest in guestDatas1)
  10166. {
  10167. string guestName = "";
  10168. if (guest.Sex == 0) guestName += @"MR.";
  10169. else if (guest.Sex == 1) guestName += @"MS.";
  10170. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10171. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10172. guestNames += @$"{guestName.Trim()}、";
  10173. }
  10174. if (guestNames.Length > 0)
  10175. {
  10176. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10177. }
  10178. }
  10179. }
  10180. //if (!string.IsNullOrEmpty(guestNames))
  10181. //{
  10182. hrDtas[i].GuestName = guestNames;
  10183. //}
  10184. }
  10185. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10186. Document doc = new Document();
  10187. DocumentBuilder builder = new DocumentBuilder(doc);
  10188. try
  10189. {
  10190. builder.MoveToDocumentStart();
  10191. foreach (var item in hrDtas)
  10192. {
  10193. //标题
  10194. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10195. builder.ParagraphFormat.LineSpacing = 1;
  10196. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10197. builder.ParagraphFormat.Style.Font.Size = 9;
  10198. builder.ParagraphFormat.Style.Font.Bold = true;
  10199. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10200. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10201. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10202. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10203. builder.ParagraphFormat.LineSpacing = 1;
  10204. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10205. builder.ParagraphFormat.Style.Font.Size = 9;
  10206. builder.ParagraphFormat.Style.Font.Bold = true;
  10207. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10208. builder.StartTable();
  10209. // 设置边框颜色
  10210. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10211. //设置边框样式
  10212. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10213. //表格
  10214. #region 第一行
  10215. builder.InsertCell();
  10216. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10217. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10218. //builder.CellFormat.AllowAutoFit = false;
  10219. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10220. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10221. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10222. builder.CellFormat.WrapText = true; //自动换行
  10223. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10224. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10225. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10226. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10227. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10228. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10229. builder.Write("TOUR NO:");
  10230. builder.InsertCell();
  10231. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10232. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10233. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10234. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10235. builder.ParagraphFormat.Style.Font.Bold = false;
  10236. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10237. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10238. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10239. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10240. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10241. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10242. builder.Write($"{dele?.TourCode ?? "-"}");
  10243. builder.InsertCell();
  10244. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10245. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10246. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10247. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10248. builder.ParagraphFormat.Style.Font.Bold = false;
  10249. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10250. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10251. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10252. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10253. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10254. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10255. builder.Write($"CITY:");
  10256. builder.InsertCell();
  10257. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10258. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10259. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10260. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10261. builder.ParagraphFormat.Style.Font.Bold = false;
  10262. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10263. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10264. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10265. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10266. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10267. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10268. builder.Write($"{item.City}");
  10269. builder.EndRow();
  10270. #endregion
  10271. #region 第二行
  10272. builder.InsertCell();
  10273. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10274. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10275. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10276. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10277. builder.ParagraphFormat.Style.Font.Bold = false;
  10278. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10279. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10280. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10281. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10282. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10283. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10284. builder.Write("CONFIRMATION NO:");
  10285. builder.InsertCell();
  10286. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10287. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10288. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10289. builder.ParagraphFormat.Style.Font.Bold = false;
  10290. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10291. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10292. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10293. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10294. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10295. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10296. builder.CellFormat.VerticalMerge = CellMerge.None;
  10297. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10298. builder.Write($"{item.DetermineNo}");
  10299. builder.InsertCell();
  10300. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10301. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10302. builder.InsertCell();
  10303. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10304. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10305. builder.EndRow();
  10306. #endregion
  10307. #region 第三行
  10308. builder.InsertCell();
  10309. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10310. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10311. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10312. builder.ParagraphFormat.Style.Font.Bold = false;
  10313. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10314. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10315. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10316. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10317. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10318. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10319. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10320. builder.Write($"HOTEL NAME:");
  10321. builder.InsertCell();
  10322. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10323. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10324. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10325. builder.ParagraphFormat.Style.Font.Bold = false;
  10326. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10327. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10328. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10329. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10330. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10331. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10332. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10333. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10334. builder.Write($"{item.HotelName}");
  10335. builder.InsertCell();
  10336. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10337. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10338. builder.InsertCell();
  10339. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10340. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10341. builder.EndRow();
  10342. #endregion
  10343. #region 第四行
  10344. builder.InsertCell();
  10345. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10346. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10347. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10348. builder.ParagraphFormat.Style.Font.Bold = false;
  10349. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10350. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10351. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10352. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10353. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10354. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10355. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10356. builder.Write($"HOTEL ADDRESS:");
  10357. builder.InsertCell();
  10358. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10359. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10360. builder.ParagraphFormat.Style.Font.Size = 8;
  10361. builder.ParagraphFormat.Style.Font.Bold = false;
  10362. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10363. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10364. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10365. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10366. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10367. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10368. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10369. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10370. builder.Write($"{item.HotelAddress}");
  10371. builder.InsertCell();
  10372. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10373. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10374. builder.InsertCell();
  10375. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10376. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10377. builder.EndRow();
  10378. #endregion
  10379. #region 第五行
  10380. builder.InsertCell();
  10381. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10382. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10383. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10384. builder.ParagraphFormat.Style.Font.Bold = false;
  10385. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10386. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10387. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10388. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10389. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10390. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10391. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10392. builder.Write("TEL:");
  10393. builder.InsertCell();
  10394. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10395. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10396. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10397. builder.ParagraphFormat.Style.Font.Bold = false;
  10398. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10399. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10400. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10401. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10402. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10403. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10404. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10405. builder.Write($"{item.HotelTel}");
  10406. builder.InsertCell();
  10407. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10408. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10409. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10410. builder.ParagraphFormat.Style.Font.Bold = false;
  10411. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10412. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10413. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10414. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10415. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10416. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10417. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10418. builder.Write($"FAX:");
  10419. builder.InsertCell();
  10420. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10421. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10422. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10423. builder.ParagraphFormat.Style.Font.Bold = false;
  10424. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10425. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10426. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10427. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10428. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10429. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10430. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10431. builder.Write($"{item.HotelFax}");
  10432. builder.EndRow();
  10433. #endregion
  10434. #region 第六行
  10435. builder.InsertCell();
  10436. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10437. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10438. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10439. builder.ParagraphFormat.Style.Font.Bold = false;
  10440. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10441. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10442. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10443. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10444. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10445. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10446. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10447. builder.Write("CHECK IN:");
  10448. builder.InsertCell();
  10449. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10450. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10451. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10452. builder.ParagraphFormat.Style.Font.Bold = false;
  10453. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10454. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10455. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10456. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10457. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10458. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10459. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10460. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10461. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10462. builder.Write($"{checkInStr}");
  10463. builder.InsertCell();
  10464. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10465. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10466. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10467. builder.ParagraphFormat.Style.Font.Bold = false;
  10468. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10469. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10470. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10471. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10472. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10473. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10474. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10475. builder.Write($"CHECK OUT:");
  10476. builder.InsertCell();
  10477. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10478. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10479. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10480. builder.ParagraphFormat.Style.Font.Bold = false;
  10481. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10482. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10483. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10484. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10485. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10486. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10487. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10488. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10489. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10490. builder.Write($"{checkOutStr}");
  10491. builder.EndRow();
  10492. #endregion
  10493. #region 第七行
  10494. builder.InsertCell();
  10495. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10496. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10497. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10498. builder.ParagraphFormat.Style.Font.Bold = false;
  10499. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10500. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10501. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10502. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10503. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10504. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10505. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10506. builder.Write($"GUEST NAME:");
  10507. builder.InsertCell();
  10508. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10509. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10510. builder.ParagraphFormat.Style.Font.Size = 8;
  10511. builder.ParagraphFormat.Style.Font.Bold = false;
  10512. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10513. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10514. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10515. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10516. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10517. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10518. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10519. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10520. builder.Write($"{item.GuestName}");
  10521. builder.InsertCell();
  10522. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10523. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10524. builder.InsertCell();
  10525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10526. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10527. builder.EndRow();
  10528. #endregion
  10529. #region 第八行
  10530. builder.InsertCell();
  10531. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10532. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10533. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10534. builder.ParagraphFormat.Style.Font.Bold = false;
  10535. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10536. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10537. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10538. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10539. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10540. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10541. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10542. builder.Write($"ROOM TYPE:");
  10543. builder.InsertCell();
  10544. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10545. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10546. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10547. builder.ParagraphFormat.Style.Font.Bold = false;
  10548. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10549. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10550. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10551. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10552. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10553. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10554. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10555. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10556. builder.Write($"{item.RoomExplanation}");
  10557. builder.InsertCell();
  10558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10559. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10560. builder.InsertCell();
  10561. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10562. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10563. builder.EndRow();
  10564. #endregion
  10565. #region 第九行
  10566. builder.InsertCell();
  10567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10569. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10570. builder.ParagraphFormat.Style.Font.Bold = false;
  10571. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10572. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10573. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10574. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10575. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10576. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10577. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10578. builder.Write($"NOTE:");
  10579. builder.InsertCell();
  10580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10581. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10582. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10583. builder.ParagraphFormat.Style.Font.Bold = false;
  10584. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10585. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10586. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10587. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10588. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  10589. builder.InsertCell();
  10590. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10591. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10592. builder.InsertCell();
  10593. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10594. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10595. builder.EndRow();
  10596. #endregion
  10597. builder.EndTable();
  10598. //换行
  10599. builder.Writeln("");
  10600. builder.Writeln("");
  10601. }
  10602. #region 获取文档中的所有表格 设置文字自适应
  10603. // 获取文档中的所有表格。
  10604. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10605. {
  10606. // 遍历表格中的所有行。
  10607. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10608. {
  10609. foreach (Cell cell in row.Cells)
  10610. {
  10611. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10612. cellFormat.Width = 0;
  10613. }
  10614. }
  10615. }
  10616. #endregion
  10617. #region 设置页眉
  10618. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10619. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10620. if (System.IO.File.Exists(voucherHeaderPath))
  10621. {
  10622. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10623. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10624. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10625. Shape shape = builder.InsertImage(imageBytes);
  10626. // 调整图片位置
  10627. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10628. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10629. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10630. shape.Left = 0; // 将图片距离页面左边缘的距离
  10631. shape.Width = 81; // 设置图片宽度
  10632. shape.Height = 36; // 设置图片高度
  10633. }
  10634. //靠右
  10635. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10636. //// 设置页脚上下边距
  10637. //builder.PageSetup.HeaderDistance = 42;
  10638. // 添加页眉线
  10639. Aspose.Words.Border borderHeader = null;
  10640. try
  10641. {
  10642. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10643. }
  10644. catch (Exception e)
  10645. {
  10646. // TODO Auto-generated catch block
  10647. //e.printStackTrace();
  10648. }
  10649. borderHeader.Shadow = true;
  10650. borderHeader.DistanceFromText = 2;
  10651. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10652. #endregion
  10653. }
  10654. catch (Exception ex)
  10655. {
  10656. }
  10657. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10658. doc.Save(fileDir);
  10659. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10660. return Ok(JsonView(true, "操作成功!", Url));
  10661. }
  10662. /// <summary>
  10663. /// 酒店预订
  10664. /// 生成 预定成本 Excel
  10665. /// </summary>
  10666. /// <param name="_dto"></param>
  10667. /// <returns></returns>
  10668. [HttpPost]
  10669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10670. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10671. {
  10672. #region 参数验证
  10673. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10674. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10675. if (!vadalitorRes.IsValid)
  10676. {
  10677. var errors = new StringBuilder();
  10678. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10679. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10680. }
  10681. #region 团组操作权限验证 76 酒店预定模块
  10682. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10683. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10684. #endregion
  10685. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10686. #region 页面操作权限验证
  10687. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10688. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10689. #endregion
  10690. #endregion
  10691. decimal _rate = 1.00M;
  10692. string _currency = string.Empty;
  10693. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10694. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10695. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10696. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10697. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10698. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  10699. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10700. if (_GroupCostParameter == null)
  10701. {
  10702. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10703. bool isIntType = int.TryParse(_currency, out int currId);
  10704. if (isIntType)
  10705. {
  10706. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10707. }
  10708. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10709. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10710. if (currInfo == null)
  10711. {
  10712. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10713. }
  10714. else _rate = currInfo.Rate;
  10715. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  10716. {
  10717. _rate = _GroupCostParameter.Rate;
  10718. }
  10719. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10720. string strFileName = "HotelStatement/";
  10721. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10722. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10723. var rateDatas = new List<dynamic>();
  10724. #region 数据处理
  10725. foreach (var item in hrDtas)
  10726. {
  10727. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10728. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10729. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10730. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10731. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10732. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  10733. {
  10734. continue;
  10735. }
  10736. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10737. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  10738. string singleRoomFeeStr = string.Empty,
  10739. doubleRoomFeeStr = string.Empty,
  10740. suiteRoomFeeStr = string.Empty,
  10741. otherRoomFeeStr = string.Empty,
  10742. payMoneyStr = string.Empty,
  10743. cardPriceStr = string.Empty;
  10744. if (roomCurr.Equals("CNY"))
  10745. {
  10746. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  10747. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10748. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10749. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10750. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10751. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  10752. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  10753. }
  10754. else
  10755. {
  10756. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10757. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10758. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10759. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10760. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10761. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10762. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10763. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10764. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10765. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10766. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  10767. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  10768. if (ccpPaymentCurrency.Equals("CNY"))
  10769. {
  10770. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  10771. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10772. }
  10773. else
  10774. {
  10775. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  10776. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  10777. }
  10778. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  10779. if (hotelcardPriceCurrency.Equals("CNY"))
  10780. {
  10781. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10782. }
  10783. else
  10784. {
  10785. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  10786. }
  10787. }
  10788. string breakfastPriceStr = string.Empty,
  10789. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10790. governmentRentStr = string.Empty,
  10791. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10792. cityTaxStr = string.Empty,
  10793. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10794. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  10795. if (!string.IsNullOrEmpty(breakfastCurrency1))
  10796. {
  10797. if (breakfastCurrency1.Equals("CNY"))
  10798. {
  10799. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10800. }
  10801. else
  10802. {
  10803. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  10804. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  10805. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  10806. }
  10807. }
  10808. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10809. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  10810. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  10811. {
  10812. if (governmentRentCurrency.Equals("CNY"))
  10813. {
  10814. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10815. }
  10816. else
  10817. {
  10818. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  10819. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  10820. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  10821. }
  10822. }
  10823. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10824. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  10825. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  10826. {
  10827. if (cityTaxStrCurrency1.Equals("CNY"))
  10828. {
  10829. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10830. }
  10831. else
  10832. {
  10833. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  10834. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  10835. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  10836. }
  10837. }
  10838. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10839. int payDId = roomInfo?.PayDId ?? 0;
  10840. pcfds.Add(new HotelReservations_PCFD_View()
  10841. {
  10842. City = item.City,
  10843. HotelName = item.HotelName,
  10844. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10845. // SingleRoomCount = item.SingleRoomCount,
  10846. SingleRoomPrice = singleRoomFeeStr,
  10847. // DoubleRoomCount = item.DoubleRoomCount,
  10848. DoubleRoomPrice = doubleRoomFeeStr,
  10849. //SuiteRoomCount = item.SuiteRoomCount,
  10850. SuiteRoomPrice = suiteRoomFeeStr,
  10851. OtherRoomPrice = otherRoomFeeStr,
  10852. //OtherRoomCount = item.OtherRoomCount,
  10853. BreakfastPrice = breakfastPriceStr,
  10854. GovernmentRent = governmentRentStr,
  10855. CityTax = cityTaxStr,
  10856. RoomExplanation = item.RoomExplanation,
  10857. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10858. PayTime = roomInfo?.ConsumptionDate,
  10859. BankNo = roomInfo?.BankNo,
  10860. PayMoney = payMoneyStr,
  10861. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10862. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10863. CardPrice = cardPriceStr,
  10864. Remark = ccpInfo.Remark
  10865. });
  10866. }
  10867. #endregion
  10868. //载入模板
  10869. WorkbookDesigner designer = new WorkbookDesigner();
  10870. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10871. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10872. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10873. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10874. var rateDatas1 = rateDatas.Distinct();
  10875. var rateStr = string.Empty;
  10876. foreach (var item in rateDatas1)
  10877. {
  10878. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  10879. }
  10880. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  10881. designer.SetDataSource("Opertor", userInfo.CnName);
  10882. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10883. dt.TableName = "ViewMyHotelReservations";
  10884. designer.SetDataSource(dt);
  10885. designer.Process();
  10886. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10887. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10888. designer.Workbook.Save(serverPath);
  10889. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10890. #region 删除指定行
  10891. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10892. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10893. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10894. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10895. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10896. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10897. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10898. cssIndex = dt.Columns["CityTax"].Ordinal,
  10899. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10900. remarkIndex = dt.Columns["Remark"].Ordinal;
  10901. //删除指定列
  10902. foreach (DataRow item in dt.Rows)
  10903. {
  10904. string singleStr = item["SingleRoomPrice"].ToString();
  10905. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10906. if (containsDigitButNotZero1) singleDel = false;
  10907. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10908. string doubleStr = item["DoubleRoomPrice"].ToString();
  10909. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10910. if (containsDigitButNotZero2) doubleDel = false;
  10911. string suiteStr = item["SuiteRoomPrice"].ToString();
  10912. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10913. if (containsDigitButNotZero3) suiteDel = false;
  10914. string otherStr = item["OtherRoomPrice"].ToString();
  10915. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10916. if (containsDigitButNotZero4) otherDel = false;
  10917. string zcStr = item["BreakfastPrice"].ToString();
  10918. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10919. if (containsDigitButNotZero5) zcDel = false;
  10920. string dsStr = item["GovernmentRent"].ToString();
  10921. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10922. if (containsDigitButNotZero6) dsDel = false;
  10923. string cssStr = item["CityTax"].ToString();
  10924. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10925. if (containsDigitButNotZero7) cssDel = false;
  10926. string cpStr = item["ConsumptionPatterns"].ToString();
  10927. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10928. string remarkStr = item["Remark"].ToString();
  10929. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10930. }
  10931. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10932. DeleteColumn(serverPath, cpIndex, cpDel);
  10933. DeleteColumn(serverPath, dsIndex, dsDel);
  10934. DeleteColumn(serverPath, cssIndex, cssDel);
  10935. DeleteColumn(serverPath, zcIndex, zcDel);
  10936. DeleteColumn(serverPath, otherIndex, otherDel);
  10937. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10938. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10939. DeleteColumn(serverPath, singleIndex, singleDel);
  10940. #endregion
  10941. //只保留第一个表格
  10942. DeleteSheet(serverPath);
  10943. return Ok(JsonView(true, "操作成功", url = rst));
  10944. }
  10945. else
  10946. {
  10947. _currency = _GroupCostParameter.Currency;
  10948. bool isIntType = int.TryParse(_currency, out int currId);
  10949. if (isIntType)
  10950. {
  10951. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10952. }
  10953. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10954. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10955. if (currInfo == null)
  10956. {
  10957. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10958. }
  10959. if (!_currency.ToUpper().Equals("CNY"))
  10960. {
  10961. _rate = _GroupCostParameter.Rate;
  10962. }
  10963. _rate = currInfo.Rate;
  10964. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10965. string strFileName = "HotelStatement/";
  10966. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10967. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10968. #region 数据处理
  10969. foreach (var item in hrDtas)
  10970. {
  10971. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10972. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10973. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10974. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10975. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10976. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10977. string singleRoomFeeStr = string.Empty,
  10978. doubleRoomFeeStr = string.Empty,
  10979. suiteRoomFeeStr = string.Empty,
  10980. otherRoomFeeStr = string.Empty,
  10981. payMoneyStr = string.Empty,
  10982. cardPriceStr = string.Empty;
  10983. if (roomCurr.Equals(_currency))
  10984. {
  10985. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10986. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10987. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10988. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10989. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10990. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10991. }
  10992. else
  10993. {
  10994. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10995. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10996. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10997. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10998. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10999. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11000. }
  11001. string breakfastPriceStr = string.Empty,
  11002. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11003. governmentRentStr = string.Empty,
  11004. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11005. cityTaxStrStr = string.Empty,
  11006. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11007. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  11008. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  11009. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  11010. int payDId = roomInfo?.PayDId ?? 0;
  11011. pcfds.Add(new HotelReservations_PCFD_View()
  11012. {
  11013. City = item.City,
  11014. HotelName = item.HotelName,
  11015. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11016. // SingleRoomCount = item.SingleRoomCount,
  11017. SingleRoomPrice = singleRoomFeeStr,
  11018. // DoubleRoomCount = item.DoubleRoomCount,
  11019. DoubleRoomPrice = doubleRoomFeeStr,
  11020. //SuiteRoomCount = item.SuiteRoomCount,
  11021. SuiteRoomPrice = suiteRoomFeeStr,
  11022. OtherRoomPrice = otherRoomFeeStr,
  11023. //OtherRoomCount = item.OtherRoomCount,
  11024. BreakfastPrice = breakfastPriceStr,
  11025. GovernmentRent = governmentRentStr,
  11026. CityTax = cityTaxStrStr,
  11027. RoomExplanation = item.RoomExplanation,
  11028. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11029. PayTime = roomInfo?.ConsumptionDate,
  11030. BankNo = roomInfo?.BankNo,
  11031. PayMoney = payMoneyStr,
  11032. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11033. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11034. CardPrice = cardPriceStr,
  11035. Remark = ccpInfo.Remark
  11036. });
  11037. }
  11038. #endregion
  11039. //载入模板
  11040. WorkbookDesigner designer = new WorkbookDesigner();
  11041. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11042. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11043. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11044. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11045. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  11046. designer.SetDataSource("Opertor", userInfo.CnName);
  11047. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11048. dt.TableName = "ViewMyHotelReservations";
  11049. designer.SetDataSource(dt);
  11050. designer.Process();
  11051. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11052. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11053. designer.Workbook.Save(serverPath);
  11054. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11055. #region 删除指定行
  11056. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11057. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11058. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11059. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11060. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11061. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11062. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11063. cssIndex = dt.Columns["CityTax"].Ordinal,
  11064. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11065. remarkIndex = dt.Columns["Remark"].Ordinal;
  11066. //删除指定列
  11067. foreach (DataRow item in dt.Rows)
  11068. {
  11069. string singleStr = item["SingleRoomPrice"].ToString();
  11070. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11071. if (containsDigitButNotZero1) singleDel = false;
  11072. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11073. string doubleStr = item["DoubleRoomPrice"].ToString();
  11074. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11075. if (containsDigitButNotZero2) doubleDel = false;
  11076. string suiteStr = item["SuiteRoomPrice"].ToString();
  11077. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11078. if (containsDigitButNotZero3) suiteDel = false;
  11079. string otherStr = item["OtherRoomPrice"].ToString();
  11080. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11081. if (containsDigitButNotZero4) otherDel = false;
  11082. string zcStr = item["BreakfastPrice"].ToString();
  11083. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11084. if (containsDigitButNotZero5) zcDel = false;
  11085. string dsStr = item["GovernmentRent"].ToString();
  11086. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11087. if (containsDigitButNotZero6) dsDel = false;
  11088. string cssStr = item["CityTax"].ToString();
  11089. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11090. if (containsDigitButNotZero7) cssDel = false;
  11091. string cpStr = item["ConsumptionPatterns"].ToString();
  11092. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11093. string remarkStr = item["Remark"].ToString();
  11094. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11095. }
  11096. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11097. DeleteColumn(serverPath, cpIndex, cpDel);
  11098. DeleteColumn(serverPath, dsIndex, dsDel);
  11099. DeleteColumn(serverPath, cssIndex, cssDel);
  11100. DeleteColumn(serverPath, zcIndex, zcDel);
  11101. DeleteColumn(serverPath, otherIndex, otherDel);
  11102. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11103. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11104. DeleteColumn(serverPath, singleIndex, singleDel);
  11105. #endregion
  11106. //只保留第一个表格
  11107. DeleteSheet(serverPath);
  11108. return Ok(JsonView(true, "操作成功", url = rst));
  11109. }
  11110. return Ok(JsonView(false));
  11111. }
  11112. /// <summary>
  11113. /// 删除指定列
  11114. /// </summary>
  11115. /// <param name="file"></param>
  11116. /// <param name="columnIndex"></param>
  11117. /// <param name="isDel"></param>
  11118. private void DeleteColumn(string file, int columnIndex, bool isDel)
  11119. {
  11120. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11121. //wb.Save(file);
  11122. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  11123. if (sheet1 != null)
  11124. {
  11125. if (isDel)
  11126. {
  11127. Cells cells = sheet1.Cells;
  11128. cells.DeleteColumn(columnIndex);
  11129. }
  11130. }
  11131. wb.Save(file);
  11132. }
  11133. /// <summary>
  11134. /// 删除sheet
  11135. /// </summary>
  11136. /// <param name="file"></param>
  11137. /// <param name="sheetName"></param>
  11138. private void DeleteSheet(string file, string sheetName = "")
  11139. {
  11140. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11141. //wb.Save(file);
  11142. List<string> sheets = new List<string>();
  11143. foreach (var item in wb.Worksheets)
  11144. {
  11145. sheets.Add(item.Name);
  11146. }
  11147. if (sheets.Count > 0)
  11148. {
  11149. sheets.RemoveAt(0);//不删除第一个sheet
  11150. foreach (var item in sheets)
  11151. {
  11152. wb.Worksheets.RemoveAt(item);
  11153. }
  11154. }
  11155. wb.Save(file);
  11156. }
  11157. /// <summary>
  11158. /// 酒店预订
  11159. /// 确认单
  11160. /// </summary>
  11161. /// <param name="_dto"></param>
  11162. /// <returns></returns>
  11163. [HttpPost]
  11164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11165. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  11166. {
  11167. try
  11168. {
  11169. #region 参数验证
  11170. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11171. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11172. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11173. #region 团组操作权限验证 76 酒店预定模块
  11174. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11175. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11176. #endregion
  11177. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11178. #region 页面操作权限验证
  11179. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11180. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11181. #endregion
  11182. #endregion
  11183. //团组信息
  11184. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  11185. //酒店数据
  11186. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  11187. if (listhoteldata.Count < 0)
  11188. {
  11189. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  11190. }
  11191. //利datatable存储
  11192. DataTable dt = new DataTable();
  11193. dt.Columns.Add("CheckInDate", typeof(string));
  11194. dt.Columns.Add("City", typeof(string));
  11195. dt.Columns.Add("Hotel", typeof(string));
  11196. dt.Columns.Add("Room", typeof(string));
  11197. for (int i = 0; i < listhoteldata.Count; i++)
  11198. {
  11199. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  11200. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  11201. while (dayStart < dayEnd)
  11202. {
  11203. string temp = "";
  11204. DataRow row = dt.NewRow();
  11205. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  11206. row["City"] = listhoteldata[i].City;
  11207. row["Hotel"] = listhoteldata[i].HotelName;
  11208. if (listhoteldata[i].SingleRoomCount > 0)
  11209. {
  11210. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  11211. }
  11212. if (listhoteldata[i].DoubleRoomCount > 0)
  11213. {
  11214. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  11215. }
  11216. if (listhoteldata[i].SuiteRoomCount > 0)
  11217. {
  11218. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  11219. }
  11220. if (listhoteldata[i].OtherRoomCount > 0)
  11221. {
  11222. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  11223. }
  11224. row["Room"] = temp;
  11225. dt.Rows.Add(row);
  11226. dayStart = dayStart.AddDays(1);
  11227. }
  11228. }
  11229. Dictionary<string, string> dic = new Dictionary<string, string>();
  11230. dic.Add("Dele", di.TeamName);
  11231. dic.Add("City", di.VisitCountry);
  11232. //模板路径
  11233. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  11234. //载入模板
  11235. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  11236. DocumentBuilder builder = new DocumentBuilder(doc);
  11237. foreach (var key in dic.Keys)
  11238. {
  11239. builder.MoveToBookmark(key);
  11240. builder.Write(dic[key]);
  11241. }
  11242. //获取word里所有表格
  11243. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11244. //获取所填表格的序数
  11245. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11246. var rowStart = tableOne.Rows[0]; //获取第1行
  11247. //循环赋值
  11248. for (int i = 0; i < dt.Rows.Count; i++)
  11249. {
  11250. builder.MoveToCell(0, i + 1, 0, 0);
  11251. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  11252. builder.MoveToCell(0, i + 1, 1, 0);
  11253. builder.Write(dt.Rows[i]["City"].ToString());
  11254. builder.MoveToCell(0, i + 1, 2, 0);
  11255. builder.Write(dt.Rows[i]["Hotel"].ToString());
  11256. builder.MoveToCell(0, i + 1, 3, 0);
  11257. builder.Write(dt.Rows[i]["Room"].ToString());
  11258. }
  11259. //删除多余行
  11260. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  11261. {
  11262. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  11263. }
  11264. string strFileName = di.TeamName + "酒店确认单.doc";
  11265. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  11266. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  11267. return Ok(JsonView(true, "成功", url));
  11268. }
  11269. catch (Exception ex)
  11270. {
  11271. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  11272. }
  11273. }
  11274. #endregion
  11275. #region 团组状态
  11276. /// <summary>
  11277. /// 团组状态列表 Page
  11278. /// </summary>
  11279. /// <param name="dto">团组列表请求dto</param>
  11280. /// <returns></returns>
  11281. [HttpPost]
  11282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11283. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11284. {
  11285. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11286. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11287. {
  11288. string sqlWhere = string.Empty;
  11289. if (dto.IsSure == 0) //未完成
  11290. {
  11291. sqlWhere += string.Format(@" And IsSure = 0");
  11292. }
  11293. else if (dto.IsSure == 1) //已完成
  11294. {
  11295. sqlWhere += string.Format(@" And IsSure = 1");
  11296. }
  11297. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11298. {
  11299. string tj = dto.SearchCriteria;
  11300. 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}%')",
  11301. tj, tj, tj, tj, tj);
  11302. }
  11303. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11304. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11305. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11306. From (
  11307. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11308. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11309. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11310. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11311. From Grp_DelegationInfo gdi
  11312. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11313. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11314. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11315. Where gdi.IsDel = 0 {0}
  11316. ) temp ", sqlWhere);
  11317. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11318. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11319. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11320. }
  11321. else
  11322. {
  11323. return Ok(JsonView(false, "查询失败"));
  11324. }
  11325. }
  11326. /// <summary>
  11327. /// 团组状态
  11328. /// 设置操作完成
  11329. /// </summary>
  11330. /// <param name="dto">团组列表请求dto</param>
  11331. /// <returns></returns>
  11332. [HttpPost]
  11333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11334. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11335. {
  11336. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11337. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11338. {
  11339. Id = dto.Id,
  11340. IsSure = 1
  11341. };
  11342. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11343. .UpdateColumns(it => new { it.IsSure })
  11344. .WhereColumns(it => new { it.Id })
  11345. .ExecuteCommandAsync();
  11346. if (result > 0)
  11347. {
  11348. return Ok(JsonView(true, "操作完成!"));
  11349. }
  11350. return Ok(JsonView(false, "操作失败!"));
  11351. }
  11352. #endregion
  11353. #region 保险费用录入
  11354. /// <summary>
  11355. /// 根据团组Id查询保险费用列表
  11356. /// </summary>
  11357. /// <param name="dto"></param>
  11358. /// <returns></returns>
  11359. [HttpPost]
  11360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11361. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11362. {
  11363. Result groupData = await _customersRep.CustomersByDiId(dto);
  11364. if (groupData.Code != 0)
  11365. {
  11366. return Ok(JsonView(false, groupData.Msg));
  11367. }
  11368. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11369. }
  11370. /// <summary>
  11371. /// 根据保险费用Id查询保险费用详细
  11372. /// </summary>
  11373. /// <param name="dto"></param>
  11374. /// <returns></returns>
  11375. [HttpPost]
  11376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11377. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11378. {
  11379. try
  11380. {
  11381. Result groupData = await _customersRep.CustomersById(dto);
  11382. if (groupData.Code != 0)
  11383. {
  11384. return Ok(JsonView(false, groupData.Msg));
  11385. }
  11386. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11387. }
  11388. catch (Exception ex)
  11389. {
  11390. return Ok(JsonView(false, ex.Message));
  11391. }
  11392. }
  11393. /// <summary>
  11394. /// 保险费用录入页面初始化绑定
  11395. /// </summary>
  11396. /// <param name="dto"></param>
  11397. /// <returns></returns>
  11398. [HttpPost]
  11399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11400. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11401. {
  11402. try
  11403. {
  11404. Result groupData = await _customersRep.CustomersInitialize(dto);
  11405. if (groupData.Code != 0)
  11406. {
  11407. return Ok(JsonView(false, groupData.Msg));
  11408. }
  11409. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11410. }
  11411. catch (Exception ex)
  11412. {
  11413. return Ok(JsonView(false, ex.Message));
  11414. }
  11415. }
  11416. /// <summary>
  11417. /// 保险费用操作(Status:1.新增,2.修改)
  11418. /// </summary>
  11419. /// <param name="dto"></param>
  11420. /// <returns></returns>
  11421. [HttpPost]
  11422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11423. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11424. {
  11425. Result groupData = await _customersRep.OpCustomers(dto);
  11426. if (groupData.Code != 0)
  11427. {
  11428. return Ok(JsonView(false, groupData.Msg));
  11429. }
  11430. #region 应用推送
  11431. try
  11432. {
  11433. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11434. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11435. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11436. //2024-10-21 新增LZ UID
  11437. var userIds = new List<int>() { 21 };
  11438. string title = $"系统通知";
  11439. var diId = dto.DiId;
  11440. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11441. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11442. string content = "";
  11443. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11444. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11445. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11446. await GeneralMethod.iOS_PushNotifications("051", $"保险费用审核", "", content);
  11447. }
  11448. catch (Exception ex)
  11449. {
  11450. }
  11451. #endregion
  11452. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11453. }
  11454. /// <summary>
  11455. /// 保险文件上传
  11456. /// </summary>
  11457. /// <param name="file"></param>
  11458. /// <returns></returns>
  11459. [HttpPost]
  11460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11461. public async Task<IActionResult> UploadCus(IFormFile file)
  11462. {
  11463. try
  11464. {
  11465. if (file != null)
  11466. {
  11467. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11468. //文件名称
  11469. string projectFileName = file.FileName;
  11470. //上传的文件的路径
  11471. string filePath = "";
  11472. if (!Directory.Exists(fileDir))
  11473. {
  11474. Directory.CreateDirectory(fileDir);
  11475. }
  11476. //上传的文件的路径
  11477. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11478. using (FileStream fs = System.IO.File.Create(filePath))
  11479. {
  11480. file.CopyTo(fs);
  11481. fs.Flush();
  11482. }
  11483. return Ok(JsonView(true, "上传成功!", projectFileName));
  11484. }
  11485. else
  11486. {
  11487. return Ok(JsonView(false, "上传失败!"));
  11488. }
  11489. }
  11490. catch (Exception ex)
  11491. {
  11492. return Ok(JsonView(false, "程序错误!"));
  11493. throw;
  11494. }
  11495. }
  11496. /// <summary>
  11497. /// 保险删除指定文件
  11498. /// </summary>
  11499. /// <param name="dto"></param>
  11500. /// <returns></returns>
  11501. [HttpPost]
  11502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11503. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11504. {
  11505. try
  11506. {
  11507. string filePath = "";
  11508. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11509. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11510. //int id = 0;
  11511. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11512. // 删除该文件
  11513. try
  11514. {
  11515. System.IO.File.Delete(filePath);
  11516. 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()
  11517. {
  11518. Attachment = "",
  11519. }).ExecuteCommandAsync();
  11520. if (result != 0)
  11521. {
  11522. return Ok(JsonView(true, "成功!"));
  11523. }
  11524. else
  11525. {
  11526. return Ok(JsonView(false, "失败!"));
  11527. }
  11528. }
  11529. catch (Exception)
  11530. {
  11531. 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()
  11532. {
  11533. Attachment = "",
  11534. }).ExecuteCommandAsync();
  11535. if (result != 0)
  11536. {
  11537. return Ok(JsonView(true, "成功!"));
  11538. }
  11539. else
  11540. {
  11541. return Ok(JsonView(false, "失败!"));
  11542. }
  11543. }
  11544. }
  11545. catch (Exception ex)
  11546. {
  11547. return Ok(JsonView(false, "程序错误!"));
  11548. throw;
  11549. }
  11550. }
  11551. /// <summary>
  11552. /// 保险费用操作(删除)
  11553. /// </summary>
  11554. /// <param name="dto"></param>
  11555. /// <returns></returns>
  11556. [HttpPost]
  11557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11558. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11559. {
  11560. try
  11561. {
  11562. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11563. if (!res)
  11564. {
  11565. return Ok(JsonView(false, "删除失败"));
  11566. }
  11567. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11568. {
  11569. IsDel = 1,
  11570. DeleteUserId = dto.DeleteUserId,
  11571. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11572. }).ExecuteCommandAsync();
  11573. return Ok(JsonView(true, "删除成功!"));
  11574. }
  11575. catch (Exception ex)
  11576. {
  11577. return Ok(JsonView(false, "程序错误!"));
  11578. throw;
  11579. }
  11580. }
  11581. #endregion
  11582. #region 接团客户名单 PageId 104
  11583. /// <summary>
  11584. /// 接团客户名单
  11585. /// 迁移数据(慎用!)
  11586. /// </summary>
  11587. /// <param name="dto"></param>
  11588. /// <returns></returns>
  11589. [HttpPost]
  11590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11591. public async Task<IActionResult> PostTourClientListChange()
  11592. {
  11593. try
  11594. {
  11595. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11596. //var groupClinetData1
  11597. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11598. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11599. int updateCount = 0;
  11600. if (oldOAClientList.Count > 0)
  11601. {
  11602. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11603. _sqlSugar.BeginTran();
  11604. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11605. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11606. foreach (var item in oldOAClientList)
  11607. {
  11608. int comId = 0;
  11609. string format = "yyyy-MM-dd HH:mm:ss";
  11610. string data11 = "1990-01-01 00:00";
  11611. var data1 = IsValidDate(item.OPdate, format);
  11612. if (data1) data11 = item.OPdate;
  11613. //客户公司验证
  11614. if (!string.IsNullOrEmpty(item.Company))
  11615. {
  11616. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11617. if (clientComInfo == null) // add
  11618. {
  11619. var addInfo = new Crm_CustomerCompany()
  11620. {
  11621. CompanyAbbreviation = "",
  11622. CompanyFullName = item.Company,
  11623. Address = "",
  11624. PostCodes = "",
  11625. LastedOpUserId = item.OPer,
  11626. LastedOpDt = Convert.ToDateTime(data11),
  11627. CreateUserId = item.OPer,
  11628. CreateTime = Convert.ToDateTime(data11),
  11629. IsDel = 0
  11630. };
  11631. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11632. if (comId1 > 0) comId = comId1;
  11633. }
  11634. else comId = clientComInfo.Id;
  11635. }
  11636. //客户人员验证
  11637. int clientId = 0;
  11638. string name = item.LastName + item.Name;
  11639. if (!string.IsNullOrEmpty(name))
  11640. {
  11641. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11642. if (clientInfo == null)
  11643. {
  11644. DateTime? dateTime = null;
  11645. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11646. if (isDt) dateTime = birthDayDt;
  11647. var addInfo1 = new Crm_DeleClient()
  11648. {
  11649. CrmCompanyId = comId,
  11650. DiId = -1,
  11651. LastName = item.LastName,
  11652. FirstName = item.Name,
  11653. OldName = "",
  11654. Pinyin = item.Pinyin,
  11655. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11656. Marriage = 0,
  11657. Phone = item.Phone,
  11658. Job = item.Job,
  11659. BirthDay = dateTime
  11660. };
  11661. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11662. if (clientId1 > 0) clientId = clientId1;
  11663. }
  11664. else clientId = clientInfo.Id;
  11665. }
  11666. if (clientId < 1)
  11667. {
  11668. continue;
  11669. }
  11670. int airType = 0;
  11671. if (item.AirType == "超经舱") airType = 459;
  11672. else if (item.AirType == "公务舱") airType = 458;
  11673. else if (item.AirType == "经济舱") airType = 460;
  11674. else if (item.AirType == "其他") airType = 565;
  11675. else if (item.AirType == "头等舱") airType = 457;
  11676. var _TourClientListEntity = new Grp_TourClientList()
  11677. {
  11678. DiId = item.Diid,
  11679. ClientId = clientId,
  11680. CreateUserId = item.OPer,
  11681. CreateTime = Convert.ToDateTime(data11),
  11682. Remark = item.Remark,
  11683. IsDel = item.Isdel,
  11684. ShippingSpaceTypeId = airType,
  11685. ShippingSpaceSpecialNeeds = item.AirRemark,
  11686. HotelSpecialNeeds = item.RoomType
  11687. };
  11688. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11689. if (_TourClientList > 0)
  11690. {
  11691. updateCount++;
  11692. }
  11693. }
  11694. _sqlSugar.CommitTran();
  11695. }
  11696. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11697. }
  11698. catch (Exception ex)
  11699. {
  11700. _sqlSugar.RollbackTran();
  11701. return Ok(JsonView(false, ex.Message));
  11702. }
  11703. return Ok(JsonView(true));
  11704. }
  11705. private bool IsValidDate(string dateString, string format)
  11706. {
  11707. DateTime dateValue;
  11708. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11709. return valid;
  11710. }
  11711. /// <summary>
  11712. /// 接团客户名单
  11713. /// 根据团组Id查询List
  11714. /// </summary>
  11715. /// <param name="dto"></param>
  11716. /// <returns></returns>
  11717. [HttpPost]
  11718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11719. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11720. {
  11721. #region 参数验证
  11722. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11723. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11724. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11725. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11726. #region 页面操作权限验证
  11727. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11728. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11729. #endregion
  11730. #endregion
  11731. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11732. if (viewData.Code != 0)
  11733. {
  11734. return Ok(JsonView(false, viewData.Msg));
  11735. }
  11736. return Ok(JsonView(viewData.Data));
  11737. }
  11738. /// <summary>
  11739. /// 接团客户名单
  11740. /// 基础数据 Init
  11741. /// </summary>
  11742. /// <param name="_dto"></param>
  11743. /// <returns></returns>
  11744. [HttpPost]
  11745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11746. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11747. {
  11748. #region 参数验证
  11749. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11750. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11751. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11752. #region 页面操作权限验证
  11753. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11755. #endregion
  11756. #endregion
  11757. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11758. }
  11759. /// <summary>
  11760. /// 接团客户名单
  11761. /// 根据 Id查询 Details
  11762. /// </summary>
  11763. /// <param name="_dto"></param>
  11764. /// <returns></returns>
  11765. [HttpPost]
  11766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11767. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11768. {
  11769. #region 参数验证
  11770. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11771. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11772. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11773. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11774. #region 页面操作权限验证
  11775. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11776. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11777. #endregion
  11778. #endregion
  11779. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11780. if (viewData.Code != 0)
  11781. {
  11782. return Ok(JsonView(false, viewData.Msg));
  11783. }
  11784. return Ok(JsonView(viewData.Data));
  11785. }
  11786. /// <summary>
  11787. /// 接团客户名单
  11788. /// Add Or Edit
  11789. /// </summary>
  11790. /// <param name="_dto"></param>
  11791. /// <returns></returns>
  11792. [HttpPost]
  11793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11794. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11795. {
  11796. #region 参数验证
  11797. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11798. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11799. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11800. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11801. #region 页面操作权限验证
  11802. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11803. if (_dto.Id == 0) //添加
  11804. {
  11805. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11806. }
  11807. else if (_dto.Id >= 0) //修改
  11808. {
  11809. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11810. }
  11811. #endregion
  11812. #endregion
  11813. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11814. if (viewData.Code != 0)
  11815. {
  11816. return Ok(JsonView(false, viewData.Msg));
  11817. }
  11818. return Ok(JsonView(true));
  11819. }
  11820. /// <summary>
  11821. /// 接团客户名单
  11822. /// AddMultiple(添加多个)
  11823. /// </summary>
  11824. /// <param name="_dto"></param>
  11825. /// <returns></returns>
  11826. [HttpPost]
  11827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11828. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11829. {
  11830. #region 参数验证
  11831. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11832. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11833. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11834. #region 页面操作权限验证
  11835. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11836. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11837. #endregion
  11838. #endregion
  11839. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11840. if (viewData.Code != 0)
  11841. {
  11842. return Ok(JsonView(false, viewData.Msg));
  11843. }
  11844. return Ok(JsonView(true));
  11845. }
  11846. /// <summary>
  11847. /// 接团客户名单
  11848. /// Del
  11849. /// </summary>
  11850. /// <param name="_dto"></param>
  11851. /// <returns></returns>
  11852. [HttpPost]
  11853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11854. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11855. {
  11856. #region 参数验证
  11857. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11858. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11859. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11860. #region 页面操作权限验证
  11861. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11862. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11863. #endregion
  11864. #endregion
  11865. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11866. if (viewData.Code != 0)
  11867. {
  11868. return Ok(JsonView(false, viewData.Msg));
  11869. }
  11870. return Ok(JsonView(true));
  11871. }
  11872. /// <summary>
  11873. /// 接团客户名单
  11874. /// 文件下载 客户名单
  11875. /// </summary>
  11876. /// <param name="_dto"></param>
  11877. /// <returns></returns>
  11878. [HttpPost]
  11879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11880. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11881. {
  11882. #region 参数验证
  11883. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11884. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11885. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11886. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11887. #region 页面操作权限验证
  11888. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11889. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11890. #endregion
  11891. #endregion
  11892. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11893. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11894. From Grp_TourClientList tcl
  11895. Left Join
  11896. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11897. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11898. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11899. From Crm_DeleClient dc
  11900. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11901. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11902. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11903. Where dc.IsDel = 0) temp
  11904. On temp.DcId =tcl.ClientId
  11905. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11906. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11907. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11908. //载入模板
  11909. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11910. if (_dto.Language == 1)
  11911. {
  11912. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11913. }
  11914. //载入模板
  11915. var doc = new Document(tempPath);
  11916. DocumentBuilder builder = new DocumentBuilder(doc);
  11917. //获取word里所有表格
  11918. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11919. //获取所填表格的序数
  11920. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11921. var rowStart = tableOne.Rows[0]; //获取第1行
  11922. if (_dto.Language == 0)
  11923. {
  11924. //循环赋值
  11925. for (int i = 0; i < DcList.Count; i++)
  11926. {
  11927. builder.MoveToCell(0, i + 1, 0, 0);
  11928. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11929. builder.MoveToCell(0, i + 1, 1, 0);
  11930. int sex = DcList[i].Sex;
  11931. string sexStr = string.Empty;
  11932. if (sex == 0) sexStr = "男";
  11933. else if (sex == 1) sexStr = "女";
  11934. else sexStr = "未设置";
  11935. builder.Write(sexStr);
  11936. builder.MoveToCell(0, i + 1, 2, 0);
  11937. string birthDay = DcList[i].BirthDay;
  11938. string birthDayStr = string.Empty;
  11939. if (!string.IsNullOrEmpty(birthDay))
  11940. {
  11941. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11942. }
  11943. builder.Write(birthDayStr);
  11944. builder.MoveToCell(0, i + 1, 3, 0);
  11945. string company = "";
  11946. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11947. {
  11948. company = DcList[i].CompanyFullName.ToString();
  11949. }
  11950. builder.Write(company);
  11951. builder.MoveToCell(0, i + 1, 4, 0);
  11952. builder.Write(DcList[i].Job);
  11953. }
  11954. }
  11955. else if (_dto.Language == 1)
  11956. {
  11957. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11958. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11959. List<string> transArrayStr = new List<string>();
  11960. string transStrRes1 = "";
  11961. for (int i = 0; i < DcList.Count; i++)
  11962. {
  11963. var dc = DcList[i];
  11964. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11965. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11966. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11967. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11968. else transStrRes1 += $"{str1}|";
  11969. }
  11970. //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";
  11971. string transStrRes = "";
  11972. if (transStrRes1.Length > 0)
  11973. {
  11974. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11975. }
  11976. //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
  11977. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11978. //List<string> transArray = new List<string> { };
  11979. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11980. if (transStrRes.Contains("|"))
  11981. {
  11982. string[] transArray1 = transStrRes.Split('|');
  11983. if (transArray1.Length > 0)
  11984. {
  11985. foreach (var item in transArray1)
  11986. {
  11987. if (item.Contains("&"))
  11988. {
  11989. string[] transArray2 = item.Split('&');
  11990. int index = 0;
  11991. string companyName = "", job = "";
  11992. if (transArray2.Length > 0)
  11993. {
  11994. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11995. if (1 < transArray2.Length) companyName = transArray2[1];
  11996. if (2 < transArray2.Length) job = transArray2[2];
  11997. }
  11998. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11999. }
  12000. }
  12001. }
  12002. }
  12003. //循环赋值
  12004. for (int i = 0; i < DcList.Count; i++)
  12005. {
  12006. string PYName = "";
  12007. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  12008. {
  12009. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  12010. string PY_First = DcList[i].Pinyin.Split('/')[1];
  12011. PYName = PY_First + " " + PY_Last;
  12012. }
  12013. else
  12014. {
  12015. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  12016. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  12017. PYName = PY_First + " " + PY_Last;
  12018. }
  12019. builder.MoveToCell(0, i + 1, 0, 0);
  12020. builder.Write(PYName);
  12021. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  12022. builder.MoveToCell(0, i + 1, 1, 0);
  12023. builder.Write(sex);
  12024. DateTime birthDt;
  12025. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  12026. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  12027. builder.MoveToCell(0, i + 1, 2, 0);
  12028. builder.Write(birthday);
  12029. string company = string.Empty, job = string.Empty;
  12030. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  12031. if (dcTransInfo != null)
  12032. {
  12033. company = dcTransInfo.CompanyName;
  12034. job = dcTransInfo.Job;
  12035. }
  12036. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12037. {
  12038. //查询对照表
  12039. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  12040. if (tempCec != null)
  12041. {
  12042. company = tempCec.enName;
  12043. }
  12044. //翻译
  12045. else
  12046. {
  12047. }
  12048. }
  12049. builder.MoveToCell(0, i + 1, 3, 0);
  12050. builder.Write(company);
  12051. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  12052. {
  12053. //查询对照表
  12054. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  12055. if (tempPec != null)
  12056. {
  12057. job = tempPec.enName;
  12058. }
  12059. //翻译
  12060. else
  12061. {
  12062. }
  12063. }
  12064. builder.MoveToCell(0, i + 1, 4, 0);
  12065. builder.Write(job);
  12066. }
  12067. }
  12068. //删除多余行
  12069. while (tableOne.Rows.Count > DcList.Count + 1)
  12070. {
  12071. tableOne.Rows.RemoveAt(DcList.Count + 1);
  12072. }
  12073. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  12074. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  12075. doc.Save(fileDir);
  12076. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  12077. return Ok(JsonView(true, "操作成功!", Url));
  12078. }
  12079. private class TranslateInfo
  12080. {
  12081. public int Index { get; set; }
  12082. public string CompanyName { get; set; }
  12083. public string Job { get; set; }
  12084. }
  12085. #endregion
  12086. #region 团组倒推表
  12087. /// <summary>
  12088. /// 倒推表基础数据
  12089. /// Init
  12090. /// </summary>
  12091. /// <param name="dto"></param>
  12092. /// <returns></returns>
  12093. [HttpPost]
  12094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12095. public async Task<IActionResult> PostInvertedListInit()
  12096. {
  12097. var viewData = await _invertedListRep._Init();
  12098. if (viewData.Code != 0)
  12099. {
  12100. return Ok(JsonView(false, viewData.Msg));
  12101. }
  12102. return Ok(JsonView(viewData.Data));
  12103. }
  12104. /// <summary>
  12105. /// 倒推表
  12106. /// Info
  12107. /// </summary>
  12108. /// <param name="dto"></param>
  12109. /// <returns></returns>
  12110. [HttpPost]
  12111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12112. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  12113. {
  12114. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  12115. if (viewData.Code != 0)
  12116. {
  12117. return Ok(JsonView(false, viewData.Msg));
  12118. }
  12119. return Ok(JsonView(viewData.Data));
  12120. }
  12121. /// <summary>
  12122. /// 倒推表
  12123. /// Create
  12124. /// </summary>
  12125. /// <param name="dto"></param>
  12126. /// <returns></returns>
  12127. [HttpPost]
  12128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12129. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  12130. {
  12131. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  12132. if (viewData.Code != 0)
  12133. {
  12134. return Ok(JsonView(false, viewData.Msg));
  12135. }
  12136. return Ok(JsonView(viewData.Data));
  12137. }
  12138. /// <summary>
  12139. /// 倒推表
  12140. /// Update
  12141. /// </summary>
  12142. /// <param name="dto"></param>
  12143. /// <returns></returns>
  12144. [HttpPost]
  12145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12146. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  12147. {
  12148. var viewData = await _invertedListRep._Update(dto);
  12149. if (viewData.Code != 0)
  12150. {
  12151. return Ok(JsonView(false, viewData.Msg));
  12152. }
  12153. return Ok(JsonView(viewData.Data));
  12154. }
  12155. /// <summary>
  12156. /// 倒推表
  12157. /// File Download
  12158. /// </summary>
  12159. /// <param name="dto"></param>
  12160. /// <returns></returns>
  12161. [HttpPost]
  12162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12163. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  12164. {
  12165. var info2 = await _invertedListRep._Info(1, dto.DiId);
  12166. if (info2.Code != 0)
  12167. {
  12168. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  12169. }
  12170. var info1 = info2.Data as InvertedListInfoView;
  12171. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  12172. string teamName = "";
  12173. if (info != null) teamName = info.TeamName;
  12174. //载入模板
  12175. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  12176. DocumentBuilder builder = new DocumentBuilder(doc);
  12177. //利用键值对存放数据
  12178. Dictionary<string, string> dic = new Dictionary<string, string>();
  12179. dic.Add("TeamName", teamName);
  12180. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  12181. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  12182. dic.Add("BPRemark", info1.ApprovalDataRemark);
  12183. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  12184. dic.Add("SQRemark", info1.ApprovalRemark);
  12185. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  12186. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  12187. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  12188. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  12189. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  12190. dic.Add("QZRemark", info1.VisaInformationRemark);
  12191. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  12192. dic.Add("SQQZRemark", info1.SendVisaRemark);
  12193. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  12194. dic.Add("CQRemark", info1.IssueVisaRemark);
  12195. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  12196. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  12197. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  12198. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  12199. #region 填充word模板书签内容
  12200. foreach (var key in dic.Keys)
  12201. {
  12202. builder.MoveToBookmark(key);
  12203. builder.Write(dic[key]);
  12204. }
  12205. #endregion
  12206. var fileDir = AppSettingsHelper.Get("WordBasePath");
  12207. string fileName = $"{teamName}团出行准备流程表.doc";
  12208. string filePath = fileDir + $@"InvertedList/{fileName}";
  12209. doc.Save(filePath);
  12210. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  12211. return Ok(JsonView(true, "操作成功!", Url));
  12212. }
  12213. #endregion
  12214. #region 三公签证费用(签证费、代办费)
  12215. /// <summary>
  12216. /// 三公签证费用(签证费、代办费)
  12217. /// List
  12218. /// </summary>
  12219. /// <returns></returns>
  12220. [HttpPost]
  12221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12222. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  12223. {
  12224. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  12225. if (_view.Code != 0)
  12226. {
  12227. return Ok(JsonView(false, _view.Msg));
  12228. }
  12229. return Ok(JsonView(true, "操作成功!", _view.Data));
  12230. }
  12231. /// <summary>
  12232. /// 三公签证费用(签证费、代办费)
  12233. /// Add Or Update
  12234. /// </summary>
  12235. /// <returns></returns>
  12236. [HttpPost]
  12237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12238. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  12239. {
  12240. var _view = await _visaFeeInfoRep._Update(_dto);
  12241. if (_view.Code != 0)
  12242. {
  12243. return Ok(JsonView(false, _view.Msg));
  12244. }
  12245. return Ok(JsonView(true, _view.Msg));
  12246. }
  12247. #endregion
  12248. #region 酒店询价
  12249. /// <summary>
  12250. /// 酒店询价
  12251. /// Init
  12252. /// </summary>
  12253. /// <param name="dto"></param>
  12254. /// <returns></returns>
  12255. [HttpPost]
  12256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12257. public async Task<IActionResult> PostHotelInquiryInit()
  12258. {
  12259. var res = await _hotelInquiryRep._Init();
  12260. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12261. return Ok(JsonView(true, res.Msg, res.Data));
  12262. }
  12263. /// <summary>
  12264. /// 酒店询价
  12265. /// page Item
  12266. /// </summary>
  12267. /// <param name="_dto"></param>
  12268. /// <returns></returns>
  12269. [HttpPost]
  12270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12271. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  12272. {
  12273. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  12274. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12275. var view = res.Data as PageDataViewBase;
  12276. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  12277. }
  12278. /// <summary>
  12279. /// 酒店询价
  12280. /// info
  12281. /// </summary>
  12282. /// <param name="_dto"></param>
  12283. /// <returns></returns>
  12284. [HttpPost]
  12285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12286. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12287. {
  12288. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12289. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12290. return Ok(JsonView(true, res.Msg, res.Data));
  12291. }
  12292. /// <summary>
  12293. /// 酒店询价
  12294. /// Add Or Edit
  12295. /// </summary>
  12296. /// <param name="_dto"></param>
  12297. /// <returns></returns>
  12298. [HttpPost]
  12299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12300. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12301. {
  12302. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12303. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12304. return Ok(JsonView(true, res.Msg, res.Data));
  12305. }
  12306. /// <summary>
  12307. /// 酒店询价
  12308. /// Del
  12309. /// </summary>
  12310. /// <param name="_dto"></param>
  12311. /// <returns></returns>
  12312. [HttpPost]
  12313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12314. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12315. {
  12316. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12317. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12318. return Ok(JsonView(true, res.Msg, res.Data));
  12319. }
  12320. #endregion
  12321. #region 下载匹配op行程单
  12322. /// <summary>
  12323. /// 匹配op行程单
  12324. /// Init
  12325. /// </summary>
  12326. /// <param name="dto">团组列表请求dto</param>
  12327. /// <returns></returns>
  12328. [HttpPost]
  12329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12330. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12331. {
  12332. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12333. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12334. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12335. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12336. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12337. .Where(it => it.IsDel == 0)
  12338. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12339. .OrderByDescending(it => it.CreateUserId)
  12340. .ToList();
  12341. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12342. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12343. var diids = groupInfos.Select(it => it.Id).ToList();
  12344. List<string> countrys = new List<string>();
  12345. foreach (var item in country)
  12346. {
  12347. var data = _groupRepository.FormartTeamName(item);
  12348. var dataArray = _groupRepository.GroupSplitCountry(data);
  12349. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12350. }
  12351. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12352. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12353. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12354. foreach (var item in areaItem)
  12355. {
  12356. string areaStr = item.Value;
  12357. if (!string.IsNullOrEmpty(areaStr))
  12358. {
  12359. string[] str1 = areaStr.Split("-");
  12360. if (str1.Length > 0)
  12361. {
  12362. areaArray.AddRange(str1);
  12363. }
  12364. }
  12365. }
  12366. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12367. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12368. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12369. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12370. .ToList();
  12371. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12372. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12373. .Where(it => countriesIds.Contains(it.Id))
  12374. .Select(it => new { it.Id, Name = it.Name_CN })
  12375. .ToList();
  12376. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12377. .Select(it => it.TeamName).ToList();
  12378. stopwatch.Stop();
  12379. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12380. }
  12381. ///// <summary>
  12382. ///// 匹配op行程单
  12383. ///// Init 查询区域数据
  12384. ///// </summary>
  12385. ///// <param name="dto">团组列表请求dto</param>
  12386. ///// <returns></returns>
  12387. //[HttpPost]
  12388. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12389. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12390. //{
  12391. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12392. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12393. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12394. // if (string.IsNullOrEmpty(countriesDataStr))
  12395. // {
  12396. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12397. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12398. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12399. // }
  12400. // else
  12401. // {
  12402. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12403. // }
  12404. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12405. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12406. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12407. // List<dynamic> childList = new List<dynamic>();
  12408. // int parentId = dto.CountriesId;
  12409. // if (provinceData.Count > 1)
  12410. // {
  12411. // foreach (var item1 in provinceData)
  12412. // {
  12413. // List<dynamic> childList1 = new List<dynamic>();
  12414. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12415. // foreach (var item2 in citiesData1)
  12416. // {
  12417. // List<dynamic> childList2 = new List<dynamic>();
  12418. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12419. // foreach (var item3 in countiesData1)
  12420. // {
  12421. // childList2.Add(new
  12422. // {
  12423. // id = item3.Id,
  12424. // parentId = item2.Id,
  12425. // level = "district",
  12426. // name = item3.Name_CN,
  12427. // });
  12428. // }
  12429. // childList1.Add(new
  12430. // {
  12431. // id = item2.Id,
  12432. // parentId = item1.Id,
  12433. // level = "city",
  12434. // name = item2.Name_CN,
  12435. // childList = childList2
  12436. // });
  12437. // }
  12438. // childList.Add(new
  12439. // {
  12440. // id = item1.Id,
  12441. // parentId = parentId,
  12442. // level = "province",
  12443. // name = item1.Name_CN,
  12444. // childList = childList1
  12445. // });
  12446. // }
  12447. // //城市
  12448. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12449. // foreach (var item2 in citiesData2)
  12450. // {
  12451. // List<dynamic> childList22 = new List<dynamic>();
  12452. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12453. // foreach (var item3 in countiesData1)
  12454. // {
  12455. // childList22.Add(new
  12456. // {
  12457. // id = item3.Id,
  12458. // parentId = item2.Id,
  12459. // level = "district",
  12460. // name = item3.Name_CN,
  12461. // });
  12462. // }
  12463. // childList.Add(new
  12464. // {
  12465. // id = item2.Id,
  12466. // parentId = parentId,
  12467. // level = "city",
  12468. // name = item2.Name_CN,
  12469. // childList = childList22
  12470. // });
  12471. // }
  12472. // }
  12473. // else
  12474. // {
  12475. // foreach (var item2 in citiesData)
  12476. // {
  12477. // string cname = item2.Name_CN;
  12478. // List<dynamic> childList1 = new List<dynamic>();
  12479. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12480. // foreach (var item3 in countiesData1)
  12481. // {
  12482. // childList1.Add(new
  12483. // {
  12484. // Id = item3.Id,
  12485. // parentId = item2.Id,
  12486. // level = "district",
  12487. // name = item3.Name_CN
  12488. // });
  12489. // }
  12490. // childList.Add(new
  12491. // {
  12492. // id = item2.Id,
  12493. // parentId = parentId,
  12494. // level = "city",
  12495. // name = item2.Name_CN,
  12496. // childList = childList1
  12497. // });
  12498. // }
  12499. // }
  12500. // stopwatch.Stop();
  12501. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12502. //}
  12503. /// <summary>
  12504. /// 匹配op行程单
  12505. /// 接团信息列表 Page
  12506. /// </summary>
  12507. /// <param name="dto">团组列表请求dto</param>
  12508. /// <returns></returns>
  12509. [HttpPost]
  12510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12511. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12512. {
  12513. var swatch = new Stopwatch();
  12514. swatch.Start();
  12515. #region 参数验证
  12516. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12517. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12518. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12519. #region 页面操作权限验证
  12520. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12521. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12522. #endregion
  12523. #endregion
  12524. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12525. {
  12526. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12527. string sqlWhere = "";
  12528. if (!string.IsNullOrEmpty(dto.Country))
  12529. {
  12530. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12531. }
  12532. if (!string.IsNullOrEmpty(dto.Area))
  12533. {
  12534. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12535. }
  12536. if (!string.IsNullOrEmpty(dto.TeamName))
  12537. {
  12538. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12539. }
  12540. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12541. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12542. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12543. swatch.Stop();
  12544. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12545. }
  12546. else
  12547. {
  12548. return Ok(JsonView(false, "查询失败"));
  12549. }
  12550. }
  12551. /// <summary>
  12552. /// 匹配op行程单
  12553. /// 行程单下载
  12554. /// </summary>
  12555. /// <param name="dto">团组列表请求dto</param>
  12556. /// <returns></returns>
  12557. [HttpPost]
  12558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12559. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12560. {
  12561. #region 参数验证
  12562. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12563. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12564. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12565. #region 页面操作权限验证
  12566. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12567. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12568. #endregion
  12569. #endregion
  12570. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12571. {
  12572. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12573. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12574. }
  12575. else
  12576. {
  12577. return Ok(JsonView(false, "下载失败!"));
  12578. }
  12579. }
  12580. #endregion
  12581. #region 国家信息 数据 注释
  12582. //[HttpPost]
  12583. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12584. //{
  12585. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12586. // foreach (var item in dto)
  12587. // {
  12588. // infos.Add(new Grp_GroupsTaskAssignment()
  12589. // {
  12590. // DIId = item,
  12591. // CTId = 82,
  12592. // UId = 248,
  12593. // IsEnable = 1,
  12594. // CreateUserId = 233,
  12595. // CreateTime = DateTime.Now,
  12596. // IsDel = 0
  12597. // });
  12598. // infos.Add(new Grp_GroupsTaskAssignment()
  12599. // {
  12600. // DIId = item,
  12601. // CTId = 82,
  12602. // UId = 286,
  12603. // IsEnable = 1,
  12604. // CreateUserId = 233,
  12605. // CreateTime = DateTime.Now,
  12606. // IsDel = 0
  12607. // });
  12608. // }
  12609. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12610. // return Ok("操作成功");
  12611. //}
  12612. //public class paramJsonDto
  12613. //{
  12614. // public List<CountriesInfo> str { get; set; }
  12615. //}
  12616. //[HttpPost]
  12617. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12618. //{
  12619. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12620. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12621. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12622. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12623. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12624. // _sqlSugar.BeginTran();
  12625. // int countitiesIndex = 0;
  12626. // foreach (var item in dto.str)
  12627. // {
  12628. // dynamic data = item.c;
  12629. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12630. // if (data != null)
  12631. // {
  12632. // countitiesIndex++;
  12633. // foreach (var item1 in data)
  12634. // {
  12635. // string cnname = item1.cn;
  12636. // string enname = item1.en;
  12637. // Sys_Cities provinceInfo = new Sys_Cities()
  12638. // {
  12639. // CountriesId = countriesId,
  12640. // Name_CN = cnname,
  12641. // Name_EN = enname,
  12642. // ParentId = 0,
  12643. // IsCapital = 1,
  12644. // CreateUserId = 208,
  12645. // CreateTime = DateTime.Now,
  12646. // IsDel = 0
  12647. // };
  12648. // if (item1.lv == "province") //省份
  12649. // {
  12650. // provinceInfo.Level = 1;
  12651. // int provinceId = 0;
  12652. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12653. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12654. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12655. // var data1 = item1.c;
  12656. // foreach (var item2 in data1)
  12657. // {
  12658. // if (item2.lv == "city")
  12659. // {
  12660. // string citycnname = item2.cn;
  12661. // string cityenname = item2.en;
  12662. // Sys_Cities cityInfo = new Sys_Cities()
  12663. // {
  12664. // CountriesId = countriesId,
  12665. // ParentId = provinceId,
  12666. // Level = 2,
  12667. // Name_CN = citycnname,
  12668. // Name_EN = cityenname,
  12669. // IsCapital = 1,
  12670. // CreateUserId = 208,
  12671. // CreateTime = DateTime.Now,
  12672. // IsDel = 0
  12673. // };
  12674. // if (item2.c != null)
  12675. // {
  12676. // int cityId = 0;
  12677. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12678. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12679. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12680. // foreach (var item3 in item2.c)
  12681. // {
  12682. // if (item3.lv == "district")
  12683. // {
  12684. // var districtInfo = new Sys_Cities()
  12685. // {
  12686. // CountriesId = countriesId,
  12687. // Name_CN = item3.cn,
  12688. // Name_EN = item3.en,
  12689. // Level = 3,
  12690. // ParentId = cityId,
  12691. // IsCapital = 1,
  12692. // CreateUserId = 208,
  12693. // CreateTime = DateTime.Now,
  12694. // IsDel = 0
  12695. // };
  12696. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12697. // //{
  12698. // districts.Add(districtInfo);
  12699. // //}
  12700. // }
  12701. // }
  12702. // }
  12703. // else
  12704. // {
  12705. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12706. // //{
  12707. // cities.Add(cityInfo);
  12708. // //}
  12709. // }
  12710. // }
  12711. // }
  12712. // }
  12713. // else if (item1.lv == "city")//城市
  12714. // {
  12715. // provinceInfo.Level = 2;
  12716. // if (item1.c != null)
  12717. // {
  12718. // int cityId = 0;
  12719. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12720. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12721. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12722. // foreach (var item3 in item1.c)
  12723. // {
  12724. // if (item3.lv == "district")
  12725. // {
  12726. // var districtInfo = new Sys_Cities()
  12727. // {
  12728. // CountriesId = countriesId,
  12729. // Name_CN = item3.cn,
  12730. // Name_EN = item3.en,
  12731. // Level = 3,
  12732. // ParentId = cityId,
  12733. // IsCapital = 1,
  12734. // CreateUserId = 208,
  12735. // CreateTime = DateTime.Now,
  12736. // IsDel = 0
  12737. // };
  12738. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12739. // //{
  12740. // districts.Add(districtInfo);
  12741. // //}
  12742. // }
  12743. // }
  12744. // }
  12745. // else
  12746. // {
  12747. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12748. // //{
  12749. // cities.Add(provinceInfo);
  12750. // //}
  12751. // }
  12752. // }
  12753. // }
  12754. // }
  12755. // }
  12756. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12757. // cities = cities.Distinct().ToList();
  12758. // districts = districts.Distinct().ToList();
  12759. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12760. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12761. // cities.AddRange(districts);
  12762. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12763. // //_sqlSugar.RollbackTran();
  12764. // _sqlSugar.CommitTran();
  12765. // return Ok(JsonView(false, "操作成功!"));
  12766. //}
  12767. //[HttpPost]
  12768. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12769. //{
  12770. // List<CountitiesInfo> infos = dto.MyProperty;
  12771. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12772. // _sqlSugar.BeginTran();
  12773. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12774. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12775. // foreach (var item in infos)
  12776. // {
  12777. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12778. // if (countryInfo != null)
  12779. // {
  12780. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12781. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12782. // if (cityInfo1 != null)
  12783. // {
  12784. // cityInfo1.IsCapital = 0;
  12785. // cityInfos.Add(cityInfo1);
  12786. // }
  12787. // }
  12788. // }
  12789. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12790. // .UpdateColumns(it => it.IsCapital)
  12791. // .WhereColumns(it => it.Id)
  12792. // .ExecuteCommand();
  12793. // //_sqlSugar.RollbackTran();
  12794. // _sqlSugar.CommitTran();
  12795. // return Ok(JsonView(false, "操作成功!"));
  12796. //}
  12797. //public class CounrtiesDto
  12798. //{
  12799. // public List<CountitiesInfo> MyProperty { get; set; }
  12800. //}
  12801. //public class CountitiesInfo
  12802. //{
  12803. // /// <summary>
  12804. // /// 圣约翰
  12805. // /// </summary>
  12806. // public string capital_name_chinese { get; set; }
  12807. // /// <summary>
  12808. // ///
  12809. // /// </summary>
  12810. // public string capital_name { get; set; }
  12811. // /// <summary>
  12812. // ///
  12813. // /// </summary>
  12814. // public string country_type { get; set; }
  12815. // /// <summary>
  12816. // /// 安提瓜和巴布达
  12817. // /// </summary>
  12818. // public string country_name_chinese { get; set; }
  12819. // /// <summary>
  12820. // /// 安提瓜和巴布达
  12821. // /// </summary>
  12822. // public string country_name_chinese_short { get; set; }
  12823. // /// <summary>
  12824. // /// 安提瓜和巴布达
  12825. // /// </summary>
  12826. // public string country_name_chinese_UN { get; set; }
  12827. // /// <summary>
  12828. // ///
  12829. // /// </summary>
  12830. // public string country_name_english_abbreviation { get; set; }
  12831. // /// <summary>
  12832. // ///
  12833. // /// </summary>
  12834. // public string country_name_english_formal { get; set; }
  12835. // /// <summary>
  12836. // ///
  12837. // /// </summary>
  12838. // public string country_name_english_UN { get; set; }
  12839. // /// <summary>
  12840. // ///
  12841. // /// </summary>
  12842. // public string continent_name { get; set; }
  12843. // /// <summary>
  12844. // ///
  12845. // /// </summary>
  12846. // public string subregion_name { get; set; }
  12847. // /// <summary>
  12848. // ///
  12849. // /// </summary>
  12850. // public string country_code2 { get; set; }
  12851. // /// <summary>
  12852. // ///
  12853. // /// </summary>
  12854. // public string country_code3 { get; set; }
  12855. // /// <summary>
  12856. // ///
  12857. // /// </summary>
  12858. // public string phone_code { get; set; }
  12859. //}
  12860. //public class CountriesInfo : BasicInfo
  12861. //{
  12862. // public List<CitiesInfo> c { get; set; }
  12863. //}
  12864. //public class CitiesInfo : BasicInfo
  12865. //{
  12866. // public List<AreaInfo> c { get; set; }
  12867. //}
  12868. //public class AreaInfo : BasicInfo
  12869. //{
  12870. // public List<AreaInfo> c { get; set; }
  12871. //}
  12872. //public class BasicInfo
  12873. //{
  12874. // public string code { get; set; }
  12875. // public string cn { get; set; }
  12876. // public string lv { get; set; }
  12877. // public string en { get; set; }
  12878. //}
  12879. #endregion
  12880. #region 查看邀请方
  12881. /// <summary>
  12882. /// 查看邀请方
  12883. /// 邀请方信息 Init
  12884. /// </summary>
  12885. /// <param name="dto"></param>
  12886. /// <returns></returns>
  12887. [HttpPost]
  12888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12889. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12890. {
  12891. string sqlWhere = string.Empty;
  12892. if (!string.IsNullOrEmpty(dto.Search))
  12893. {
  12894. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12895. }
  12896. string sql = string.Format($@"Select
  12897. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12898. Id,
  12899. UnitName
  12900. From Res_InvitationOfficialActivityData
  12901. Where IsDel = 0
  12902. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12903. RefAsync<int> total = 0;
  12904. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12905. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12906. }
  12907. /// <summary>
  12908. /// 查看邀请方
  12909. /// 国家信息 Init
  12910. /// </summary>
  12911. /// <param name="dto"></param>
  12912. /// <returns></returns>
  12913. [HttpPost]
  12914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12915. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12916. {
  12917. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12918. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12919. var diids = groupInfos.Select(it => it.Id).ToList();
  12920. List<string> countrys = new List<string>();
  12921. foreach (var item in country)
  12922. {
  12923. var data = _groupRepository.FormartTeamName(item);
  12924. var dataArray = _groupRepository.GroupSplitCountry(data);
  12925. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12926. }
  12927. countrys = countrys.Distinct().ToList();
  12928. for (int i = 0; i < countrys.Count; i++)
  12929. {
  12930. string item = countrys[i];
  12931. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12932. {
  12933. countrys.Remove(item);
  12934. i--;
  12935. }
  12936. }
  12937. RefAsync<int> total = 0;
  12938. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12939. .Where(it => countrys.Contains(it.Name_CN))
  12940. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12941. .Select(it => new { id = it.Id, name = it.Name_CN })
  12942. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12943. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12944. }
  12945. /// <summary>
  12946. /// 查看邀请方
  12947. /// 城市信息 Init
  12948. /// </summary>
  12949. /// <param name="dto"></param>
  12950. /// <returns></returns>
  12951. [HttpPost]
  12952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12953. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12954. {
  12955. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12956. RefAsync<int> total = 0;
  12957. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12958. .Where(it => it.CountriesId == dto.CountiesId)
  12959. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12960. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12961. .Select(it => new { id = it.Id, name = it.Name_CN })
  12962. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12963. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12964. }
  12965. /// <summary>
  12966. /// 查看邀请方
  12967. /// 团组名称 Init
  12968. /// </summary>
  12969. /// <param name="dto"></param>
  12970. /// <returns></returns>
  12971. [HttpPost]
  12972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12973. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12974. {
  12975. var watch = new Stopwatch();
  12976. watch.Start();
  12977. RefAsync<int> total = 0;
  12978. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12979. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12980. .Where((oa, di) => oa.IsDel == 0)
  12981. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12982. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12983. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12984. .Distinct()
  12985. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12986. watch.Stop();
  12987. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12988. }
  12989. /// <summary>
  12990. /// 查看邀请方
  12991. /// 团组 & 邀请方信息
  12992. /// </summary>
  12993. /// <param name="dto"></param>
  12994. /// <returns></returns>
  12995. [HttpPost]
  12996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12997. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12998. {
  12999. var watch = new Stopwatch();
  13000. watch.Start();
  13001. RefAsync<int> total = 0;
  13002. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  13003. .AS("Grp_DelegationInfo")
  13004. .Includes(x => x.InvitingInfos)
  13005. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  13006. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  13007. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  13008. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  13009. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  13010. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  13011. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13012. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  13013. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  13014. infos.ForEach(x =>
  13015. {
  13016. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  13017. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  13018. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  13019. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  13020. });
  13021. watch.Stop();
  13022. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  13023. }
  13024. #endregion
  13025. #region 报批行程
  13026. /// <summary>
  13027. /// 报批行程初始化
  13028. /// </summary>
  13029. /// <param name="dto"></param>
  13030. /// <returns></returns>
  13031. [HttpPost]
  13032. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  13033. {
  13034. const int chiNumber = 5;
  13035. var jw = JsonView(false);
  13036. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  13037. var group = groupList.First();
  13038. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13039. group = groupList.First(x => x.Id == diid);
  13040. if (group == null)
  13041. {
  13042. jw.Msg = "暂无团组!";
  13043. return Ok(jw);
  13044. }
  13045. var data = new
  13046. {
  13047. groupList = groupList.Select(x => new
  13048. {
  13049. x.TeamName,
  13050. x.Id
  13051. }),
  13052. content = new ArrayList(),
  13053. groupInfo = new
  13054. {
  13055. group.VisitDays,
  13056. group.TourCode,
  13057. group.VisitPNumber,
  13058. group.TeamName,
  13059. group.Id,
  13060. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  13061. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  13062. },
  13063. };
  13064. var resultArr = new ArrayList();
  13065. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  13066. if (content.Count == 0)
  13067. {
  13068. var stay = "-";
  13069. var cityPath = "-";
  13070. //添加城市路径以及住宿地
  13071. //黑屏代码数据
  13072. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13073. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13074. {
  13075. jw = JsonView(true, "黑屏代码有误!", data);
  13076. return Ok(jw);
  13077. }
  13078. foreach (DataRow row in dtBlack.Rows)
  13079. {
  13080. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13081. {
  13082. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  13083. return Ok(jw);
  13084. }
  13085. }
  13086. //黑屏代码获取时间区间
  13087. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13088. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13089. _sqlSugar.BeginTran();
  13090. for (int i = 0; i < timeArr.Count; i++)
  13091. {
  13092. stay = "-";
  13093. cityPath = "-";
  13094. DateTime NewData = DateTime.Parse(timeArr[i]);
  13095. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13096. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13097. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13098. if (tbSelect.Length > 0)
  13099. {
  13100. List<string> threeCodeStr = new List<string>();
  13101. foreach (var item in tbSelect)
  13102. {
  13103. var threeCode = item["Three"].ToString() ?? "";
  13104. if (threeCode.Length == 6)
  13105. {
  13106. var start = threeCode.Substring(0, 3);
  13107. var end = threeCode.Substring(3, 3);
  13108. if (threeCodeStr.Count == 0)
  13109. {
  13110. threeCodeStr.Add(start);
  13111. threeCodeStr.Add(end);
  13112. }
  13113. else
  13114. {
  13115. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13116. {
  13117. threeCodeStr.Add(end);
  13118. }
  13119. else
  13120. {
  13121. threeCodeStr.Add(start);
  13122. threeCodeStr.Add(end);
  13123. }
  13124. }
  13125. }
  13126. }
  13127. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13128. var last = threeCodeStr.Last();
  13129. foreach (var item in threeCodeStr)
  13130. {
  13131. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13132. if (item.Equals(last))
  13133. {
  13134. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13135. }
  13136. }
  13137. cityPath = cityPath.Trim('-');
  13138. }
  13139. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13140. appro.Diid = diid ?? -1;
  13141. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13142. appro.Id = thisId;
  13143. appro.CreateUserId = dto.UserId;
  13144. appro.CreateTime = DateTime.Now;
  13145. content.Add(appro);
  13146. }
  13147. _sqlSugar.CommitTran();
  13148. }
  13149. foreach (var x in content)
  13150. {
  13151. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  13152. if (chiList.Count < chiNumber)
  13153. {
  13154. for (int i = chiList.Count; i < chiNumber; i++)
  13155. {
  13156. chiList.Add(new Grp_ApprovalTravelDetails());
  13157. }
  13158. }
  13159. resultArr.Add(new
  13160. {
  13161. x.Id,
  13162. x.Date,
  13163. x.Diid,
  13164. chiList = chiList.Select(x1 => new
  13165. {
  13166. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13167. x1.Details,
  13168. x1.ParentId,
  13169. x1.Id
  13170. })
  13171. });
  13172. }
  13173. data = data with
  13174. {
  13175. content = resultArr,
  13176. };
  13177. jw = JsonView(true, "获取成功!", data);
  13178. return Ok(jw);
  13179. }
  13180. /// <summary>
  13181. /// 报批行程删除
  13182. /// </summary>
  13183. /// <param name="dto"></param>
  13184. /// <returns></returns>
  13185. [HttpPost]
  13186. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  13187. {
  13188. var jw = JsonView(false);
  13189. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13190. if (group == null)
  13191. {
  13192. jw.Msg = "团组参数有误!";
  13193. return Ok(jw);
  13194. }
  13195. try
  13196. {
  13197. _sqlSugar.BeginTran();
  13198. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  13199. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  13200. {
  13201. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13202. DeleteUserId = dto.uesrId,
  13203. IsDel = 1
  13204. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  13205. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  13206. {
  13207. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13208. DeleteUserId = dto.uesrId,
  13209. IsDel = 1
  13210. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  13211. _sqlSugar.CommitTran();
  13212. jw = JsonView(true, "删除成功");
  13213. }
  13214. catch (Exception ex)
  13215. {
  13216. jw = JsonView(false, ex.Message);
  13217. }
  13218. return Ok(jw);
  13219. }
  13220. /// <summary>
  13221. /// 报批行程保存
  13222. /// </summary>
  13223. /// <param name="dto"></param>
  13224. /// <returns></returns>
  13225. [HttpPost]
  13226. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  13227. {
  13228. var jw = JsonView(false);
  13229. var Find = dto.Arr.Find(x => x.id == 0);
  13230. if (Find != null)
  13231. {
  13232. jw.Msg = "生成的ID为0!";
  13233. return Ok(jw);
  13234. }
  13235. foreach (var item in dto.Arr)
  13236. {
  13237. foreach (var chi in item.chiList)
  13238. {
  13239. if (chi.parentId == 0)
  13240. {
  13241. chi.parentId = item.id;
  13242. }
  13243. }
  13244. }
  13245. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  13246. _sqlSugar.BeginTran();
  13247. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  13248. {
  13249. var parentIds = dto.Arr.Select(x => x.id).ToList();
  13250. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  13251. {
  13252. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13253. DeleteUserId = dto.UserId,
  13254. IsDel = 1
  13255. }).ExecuteCommand();
  13256. }
  13257. try
  13258. {
  13259. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  13260. {
  13261. CreateTime = DateTime.Now,
  13262. CreateUserId = dto.UserId,
  13263. Details = x.details,
  13264. ParentId = x.parentId,
  13265. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13266. Remark = "",
  13267. IsDel = 0
  13268. }).ToList()).ExecuteCommand();
  13269. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  13270. {
  13271. Id = x.id,
  13272. Details = x.details,
  13273. ParentId = x.parentId,
  13274. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13275. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  13276. {
  13277. Details = x.Details,
  13278. ParentId = x.ParentId,
  13279. Time = x.Time
  13280. }).ExecuteCommand();
  13281. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  13282. {
  13283. Id = x.id,
  13284. Date = x.date,
  13285. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13286. {
  13287. Date = x.Date
  13288. }).ExecuteCommand();
  13289. _sqlSugar.CommitTran();
  13290. jw = JsonView(true, "保存成功!");
  13291. }
  13292. catch (Exception ex)
  13293. {
  13294. _sqlSugar.RollbackTran();
  13295. jw = JsonView(false, "保存失败!" + ex.Message);
  13296. }
  13297. return Ok(jw);
  13298. }
  13299. /// <summary>
  13300. /// 报批行程生成
  13301. /// </summary>
  13302. /// <param name="dto"></param>
  13303. /// <returns></returns>
  13304. [HttpPost]
  13305. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13306. {
  13307. var jw = JsonView(false);
  13308. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13309. if (group == null)
  13310. {
  13311. jw.Msg = "暂无该团组!";
  13312. return Ok(jw);
  13313. }
  13314. //黑屏代码数据
  13315. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13316. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13317. {
  13318. jw.Msg = "黑屏代码有误!";
  13319. return Ok(jw);
  13320. }
  13321. foreach (DataRow row in dtBlack.Rows)
  13322. {
  13323. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13324. {
  13325. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13326. return Ok(jw);
  13327. }
  13328. }
  13329. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13330. var resultArr = new ArrayList();
  13331. if (officialActivitiesArr.Count == 0)
  13332. {
  13333. jw.Msg = "暂无公务出访信息!";
  13334. return Ok(jw);
  13335. }
  13336. try
  13337. {
  13338. _sqlSugar.BeginTran();
  13339. DeleteApprovalJourney(new
  13340. Domain.Dtos.Groups.DeleteApprovalJourney
  13341. {
  13342. Diid = dto.Diid,
  13343. uesrId = dto.Userid
  13344. });
  13345. var stay = "-";
  13346. var cityPath = "-";
  13347. //添加城市路径以及住宿地
  13348. //黑屏代码获取时间区间
  13349. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13350. var empty = "【未收入该三字码!请机票同事录入】";
  13351. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13352. for (int i = 0; i < timeArr.Count; i++)
  13353. {
  13354. stay = "-";
  13355. cityPath = "-";
  13356. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13357. DateTime NewData = DateTime.Parse(timeArr[i]);
  13358. 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();
  13359. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13360. if (tbSelect.Length > 0)
  13361. {
  13362. List<string> threeCodeStr = new List<string>();
  13363. bool isTrade = false;
  13364. string trip = string.Empty;
  13365. var rowLast = tbSelect.Last();
  13366. var rowFirst = tbSelect.First();
  13367. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13368. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13369. var takeOffTime = DateTime.Parse(timeArr[i]);
  13370. var fallToTime = DateTime.Parse(timeArr[i]);
  13371. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13372. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13373. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13374. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13375. foreach (var item in tbSelect)
  13376. {
  13377. var start = string.Empty;
  13378. var end = string.Empty;
  13379. var threeCode = item["Three"].ToString() ?? "";
  13380. if (threeCode.Length == 6)
  13381. {
  13382. start = threeCode.Substring(0, 3);
  13383. end = threeCode.Substring(3, 3);
  13384. if (threeCodeStr.Count == 0)
  13385. {
  13386. threeCodeStr.Add(start);
  13387. threeCodeStr.Add(end);
  13388. }
  13389. else
  13390. {
  13391. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13392. {
  13393. threeCodeStr.Add(end);
  13394. }
  13395. else
  13396. {
  13397. threeCodeStr.Add(start);
  13398. threeCodeStr.Add(end);
  13399. }
  13400. }
  13401. }
  13402. //处理机票信息
  13403. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13404. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13405. if (start_Object == null)
  13406. {
  13407. start_Object = new Res_ThreeCode()
  13408. {
  13409. AirPort = empty,
  13410. AirPort_En = empty,
  13411. City = empty,
  13412. Country = empty,
  13413. Four = empty,
  13414. Three = empty,
  13415. };
  13416. }
  13417. if (end_Object == null)
  13418. {
  13419. end_Object = new Res_ThreeCode()
  13420. {
  13421. AirPort = empty,
  13422. AirPort_En = empty,
  13423. City = empty,
  13424. Country = empty,
  13425. Four = empty,
  13426. Three = empty,
  13427. };
  13428. }
  13429. //机型判断
  13430. string airModel = item["AirModel"].ToString();
  13431. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13432. string flightTime = item["FlightTime"].ToString();
  13433. if (flightTime!.Contains(":"))
  13434. {
  13435. flightTime = flightTime.Replace(":", "小时");
  13436. flightTime += "分钟";
  13437. }
  13438. if (flightTime.Contains("H"))
  13439. {
  13440. flightTime = flightTime.Replace("H", "小时");
  13441. }
  13442. if (flightTime.Contains("M"))
  13443. {
  13444. flightTime = flightTime.Replace("M", "分钟");
  13445. }
  13446. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13447. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13448. {
  13449. flightTime = flightDataTime.Hour > 0
  13450. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13451. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13452. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13453. }
  13454. //航班号
  13455. string flightcode = item["Fliagtcode"].ToString();
  13456. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13457. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13458. if (aircompany == null)
  13459. {
  13460. aircompany = new Res_AirCompany
  13461. {
  13462. CnName = hsEmpty,
  13463. EnName = hsEmpty,
  13464. ShortCode = hsEmpty,
  13465. };
  13466. }
  13467. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13468. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13469. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13470. if (isTrade)
  13471. {
  13472. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13473. }
  13474. else
  13475. {
  13476. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13477. }
  13478. }
  13479. chiarr.Add(new Grp_ApprovalTravelDetails
  13480. {
  13481. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13482. CreateTime = DateTime.Now,
  13483. CreateUserId = dto.Userid,
  13484. ParentId = 0,
  13485. Details = trip
  13486. });
  13487. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13488. var last = threeCodeStr.Last();
  13489. foreach (var item in threeCodeStr)
  13490. {
  13491. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13492. if (item.Equals(last))
  13493. {
  13494. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13495. }
  13496. }
  13497. cityPath = cityPath.Trim('-');
  13498. }
  13499. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13500. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13501. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13502. appro.Diid = dto.Diid;
  13503. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13504. appro.Id = thisId;
  13505. appro.CreateUserId = dto.Userid;
  13506. appro.CreateTime = DateTime.Now;
  13507. foreach (var item in gwinfo)
  13508. {
  13509. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13510. chi.Details = "拜访" + item.Client;
  13511. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13512. {
  13513. chi.Details += "," + item.ReqSample;
  13514. }
  13515. chi.ParentId = thisId;
  13516. chi.Time = item.Time;
  13517. chiarr.Add(chi);
  13518. }
  13519. if (chiarr.Count < 5)
  13520. {
  13521. for (int j = chiarr.Count; j < 5; j++)
  13522. {
  13523. chiarr.Add(new
  13524. Grp_ApprovalTravelDetails());
  13525. }
  13526. }
  13527. resultArr.Add(new
  13528. {
  13529. appro.Id,
  13530. appro.Date,
  13531. appro.Diid,
  13532. chiList = chiarr.Select(x1 => new
  13533. {
  13534. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13535. x1.Details,
  13536. x1.ParentId,
  13537. x1.Id
  13538. })
  13539. });
  13540. }
  13541. _sqlSugar.CommitTran();
  13542. jw = JsonView(true, "生成成功!", resultArr);
  13543. }
  13544. catch (Exception ex)
  13545. {
  13546. jw.Code = 400;
  13547. jw.Msg = "生成失败!" + ex.Message;
  13548. }
  13549. return Ok(jw);
  13550. }
  13551. /// <summary>
  13552. /// 报批行程word导出
  13553. /// </summary>
  13554. /// <param name="dto"></param>
  13555. /// <returns></returns>
  13556. [HttpPost]
  13557. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13558. {
  13559. var jw = JsonView(false);
  13560. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13561. if (group == null)
  13562. {
  13563. jw.Msg = "暂无该团组!";
  13564. return Ok(jw);
  13565. }
  13566. //模板路径
  13567. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13568. //载入模板
  13569. Document doc = new Document(tempPath);
  13570. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13571. //获取所填表格的序数
  13572. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13573. Aspose.Words.Tables.Row titleRowClone = null;
  13574. Aspose.Words.Tables.Row CenterRowClone = null;
  13575. int index = 0;
  13576. int indexChi = 0;
  13577. int SetIndex = 0;
  13578. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13579. //获取数据,放到datatable
  13580. foreach (var item in ApprovalTravelArr)
  13581. {
  13582. if (index > 0)
  13583. {
  13584. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13585. tableOne.AppendChild(titleRowClone);
  13586. }
  13587. var textTime = item.Date;
  13588. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13589. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13590. SetIndex++;
  13591. if (ChiRep.Count > 0)
  13592. {
  13593. foreach (var itemChi in ChiRep)
  13594. {
  13595. var txtTime = itemChi.Time;
  13596. var txtDetail = itemChi.Details;
  13597. if (indexChi > 0)
  13598. {
  13599. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13600. tableOne.AppendChild(CenterRowClone);
  13601. }
  13602. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13603. {
  13604. SetCells(tableOne, doc, SetIndex, 0, "");
  13605. SetCells(tableOne, doc, SetIndex, 1, "");
  13606. indexChi++;
  13607. SetIndex++;
  13608. break;
  13609. }
  13610. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13611. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13612. indexChi++;
  13613. SetIndex++;
  13614. }
  13615. }
  13616. else
  13617. {
  13618. if (indexChi > 0)
  13619. {
  13620. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13621. tableOne.AppendChild(CenterRowClone);
  13622. }
  13623. SetCells(tableOne, doc, SetIndex, 0, "");
  13624. SetCells(tableOne, doc, SetIndex, 1, "");
  13625. indexChi++;
  13626. SetIndex++;
  13627. }
  13628. index++;
  13629. }
  13630. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13631. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13632. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13633. jw.Code = 200;
  13634. jw.Msg = "";
  13635. return Ok(jw);
  13636. }
  13637. private string intToString(int numberVal)
  13638. {
  13639. string numberval = numberVal.ToString();
  13640. Dictionary<char, string> Number = new Dictionary<char, string>();
  13641. Number.Add('1', "一");
  13642. Number.Add('2', "二");
  13643. Number.Add('3', "三");
  13644. Number.Add('4', "四");
  13645. Number.Add('5', "五");
  13646. Number.Add('6', "六");
  13647. Number.Add('7', "七");
  13648. Number.Add('8', "八");
  13649. Number.Add('9', "九");
  13650. string stringNumberVal = string.Empty;
  13651. for (int i = 0; i < numberval.Length; i++)
  13652. {
  13653. if (i == 0)
  13654. {
  13655. stringNumberVal += Number[numberval[i]];
  13656. }
  13657. else if (i >= 1)
  13658. {
  13659. if (numberval[i] == '0')
  13660. {
  13661. stringNumberVal = "十";
  13662. }
  13663. else
  13664. {
  13665. stringNumberVal += "十" + Number[numberval[i]];
  13666. }
  13667. }
  13668. }
  13669. return stringNumberVal;
  13670. }
  13671. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13672. {
  13673. //获取table中的某个单元格,从0开始
  13674. Cell lshCell = table.Rows[rows].Cells[cells];
  13675. //将单元格中段落移除
  13676. foreach (Node item in lshCell.Paragraphs)
  13677. {
  13678. lshCell.Paragraphs.Remove(item);
  13679. }
  13680. if (val.Contains("\r\n"))
  13681. {
  13682. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13683. foreach (var item in spArr)
  13684. {
  13685. //新建一个段落
  13686. Paragraph p = new Paragraph(doc);
  13687. var r = new Run(doc, item);
  13688. //把设置的值赋给之前新建的段落
  13689. p.AppendChild(r);
  13690. //将此段落加到单元格内
  13691. lshCell.AppendChild(p);
  13692. }
  13693. }
  13694. else
  13695. {
  13696. //新建一个段落
  13697. Paragraph p = new Paragraph(doc);
  13698. var r = new Run(doc, val);
  13699. //把设置的值赋给之前新建的段落
  13700. p.AppendChild(r);
  13701. //将此段落加到单元格内
  13702. lshCell.AppendChild(p);
  13703. }
  13704. }
  13705. [HttpPost]
  13706. public async Task<IActionResult> ServerHttp(string paramStr)
  13707. {
  13708. paramStr = paramStr.TrimEnd('\'');
  13709. paramStr = paramStr.TrimStart('\'');
  13710. JsonView jw = JsonView(false);
  13711. JObject param = JObject.Parse(paramStr);
  13712. if (!param.ContainsKey("url"))
  13713. {
  13714. jw.Msg = "url null";
  13715. return Ok(jw);
  13716. }
  13717. string url = param["url"]!.ToString();
  13718. var methon = "get";
  13719. Dictionary<string, string> headValues = null;
  13720. string bodyStr = string.Empty;
  13721. if (param.ContainsKey("methon"))
  13722. {
  13723. methon = param["methon"]!.ToString().ToLower();
  13724. }
  13725. if (param.ContainsKey("header"))
  13726. {
  13727. var header = param["header"]!.ToString();
  13728. JObject headerJobject = JObject.Parse(header);
  13729. headValues = new Dictionary<string, string>();
  13730. foreach (JProperty item in headerJobject.Properties())
  13731. {
  13732. var value = item.Value.ToString();
  13733. var head = item.Path;
  13734. headValues.Add(head, value);
  13735. }
  13736. }
  13737. HttpClient client = new HttpClient();
  13738. string responseString = string.Empty;
  13739. StringContent content = null;
  13740. if (headValues != null)
  13741. {
  13742. foreach (var item in headValues.Keys)
  13743. {
  13744. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13745. {
  13746. if (param.ContainsKey("body"))
  13747. {
  13748. bodyStr = param["body"]!.ToString();
  13749. }
  13750. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13751. }
  13752. else
  13753. {
  13754. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13755. }
  13756. }
  13757. }
  13758. try
  13759. {
  13760. if (methon == "get")
  13761. {
  13762. responseString = await client.GetStringAsync(url);
  13763. }
  13764. else if (methon == "post")
  13765. {
  13766. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13767. {
  13768. Content = content
  13769. };
  13770. var response = await client.SendAsync(request);
  13771. try
  13772. {
  13773. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13774. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13775. {
  13776. using (StreamReader reader = new StreamReader(gzipStream))
  13777. {
  13778. responseString = await reader.ReadToEndAsync();
  13779. }
  13780. }
  13781. }
  13782. catch (Exception)
  13783. {
  13784. responseString = await response.Content.ReadAsStringAsync();
  13785. }
  13786. }
  13787. else
  13788. {
  13789. responseString = "methon error";
  13790. }
  13791. jw = JsonView(true, "success", responseString);
  13792. }
  13793. catch (Exception ex)
  13794. {
  13795. jw.Msg = "error " + ex.Message;
  13796. jw.Data = ex.StackTrace;
  13797. }
  13798. finally
  13799. {
  13800. client.Dispose();
  13801. }
  13802. return Ok(jw);
  13803. }
  13804. #endregion
  13805. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13806. /// <summary>
  13807. /// 团组接待意见调查 - 信息管理
  13808. /// 基础数据(团组)
  13809. /// </summary>
  13810. /// <param name="dto"></param>
  13811. /// <returns></returns>
  13812. [HttpGet]
  13813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13814. public async Task<IActionResult> OpinionaireInit()
  13815. {
  13816. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13817. .Select(x => new
  13818. {
  13819. x.Id,
  13820. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13821. })
  13822. .OrderByDescending(x => x.Id)
  13823. .ToListAsync();
  13824. return Ok(JsonView(groupData, groupData.Count));
  13825. }
  13826. /// <summary>
  13827. /// 团组接待意见调查 - 信息管理
  13828. /// 列表
  13829. /// </summary>
  13830. /// <param name="groupId"></param>
  13831. /// <returns></returns>
  13832. [HttpGet("{groupId}")]
  13833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13834. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13835. {
  13836. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13837. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13838. .Select(x => new
  13839. {
  13840. x.Id,
  13841. x.TourGuideName,
  13842. x.CityName,
  13843. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13844. x.CreateTime
  13845. })
  13846. .OrderBy(x => x.Id)
  13847. .ToListAsync();
  13848. return Ok(JsonView(data));
  13849. }
  13850. /// <summary>
  13851. /// 团组接待意见调查 - 信息管理
  13852. /// 保存
  13853. /// </summary>
  13854. /// <param name="dto"></param>
  13855. /// <returns></returns>
  13856. [HttpPost]
  13857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13858. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  13859. {
  13860. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13861. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13862. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13863. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  13864. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  13865. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  13866. _opinionaireRep.BeginTran();
  13867. if (addData != null && addData.Count > 0)
  13868. {
  13869. foreach (var item in addData)
  13870. {
  13871. item.CreateUserId = currUserInfo.UserId;
  13872. item.DiId = dto.DiId;
  13873. }
  13874. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  13875. }
  13876. if (updData != null && updData.Count > 0)
  13877. {
  13878. var upd = await _opinionaireRep._sqlSugar
  13879. .Updateable(updData)
  13880. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  13881. .WhereColumns(x => new { x.Id })
  13882. .ExecuteCommandAsync();
  13883. }
  13884. _opinionaireRep.CommitTran();
  13885. return Ok(JsonView("操作成功!"));
  13886. }
  13887. /// <summary>
  13888. /// 团组接待意见调查 - 信息管理
  13889. /// 删除
  13890. /// </summary>
  13891. /// <param name="id"></param>
  13892. /// <returns></returns>
  13893. [HttpDelete("{id}")]
  13894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13895. public async Task<IActionResult> OpinionaireManageDel(int id)
  13896. {
  13897. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13898. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13899. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  13900. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  13901. if (!del) return Ok(JsonView("操作失败!"));
  13902. return Ok(JsonView("操作成功!"));
  13903. }
  13904. /// <summary>
  13905. /// 团组接待意见调查 - 用户
  13906. /// 列表
  13907. /// </summary>
  13908. /// <param name="id"></param>
  13909. /// <returns></returns>
  13910. [HttpGet("{diId}")]
  13911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13912. public async Task<IActionResult> OpinionaireUserList(int diId)
  13913. {
  13914. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13915. var sql = string.Format(@"
  13916. SELECT
  13917. o.Id,
  13918. o.DiId,
  13919. di.TeamName AS 'GroupName',
  13920. di.VisitPNumber AS 'PeopleNumber',
  13921. di.ClientName AS 'LeadGroup',
  13922. di.VisitCountry AS 'Travel',
  13923. di.VisitDays AS 'Days',
  13924. o.CityName,
  13925. o.TourGuideName,
  13926. o.Catering,
  13927. o.CateringReason,
  13928. o.Stay,
  13929. o.StayReason,
  13930. o.[Route],
  13931. o.RouteReason,
  13932. o.OfficialActivity,
  13933. o.OfficialActivityReason,
  13934. o.TourGuide,
  13935. o.TourGuideReason,
  13936. o.[Translate],
  13937. o.TranslateReason,
  13938. o.Trip,
  13939. o.TripReason,
  13940. o.ESFileName,
  13941. o.SignatureDate,
  13942. o.Remark
  13943. FROM
  13944. Grp_Opinionaire o
  13945. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  13946. WHERE
  13947. o.IsDel = 0
  13948. AND o.DiId = {0}
  13949. ORDER BY
  13950. o.Id ASC", diId);
  13951. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  13952. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  13953. return Ok(JsonView(data));
  13954. }
  13955. /// <summary>
  13956. /// 团组接待意见调查 - 用户
  13957. /// 保存
  13958. /// </summary>
  13959. /// <param name="id"></param>
  13960. /// <returns></returns>
  13961. [HttpPost]
  13962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13963. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  13964. {
  13965. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  13966. foreach (var item in dto)
  13967. {
  13968. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  13969. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  13970. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  13971. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  13972. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  13973. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  13974. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  13975. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  13976. }
  13977. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  13978. if (!Directory.Exists(filePathBase))
  13979. {
  13980. Directory.CreateDirectory(filePathBase);
  13981. }
  13982. #region 上传文件
  13983. var filePaths = new List<string>();
  13984. foreach (var item in dto)
  13985. {
  13986. var file = item.File;
  13987. // 将文件保存到指定位置
  13988. var filePath = Path.Combine(filePathBase, file.FileName);
  13989. using (var stream = new FileStream(filePath, FileMode.Create))
  13990. {
  13991. await file.CopyToAsync(stream);
  13992. }
  13993. //验证文件是否上传成功
  13994. if (!System.IO.File.Exists(filePath))
  13995. {
  13996. foreach (var filePathStr in filePaths)
  13997. {
  13998. System.IO.File.Delete(filePathStr);
  13999. }
  14000. return Ok(JsonView(false, "文件上传失败!"));
  14001. }
  14002. item.ESFileName = file.FileName;
  14003. }
  14004. #endregion
  14005. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  14006. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  14007. .UpdateColumns(x => new
  14008. {
  14009. x.Catering,
  14010. x.CateringReason,
  14011. x.Stay,
  14012. x.StayReason,
  14013. x.Route,
  14014. x.RouteReason,
  14015. x.OfficialActivity,
  14016. x.OfficialActivityReason,
  14017. x.TourGuide,
  14018. x.TourGuideReason,
  14019. x.Translate,
  14020. x.TranslateReason,
  14021. x.Trip,
  14022. x.TripReason,
  14023. x.ESFileName,
  14024. x.SignatureDate,
  14025. x.Remark
  14026. })
  14027. .WhereColumns(x => new { x.Id })
  14028. .ExecuteCommandAsync();
  14029. if (upd < 1)
  14030. {
  14031. foreach (var filePathStr in filePaths)
  14032. {
  14033. System.IO.File.Delete(filePathStr);
  14034. }
  14035. return Ok(JsonView(false));
  14036. }
  14037. return Ok(JsonView(true));
  14038. }
  14039. #endregion
  14040. // /// <summary>
  14041. // ///
  14042. // /// </summary>
  14043. // /// <param name="_dto"></param>
  14044. // /// <returns></returns>
  14045. // [HttpPost]
  14046. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14047. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14048. // {
  14049. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14050. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  14051. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  14052. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14053. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  14054. // dic_psg.Add("客人", 974);
  14055. // dic_psg.Add("司机", 975);
  14056. // dic_psg.Add("导游", 976);
  14057. // dic_psg.Add("公司内部人员", 977);
  14058. // dic_psg.Add("司机/导游/公司内部人员", 978);
  14059. // foreach (var item in list_visa)
  14060. // {
  14061. // Grp_VisaInfo temp = new Grp_VisaInfo();
  14062. // temp.Id = item.Id;
  14063. // temp.DIId = item.DIId;
  14064. // temp.VisaClient = item.VisaClient;
  14065. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  14066. // temp.VisaCurrency = item.VisaCurrency;
  14067. // temp.IsThird = item.IsThird;
  14068. // if (dic_psg.ContainsKey(item.PassengerType))
  14069. // {
  14070. // temp.PassengerType = dic_psg[item.PassengerType];
  14071. // }
  14072. // else {
  14073. // temp.PassengerType = -1;
  14074. // }
  14075. // temp.VisaNumber = item.VisaNumber;
  14076. // temp.VisaFreeNumber = item.VisaFreeNumber;
  14077. // temp.CreateUserId = item.Operators;
  14078. // DateTime dt_ct;
  14079. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  14080. // if (b_ct)
  14081. // {
  14082. // temp.CreateTime = dt_ct;
  14083. // }
  14084. // else
  14085. // {
  14086. // temp.CreateTime = DateTime.Now;
  14087. // }
  14088. // temp.DeleteTime = "";
  14089. // temp.DeleteUserId = 0;
  14090. // temp.Remark = item.Remark;
  14091. // if (string.IsNullOrEmpty(temp.Remark)) {
  14092. // temp.Remark = "";
  14093. // }
  14094. // temp.IsDel = item.IsDel;
  14095. // temp.VisaDescription = item.VisaAttachment;
  14096. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  14097. //([Id]
  14098. // ,[DIId]
  14099. // ,[VisaClient]
  14100. // ,[VisaPrice]
  14101. // ,[VisaCurrency]
  14102. // ,[IsThird]
  14103. // ,[PassengerType]
  14104. // ,[VisaNumber]
  14105. // ,[VisaFreeNumber]
  14106. // ,[CreateUserId]
  14107. // ,[CreateTime]
  14108. // ,[DeleteTime]
  14109. // ,[DeleteUserId]
  14110. // ,[Remark]
  14111. // ,[IsDel]
  14112. // ,[visaDescription])
  14113. // VALUES
  14114. // ({0},{1},'{2}',{3},{4}
  14115. //,{5},{6},{7},{8},{9}
  14116. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  14117. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  14118. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  14119. //);
  14120. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  14121. // }
  14122. // return Ok(JsonView(true, "操作成功!"));
  14123. // }
  14124. /// <summary>
  14125. /// 123132123
  14126. /// </summary>
  14127. /// <param name="_dto"></param>
  14128. /// <returns></returns>
  14129. [HttpPost]
  14130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14131. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14132. {
  14133. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14134. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  14135. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  14136. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14137. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  14138. dicDetail.Add(789, 1034);
  14139. dicDetail.Add(790, 1035);
  14140. dicDetail.Add(791, 1036);
  14141. dicDetail.Add(792, 1037);
  14142. dicDetail.Add(793, 1038);
  14143. dicDetail.Add(794, 1039);
  14144. dicDetail.Add(795, 1040);
  14145. dicDetail.Add(796, 1041);
  14146. dicDetail.Add(797, 1042);
  14147. dicDetail.Add(798, 1043);
  14148. dicDetail.Add(801, 1044);
  14149. dicDetail.Add(802, 1045);
  14150. dicDetail.Add(803, 1046);
  14151. Dictionary<int, int> dic = new Dictionary<int, int>();
  14152. dic.Add(806, 1027);
  14153. dic.Add(807, 1028);
  14154. dic.Add(808, 1029);
  14155. dic.Add(809, 1030);
  14156. dic.Add(810, 1031);
  14157. dic.Add(811, 1032);
  14158. dic.Add(812, 1033);
  14159. foreach (var item in list_visa)
  14160. {
  14161. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  14162. temp.Coefficient = item.coefficient;
  14163. DateTime dtCrt;
  14164. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  14165. if (b1)
  14166. {
  14167. temp.CreateTime = dtCrt;
  14168. }
  14169. else
  14170. {
  14171. temp.CreateTime = DateTime.Now;
  14172. }
  14173. temp.CreateUserId = item.Operators;
  14174. temp.DeleteTime = "";
  14175. temp.DeleteUserId = 0;
  14176. temp.DiId = int.Parse(item.DIID);
  14177. temp.FilePath = item.FilePath;
  14178. temp.IsDel = item.IsDel;
  14179. temp.Price = item.Price;
  14180. temp.PriceCount = 1;
  14181. temp.PriceCurrency = item.Currency;
  14182. int detailId = 0;
  14183. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  14184. {
  14185. detailId = dicDetail[item.PriceTypeDetail];
  14186. }
  14187. temp.PriceDetailType = detailId;
  14188. temp.PriceDt = DateTime.Now;
  14189. temp.PriceName = item.PriceName;
  14190. temp.PriceSum = item.Price;
  14191. int tid = 0;
  14192. if (dic.ContainsKey(item.PriceType))
  14193. {
  14194. tid = dic[item.PriceType];
  14195. }
  14196. temp.PriceType = tid;
  14197. temp.Remark = item.Remark;
  14198. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  14199. }
  14200. return Ok(JsonView(true, "操作成功!"));
  14201. }
  14202. }
  14203. }