GroupsController.cs 763 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using EyeSoft.Collections.Generic;
  7. using EyeSoft.IO;
  8. using Microsoft.AspNetCore.SignalR;
  9. using MySqlX.XDevAPI.Relational;
  10. using NPOI.HSSF.UserModel;
  11. using NPOI.SS.Format;
  12. using NPOI.SS.Formula.Functions;
  13. using NPOI.SS.UserModel;
  14. using NPOI.SS.Util;
  15. using NPOI.XSSF.UserModel;
  16. using OASystem.API.OAMethodLib;
  17. using OASystem.API.OAMethodLib.File;
  18. using OASystem.API.OAMethodLib.Hub.HubClients;
  19. using OASystem.API.OAMethodLib.Hub.Hubs;
  20. using OASystem.API.OAMethodLib.JuHeAPI;
  21. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  22. using OASystem.Domain.Dtos.CRM;
  23. using OASystem.Domain.Dtos.FileDto;
  24. using OASystem.Domain.Dtos.Financial;
  25. using OASystem.Domain.Dtos.Groups;
  26. using OASystem.Domain.Entities.Customer;
  27. using OASystem.Domain.Entities.Financial;
  28. using OASystem.Domain.Entities.Groups;
  29. using OASystem.Domain.ViewModels;
  30. using OASystem.Domain.ViewModels.Groups;
  31. using OASystem.Domain.ViewModels.Statistics;
  32. using OASystem.Infrastructure.Repositories.Financial;
  33. using OASystem.Infrastructure.Repositories.Groups;
  34. using OfficeOpenXml;
  35. using Org.BouncyCastle.Asn1.Ocsp;
  36. using Quartz.Util;
  37. using SqlSugar;
  38. using SqlSugar.Extensions;
  39. using System.Collections;
  40. using System.Data;
  41. using System.Data.OleDb;
  42. using System.Diagnostics;
  43. using System.Globalization;
  44. using System.IO;
  45. using System.IO.Compression;
  46. using System.Net.Http;
  47. using System.Reflection.PortableExecutable;
  48. using System.Security.Cryptography;
  49. using Ubiety.Dns.Core;
  50. using static NPOI.POIFS.Crypt.CryptoFunctions;
  51. using static OASystem.API.OAMethodLib.JWTHelper;
  52. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  53. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  54. using Bookmark = Aspose.Words.Bookmark;
  55. using Cell = Aspose.Words.Tables.Cell;
  56. using Table = Aspose.Words.Tables.Table;
  57. namespace OASystem.API.Controllers
  58. {
  59. /// <summary>
  60. /// 团组相关
  61. /// </summary>
  62. //[Authorize]
  63. [Route("api/[controller]/[action]")]
  64. public class GroupsController : ControllerBase
  65. {
  66. private readonly ILogger<GroupsController> _logger;
  67. private readonly GrpScheduleRepository _grpScheduleRep;
  68. private readonly IMapper _mapper;
  69. private readonly DelegationInfoRepository _groupRepository;
  70. private readonly TaskAssignmentRepository _taskAssignmentRep;
  71. private readonly AirTicketResRepository _airTicketResRep;
  72. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  73. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  74. private readonly DelegationEnDataRepository _delegationEnDataRep;
  75. private readonly DelegationVisaRepository _delegationVisaRep;
  76. private readonly VisaPriceRepository _visaPriceRep;
  77. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  78. private readonly HotelPriceRepository _hotelPriceRep;
  79. private readonly CustomersRepository _customersRep;
  80. private readonly MessageRepository _message;
  81. private readonly SqlSugarClient _sqlSugar;
  82. private readonly TourClientListRepository _tourClientListRep;
  83. private readonly TeamRateRepository _teamRateRep;
  84. #region 成本相关
  85. private readonly CheckBoxsRepository _checkBoxs;
  86. private readonly GroupCostRepository _GroupCostRepository;
  87. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  88. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  89. #endregion
  90. private readonly SetDataRepository _setDataRep;
  91. private string url;
  92. private string path;
  93. private readonly EnterExitCostRepository _enterExitCostRep;
  94. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  95. private readonly UsersRepository _usersRep;
  96. private readonly IJuHeApiService _juHeApi;
  97. private readonly InvertedListRepository _invertedListRep;
  98. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  99. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  100. private readonly ThreeCodeRepository _threeCodeRepository;
  101. private readonly HotelInquiryRepository _hotelInquiryRep;
  102. private readonly FeeAuditRepository _feeAuditRep;
  103. private readonly VisaCommissionRepository _visaCommissionRep;
  104. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  105. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  106. public GroupsController(
  107. ILogger<GroupsController> logger,
  108. IMapper mapper,
  109. IHubContext<ChatHub, IChatClient> hubContext,
  110. SqlSugarClient sqlSugar,
  111. GrpScheduleRepository grpScheduleRep,
  112. DelegationInfoRepository groupRepository,
  113. TaskAssignmentRepository taskAssignmentRep,
  114. AirTicketResRepository airTicketResRep,
  115. DecreasePaymentsRepository decreasePaymentsRep,
  116. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  117. DelegationEnDataRepository delegationEnDataRep,
  118. EnterExitCostRepository enterExitCostRep,
  119. DelegationVisaRepository delegationVisaRep,
  120. MessageRepository message,
  121. VisaPriceRepository visaPriceRep,
  122. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  123. CheckBoxsRepository checkBoxs,
  124. GroupCostRepository GroupCostRepository,
  125. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  126. GroupCostParameterRepository GroupCostParameterRepository,
  127. HotelPriceRepository hotelPriceRep,
  128. CustomersRepository customersRep,
  129. SetDataRepository setDataRep,
  130. TourClientListRepository tourClientListRep,
  131. TeamRateRepository teamRateRep,
  132. UsersRepository usersRep, IJuHeApiService juHeApi,
  133. InvertedListRepository invertedListRep,
  134. VisaFeeInfoRepository visaFeeInfoRep,
  135. TicketBlackCodeRepository ticketBlackCodeRep,
  136. HotelInquiryRepository hotelInquiryRep,
  137. ThreeCodeRepository threeCodeRepository,
  138. FeeAuditRepository feeAuditRep,
  139. VisaCommissionRepository visaCommissionRep,
  140. ForeignReceivablesRepository ffrRep,
  141. OpinionaireRepository opinionaireRep
  142. )
  143. {
  144. _logger = logger;
  145. _mapper = mapper;
  146. _grpScheduleRep = grpScheduleRep;
  147. _groupRepository = groupRepository;
  148. _taskAssignmentRep = taskAssignmentRep;
  149. _airTicketResRep = airTicketResRep;
  150. _sqlSugar = sqlSugar;
  151. url = AppSettingsHelper.Get("ExcelBaseUrl");
  152. path = AppSettingsHelper.Get("ExcelBasePath");
  153. if (!System.IO.Directory.Exists(path))
  154. {
  155. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  156. }
  157. _decreasePaymentsRep = decreasePaymentsRep;
  158. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  159. _delegationEnDataRep = delegationEnDataRep;
  160. _enterExitCostRep = enterExitCostRep;
  161. _delegationVisaRep = delegationVisaRep;
  162. _message = message;
  163. _visaPriceRep = visaPriceRep;
  164. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  165. _checkBoxs = checkBoxs;
  166. _GroupCostRepository = GroupCostRepository;
  167. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  168. _GroupCostParameterRepository = GroupCostParameterRepository;
  169. _hotelPriceRep = hotelPriceRep;
  170. _customersRep = customersRep;
  171. _setDataRep = setDataRep;
  172. _tourClientListRep = tourClientListRep;
  173. _teamRateRep = teamRateRep;
  174. _hubContext = hubContext;
  175. _usersRep = usersRep;
  176. _juHeApi = juHeApi;
  177. _invertedListRep = invertedListRep;
  178. _visaFeeInfoRep = visaFeeInfoRep;
  179. _ticketBlackCodeRep = ticketBlackCodeRep;
  180. _hotelInquiryRep = hotelInquiryRep;
  181. _threeCodeRepository = threeCodeRepository;
  182. _feeAuditRep = feeAuditRep;
  183. _visaCommissionRep = visaCommissionRep;
  184. _ffrRep = ffrRep;
  185. _opinionaireRep = opinionaireRep;
  186. }
  187. #region 流程管控
  188. /// <summary>
  189. /// 获取团组流程管控信息
  190. /// </summary>
  191. /// <param name="paras">参数Json字符串</param>
  192. /// <returns></returns>
  193. [HttpPost]
  194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  195. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  196. {
  197. if (string.IsNullOrEmpty(_jsonDto.Paras))
  198. {
  199. return Ok(JsonView(false, "参数为空"));
  200. }
  201. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  202. if (_ScheduleDto != null)
  203. {
  204. if (_ScheduleDto.SearchType == 2)//获取列表
  205. {
  206. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  207. return Ok(JsonView(_grpScheduleViewList));
  208. }
  209. else//获取对象
  210. {
  211. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  212. if (_grpScheduleView != null)
  213. {
  214. return Ok(JsonView(_grpScheduleView));
  215. }
  216. }
  217. }
  218. else
  219. {
  220. return Ok(JsonView(false, "参数反序列化失败"));
  221. }
  222. return Ok(JsonView(false, "暂无数据!"));
  223. }
  224. /// <summary>
  225. /// 修改团组流程管控详细表数据
  226. /// </summary>
  227. /// <param name="paras"></param>
  228. /// <returns></returns>
  229. [HttpPost]
  230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  231. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  232. {
  233. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  234. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  235. .SetColumns(it => it.Duty == _detail.Duty)
  236. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  237. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  238. .SetColumns(it => it.JobContent == _detail.JobContent)
  239. .SetColumns(it => it.Remark == _detail.Remark)
  240. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  241. .Where(s => s.Id == dto.Id)
  242. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  243. .ExecuteCommandAsync();
  244. if (result > 0)
  245. {
  246. return Ok(JsonView(true, "保存成功!"));
  247. }
  248. return Ok(JsonView(false, "保存失败!"));
  249. }
  250. /// <summary>
  251. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  252. /// </summary>
  253. /// <param name="dto"></param>
  254. /// <returns></returns>
  255. [HttpPost]
  256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  257. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  258. {
  259. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  260. _detail.IsDel = 1;
  261. _detail.DeleteUserId = dto.Duty;
  262. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  263. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  264. .SetColumns(it => it.IsDel == _detail.IsDel)
  265. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  266. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  267. .Where(it => it.Id == dto.Id)
  268. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  269. //.WhereColumns(s => s.Id == dto.Id)
  270. .ExecuteCommandAsync();
  271. if (result > 0)
  272. {
  273. return Ok(JsonView(true, "删除成功!"));
  274. }
  275. return Ok(JsonView(false, "删除失败!"));
  276. }
  277. /// <summary>
  278. /// 增加团组流程管控详细表数据
  279. /// </summary>
  280. /// <param name="dto"></param>
  281. /// <returns></returns>
  282. [HttpPost]
  283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  284. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  285. {
  286. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  287. if (DateTime.Now < _detail.ExpectBeginDt)
  288. {
  289. _detail.StepStatus = 0;
  290. }
  291. else
  292. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  293. _detail.StepStatus = 1;
  294. }
  295. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  296. if (result > 0)
  297. {
  298. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  299. return Ok(JsonView(true, "添加成功!", _result));
  300. }
  301. return Ok(JsonView(false, "添加失败!"));
  302. }
  303. #endregion
  304. #region 团组基本信息
  305. /// <summary>
  306. /// 接团信息列表
  307. /// </summary>
  308. /// <param name="dto">团组列表请求dto</param>
  309. /// <returns></returns>
  310. [HttpPost]
  311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  312. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  313. {
  314. var groupData = await _groupRepository.GetGroupList(dto);
  315. if (groupData.Code != 0)
  316. {
  317. return Ok(JsonView(false, groupData.Msg));
  318. }
  319. return Ok(JsonView(groupData.Data));
  320. }
  321. /// <summary>
  322. /// 分页查询团组列表
  323. /// </summary>
  324. /// <param name="dto"></param>
  325. /// <returns></returns>
  326. [HttpPost]
  327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  328. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  329. {
  330. var watch = new Stopwatch();
  331. watch.Start();
  332. RefAsync<int> total = 0;
  333. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  334. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  335. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  336. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  337. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  338. .Distinct()
  339. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  340. watch.Stop();
  341. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  342. }
  343. /// <summary>
  344. /// 接团信息列表 Page
  345. /// </summary>
  346. /// <param name="dto">团组列表请求dto</param>
  347. /// <returns></returns>
  348. [HttpPost]
  349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  350. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  351. {
  352. #region 参数验证
  353. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  354. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  355. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  356. #region 页面操作权限验证
  357. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  358. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  359. #endregion
  360. #endregion
  361. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  362. {
  363. string sqlWhere = string.Empty;
  364. if (dto.IsSure == 0) //未完成
  365. {
  366. sqlWhere += string.Format(@" And IsSure = 0");
  367. }
  368. else if (dto.IsSure == 1) //已完成
  369. {
  370. sqlWhere += string.Format(@" And IsSure = 1");
  371. }
  372. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  373. {
  374. string tj = dto.SearchCriteria;
  375. 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}%')",
  376. tj, tj, tj, tj, tj);
  377. }
  378. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  379. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  380. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  381. JietuanOperator,IsSure,CreateTime,IsBid
  382. From (
  383. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  384. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  385. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  386. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  387. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  388. From Grp_DelegationInfo gdi
  389. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  390. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  391. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  392. Where gdi.IsDel = 0 {0}
  393. ) temp", sqlWhere);
  394. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  395. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  396. #region 处理所属部门
  397. /*
  398. * 1.sq 和 gyy 等显示 市场部
  399. * 2.王鸽和主管及张总还有管理员号统一国交部
  400. * 2-1. 4 管理员 ,21 张海麟
  401. */
  402. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  403. List<int> userIds1 = new List<int>() { 4, 21 };
  404. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  405. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  406. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  407. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  408. .ToList();
  409. foreach (var item in _DelegationList)
  410. {
  411. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  412. }
  413. #endregion
  414. var _view = new
  415. {
  416. PageFuncAuth = pageFunAuthView,
  417. Data = _DelegationList
  418. };
  419. return Ok(JsonView(true, "查询成功!", _view, total));
  420. }
  421. else
  422. {
  423. return Ok(JsonView(false, "查询失败"));
  424. }
  425. }
  426. /// <summary>
  427. /// 团组列表
  428. /// </summary>
  429. /// <returns></returns>
  430. [HttpPost]
  431. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  432. {
  433. #region 参数验证
  434. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  435. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  436. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  437. #region 页面操作权限验证
  438. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  439. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  440. #endregion
  441. #endregion
  442. if (dto.PortType != 1 && dto.PortType != 2)
  443. {
  444. return Ok(JsonView(false, "查询失败!"));
  445. }
  446. string orderbyStr = "order by gdi.CreateTime Desc";
  447. string sqlWhere = string.Empty;
  448. if (dto.IsSure == 0) //未完成
  449. {
  450. sqlWhere += string.Format(@" And IsSure = 0");
  451. }
  452. else if (dto.IsSure == 1) //已完成
  453. {
  454. sqlWhere += string.Format(@" And IsSure = 1");
  455. }
  456. //团组类型
  457. if (dto.TeamDid > 0)
  458. {
  459. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  460. }
  461. //团组名称
  462. if (!string.IsNullOrEmpty(dto.TeamName))
  463. {
  464. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  465. }
  466. //客户名称
  467. if (!string.IsNullOrEmpty(dto.ClientName))
  468. {
  469. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  470. }
  471. //客户单位
  472. if (!string.IsNullOrEmpty(dto.ClientUnit))
  473. {
  474. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  475. }
  476. //出访时间
  477. if (!string.IsNullOrEmpty(dto.visitDataTime))
  478. {
  479. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  480. orderbyStr = "order by gdi.VisitDate";
  481. }
  482. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  483. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  484. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  485. JietuanOperator,IsSure,CreateTime
  486. From (
  487. Select row_number() over({0}) as Row_Number,
  488. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  489. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  490. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  491. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  492. From Grp_DelegationInfo gdi
  493. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  494. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  495. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  496. Where gdi.IsDel = 0 {1}
  497. ) temp ", orderbyStr, sqlWhere);
  498. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  499. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  500. #region 处理所属部门
  501. /*
  502. * 1.sq 和 gyy 等显示 市场部
  503. * 2.王鸽和主管及张总还有管理员号统一国交部
  504. * 2-1. 4 管理员 ,21 张海麟
  505. */
  506. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  507. List<int> userIds1 = new List<int>() { 4, 21 };
  508. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  509. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  510. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  511. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  512. .ToList();
  513. foreach (var item in _DelegationList)
  514. {
  515. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  516. }
  517. #endregion
  518. var _view = new
  519. {
  520. PageFuncAuth = pageFunAuthView,
  521. Data = _DelegationList
  522. };
  523. return Ok(JsonView(true, "查询成功!", _view, total));
  524. }
  525. /// <summary>
  526. /// 接团信息详情
  527. /// </summary>
  528. /// <param name="dto">团组info请求dto</param>
  529. /// <returns></returns>
  530. [HttpPost]
  531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  532. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  533. {
  534. var groupData = await _groupRepository.GetGroupInfo(dto);
  535. if (groupData.Code != 0)
  536. {
  537. return Ok(JsonView(false, groupData.Msg));
  538. }
  539. return Ok(JsonView(groupData.Data));
  540. }
  541. /// <summary>
  542. /// 接团信息 编辑添加
  543. /// 基础信息数据源
  544. /// </summary>
  545. /// <param name="dto"></param>
  546. /// <returns></returns>
  547. [HttpPost]
  548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  549. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  550. {
  551. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  552. if (groupData.Code != 0)
  553. {
  554. return Ok(JsonView(false, groupData.Msg));
  555. }
  556. return Ok(JsonView(groupData.Data));
  557. }
  558. /// <summary>
  559. /// 接团信息 操作(增改)
  560. /// </summary>
  561. /// <param name="dto"></param>
  562. /// <returns></returns>
  563. [HttpPost]
  564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  565. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  566. {
  567. try
  568. {
  569. decimal ffrPrice = 0.00M;
  570. DateTime? visitDt = null;
  571. if (dto.Status == 2)
  572. {
  573. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  574. if (groupInfo != null)
  575. {
  576. ffrPrice = groupInfo.PaymentMoney;
  577. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  578. }
  579. }
  580. var groupData = await _groupRepository.GroupOperation(dto);
  581. if (groupData.Code != 0)
  582. {
  583. return Ok(JsonView(false, groupData.Msg));
  584. }
  585. int diId = 0;
  586. //添加时 默认加入团组汇率
  587. if (dto.Status == 1) //添加
  588. {
  589. diId = groupData.Data;
  590. //添加默认币种
  591. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  592. //默认分配权限
  593. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  594. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  595. var _managerIds = new List<int>() { 22, 32, 21 };
  596. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  597. if (userIds.Count > 0)
  598. {
  599. userIds.Add(208);
  600. //创建团组管控
  601. GroupStepForDelegation.CreateWorkStep(diId);
  602. //发送消息
  603. string groupName = dto.TeamName;
  604. string createGroupUser = string.Empty;
  605. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  606. if (userInfo != null) createGroupUser = userInfo.CnName;
  607. string title = $"系统通知";
  608. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  609. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  610. }
  611. //默认创建倒推表
  612. await _invertedListRep._Create(dto.UserId, diId);
  613. }
  614. else if (dto.Status == 2)
  615. {
  616. diId = dto.Id;
  617. }
  618. #region 签证人员团组时间通知
  619. #region 计算出访起止时间
  620. var startTime = new DateTime();
  621. var endTime = new DateTime();
  622. if (DateTime.TryParse(dto.VisitDate, out startTime))
  623. {
  624. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  625. }
  626. #endregion
  627. if (diId > 0)
  628. {
  629. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  630. }
  631. #endregion
  632. #region 团组操作默认添加/修改收款账单
  633. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  634. {
  635. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  636. .Where(x => x.IsDel == 0 &&
  637. x.Diid == diId &&
  638. x.Remark.Equals("预付款")
  639. )
  640. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  641. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  642. .FirstAsync();
  643. ffrInfo = new Fin_ForeignReceivables()
  644. {
  645. Diid = diId,
  646. PriceName = dto.ClientUnit,
  647. Price = dto.PaymentMoney,
  648. Count = 1,
  649. Unit = $"元",
  650. ItemSumPrice = dto.PaymentMoney,
  651. Rate = 1.0000M,
  652. Currency = 836,
  653. AddingWay = 0,
  654. CreateUserId = dto.UserId,
  655. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  656. Remark = $"预付款"
  657. };
  658. if (ffrInfo == null) //Add
  659. {
  660. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  661. }
  662. else //修改
  663. {
  664. await _sqlSugar.Updateable(ffrInfo)
  665. .UpdateColumns(x => new
  666. {
  667. x.PriceName,
  668. x.Price,
  669. x.ItemSumPrice,
  670. x.CreateTime,
  671. x.CreateUserId
  672. })
  673. .WhereColumns(x => x.Id)
  674. .ExecuteCommandAsync();
  675. }
  676. }
  677. #endregion
  678. return Ok(JsonView(true, "操作成功!", diId));
  679. }
  680. catch (Exception ex)
  681. {
  682. Logs("[response]" + JsonConvert.SerializeObject(dto));
  683. Logs(ex.Message);
  684. return Ok(JsonView(false, ex.Message));
  685. }
  686. }
  687. /// <summary>
  688. /// 接团流程操作(增改)
  689. /// 安卓端使用 建团时添加客户名单
  690. /// </summary>
  691. /// <param name="dto"></param>
  692. /// <returns></returns>
  693. [HttpPost]
  694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  695. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  696. {
  697. try
  698. {
  699. #region 参数验证
  700. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  701. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  702. #region 页面操作权限验证
  703. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  704. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  705. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  706. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  707. #endregion
  708. #endregion
  709. _sqlSugar.BeginTran();
  710. decimal ffrPrice = 0.00M;
  711. DateTime? visitDt = null;
  712. if (dto.Status == 2)
  713. {
  714. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  715. if (groupInfo != null)
  716. {
  717. ffrPrice = groupInfo.PaymentMoney;
  718. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  719. }
  720. }
  721. var _dto = new GroupOperationDto();
  722. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  723. var groupData = await _groupRepository.GroupOperation(_dto);
  724. if (groupData.Code != 0)
  725. {
  726. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  727. }
  728. int diId = 0;
  729. //添加时 默认加入团组汇率
  730. if (dto.Status == 1) //添加
  731. {
  732. diId = groupData.Data;
  733. //添加默认币种
  734. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  735. //默认分配权限
  736. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  737. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  738. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  739. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  740. if (userIds.Count > 0)
  741. {
  742. userIds.Add(208);
  743. //创建团组管控
  744. GroupStepForDelegation.CreateWorkStep(diId);
  745. //发送消息
  746. string groupName = dto.TeamName;
  747. string createGroupUser = string.Empty;
  748. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  749. if (userInfo != null) createGroupUser = userInfo.CnName;
  750. string title = $"系统通知";
  751. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  752. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  753. }
  754. #region 应用推送
  755. try
  756. {
  757. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  758. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  759. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  760. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  761. {
  762. List<string> userList = new List<string>() { users.QiyeChatUserId };
  763. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  764. }
  765. }
  766. catch (Exception ex)
  767. {
  768. }
  769. #endregion
  770. //默认创建倒推表
  771. await _invertedListRep._Create(dto.UserId, diId);
  772. }
  773. if (dto.Status == 2)
  774. {
  775. diId = dto.Id;
  776. if (diId == 0)
  777. {
  778. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  779. }
  780. }
  781. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  782. if (viewData.Code != 0)
  783. {
  784. _sqlSugar.RollbackTran();
  785. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  786. }
  787. #region 团组操作默认添加/修改收款账单
  788. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  789. {
  790. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  791. .Where(x => x.IsDel == 0 &&
  792. x.Diid == diId &&
  793. x.Remark.Equals("预付款")
  794. )
  795. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  796. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  797. .FirstAsync();
  798. ffrInfo = new Fin_ForeignReceivables()
  799. {
  800. Diid = diId,
  801. PriceName = dto.ClientUnit,
  802. Price = dto.PaymentMoney,
  803. Count = 1,
  804. Unit = $"元",
  805. ItemSumPrice = dto.PaymentMoney,
  806. Rate = 1.0000M,
  807. Currency = 836,
  808. AddingWay = 0,
  809. CreateUserId = dto.UserId,
  810. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  811. Remark = $"预付款"
  812. };
  813. if (ffrInfo == null) //Add
  814. {
  815. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  816. }
  817. else //修改
  818. {
  819. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  820. .UpdateColumns(x => new
  821. {
  822. x.PriceName,
  823. x.Price,
  824. x.ItemSumPrice,
  825. x.CreateTime,
  826. x.CreateUserId
  827. })
  828. .WhereColumns(x => x.Id)
  829. .ExecuteCommandAsync();
  830. }
  831. }
  832. #endregion
  833. #region 签证人员团组时间通知
  834. #region 计算出访起止时间
  835. var startTime = new DateTime();
  836. var endTime = new DateTime();
  837. if (DateTime.TryParse(dto.VisitDate, out startTime))
  838. {
  839. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  840. }
  841. #endregion
  842. if (diId > 0)
  843. {
  844. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  845. }
  846. #endregion
  847. _sqlSugar.CommitTran();
  848. return Ok(JsonView(true, "添加成功"));
  849. }
  850. catch (Exception ex)
  851. {
  852. _sqlSugar.RollbackTran();
  853. return Ok(JsonView(false, ex.Message));
  854. }
  855. }
  856. /// <summary>
  857. /// 接团信息 操作(删除)
  858. /// </summary>
  859. /// <param name="dto"></param>
  860. /// <returns></returns>
  861. [HttpPost]
  862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  863. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  864. {
  865. try
  866. {
  867. var groupData = await _groupRepository.GroupDel(dto);
  868. if (groupData.Code != 0)
  869. {
  870. return Ok(JsonView(false, groupData.Msg));
  871. }
  872. return Ok(JsonView(true));
  873. }
  874. catch (Exception ex)
  875. {
  876. Logs("[response]" + JsonConvert.SerializeObject(dto));
  877. Logs(ex.Message);
  878. return Ok(JsonView(false, ex.Message));
  879. }
  880. }
  881. /// <summary>
  882. /// 获取团组销售报价号
  883. /// 团组添加时 使用
  884. /// </summary>
  885. /// <returns></returns>
  886. [HttpPost]
  887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  888. public async Task<IActionResult> GetGroupSalesQuoteNo()
  889. {
  890. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  891. if (groupData.Code != 0)
  892. {
  893. return Ok(JsonView(false, groupData.Msg));
  894. }
  895. object salesQuoteNo = new
  896. {
  897. SalesQuoteNo = groupData.Data
  898. };
  899. return Ok(JsonView(salesQuoteNo));
  900. }
  901. /// <summary>
  902. /// 设置确认出团
  903. /// </summary>
  904. /// <param name="dto"></param>
  905. /// <returns></returns>
  906. [HttpPost]
  907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  908. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  909. {
  910. var groupData = await _groupRepository.ConfirmationGroup(dto);
  911. if (groupData.Code != 0)
  912. {
  913. return Ok(JsonView(false, groupData.Msg));
  914. }
  915. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  916. #region OA消息推送
  917. try
  918. {
  919. string groupName = groupInfo.TeamName;
  920. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  921. List<int> userIds = new List<int>();
  922. listUser.ForEach(s => userIds.Add(s.Id));
  923. string title = $"系统通知";
  924. string content = $"团组[{groupName}]已确认出团!";
  925. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  926. }
  927. catch (Exception ex)
  928. {
  929. }
  930. #endregion
  931. #region 应用推送
  932. try
  933. {
  934. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  935. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  936. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  937. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  938. {
  939. List<string> userList = new List<string>() { users.QiyeChatUserId };
  940. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  941. }
  942. }
  943. catch (Exception ex)
  944. {
  945. }
  946. #endregion
  947. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  948. return Ok(JsonView(true, "操作成功!", groupData.Data));
  949. }
  950. /// <summary>
  951. /// 获取团组名称data And 签证国别Data
  952. /// </summary>
  953. /// <param name="dto"></param>
  954. /// <returns></returns>
  955. [HttpPost]
  956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  957. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  958. {
  959. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  960. if (groupData.Code != 0)
  961. {
  962. return Ok(JsonView(false, groupData.Msg));
  963. }
  964. return Ok(JsonView(groupData.Data));
  965. }
  966. /// <summary>
  967. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  968. /// </summary>
  969. /// <returns></returns>
  970. [HttpPost]
  971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  972. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  973. {
  974. try
  975. {
  976. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  977. if (groupData.Code != 0)
  978. {
  979. return Ok(JsonView(false, groupData.Msg));
  980. }
  981. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  982. }
  983. catch (Exception ex)
  984. {
  985. return Ok(JsonView(false, "程序错误!"));
  986. throw;
  987. }
  988. }
  989. /// <summary>
  990. /// 团组清单 Excel
  991. /// </summary>
  992. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  993. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  994. /// <returns></returns>
  995. [HttpGet]
  996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  997. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  998. {
  999. DateTime _beginDt, _endDt;
  1000. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1001. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1002. if (!beginBool && !endBool)
  1003. {
  1004. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1005. }
  1006. string sql = string.Format(@"
  1007. SELECT
  1008. ROW_NUMBER,
  1009. Id,
  1010. SalesQuoteNo,
  1011. TourCode,
  1012. TeamTypeId,
  1013. TeamType,
  1014. TeamLevId,
  1015. TeamLev,
  1016. TeamName,
  1017. ClientName,
  1018. ClientUnit,
  1019. VisitDate,
  1020. VisitDays,
  1021. VisitPNumber,
  1022. JietuanOperatorId,
  1023. JietuanOperator,
  1024. IsSure,
  1025. CreateTime,
  1026. IsBid
  1027. FROM
  1028. (
  1029. SELECT
  1030. ROW_NUMBER() OVER(
  1031. ORDER BY
  1032. gdi.CreateTime Desc
  1033. ) AS ROW_NUMBER,
  1034. gdi.Id,
  1035. SalesQuoteNo,
  1036. TourCode,
  1037. ssd.Id TeamTypeId,
  1038. ssd.Name TeamType,
  1039. ssd1.Id TeamLevId,
  1040. ssd1.Name TeamLev,
  1041. TeamName,
  1042. ClientName,
  1043. ClientUnit,
  1044. VisitDate,
  1045. VisitDays,
  1046. VisitPNumber,
  1047. JietuanOperator JietuanOperatorId,
  1048. su.CnName JietuanOperator,
  1049. IsSure,
  1050. gdi.CreateTime,
  1051. gdi.IsBid
  1052. FROM
  1053. Grp_DelegationInfo gdi
  1054. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1055. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1056. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1057. WHERE
  1058. gdi.IsDel = 0
  1059. AND gdi.IsBid = 0
  1060. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1061. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1062. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1063. #region 处理所属部门
  1064. /*
  1065. * 1.sq 和 gyy 等显示 市场部
  1066. * 2.王鸽和主管及张总还有管理员号统一国交部
  1067. * 2-1. 4 管理员 ,21 张海麟
  1068. */
  1069. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1070. List<int> userIds1 = new List<int>() { 4, 21 };
  1071. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1072. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1073. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1074. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1075. .ToListAsync();
  1076. foreach (var item in groupList)
  1077. {
  1078. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1079. }
  1080. #endregion
  1081. #region Excel
  1082. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1083. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1084. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1085. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1086. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1087. //载入模板
  1088. WorkbookDesigner designer = new WorkbookDesigner();
  1089. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1090. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1091. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1092. dt.TableName = "GroupList";
  1093. designer.SetDataSource(dt);
  1094. designer.Process();
  1095. if (!Directory.Exists(savePath))
  1096. {
  1097. Directory.CreateDirectory(savePath);
  1098. }
  1099. string serverPath = $"{savePath}{fileName}";
  1100. designer.Workbook.Save(serverPath);
  1101. string rst = $"{servicePath}{ftpPath}{fileName}";
  1102. #endregion
  1103. return Ok(JsonView(true, "操作成功!", rst));
  1104. }
  1105. #endregion
  1106. #region 团组&签证
  1107. /// <summary>
  1108. /// 根据团组Id获取签证客户信息List
  1109. /// </summary>
  1110. /// <param name="dto">请求dto</param>
  1111. /// <returns></returns>
  1112. [HttpPost]
  1113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1114. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1115. {
  1116. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1117. if (groupData.Code != 0)
  1118. {
  1119. return Ok(JsonView(false, groupData.Msg));
  1120. }
  1121. return Ok(JsonView(groupData.Data));
  1122. }
  1123. /// <summary>
  1124. /// IOS获取团组签证拍照上传进度01(团组列表)
  1125. /// </summary>
  1126. /// <param name="dto">请求dto</param>
  1127. /// <returns></returns>
  1128. [HttpPost]
  1129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1130. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1131. {
  1132. if (dto == null)
  1133. {
  1134. return Ok(JsonView(false, "参数为空"));
  1135. }
  1136. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1137. return Ok(JsonView(visaList));
  1138. }
  1139. /// <summary>
  1140. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1141. /// </summary>
  1142. /// <returns></returns>
  1143. [HttpPost]
  1144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1145. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1146. {
  1147. if (dto == null)
  1148. {
  1149. return Ok(JsonView(false, "请求错误:"));
  1150. }
  1151. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1152. return Ok(JsonView(list));
  1153. }
  1154. /// <summary>
  1155. /// IOS获取团组签证拍照上传进度03(相册)
  1156. /// </summary>
  1157. /// <returns></returns>
  1158. [HttpPost]
  1159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1160. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1161. {
  1162. if (dto == null)
  1163. {
  1164. return Ok(JsonView(false, "请求错误:"));
  1165. }
  1166. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1167. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1168. list.ForEach(s => s.url = url);
  1169. return Ok(JsonView(list));
  1170. }
  1171. /// <summary>
  1172. /// IOS获取团组签证拍照上传进度04(图片上传)
  1173. /// </summary>
  1174. /// <param name="dto"></param>
  1175. /// <returns></returns>
  1176. [HttpPost]
  1177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1178. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1179. {
  1180. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1181. //if (!string.IsNullOrEmpty(result))
  1182. //{
  1183. //}
  1184. //else {
  1185. // return Ok(JsonView(false, "上传失败"));
  1186. //}
  1187. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1188. int sucNum = 0;
  1189. try
  1190. {
  1191. foreach (var item in dto.base64DataList)
  1192. {
  1193. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1194. string result = decodeBase64ToImage(item, imageName);
  1195. if (!string.IsNullOrEmpty(result))
  1196. {
  1197. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1198. pic.CreateUserId = dto.CreateUserId;
  1199. pic.PicName = imageName;
  1200. pic.PicPath = result;
  1201. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1202. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1203. if (insertResult > 0)
  1204. {
  1205. sucNum++;
  1206. }
  1207. }
  1208. }
  1209. }
  1210. catch (Exception ex)
  1211. {
  1212. return Ok(JsonView(false, ex.Message));
  1213. }
  1214. string msg = string.Format(@"成功上传{0}张", sucNum);
  1215. return Ok(JsonView(true, msg));
  1216. }
  1217. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1218. {
  1219. string filename = "";//声明一个string类型的相对路径
  1220. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1221. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1222. try//会有异常抛出,try,catch一下
  1223. {
  1224. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1225. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1226. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1227. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1228. //文件名称
  1229. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1230. //上传的文件的路径
  1231. string filePath = "";
  1232. if (!Directory.Exists(fileDir))
  1233. {
  1234. Directory.CreateDirectory(fileDir);
  1235. }
  1236. //上传的文件的路径
  1237. filePath = fileDir + filename;
  1238. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1239. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1240. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1241. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1242. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1243. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1244. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1245. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1246. bitmap.Dispose();
  1247. }
  1248. catch (Exception e)
  1249. {
  1250. string massage = e.Message;
  1251. Logs("IOS图片上传Error:" + massage);
  1252. //filename = e.Message;
  1253. }
  1254. return filename;//返回相对路径
  1255. }
  1256. /// <summary>
  1257. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1258. /// </summary>
  1259. /// <param name="dto"></param>
  1260. /// <returns></returns>
  1261. [HttpPost]
  1262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1263. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1264. {
  1265. if (dto == null)
  1266. {
  1267. return Ok(JsonView(false, "请求错误:"));
  1268. }
  1269. string msg = "参数错误";
  1270. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1271. {
  1272. try
  1273. {
  1274. //_delegationVisaRep.BeginTran();
  1275. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1276. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1277. .Where(s => s.Id == dto.visaProgressCustomerId)
  1278. .ExecuteCommandAsync();
  1279. if (updCount > 0 && dto.publishCode == 1)
  1280. {
  1281. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1282. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1283. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1284. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1285. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1286. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1287. if (groupData == null)
  1288. {
  1289. _delegationVisaRep.RollbackTran();
  1290. }
  1291. string title = string.Format(@"[签证进度更新]");
  1292. string content = string.Format(@"测试文本");
  1293. bool rst = await _message.AddMsg(new MessageDto()
  1294. {
  1295. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1296. IssuerId = dto.publisher,
  1297. Title = title,
  1298. Content = content,
  1299. ReleaseTime = DateTime.Now,
  1300. UIdList = new List<int> {
  1301. 234
  1302. }
  1303. });
  1304. if (rst)
  1305. {
  1306. return Ok(JsonView(true, "发送通知成功"));
  1307. }
  1308. }
  1309. //_delegationVisaRep.CommitTran();
  1310. }
  1311. catch (Exception)
  1312. {
  1313. //_delegationVisaRep.RollbackTran();
  1314. }
  1315. }
  1316. return Ok(JsonView(true, msg));
  1317. }
  1318. #endregion
  1319. #region 团组任务分配
  1320. /// <summary>
  1321. /// 团组任务分配初始化
  1322. /// </summary>
  1323. /// <param name="dto"></param>
  1324. /// <returns></returns>
  1325. [HttpPost]
  1326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1327. public async Task<IActionResult> GetTaskAssignmen()
  1328. {
  1329. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1330. if (groupData.Code != 0)
  1331. {
  1332. return Ok(JsonView(false, groupData.Msg));
  1333. }
  1334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1335. }
  1336. /// <summary>
  1337. /// 团组任务分配查询
  1338. /// </summary>
  1339. /// <param name="dto"></param>
  1340. /// <returns></returns>
  1341. [HttpPost]
  1342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1343. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1344. {
  1345. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1346. if (groupData.Code != 0)
  1347. {
  1348. return Ok(JsonView(false, groupData.Msg));
  1349. }
  1350. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1351. }
  1352. /// <summary>
  1353. /// 团组任务分配操作
  1354. /// </summary>
  1355. /// <param name="dto"></param>
  1356. /// <returns></returns>
  1357. [HttpPost]
  1358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1359. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1360. {
  1361. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1362. if (groupData.Code != 0)
  1363. {
  1364. return Ok(JsonView(false, groupData.Msg));
  1365. }
  1366. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1367. }
  1368. /// <summary>
  1369. /// 团组任务分配
  1370. /// 批量分配
  1371. /// 查询团组
  1372. /// </summary>
  1373. /// <param name="dto"></param>
  1374. /// <returns></returns>
  1375. [HttpPost]
  1376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1377. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1378. {
  1379. //参数验证
  1380. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1381. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1382. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1383. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1384. }
  1385. /// <summary>
  1386. /// 团组任务分配
  1387. /// 批量分配
  1388. /// </summary>
  1389. /// <param name="dto"></param>
  1390. /// <returns></returns>
  1391. [HttpPost]
  1392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1393. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1394. {
  1395. //参数验证
  1396. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1397. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1398. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1399. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1400. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1401. }
  1402. #endregion
  1403. #region 团组费用审核
  1404. /// <summary>
  1405. /// 费用审核
  1406. /// 团组列表 Page
  1407. /// </summary>
  1408. /// <param name="_dto">团组列表请求dto</param>
  1409. /// <returns></returns>
  1410. [HttpPost]
  1411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1412. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1413. {
  1414. #region 参数验证
  1415. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1416. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1417. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1418. #region 页面操作权限验证
  1419. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1420. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1421. #endregion
  1422. #endregion
  1423. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1424. {
  1425. string sqlWhere = string.Empty;
  1426. if (_dto.IsSure == 0) //未完成
  1427. {
  1428. sqlWhere += string.Format(@" And IsSure = 0");
  1429. }
  1430. else if (_dto.IsSure == 1) //已完成
  1431. {
  1432. sqlWhere += string.Format(@" And IsSure = 1");
  1433. }
  1434. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1435. {
  1436. string tj = _dto.SearchCriteria;
  1437. 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}%')",
  1438. tj, tj, tj, tj, tj);
  1439. }
  1440. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1441. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1442. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1443. From (
  1444. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1445. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1446. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1447. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1448. From Grp_DelegationInfo gdi
  1449. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1450. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1451. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1452. Where gdi.IsDel = 0 {0}
  1453. ) temp ", sqlWhere);
  1454. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1455. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1456. var _view = new
  1457. {
  1458. PageFuncAuth = pageFunAuthView,
  1459. Data = _DelegationList
  1460. };
  1461. return Ok(JsonView(true, "查询成功!", _view, total));
  1462. }
  1463. else
  1464. {
  1465. return Ok(JsonView(false, "查询失败"));
  1466. }
  1467. }
  1468. /// <summary>
  1469. /// 获取团组费用审核
  1470. /// </summary>
  1471. /// <param name="paras">参数Json字符串</param>
  1472. /// <returns></returns>
  1473. [HttpPost]
  1474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1475. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1476. {
  1477. try
  1478. {
  1479. #region 参数验证
  1480. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1481. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1482. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1484. #region 页面操作权限验证
  1485. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1486. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1487. #endregion
  1488. #endregion
  1489. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1490. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1491. #region 费用清单
  1492. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1493. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1494. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1495. List<Grp_CreditCardPayment> entityList = _groupRepository
  1496. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1497. .Where(exp.ToExpression())
  1498. .ToList();
  1499. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1500. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1501. /*
  1502. * 76://酒店预订
  1503. */
  1504. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1505. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1506. .ToListAsync();
  1507. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1508. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1509. .ToListAsync();
  1510. /*
  1511. * 79://车/导游地接
  1512. */
  1513. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1514. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1515. .ToListAsync();
  1516. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1517. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1518. .ToListAsync();
  1519. /*
  1520. * 80: //签证
  1521. */
  1522. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1523. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1524. .ToListAsync();
  1525. /*
  1526. *81: //邀请/公务活动
  1527. */
  1528. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1529. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1530. .ToListAsync();
  1531. /*
  1532. * 82: //团组客户保险
  1533. */
  1534. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1535. /*
  1536. * Lable = 85 机票预订
  1537. */
  1538. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1539. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1540. .ToListAsync();
  1541. /*
  1542. * 85 机票预定
  1543. */
  1544. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1545. /*
  1546. * 98 其他款项
  1547. */
  1548. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1549. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1550. .ToListAsync();
  1551. /*
  1552. * 285:收款退还
  1553. */
  1554. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1555. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1556. .ToListAsync();
  1557. /*
  1558. * 1015: //超支费用
  1559. */
  1560. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1561. /*
  1562. * 币种信息
  1563. */
  1564. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1565. /*
  1566. * 车/导游地接 费用类型
  1567. */
  1568. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1569. /*
  1570. * 车/导游地接 费用类型
  1571. */
  1572. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1573. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1574. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1575. /*
  1576. * 用户信息
  1577. */
  1578. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1579. /*
  1580. * 费用模块
  1581. */
  1582. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1583. string priceModule = string.Empty;
  1584. if (sdPriceName != null)
  1585. {
  1586. priceModule = sdPriceName.Name;
  1587. }
  1588. /*
  1589. * 成本信息
  1590. */
  1591. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1592. decimal _groupRate = 0.0000M;
  1593. string _groupCurrencyCode = "-";
  1594. if (groupCost != null)
  1595. {
  1596. _groupRate = groupCost.Rate;
  1597. if (int.TryParse(groupCost.Currency, out int _currency))
  1598. {
  1599. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1600. }
  1601. else _groupCurrencyCode = groupCost.Currency;
  1602. }
  1603. string costContentSql = $"Select * From Grp_GroupCost";
  1604. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1605. //处理日期为空的天数
  1606. for (int i = 0; i < groupCostDetails.Count; i++)
  1607. if (i != 0)
  1608. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1609. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1610. /*
  1611. * 处理详情数据
  1612. */
  1613. foreach (var entity in entityList)
  1614. {
  1615. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1616. _detail.Id = entity.Id;
  1617. _detail.PriceName = priceModule;
  1618. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1619. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1620. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1621. //处理金额
  1622. if (entity.CTable == 1015)
  1623. {
  1624. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1625. if (czInfo != null)
  1626. {
  1627. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1628. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1629. }
  1630. }
  1631. /*
  1632. * 应付款金额
  1633. */
  1634. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1635. string PaymentCurrency_WaitPay = "Unknown";
  1636. string hotelCurrncyCode = "Unknown";
  1637. string hotelCurrncyName = "Unknown";
  1638. if (sdPaymentCurrency_WaitPay != null)
  1639. {
  1640. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1641. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1642. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1643. if (hotelCurrncyCode.Equals("CNY"))
  1644. {
  1645. entity.DayRate = 1.0000M;
  1646. }
  1647. }
  1648. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1649. /*
  1650. * 此次付款金额
  1651. */
  1652. decimal CurrPayStr = 0.00M,
  1653. OriginalCurrPay = 0.00M;
  1654. if (entity.PayPercentage == 0)
  1655. {
  1656. if (entity.PayThenMoney != 0)
  1657. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1658. }
  1659. else
  1660. {
  1661. if (entity.PayMoney != 0)
  1662. {
  1663. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1664. }
  1665. }
  1666. if (_dto.Label == 79)
  1667. {
  1668. string original = string.Empty;
  1669. if (hotelCurrncyCode.Equals("CNY"))
  1670. {
  1671. OriginalCurrPay = CurrPayStr;
  1672. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1673. }
  1674. else
  1675. {
  1676. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1677. //760 EUR(7600.00 CNY)
  1678. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1679. }
  1680. }
  1681. else
  1682. {
  1683. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1684. }
  1685. /*
  1686. * 剩余尾款
  1687. */
  1688. decimal BalanceStr = 0;
  1689. if (CurrPayStr != 0)
  1690. {
  1691. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1692. BalanceStr = 0;
  1693. else
  1694. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1695. }
  1696. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1697. /*
  1698. * Bus名称
  1699. */
  1700. _detail.BusName = "待增加";
  1701. /*
  1702. *费用所属
  1703. */
  1704. switch (entity.CTable)
  1705. {
  1706. case 76://酒店预订
  1707. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1708. if (hotelReservations != null)
  1709. {
  1710. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1711. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1712. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1713. string roomFeeStr = "", roomFeestr1 = "";
  1714. //是否比较房型价格
  1715. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1716. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1717. roomFeeStr += $"<br/>";
  1718. if (hotelReservations.SingleRoomPrice > 0)
  1719. {
  1720. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1721. __isSingle = true;
  1722. }
  1723. if (hotelReservations.DoubleRoomPrice > 0)
  1724. {
  1725. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1726. __isDouble = true;
  1727. }
  1728. if (hotelReservations.SuiteRoomPrice > 0)
  1729. {
  1730. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1731. __isSuite = true;
  1732. }
  1733. if (hotelReservations.OtherRoomPrice > 0)
  1734. {
  1735. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1736. __isOther = true;
  1737. }
  1738. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1739. else roomFeeStr += " 0.00 * 0";
  1740. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1741. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1742. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1743. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1744. /*
  1745. * 费用类型
  1746. * 1:房费
  1747. * 2:早餐
  1748. * 3:地税
  1749. * 4:城市税
  1750. * </summary>
  1751. */
  1752. //地税
  1753. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1754. if (governmentRentData != null)
  1755. {
  1756. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1757. governmentRentFee = governmentRentData.Price;
  1758. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1759. if (governmentRentCurrData != null)
  1760. {
  1761. governmentRentCode = governmentRentCurrData.Name;
  1762. governmentRentName = $"({governmentRentCurrData.Remark})";
  1763. }
  1764. }
  1765. //城市税
  1766. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1767. if (cityTaxData != null)
  1768. {
  1769. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1770. cityTaxFee = cityTaxData.Price;
  1771. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1772. if (cityTaxCurrData != null)
  1773. {
  1774. cityTaxCode = cityTaxCurrData.Name;
  1775. cityTaxName = $"({cityTaxCurrData.Remark})";
  1776. }
  1777. }
  1778. //酒店早餐
  1779. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1780. if (breakfastData != null)
  1781. {
  1782. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1783. breakfastFee = breakfastData.Price;
  1784. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1785. if (breakfastCurrData != null)
  1786. {
  1787. breakfastCode = breakfastCurrData.Name;
  1788. breakfastName = $"({breakfastCurrData.Remark})";
  1789. }
  1790. }
  1791. //房间费用
  1792. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1793. if (roomData != null)
  1794. {
  1795. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1796. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1797. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1798. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1799. roomFee = roomData.Price;
  1800. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1801. if (roomCurrData != null)
  1802. {
  1803. roomCode = roomCurrData.Name;
  1804. roomName = $"({roomCurrData.Remark})";
  1805. }
  1806. }
  1807. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1808. string hotelCostStr = "";
  1809. decimal hotelCsotTotal = 0.00M;
  1810. if (groupCost != null)
  1811. {
  1812. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1813. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1814. }
  1815. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1816. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1817. string hotelCost_day = "";
  1818. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1819. foreach (var item in hotelCostDetails1)
  1820. {
  1821. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1822. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1823. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1824. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1825. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1826. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1827. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1828. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1829. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1830. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1831. hotelCost_day += @$"<br/>";
  1832. }
  1833. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1834. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1835. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1836. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1837. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1838. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1839. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1840. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1841. $"房间说明: {hotelReservations.Remark} <br/>" +
  1842. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1843. $"{hotelBreakfastStr}" +
  1844. $"{hotelGovernmentRentStr}" +
  1845. $"{hotelCityTaxStr}";
  1846. _detail.PriceNameContent = hotelReservations.HotelName;
  1847. }
  1848. break;
  1849. case 79://车/导游地接
  1850. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1851. if (touristGuideGroundReservations != null)
  1852. {
  1853. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1854. {
  1855. _detail.BusName = touristGuideGroundReservations.BusName;
  1856. }
  1857. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1858. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1859. //if (isInt)
  1860. //{
  1861. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1862. // if (cityInfo != null)
  1863. // {
  1864. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1865. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1866. // if (carFeeItem != null)
  1867. // {
  1868. // nameContent += $@"({carFeeItem.Name})";
  1869. // }
  1870. // _detail.PriceNameContent = nameContent;
  1871. // }
  1872. //}
  1873. //else
  1874. //{
  1875. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1876. //}
  1877. var touristGuideGroundReservationsContents =
  1878. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1879. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1880. foreach (var item in touristGuideGroundReservationsContents)
  1881. {
  1882. string typeName = "Unknown";
  1883. string carCurrencyCode = "Unknown";
  1884. string carCurrencyName = "Unknown";
  1885. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1886. if (carTypeData != null) typeName = carTypeData.Name;
  1887. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1888. if (currencyData != null)
  1889. {
  1890. carCurrencyCode = currencyData.Name;
  1891. carCurrencyName = currencyData.Remark;
  1892. }
  1893. //op、成本 币种是否一致
  1894. bool IsCurrencyAgreement = false;
  1895. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1896. string opCostStr = string.Empty;
  1897. decimal opCostTypePrice = 0.00M;
  1898. #region 处理成本各项费用
  1899. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1900. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1901. if (opCost.Count > 0)
  1902. {
  1903. switch (item.SId)
  1904. {
  1905. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1906. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1907. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1908. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1909. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1910. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1911. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1912. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1913. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1914. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1915. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1916. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1917. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1918. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1919. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1920. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1921. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1922. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1923. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1924. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1925. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1926. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1927. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1928. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1929. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1930. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1931. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1932. }
  1933. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1934. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1935. }
  1936. #endregion
  1937. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1938. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1939. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1940. $"{opTypeStr} {opCostStr}<br/>" +
  1941. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1942. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1943. }
  1944. _detail.PriceMsgContent = priceMsg;
  1945. }
  1946. break;
  1947. case 80: //签证
  1948. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1949. if (visaInfo != null)
  1950. {
  1951. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1952. _detail.PriceNameContent = visaInfo.VisaDescription;
  1953. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1954. }
  1955. break;
  1956. case 81: //邀请/公务活动
  1957. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1958. if (_ioa != null)
  1959. {
  1960. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1961. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1962. sendCurrName = "Unknown", //快递费用币种 Name
  1963. sendCurrCode = "Unknown", //快递费用币种 Code
  1964. eventsCurrName = "Unknown", //公务活动费币种 Name
  1965. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1966. translateCurrName = "Unknown", //公务翻译费 Name
  1967. translateCurrCode = "Unknown"; //公务翻译费 Code
  1968. #region 处理费用币种
  1969. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1970. if (inviteCurrData != null)
  1971. {
  1972. inviteCurrName = inviteCurrData.Remark;
  1973. inviteCurrCode = inviteCurrData.Name;
  1974. }
  1975. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1976. if (sendCurrData != null)
  1977. {
  1978. sendCurrName = sendCurrData.Remark;
  1979. sendCurrCode = sendCurrData.Name;
  1980. }
  1981. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1982. if (eventsCurrData != null)
  1983. {
  1984. eventsCurrName = eventsCurrData.Remark;
  1985. eventsCurrCode = eventsCurrData.Name;
  1986. }
  1987. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1988. if (translateCurrData != null)
  1989. {
  1990. translateCurrName = translateCurrData.Remark;
  1991. translateCurrCode = translateCurrData.Name;
  1992. }
  1993. #endregion
  1994. _detail.PriceNameContent = _ioa.InviterArea;
  1995. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1996. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1997. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1998. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1999. $@"备注:" + _ioa.Remark + "<br/>";
  2000. }
  2001. break;
  2002. case 82: //团组客户保险
  2003. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2004. if (customers != null)
  2005. {
  2006. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2007. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2008. }
  2009. break;
  2010. case 85: //机票预订
  2011. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2012. if (jpRes != null)
  2013. {
  2014. string FlightsDescription = jpRes.FlightsDescription;
  2015. string PriceDescription = jpRes.PriceDescription;
  2016. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2017. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2018. }
  2019. break;
  2020. case 98://其他款项
  2021. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2022. if (gdpRes != null)
  2023. {
  2024. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2025. _detail.PriceNameContent = gdpRes.PriceName;
  2026. }
  2027. break;
  2028. case 285://收款退还
  2029. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2030. if (refundAndOtherMoney != null)
  2031. {
  2032. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2033. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2034. }
  2035. break;
  2036. case 751://酒店早餐
  2037. break;
  2038. case 1015://超支费用
  2039. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2040. if (groupExtraCost != null)
  2041. {
  2042. _detail.PriceNameContent = groupExtraCost.PriceName;
  2043. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2044. }
  2045. break;
  2046. default:
  2047. break;
  2048. }
  2049. /*
  2050. * 申请人
  2051. */
  2052. string operatorName = " - ";
  2053. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2054. if (_opUser != null)
  2055. {
  2056. operatorName = _opUser.CnName;
  2057. }
  2058. _detail.OperatorName = operatorName;
  2059. /*
  2060. * 审核人
  2061. */
  2062. string auditOperatorName = "Unknown";
  2063. if (entity.AuditGMOperate == 0)
  2064. auditOperatorName = " - ";
  2065. else if (entity.AuditGMOperate == 4)
  2066. auditOperatorName = "自动审核";
  2067. else
  2068. {
  2069. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2070. if (_adUser != null)
  2071. {
  2072. auditOperatorName = _adUser.CnName;
  2073. }
  2074. }
  2075. _detail.AuditOperatorName = auditOperatorName;
  2076. /*
  2077. * 超预算比例
  2078. */
  2079. string overBudgetStr = "";
  2080. if (entity.ExceedBudget == -1)
  2081. overBudgetStr = sdPriceName.Name + "尚无预算";
  2082. else if (entity.ExceedBudget == 0)
  2083. {
  2084. if (entity.CTable == 76 || entity.CTable == 79)
  2085. {
  2086. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2087. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2088. }
  2089. else
  2090. {
  2091. overBudgetStr = "未超预算";
  2092. }
  2093. }
  2094. else
  2095. overBudgetStr = entity.ExceedBudget.ToString("P");
  2096. _detail.OverBudget = overBudgetStr;
  2097. /*
  2098. * 已审核金额
  2099. */
  2100. decimal auditFee = 0.00M;
  2101. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2102. /*
  2103. * 费用总计
  2104. */
  2105. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2106. {
  2107. CurrencyId = entity.PaymentCurrency,
  2108. CurrencyName = PaymentCurrency_WaitPay,
  2109. AmountPayable = entity.PayMoney,
  2110. ThisPayment = OriginalCurrPay,
  2111. BalancePayment = BalanceStr,
  2112. AuditedFunds = auditFee
  2113. });
  2114. _detail.IsAuditGM = entity.IsAuditGM;
  2115. detailList.Add(_detail);
  2116. }
  2117. #endregion
  2118. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2119. /*
  2120. * 下方描述处理
  2121. */
  2122. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2123. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2124. if (ccpCurrencyPrice != null)
  2125. {
  2126. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2127. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2128. }
  2129. else
  2130. {
  2131. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2132. }
  2133. string amountPayableStr = string.Format(@"应付款总金额: ");
  2134. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2135. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2136. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2137. foreach (var item in nonDuplicat)
  2138. {
  2139. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2140. if (strs.Count > 0)
  2141. {
  2142. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2143. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2144. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2145. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2146. //单独处理此次付款金额
  2147. if (item.CurrencyId == 836) //人民币
  2148. {
  2149. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2150. }
  2151. else
  2152. {
  2153. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2154. }
  2155. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2156. //单独处理已审核费用
  2157. if (item.CurrencyId == 836) //人民币
  2158. {
  2159. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2160. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2161. }
  2162. else
  2163. {
  2164. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2165. }
  2166. }
  2167. }
  2168. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2169. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2170. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2171. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2172. var _view1 = new
  2173. {
  2174. PageFuncAuth = pageFunAuthView,
  2175. Data = _view
  2176. };
  2177. return Ok(JsonView(_view1));
  2178. }
  2179. catch (Exception ex)
  2180. {
  2181. return Ok(JsonView(false, ex.Message));
  2182. }
  2183. }
  2184. /// <summary>
  2185. /// 费用审核
  2186. /// 修改团组费用审核状态
  2187. /// </summary>
  2188. /// <param name="_dto">参数Json字符串</param>
  2189. /// <returns></returns>
  2190. [HttpPost]
  2191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2192. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2193. {
  2194. #region 参数验证
  2195. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2196. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2197. #endregion
  2198. #region 页面操作权限验证
  2199. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2200. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2201. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2202. #endregion
  2203. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2204. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2205. DateTime dtNow = DateTime.Now;
  2206. _groupRepository.BeginTran();
  2207. int rst = 0;
  2208. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2209. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2210. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2211. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2212. List<dynamic> msgDatas = new List<dynamic>();
  2213. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2214. foreach (var item in idList)
  2215. {
  2216. int CreditId = int.Parse(item);
  2217. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2218. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2219. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2220. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2221. .Where(s => s.Id == CreditId)
  2222. .ExecuteCommandAsync();
  2223. if (result < 1)
  2224. {
  2225. rst = -1;
  2226. _groupRepository.RollbackTran();
  2227. return Ok(JsonView(false, "操作失败并回滚!"));
  2228. }
  2229. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2230. if (creditData != null)
  2231. {
  2232. #region 应用通知配置
  2233. try
  2234. {
  2235. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2236. }
  2237. catch (Exception ex)
  2238. {
  2239. }
  2240. #endregion
  2241. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2242. string groupNameStr = string.Empty;
  2243. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2244. if (groupData != null) groupNameStr = groupData.TeamName;
  2245. string creditTypeStr = string.Empty;
  2246. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2247. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2248. string creditCurrency = string.Empty;
  2249. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2250. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2251. if (creditCurrency.Equals("CNY"))
  2252. {
  2253. creditData.DayRate = 1.0000M;
  2254. }
  2255. if (creditData.PayPercentage == 0.00M)
  2256. {
  2257. creditData.PayPercentage = 100M;
  2258. }
  2259. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2260. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2261. string msgContent = "";
  2262. if (creditCurrency.Equals("CNY"))
  2263. {
  2264. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2265. }
  2266. else
  2267. {
  2268. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2269. }
  2270. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2271. }
  2272. }
  2273. if (rst == 0)
  2274. {
  2275. _groupRepository.CommitTran();
  2276. foreach (var item in msgDatas)
  2277. {
  2278. //发送消息
  2279. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2280. }
  2281. #region 应用推送
  2282. try
  2283. {
  2284. foreach (var ccpId in dic_ccp_user.Keys)
  2285. {
  2286. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2287. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2288. }
  2289. }
  2290. catch (Exception)
  2291. {
  2292. }
  2293. #endregion
  2294. return Ok(JsonView(true, "操作成功!"));
  2295. }
  2296. return Ok(JsonView(false, "操作失败!"));
  2297. }
  2298. #endregion
  2299. #region 机票费用录入
  2300. /// <summary>
  2301. /// 机票录入当前登录人可操作团组
  2302. /// </summary>
  2303. /// <param name="dto"></param>
  2304. /// <returns></returns>
  2305. [HttpPost]
  2306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2307. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2308. {
  2309. try
  2310. {
  2311. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2312. if (groupData.Code != 0)
  2313. {
  2314. return Ok(JsonView(false, groupData.Msg));
  2315. }
  2316. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2317. }
  2318. catch (Exception ex)
  2319. {
  2320. return Ok(JsonView(false, "程序错误!"));
  2321. throw;
  2322. }
  2323. }
  2324. /// <summary>
  2325. /// 机票费用录入列表
  2326. /// </summary>
  2327. /// <param name="dto"></param>
  2328. /// <returns></returns>
  2329. [HttpPost]
  2330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2331. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2332. {
  2333. try
  2334. {
  2335. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2336. if (groupData.Code != 0)
  2337. {
  2338. return Ok(JsonView(false, groupData.Msg));
  2339. }
  2340. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2341. }
  2342. catch (Exception ex)
  2343. {
  2344. return Ok(JsonView(false, ex.Message));
  2345. throw;
  2346. }
  2347. }
  2348. /// <summary>
  2349. /// 根据id查询费用录入信息
  2350. /// </summary>
  2351. /// <param name="dto"></param>
  2352. /// <returns></returns>
  2353. [HttpPost]
  2354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2355. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2356. {
  2357. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2358. if (groupData.Code != 0)
  2359. {
  2360. return Ok(JsonView(false, groupData.Msg));
  2361. }
  2362. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2363. }
  2364. /// <summary>
  2365. /// 机票费用录入操作(Status:1.新增,2.修改)
  2366. /// </summary>
  2367. /// <param name="dto"></param>
  2368. /// <returns></returns>
  2369. [HttpPost]
  2370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2371. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2372. {
  2373. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2374. if (groupData.Code != 0)
  2375. {
  2376. return Ok(JsonView(false, groupData.Msg));
  2377. }
  2378. #region 应用推送
  2379. try
  2380. {
  2381. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2382. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2383. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2384. //2024-10-21 新增LZ UID
  2385. var userIds = new List<int>() { 21 };
  2386. string title = $"系统通知";
  2387. string content = "";
  2388. var diId = dto.AirTicketResOpData.DiId;
  2389. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2390. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2391. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2392. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2393. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2394. await GeneralMethod.iOS_PushNotifications("051", $"机票费用审核", "", content);
  2395. }
  2396. catch (Exception ex)
  2397. {
  2398. }
  2399. #endregion
  2400. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2401. }
  2402. /// <summary>
  2403. /// 根据舱位类型查询接团客户名单信息
  2404. /// </summary>
  2405. /// <param name="dto"></param>
  2406. /// <returns></returns>
  2407. [HttpPost]
  2408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2409. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2410. {
  2411. try
  2412. {
  2413. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2414. if (crm_Groups.Count != 0)
  2415. {
  2416. List<dynamic> Customer = new List<dynamic>();
  2417. foreach (var item in crm_Groups)
  2418. {
  2419. var data = new
  2420. {
  2421. Id = item.Id,
  2422. Pinyin = item.Pinyin,
  2423. Name = item.LastName + item.FirstName
  2424. };
  2425. Customer.Add(data);
  2426. }
  2427. return Ok(JsonView(true, "查询成功!", Customer));
  2428. }
  2429. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2430. }
  2431. catch (Exception ex)
  2432. {
  2433. return Ok(JsonView(false, "程序错误!"));
  2434. throw;
  2435. }
  2436. }
  2437. /// <summary>
  2438. /// 根据团号获取客户信息
  2439. /// </summary>
  2440. /// <param name="dto"></param>
  2441. /// <returns></returns>
  2442. [HttpPost]
  2443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2444. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2445. {
  2446. var jw = JsonView(false);
  2447. if (dto.DIID < 1)
  2448. {
  2449. jw.Msg += "请输入正确的diid";
  2450. return Ok(jw);
  2451. }
  2452. var arr = getSimplClientList(dto.DIID);
  2453. jw = JsonView(true, "获取成功!", arr);
  2454. return Ok(jw);
  2455. }
  2456. private List<SimplClientInfo> getSimplClientList(int diId)
  2457. {
  2458. 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);
  2459. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2460. return arr;
  2461. }
  2462. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2463. {
  2464. string result = origin;
  2465. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2466. {
  2467. string[] temparr = origin.Split(',');
  2468. string fistrStr = temparr[0];
  2469. int count = temparr.Count();
  2470. int tempId;
  2471. bool success = int.TryParse(fistrStr, out tempId);
  2472. if (success)
  2473. {
  2474. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2475. if (tempInfo != null)
  2476. {
  2477. if (count > 1)
  2478. {
  2479. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2480. }
  2481. else
  2482. {
  2483. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2484. }
  2485. }
  2486. }
  2487. }
  2488. return result;
  2489. }
  2490. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2491. {
  2492. string result = origin;
  2493. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2494. {
  2495. string[] temparr = origin.Split(',');
  2496. result = "";
  2497. foreach (var item in temparr)
  2498. {
  2499. int tempId;
  2500. bool success = int.TryParse(item, out tempId);
  2501. if (success)
  2502. {
  2503. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2504. if (tempInfo != null)
  2505. {
  2506. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2507. }
  2508. }
  2509. }
  2510. }
  2511. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2512. return result;
  2513. }
  2514. /// <summary>
  2515. /// 机票费用录入,删除
  2516. /// </summary>
  2517. /// <param name="dto"></param>
  2518. /// <returns></returns>
  2519. [HttpPost]
  2520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2521. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2522. {
  2523. try
  2524. {
  2525. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2526. if (res)
  2527. {
  2528. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2529. {
  2530. IsDel = 1,
  2531. DeleteUserId = dto.DeleteUserId,
  2532. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2533. }).ExecuteCommandAsync();
  2534. return Ok(JsonView(true, "删除成功!"));
  2535. }
  2536. return Ok(JsonView(false, "删除失败!"));
  2537. }
  2538. catch (Exception ex)
  2539. {
  2540. return Ok(JsonView(false, "程序错误!"));
  2541. throw;
  2542. }
  2543. }
  2544. /// <summary>
  2545. /// 导出机票录入报表
  2546. /// </summary>
  2547. /// <param name="dto"></param>
  2548. /// <returns></returns>
  2549. [HttpPost]
  2550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2551. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2552. {
  2553. try
  2554. {
  2555. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2556. if (groupData.Code != 0)
  2557. {
  2558. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2559. }
  2560. else
  2561. {
  2562. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2563. if (AirTicketReservations.Count != 0)
  2564. {
  2565. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2566. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2567. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2568. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2569. WorkbookDesigner designer = new WorkbookDesigner();
  2570. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2571. decimal countCost = 0;
  2572. foreach (var item in AirTicketReservations)
  2573. {
  2574. #region 处理客人姓名
  2575. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2576. item.ClientName = clientNames;
  2577. #endregion
  2578. if (item.BankType == "其他")
  2579. {
  2580. item.BankNo = "--";
  2581. }
  2582. else
  2583. {
  2584. if (!string.IsNullOrEmpty(item.BankType))
  2585. {
  2586. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2587. }
  2588. }
  2589. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2590. item.Price = System.Decimal.Round(item.Price, 2);
  2591. countCost += Convert.ToDecimal(item.Price);
  2592. }
  2593. designer.SetDataSource("Export", AirTicketReservations);
  2594. designer.SetDataSource("ExportDiCode", diCode);
  2595. designer.SetDataSource("ExportDiName", diName);
  2596. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2597. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2598. designer.Process();
  2599. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2600. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2601. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2602. return Ok(JsonView(true, "成功", url = rst));
  2603. }
  2604. else
  2605. {
  2606. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2607. }
  2608. }
  2609. }
  2610. catch (Exception ex)
  2611. {
  2612. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2613. throw;
  2614. }
  2615. }
  2616. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2617. /// <summary>
  2618. /// 行程单导出
  2619. /// </summary>
  2620. /// <param name="dto"></param>
  2621. /// <returns></returns>
  2622. [HttpPost]
  2623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2624. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2625. {
  2626. try
  2627. {
  2628. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2629. if (groupData.Code != 0)
  2630. {
  2631. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2632. }
  2633. else
  2634. {
  2635. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2636. if (dto.Language == "CN")
  2637. {
  2638. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2639. DocumentBuilder builder = new DocumentBuilder(doc);
  2640. int tableIndex = 0;//表格索引
  2641. //得到文档中的第一个表格
  2642. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2643. foreach (var item in _AirTicketReservations)
  2644. {
  2645. #region 处理固定数据
  2646. string[] FlightsCode = item.FlightsCode.Split('/');
  2647. if (FlightsCode.Length != 0)
  2648. {
  2649. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2650. if (_AirCompany != null)
  2651. {
  2652. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2653. }
  2654. else
  2655. {
  2656. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2657. }
  2658. }
  2659. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2660. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2661. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2662. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2663. string name = "";
  2664. foreach (string clientName in nameArray)
  2665. {
  2666. if (!name.Contains(clientName))
  2667. {
  2668. name += clientName + ",";
  2669. }
  2670. }
  2671. if (!string.IsNullOrWhiteSpace(name))
  2672. {
  2673. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2674. }
  2675. else
  2676. {
  2677. table.Range.Bookmarks["ClientName"].Text = "--";
  2678. }
  2679. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2680. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2681. table.Range.Bookmarks["JointTicket"].Text = "--";
  2682. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2683. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2684. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2685. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2686. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2687. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2688. #endregion
  2689. #region 循环数据处理
  2690. List<AirInfo> airs = new List<AirInfo>();
  2691. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2692. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2693. for (int i = 0; i < FlightsCode.Length; i++)
  2694. {
  2695. AirInfo air = new AirInfo();
  2696. string[] tempstr = DayArray[i]
  2697. .Replace("\r\n", string.Empty)
  2698. .Replace("\\r\\n", string.Empty)
  2699. .TrimStart().TrimEnd()
  2700. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2701. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2702. string starCity = "";
  2703. if (star_Three != null)
  2704. {
  2705. starCity = star_Three.AirPort;
  2706. }
  2707. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2708. string EndCity = "";
  2709. if (End_Three != null)
  2710. {
  2711. EndCity = End_Three.AirPort;
  2712. }
  2713. air.Destination = starCity + "/" + EndCity;
  2714. air.Flight = FlightsCode[i];
  2715. air.SeatingClass = item.CTypeName;
  2716. string dateTime = tempstr[2];
  2717. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2718. air.FlightDate = DateTemp;
  2719. air.DepartureTime = tempstr[5];
  2720. air.LandingTime = tempstr[6];
  2721. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2722. air.TicketStatus = "--";
  2723. air.Luggage = "--";
  2724. air.DepartureTerminal = "--";
  2725. air.LandingTerminal = "--";
  2726. airs.Add(air);
  2727. }
  2728. int row = 13;
  2729. for (int i = 0; i < airs.Count; i++)
  2730. {
  2731. if (airs.Count > 2)
  2732. {
  2733. for (int j = 0; j < airs.Count - 2; j++)
  2734. {
  2735. var CopyRow = table.Rows[12].Clone(true);
  2736. table.Rows.Add(CopyRow);
  2737. }
  2738. }
  2739. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2740. int index = 0;
  2741. foreach (PropertyInfo property in properties)
  2742. {
  2743. string value = property.GetValue(airs[i]).ToString();
  2744. Cell ishcel0 = table.Rows[row].Cells[index];
  2745. Paragraph p = new Paragraph(doc);
  2746. string s = value;
  2747. p.AppendChild(new Run(doc, s));
  2748. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2749. ishcel0.AppendChild(p);
  2750. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2751. index++;
  2752. }
  2753. row++;
  2754. }
  2755. #endregion
  2756. Paragraph lastParagraph = new Paragraph(doc);
  2757. //第一个表格末尾加段落
  2758. table.ParentNode.InsertAfter(lastParagraph, table);
  2759. //复制第一个表格
  2760. Table cloneTable = (Table)table.Clone(true);
  2761. //在文档末尾段落后面加入复制的表格
  2762. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2763. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2764. {
  2765. int rownewsIndex = 13;
  2766. for (int i = 0; i < 2; i++)
  2767. {
  2768. var CopyRow = table.Rows[12].Clone(true);
  2769. table.Rows.RemoveAt(13);
  2770. table.Rows.Add(CopyRow);
  2771. rownewsIndex++;
  2772. }
  2773. }
  2774. else
  2775. {
  2776. table.Rows.RemoveAt(12);
  2777. }
  2778. cloneTable.Rows.RemoveAt(12);
  2779. }
  2780. if (_AirTicketReservations.Count != 0)
  2781. {
  2782. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2783. if (FlightsCode.Length != 0)
  2784. {
  2785. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2786. if (_AirCompany != null)
  2787. {
  2788. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2789. }
  2790. else
  2791. {
  2792. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2793. }
  2794. }
  2795. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2796. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2797. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2798. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2799. string name = "";
  2800. foreach (string clientName in nameArray)
  2801. {
  2802. if (!name.Contains(clientName))
  2803. {
  2804. name += clientName + ",";
  2805. }
  2806. }
  2807. if (!string.IsNullOrWhiteSpace(name))
  2808. {
  2809. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2810. }
  2811. else
  2812. {
  2813. table.Range.Bookmarks["ClientName"].Text = "--";
  2814. }
  2815. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2816. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2817. table.Range.Bookmarks["JointTicket"].Text = "--";
  2818. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2819. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2820. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2821. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2822. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2823. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2824. }
  2825. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2826. //保存合并后的文档
  2827. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2828. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2829. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2830. return Ok(JsonView(true, "成功!", rst));
  2831. }
  2832. else
  2833. {
  2834. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2835. DocumentBuilder builder = new DocumentBuilder(doc);
  2836. int tableIndex = 0;//表格索引
  2837. //得到文档中的第一个表格
  2838. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2839. List<string> texts = new List<string>();
  2840. foreach (var item in _AirTicketReservations)
  2841. {
  2842. string[] FlightsCode = item.FlightsCode.Split('/');
  2843. if (FlightsCode.Length != 0)
  2844. {
  2845. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2846. if (_AirCompany != null)
  2847. {
  2848. if (!transDic.ContainsKey(_AirCompany.CnName))
  2849. {
  2850. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2851. }
  2852. }
  2853. else
  2854. {
  2855. if (!transDic.ContainsKey("--"))
  2856. {
  2857. transDic.Add("--", "--");
  2858. }
  2859. }
  2860. }
  2861. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2862. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2863. string name = "";
  2864. foreach (string clientName in nameArray)
  2865. {
  2866. name += clientName + ",";
  2867. }
  2868. if (!texts.Contains(name))
  2869. {
  2870. texts.Add(name);
  2871. }
  2872. List<AirInfo> airs = new List<AirInfo>();
  2873. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2874. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2875. for (int i = 0; i < FlightsCode.Length; i++)
  2876. {
  2877. AirInfo air = new AirInfo();
  2878. string[] tempstr = DayArray[i]
  2879. .Replace("\r\n", string.Empty)
  2880. .Replace("\\r\\n", string.Empty)
  2881. .TrimStart().TrimEnd()
  2882. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2883. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2884. if (star_Three != null)
  2885. {
  2886. if (!transDic.ContainsKey(star_Three.AirPort))
  2887. {
  2888. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2889. }
  2890. }
  2891. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2892. if (End_Three != null)
  2893. {
  2894. if (!transDic.ContainsKey(End_Three.AirPort))
  2895. {
  2896. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2897. }
  2898. }
  2899. if (!texts.Contains(item.CTypeName))
  2900. {
  2901. texts.Add(item.CTypeName);
  2902. }
  2903. }
  2904. }
  2905. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2906. if (transData.Count > 0)
  2907. {
  2908. foreach (TranslateResult item in transData)
  2909. {
  2910. if (!transDic.ContainsKey(item.Query))
  2911. {
  2912. transDic.Add(item.Query, item.Translation);
  2913. }
  2914. }
  2915. }
  2916. foreach (var item in _AirTicketReservations)
  2917. {
  2918. #region 处理固定数据
  2919. string[] FlightsCode = item.FlightsCode.Split('/');
  2920. if (FlightsCode.Length != 0)
  2921. {
  2922. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2923. if (_AirCompany != null)
  2924. {
  2925. string str = "--";
  2926. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2927. if (!string.IsNullOrEmpty(translateResult))
  2928. {
  2929. str = translateResult;
  2930. str = _airTicketResRep.Processing(str);
  2931. }
  2932. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2933. }
  2934. else
  2935. {
  2936. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2937. }
  2938. }
  2939. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2940. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2941. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2942. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2943. string names = "";
  2944. foreach (string clientName in nameArray)
  2945. {
  2946. names += clientName + ",";
  2947. }
  2948. if (!string.IsNullOrWhiteSpace(names))
  2949. {
  2950. string str = "--";
  2951. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2952. if (!string.IsNullOrEmpty(translateResult))
  2953. {
  2954. str = translateResult;
  2955. str = _airTicketResRep.Processing(str);
  2956. }
  2957. table.Range.Bookmarks["ClientName"].Text = str;
  2958. }
  2959. else
  2960. {
  2961. table.Range.Bookmarks["ClientName"].Text = "--";
  2962. }
  2963. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2964. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2965. table.Range.Bookmarks["JointTicket"].Text = "--";
  2966. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2967. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2968. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2969. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2970. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2971. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2972. #endregion
  2973. #region 循环数据处理
  2974. List<AirInfo> airs = new List<AirInfo>();
  2975. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2976. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2977. for (int i = 0; i < FlightsCode.Length; i++)
  2978. {
  2979. AirInfo air = new AirInfo();
  2980. string[] tempstr = DayArray[i]
  2981. .Replace("\r\n", string.Empty)
  2982. .Replace("\\r\\n", string.Empty)
  2983. .TrimStart().TrimEnd()
  2984. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2985. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2986. string starCity = "";
  2987. if (star_Three != null)
  2988. {
  2989. string str2 = "--";
  2990. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2991. if (!string.IsNullOrEmpty(translateResult2))
  2992. {
  2993. str2 = translateResult2;
  2994. str2 = _airTicketResRep.Processing(str2);
  2995. }
  2996. starCity = str2;
  2997. }
  2998. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2999. string EndCity = "";
  3000. if (End_Three != null)
  3001. {
  3002. string str1 = "--";
  3003. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3004. if (!string.IsNullOrEmpty(translateResult1))
  3005. {
  3006. str1 = translateResult1;
  3007. str1 = _airTicketResRep.Processing(str1);
  3008. }
  3009. EndCity = str1;
  3010. }
  3011. air.Destination = starCity + "/" + EndCity;
  3012. air.Flight = FlightsCode[i];
  3013. string str = "--";
  3014. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3015. if (!string.IsNullOrEmpty(translateResult))
  3016. {
  3017. str = translateResult;
  3018. str = _airTicketResRep.Processing(str);
  3019. }
  3020. air.SeatingClass = str;
  3021. string dateTime = tempstr[2];
  3022. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3023. air.FlightDate = DateTemp;
  3024. air.DepartureTime = tempstr[5];
  3025. air.LandingTime = tempstr[6];
  3026. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3027. air.TicketStatus = "--";
  3028. air.Luggage = "--";
  3029. air.DepartureTerminal = "--";
  3030. air.LandingTerminal = "--";
  3031. airs.Add(air);
  3032. }
  3033. int row = 13;
  3034. for (int i = 0; i < airs.Count; i++)
  3035. {
  3036. if (airs.Count > 2)
  3037. {
  3038. for (int j = 0; j < airs.Count - 2; j++)
  3039. {
  3040. var CopyRow = table.Rows[12].Clone(true);
  3041. table.Rows.Add(CopyRow);
  3042. }
  3043. }
  3044. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3045. int index = 0;
  3046. foreach (PropertyInfo property in properties)
  3047. {
  3048. string value = property.GetValue(airs[i]).ToString();
  3049. Cell ishcel0 = table.Rows[row].Cells[index];
  3050. Paragraph p = new Paragraph(doc);
  3051. string s = value;
  3052. p.AppendChild(new Run(doc, s));
  3053. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3054. ishcel0.AppendChild(p);
  3055. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3056. //ishcel0.CellFormat.VerticalAlignment=
  3057. index++;
  3058. }
  3059. row++;
  3060. }
  3061. #endregion
  3062. Paragraph lastParagraph = new Paragraph(doc);
  3063. //第一个表格末尾加段落
  3064. table.ParentNode.InsertAfter(lastParagraph, table);
  3065. //复制第一个表格
  3066. Table cloneTable = (Table)table.Clone(true);
  3067. //在文档末尾段落后面加入复制的表格
  3068. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3069. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3070. {
  3071. int rownewsIndex = 13;
  3072. for (int i = 0; i < 2; i++)
  3073. {
  3074. var CopyRow = table.Rows[12].Clone(true);
  3075. table.Rows.RemoveAt(13);
  3076. table.Rows.Add(CopyRow);
  3077. rownewsIndex++;
  3078. }
  3079. }
  3080. else
  3081. {
  3082. table.Rows.RemoveAt(12);
  3083. }
  3084. cloneTable.Rows.RemoveAt(12);
  3085. }
  3086. if (_AirTicketReservations.Count != 0)
  3087. {
  3088. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3089. if (FlightsCode.Length != 0)
  3090. {
  3091. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3092. if (_AirCompany != null)
  3093. {
  3094. string str = "--";
  3095. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3096. if (!string.IsNullOrEmpty(translateResult))
  3097. {
  3098. str = translateResult;
  3099. str = _airTicketResRep.Processing(str);
  3100. }
  3101. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3102. }
  3103. else
  3104. {
  3105. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3106. }
  3107. }
  3108. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3109. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3110. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3111. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3112. string names = "";
  3113. foreach (string clientName in nameArray)
  3114. {
  3115. names += clientName + ",";
  3116. }
  3117. if (!string.IsNullOrWhiteSpace(names))
  3118. {
  3119. string str = "--";
  3120. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3121. if (!string.IsNullOrEmpty(translateResult))
  3122. {
  3123. str = translateResult;
  3124. str = _airTicketResRep.Processing(str);
  3125. }
  3126. table.Range.Bookmarks["ClientName"].Text = str;
  3127. }
  3128. else
  3129. {
  3130. table.Range.Bookmarks["ClientName"].Text = "--";
  3131. }
  3132. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3133. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3134. table.Range.Bookmarks["JointTicket"].Text = "--";
  3135. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3136. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3137. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3138. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3139. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3140. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3141. }
  3142. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3143. //保存合并后的文档
  3144. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3145. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3146. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3147. return Ok(JsonView(true, "成功!", rst));
  3148. }
  3149. }
  3150. }
  3151. catch (Exception ex)
  3152. {
  3153. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3154. throw;
  3155. }
  3156. }
  3157. #endregion
  3158. #region 团组增减款项 --> 其他款项
  3159. /// <summary>
  3160. /// 团组增减款项下拉框绑定
  3161. /// </summary>
  3162. /// <param name="dto"></param>
  3163. /// <returns></returns>
  3164. [HttpPost]
  3165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3166. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3167. {
  3168. #region 参数验证
  3169. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3170. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3171. #endregion
  3172. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3173. }
  3174. /// <summary>
  3175. /// 根据团组Id查询团组增减款项
  3176. /// </summary>
  3177. /// <param name="dto"></param>
  3178. /// <returns></returns>
  3179. [HttpPost]
  3180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3181. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3182. {
  3183. #region 参数验证
  3184. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3185. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3186. #endregion
  3187. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3188. }
  3189. /// <summary>
  3190. /// 团组增减款项操作(Status:1.新增,2.修改)
  3191. /// </summary>
  3192. /// <param name="dto"></param>
  3193. /// <returns></returns>
  3194. [HttpPost]
  3195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3196. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3197. {
  3198. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3199. if (groupData.Code != 200)
  3200. {
  3201. return Ok(JsonView(false, groupData.Msg));
  3202. }
  3203. #region 应用推送
  3204. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3205. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3206. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3207. //2024-10-21 新增LZ UID
  3208. var userIds = new List<int>() { 21 };
  3209. string title = $"系统通知";
  3210. string content = "";
  3211. var diId = dto.DiId;
  3212. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3213. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3214. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3215. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3216. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3217. await GeneralMethod.iOS_PushNotifications("051", $"其他款项费用审核", "", content);
  3218. #endregion
  3219. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3220. }
  3221. /// <summary>
  3222. /// 团组增减款项操作 删除
  3223. /// </summary>
  3224. /// <param name="dto"></param>
  3225. /// <returns></returns>
  3226. [HttpPost]
  3227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3228. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3229. {
  3230. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3231. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3232. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3233. if (res.Code == 0)
  3234. {
  3235. return Ok(JsonView(true, "删除成功!"));
  3236. }
  3237. return Ok(JsonView(false, "删除失败!"));
  3238. }
  3239. /// <summary>
  3240. /// 根据团组增减款项Id查询
  3241. /// </summary>
  3242. /// <param name="dto"></param>
  3243. /// <returns></returns>
  3244. [HttpPost]
  3245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3246. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3247. {
  3248. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3249. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3250. }
  3251. /// <summary>
  3252. /// 查询供应商名称
  3253. /// </summary>
  3254. /// <param name="dto"></param>
  3255. /// <returns></returns>
  3256. [HttpPost]
  3257. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3258. {
  3259. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3260. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3261. ?? new List<Grp_DecreasePayments>();
  3262. dbResult = dbResult.Distinct(new
  3263. ProductComparer()).ToList();
  3264. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3265. {
  3266. x.Id,
  3267. x.SupplierAddress,
  3268. x.SupplierArea,
  3269. x.SupplierContact,
  3270. x.SupplierContactNumber,
  3271. x.SupplierEmail,
  3272. x.SupplierName,
  3273. x.SupplierSocialAccount,
  3274. x.SupplierTypeId,
  3275. }).ToList());
  3276. return Ok(jw);
  3277. }
  3278. /// <summary>
  3279. /// 团组增减款项 OTA匹配
  3280. /// </summary>
  3281. /// <param name="file"></param>
  3282. /// <returns></returns>
  3283. [HttpPost]
  3284. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3285. {
  3286. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3287. string fileName = file.FileName;
  3288. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3289. {
  3290. return Ok(JsonView(false, "请上传Excel文件!"));
  3291. }
  3292. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3293. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3294. if (!Directory.Exists(path))
  3295. {
  3296. Directory.CreateDirectory(path);
  3297. }
  3298. var filePath = @$"{path}/{fileName}";
  3299. //保存文件
  3300. using (FileStream fs = System.IO.File.Create(filePath))
  3301. {
  3302. file.CopyTo(fs);
  3303. fs.Flush();
  3304. }
  3305. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3306. //读取ExcelFile
  3307. DataTable dt = ConvertExcelToDataTable(filePath);
  3308. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3309. dt.TableName = "TB";
  3310. //修改table列名
  3311. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3312. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3313. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3314. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3315. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3316. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3317. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3318. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3319. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3320. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3321. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3322. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3323. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3324. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3325. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3326. var otaOrderNos = new List<string>();
  3327. foreach (DataRow item in dt.Rows)
  3328. {
  3329. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3330. }
  3331. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3332. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3333. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3334. .Select((dp, di) => new
  3335. {
  3336. dp.PriceName,
  3337. dp.OTAOrderNo,
  3338. dp.FeeTotal,
  3339. di.TeamName,
  3340. })
  3341. .ToListAsync();
  3342. foreach (DataRow item in dt.Rows)
  3343. {
  3344. var otaOrderNo = item["OTAOrderNo"].ToString();
  3345. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3346. if (oaData == null) continue;
  3347. item["GroupName"] = oaData.TeamName;
  3348. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3349. }
  3350. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3351. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3352. List<DataTable> datas = new List<DataTable>();
  3353. datas.Add(dt);
  3354. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3355. return Ok(JsonView(true, "操作成功", new { url = url }));
  3356. }
  3357. #region
  3358. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3359. {
  3360. // 创建Workbook对象
  3361. Workbook workbook = new Workbook(excelFilePath);
  3362. // 获取第一个工作表
  3363. Worksheet worksheet = workbook.Worksheets[0];
  3364. // 将工作表转换为DataTable
  3365. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3366. return dataTable;
  3367. }
  3368. #endregion
  3369. #endregion
  3370. #region 文件上传、删除
  3371. /// <summary>
  3372. /// region 文件上传 可以带参数
  3373. /// </summary>
  3374. /// <param name="file"></param>
  3375. /// <returns></returns>
  3376. [HttpPost]
  3377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3378. public async Task<IActionResult> UploadProject(IFormFile file)
  3379. {
  3380. //var TypeName = Request.Headers["TypeName"].ToString();
  3381. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3382. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3383. ////文件名称
  3384. //string projectFileName = file.FileName;
  3385. ////上传的文件的路径
  3386. //string filePath = $"{fileDir}/{projectFileName}";
  3387. //if (TypeName == "A")//A代表团组增减款项
  3388. //{
  3389. // filePath = fileDir + $@"\团组增减款项相关文件";
  3390. // if (!Directory.Exists(filePath))
  3391. // {
  3392. // Directory.CreateDirectory(filePath);
  3393. // }
  3394. // //上传的文件的路径
  3395. // filePath += $@"\{projectFileName}";
  3396. //}
  3397. //else if (TypeName == "B")//B代表商邀相关文件
  3398. //{
  3399. // //上传的文件的路径
  3400. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3401. // if (!Directory.Exists(filePath))
  3402. // {
  3403. // Directory.CreateDirectory(filePath);
  3404. // }
  3405. // //上传的文件的路径
  3406. // filePath = $@"\{projectFileName}";
  3407. //}
  3408. //try
  3409. //{
  3410. // using (FileStream fs = System.IO.File.Create(filePath))
  3411. // {
  3412. // file.CopyTo(fs);
  3413. // fs.Flush();
  3414. // }
  3415. //}
  3416. //catch (Exception ex)
  3417. //{
  3418. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3419. //}
  3420. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3421. try
  3422. {
  3423. var TypeName = Request.Headers["TypeName"].ToString();
  3424. if (file != null)
  3425. {
  3426. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3427. //文件名称
  3428. string projectFileName = file.FileName;
  3429. //上传的文件的路径
  3430. string filePath = $"{fileDir}/{projectFileName}";
  3431. if (TypeName == "A")//A代表团组增减款项
  3432. {
  3433. if (!Directory.Exists(fileDir))
  3434. {
  3435. Directory.CreateDirectory(fileDir);
  3436. }
  3437. //上传的文件的路径
  3438. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3439. }
  3440. else if (TypeName == "B")//B代表商邀相关文件
  3441. {
  3442. if (!Directory.Exists(fileDir))
  3443. {
  3444. Directory.CreateDirectory(fileDir);
  3445. }
  3446. //上传的文件的路径
  3447. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3448. }
  3449. using (FileStream fs = System.IO.File.Create(filePath))
  3450. {
  3451. file.CopyTo(fs);
  3452. fs.Flush();
  3453. }
  3454. return Ok(JsonView(true, "上传成功!", projectFileName));
  3455. }
  3456. else
  3457. {
  3458. return Ok(JsonView(false, "上传失败!"));
  3459. }
  3460. }
  3461. catch (Exception ex)
  3462. {
  3463. return Ok(JsonView(false, "程序错误!"));
  3464. }
  3465. }
  3466. /// <summary>
  3467. /// 删除指定文件
  3468. /// </summary>
  3469. /// <param name="dto"></param>
  3470. /// <returns></returns>
  3471. [HttpPost]
  3472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3473. public async Task<IActionResult> DelFile(DelFileDto dto)
  3474. {
  3475. try
  3476. {
  3477. var TypeName = Request.Headers["TypeName"].ToString();
  3478. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3479. string filePath = "";
  3480. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3481. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3482. int id = 0;
  3483. if (TypeName == "A")
  3484. {
  3485. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3486. // 删除该文件
  3487. System.IO.File.Delete(filePath);
  3488. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3489. .Where(a => a.Id == dto.Id)
  3490. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3491. .ExecuteCommandAsync();
  3492. }
  3493. else if (TypeName == "B")
  3494. {
  3495. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3496. // 删除该文件
  3497. System.IO.File.Delete(filePath);
  3498. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3499. if (info != null)
  3500. {
  3501. string[] files = new string[] { };
  3502. if (!string.IsNullOrEmpty(info.Attachment))
  3503. {
  3504. try
  3505. {
  3506. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3507. }
  3508. catch (Exception)
  3509. {
  3510. files = new List<string>() { info.Attachment }.ToArray();
  3511. }
  3512. }
  3513. if (files.Length > 0)
  3514. {
  3515. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3516. string filePath2 = string.Empty;
  3517. if (files1.Length > 0)
  3518. {
  3519. filePath2 = JsonConvert.SerializeObject(files1);
  3520. }
  3521. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3522. .Where(a => a.Id == dto.Id)
  3523. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3524. .ExecuteCommandAsync();
  3525. }
  3526. }
  3527. }
  3528. if (id != 0)
  3529. {
  3530. return Ok(JsonView(true, "成功!"));
  3531. }
  3532. else
  3533. {
  3534. return Ok(JsonView(false, "失败!"));
  3535. }
  3536. }
  3537. catch (Exception ex)
  3538. {
  3539. return Ok(JsonView(false, "程序错误!"));
  3540. throw;
  3541. }
  3542. }
  3543. /// <summary>
  3544. /// 文件上传多个文件 可以带参数
  3545. /// </summary>
  3546. /// <param name="file"></param>
  3547. /// <returns></returns>
  3548. [HttpPost]
  3549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3550. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3551. {
  3552. try
  3553. {
  3554. var TypeName = Request.Headers["TypeName"].ToString();
  3555. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3556. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3557. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3558. var filePahts = new List<string>();
  3559. foreach (var file in files)
  3560. {
  3561. //文件名称
  3562. string projectFileName = file.FileName;
  3563. //上传的文件的路径
  3564. string filePath = $"{fileDir}/{projectFileName}";
  3565. if (TypeName == "A")//A代表团组增减款项
  3566. {
  3567. if (!Directory.Exists(fileDir))
  3568. {
  3569. Directory.CreateDirectory(fileDir);
  3570. }
  3571. //上传的文件的路径
  3572. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3573. }
  3574. else if (TypeName == "B")//B代表商邀相关文件
  3575. {
  3576. if (!Directory.Exists(fileDir))
  3577. {
  3578. Directory.CreateDirectory(fileDir);
  3579. }
  3580. //上传的文件的路径
  3581. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3582. }
  3583. using (FileStream fs = System.IO.File.Create(filePath))
  3584. {
  3585. file.CopyTo(fs);
  3586. fs.Flush();
  3587. }
  3588. filePahts.Add(projectFileName);
  3589. }
  3590. return Ok(JsonView(true, "上传成功!", filePahts));
  3591. }
  3592. catch (Exception ex)
  3593. {
  3594. return Ok(JsonView(false, "程序错误!"));
  3595. }
  3596. }
  3597. #endregion
  3598. #region 商邀费用录入
  3599. /// <summary>
  3600. /// 根据团组Id查询商邀费用列表
  3601. /// </summary>
  3602. /// <param name="dto"></param>
  3603. /// <returns></returns>
  3604. [HttpPost]
  3605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3606. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3607. {
  3608. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3609. if (groupData.Code != 0)
  3610. {
  3611. return Ok(JsonView(false, groupData.Msg));
  3612. }
  3613. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3614. }
  3615. /// <summary>
  3616. /// 商邀费用列表
  3617. /// 下载文件
  3618. /// </summary>
  3619. /// <param name="dto"></param>
  3620. /// <returns></returns>
  3621. [HttpGet("{id}")]
  3622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3623. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3624. {
  3625. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3626. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3627. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3628. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3629. var filePaths = new List<string>();
  3630. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3631. try
  3632. {
  3633. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3634. }
  3635. catch (Exception ex)
  3636. {
  3637. filePaths.Add(info.Attachment);
  3638. }
  3639. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3640. for (int i = 0; i < filePaths.Count; i++)
  3641. {
  3642. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3643. }
  3644. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3645. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3646. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3647. {
  3648. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3649. {
  3650. foreach (string filePath in filePaths)
  3651. {
  3652. if (System.IO.File.Exists(filePath))
  3653. {
  3654. // 获取文件名
  3655. string fileName = Path.GetFileName(filePath);
  3656. // 将文件添加到ZIP归档中
  3657. zipArchive.CreateEntryFromFile(filePath, fileName);
  3658. }
  3659. }
  3660. }
  3661. }
  3662. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3663. }
  3664. /// <summary>
  3665. /// 商邀费用 Info Page 基础数据源
  3666. /// </summary>
  3667. /// <param name="dto"></param>
  3668. /// <returns></returns>
  3669. [HttpPost]
  3670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3671. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3672. {
  3673. try
  3674. {
  3675. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3676. if (groupData.Code != 0)
  3677. {
  3678. return Ok(JsonView(false, groupData.Msg));
  3679. }
  3680. return Ok(JsonView(true, "操作成功", groupData.Data));
  3681. }
  3682. catch (Exception ex)
  3683. {
  3684. return Ok(JsonView(false, ex.Message));
  3685. throw;
  3686. }
  3687. }
  3688. /// <summary>
  3689. /// 根据商邀费用ID查询C表和商邀费用数据
  3690. /// </summary>
  3691. /// <param name="dto"></param>
  3692. /// <returns></returns>
  3693. [HttpPost]
  3694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3695. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3696. {
  3697. try
  3698. {
  3699. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3700. if (groupData.Code != 0)
  3701. {
  3702. return Ok(JsonView(false, groupData.Msg));
  3703. }
  3704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3705. }
  3706. catch (Exception ex)
  3707. {
  3708. return Ok(JsonView(false, ex.Message));
  3709. throw;
  3710. }
  3711. }
  3712. /// <summary>
  3713. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3714. /// </summary>
  3715. /// <param name="dto"></param>
  3716. /// <returns></returns>
  3717. [HttpPost]
  3718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3719. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3720. {
  3721. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3722. if (groupData.Code != 0)
  3723. {
  3724. return Ok(JsonView(false, groupData.Msg));
  3725. }
  3726. #region 应用推送
  3727. try
  3728. {
  3729. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3730. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3731. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3732. //2024-10-21 新增LZ UID
  3733. var userIds = new List<int>() { 21 };
  3734. string title = $"系统通知";
  3735. string content = "";
  3736. var diId = dto.DiId;
  3737. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3738. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3739. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3740. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3741. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3742. await GeneralMethod.iOS_PushNotifications("051", $"商邀费用审核", "", content);
  3743. }
  3744. catch (Exception ex)
  3745. {
  3746. }
  3747. #endregion
  3748. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3749. }
  3750. /// <summary>
  3751. /// 商邀删除
  3752. /// </summary>
  3753. /// <param name="dto"></param>
  3754. /// <returns></returns>
  3755. [HttpPost]
  3756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3757. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3758. {
  3759. try
  3760. {
  3761. _sqlSugar.BeginTran();
  3762. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3763. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3764. {
  3765. IsDel = 1,
  3766. DeleteUserId = dto.DeleteUserId,
  3767. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3768. })
  3769. .Where(it => it.Id == dto.Id)
  3770. .ExecuteCommand();
  3771. if (res1 > 0)
  3772. {
  3773. int _diId = 0;
  3774. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3775. if (_ioaInfo != null)
  3776. {
  3777. _diId = _ioaInfo.DiId;
  3778. }
  3779. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3780. .SetColumns(a => new Grp_CreditCardPayment()
  3781. {
  3782. IsDel = 1,
  3783. DeleteUserId = dto.DeleteUserId,
  3784. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3785. })
  3786. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3787. .ExecuteCommand();
  3788. if (res2 > 0)
  3789. {
  3790. _sqlSugar.CommitTran();
  3791. return Ok(JsonView(true, "删除成功!"));
  3792. }
  3793. }
  3794. _sqlSugar.RollbackTran();
  3795. return Ok(JsonView(false, "删除失败"));
  3796. }
  3797. catch (Exception ex)
  3798. {
  3799. _sqlSugar.RollbackTran();
  3800. return Ok(JsonView(false, ex.Message));
  3801. }
  3802. }
  3803. /// <summary>
  3804. /// 团组模块文件上传
  3805. /// </summary>
  3806. /// <param name="dto"></param>
  3807. /// <returns></returns>
  3808. [HttpPost]
  3809. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3810. {
  3811. var jw = JsonView(false);
  3812. long M = 1024 * 1024;
  3813. if (dto.Files == null || dto.Files.Count == 0)
  3814. {
  3815. jw.Msg = "无文件信息!";
  3816. return Ok(jw);
  3817. }
  3818. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3819. {
  3820. jw.Msg = "文件大小超过20M!";
  3821. return Ok(jw);
  3822. }
  3823. //var nameSp = dto.File.FileName.Split(".");
  3824. //if (nameSp.Length < 2)
  3825. //{
  3826. // jw.Msg = "拓展名称有误!";
  3827. // return Ok(jw);
  3828. //}
  3829. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3830. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3831. //{
  3832. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3833. // return Ok(jw);
  3834. //}
  3835. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3836. if (Ctable == null)
  3837. {
  3838. jw.Msg = "Ctable指向有误!";
  3839. return Ok(jw);
  3840. }
  3841. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3842. if (groupInfo == null)
  3843. {
  3844. jw.Msg = "团组信息不存在!";
  3845. return Ok(jw);
  3846. }
  3847. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3848. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3849. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3850. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3851. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3852. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3853. try
  3854. {
  3855. if (!Directory.Exists(fileBase))
  3856. {
  3857. Directory.CreateDirectory(fileBase);
  3858. }
  3859. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3860. foreach (var fileStream in dto.Files)
  3861. {
  3862. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3863. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3864. {
  3865. Cid = dto.Cid,
  3866. CreateTime = DateTime.Now,
  3867. CreateUserId = dto.Userid,
  3868. Ctable = dto.Ctable,
  3869. Diid = dto.Diid,
  3870. IsDel = 0,
  3871. FilePath = saveFilePath,
  3872. FileName = fileStream.FileName
  3873. };
  3874. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3875. {
  3876. fileStream.CopyTo(fs);
  3877. fs.Flush();
  3878. }
  3879. saveArr.Add(file);
  3880. }
  3881. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3882. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3883. jw = JsonView(true, "保存成功!", new
  3884. {
  3885. count = addResult,
  3886. filesName = saveArr.Select(x => x.FileName)
  3887. });
  3888. }
  3889. catch (Exception ex)
  3890. {
  3891. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3892. {
  3893. count = 0,
  3894. filesName = new string[0],
  3895. });
  3896. }
  3897. return Ok(jw);
  3898. }
  3899. /// <summary>
  3900. /// 查询各模块已保存文件
  3901. /// </summary>
  3902. /// <param name="dto"></param>
  3903. /// <returns></returns>
  3904. [HttpPost]
  3905. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3906. {
  3907. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3908. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3909. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3910. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3911. {
  3912. expression = Expressionable.Create<Grp_GroupModelFile>()
  3913. .And(x => visaIds.Contains(x.CreateUserId));
  3914. }
  3915. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3916. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3917. .Where(expression.ToExpression())
  3918. .ToList();
  3919. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3920. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3921. {
  3922. x.FileName,
  3923. x.Id,
  3924. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3925. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3926. })));
  3927. }
  3928. /// <summary>
  3929. /// 下载该团组下的所有文件
  3930. /// </summary>
  3931. /// <param name="dto"></param>
  3932. /// <returns></returns>
  3933. [HttpPost]
  3934. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3935. {
  3936. var jw = JsonView(false);
  3937. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3938. if (groupInfo == null)
  3939. {
  3940. jw.Msg = "团组信息不存在!";
  3941. return Ok(jw);
  3942. }
  3943. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3944. var isModule = Convert.ToBoolean(dto.isModule);
  3945. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3946. IOOperatorHelper io = new IOOperatorHelper();
  3947. if (isModule)
  3948. {
  3949. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3950. foreach (var moduleArr in moduleGroup)
  3951. {
  3952. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3953. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3954. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3955. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3956. foreach (var item in moduleArr)
  3957. {
  3958. if (System.IO.File.Exists(item.FilePath))
  3959. {
  3960. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3961. {
  3962. byte[] bytes = new byte[fileStream.Length];
  3963. fileStream.Read(bytes, 0, bytes.Length);
  3964. fileStream.Close();
  3965. Stream stream = new MemoryStream(bytes);
  3966. chiZips.Add(item.FileName, stream);
  3967. }
  3968. }
  3969. }
  3970. if (chiZips.Count > 0)
  3971. {
  3972. var byts = io.ConvertZipStream(chiZips);
  3973. Stream stream = new MemoryStream(byts);
  3974. Zips.Add(key.Name + "_.zip", stream);
  3975. }
  3976. }
  3977. }
  3978. else
  3979. {
  3980. foreach (var item in dbQuery)
  3981. {
  3982. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3983. {
  3984. byte[] bytes = new byte[fileStream.Length];
  3985. fileStream.Read(bytes, 0, bytes.Length);
  3986. fileStream.Close();
  3987. Stream stream = new MemoryStream(bytes);
  3988. while (Zips.Keys.Contains(item.FileName))
  3989. {
  3990. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3991. }
  3992. Zips.Add(item.FileName, stream);
  3993. }
  3994. }
  3995. }
  3996. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3997. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3998. if (Zips.Count > 0)
  3999. {
  4000. var byts = io.ConvertZipStream(Zips);
  4001. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4002. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4003. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4004. }
  4005. else
  4006. {
  4007. jw.Msg = "暂无生成文件!";
  4008. }
  4009. return Ok(jw);
  4010. }
  4011. /// <summary>
  4012. /// 下载该团组下此模块的所有文件
  4013. /// </summary>
  4014. /// <param name="dto"></param>
  4015. /// <returns></returns>
  4016. [HttpPost]
  4017. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4018. {
  4019. var jw = JsonView(false);
  4020. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4021. if (groupInfo == null)
  4022. {
  4023. jw.Msg = "团组信息不存在!";
  4024. return Ok(jw);
  4025. }
  4026. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4027. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4028. && x.IsDel == 0);
  4029. if (key == null)
  4030. {
  4031. jw.Msg = "Ctable指向错误!";
  4032. return Ok(jw);
  4033. }
  4034. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4035. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4036. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4037. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4038. IOOperatorHelper io = new IOOperatorHelper();
  4039. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4040. foreach (var item in dbQuery)
  4041. {
  4042. if (System.IO.File.Exists(item.FilePath))
  4043. {
  4044. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4045. {
  4046. byte[] bytes = new byte[fileStream.Length];
  4047. fileStream.Read(bytes, 0, bytes.Length);
  4048. fileStream.Close();
  4049. Stream stream = new MemoryStream(bytes);
  4050. while (Zips.Keys.Contains(item.FileName))
  4051. {
  4052. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4053. }
  4054. Zips.Add(item.FileName, stream);
  4055. }
  4056. }
  4057. }
  4058. if (Zips.Count > 0)
  4059. {
  4060. var byts = io.ConvertZipStream(Zips);
  4061. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4062. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4063. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4064. }
  4065. else
  4066. {
  4067. jw.Msg = "暂无生成文件!";
  4068. }
  4069. return Ok(jw);
  4070. }
  4071. /// <summary>
  4072. /// 删除该团组下的指定文件
  4073. /// </summary>
  4074. /// <param name="dto"></param>
  4075. /// <returns></returns>
  4076. [HttpPost]
  4077. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4078. {
  4079. var jw = JsonView(false);
  4080. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4081. if (sing == null)
  4082. {
  4083. jw.Msg = "暂无";
  4084. return Ok(jw);
  4085. }
  4086. if (System.IO.File.Exists(sing.FilePath))
  4087. {
  4088. try
  4089. {
  4090. System.IO.File.Delete(sing.FilePath);
  4091. }
  4092. catch (Exception ex)
  4093. {
  4094. jw.Msg = "删除失败!" + ex.Message;
  4095. return Ok(jw);
  4096. }
  4097. }
  4098. sing.IsDel = 1;
  4099. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4100. sing.DeleteUserId = dto.UserId;
  4101. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4102. jw = JsonView(true, "删除成功!");
  4103. return Ok(jw);
  4104. }
  4105. #endregion
  4106. #region 团组英文资料
  4107. /// <summary>
  4108. /// 查询团组英文所有资料
  4109. /// </summary>
  4110. /// <param name="dto"></param>
  4111. /// <returns></returns>
  4112. [HttpPost]
  4113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4114. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4115. {
  4116. try
  4117. {
  4118. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4119. if (groupData.Code != 0)
  4120. {
  4121. return Ok(JsonView(false, groupData.Msg));
  4122. }
  4123. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4124. }
  4125. catch (Exception ex)
  4126. {
  4127. return Ok(JsonView(false, "程序错误!"));
  4128. throw;
  4129. }
  4130. }
  4131. /// <summary>
  4132. /// 团组英文资料操作(Status:1.新增,2.修改)
  4133. /// </summary>
  4134. /// <param name="dto"></param>
  4135. /// <returns></returns>
  4136. [HttpPost]
  4137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4138. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4139. {
  4140. try
  4141. {
  4142. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4143. if (groupData.Code != 0)
  4144. {
  4145. return Ok(JsonView(false, groupData.Msg));
  4146. }
  4147. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4148. }
  4149. catch (Exception ex)
  4150. {
  4151. return Ok(JsonView(false, "程序错误!"));
  4152. throw;
  4153. }
  4154. }
  4155. /// <summary>
  4156. /// 团组英文资料Id查询数据
  4157. /// </summary>
  4158. /// <param name="dto"></param>
  4159. /// <returns></returns>
  4160. [HttpPost]
  4161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4162. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4163. {
  4164. try
  4165. {
  4166. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4167. if (_DelegationEnData != null)
  4168. {
  4169. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4170. }
  4171. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4172. }
  4173. catch (Exception ex)
  4174. {
  4175. return Ok(JsonView(false, "程序错误!"));
  4176. throw;
  4177. }
  4178. }
  4179. /// <summary>
  4180. /// 团组英文资料删除
  4181. /// </summary>
  4182. /// <param name="dto"></param>
  4183. /// <returns></returns>
  4184. [HttpPost]
  4185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4186. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4187. {
  4188. try
  4189. {
  4190. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4191. if (!res)
  4192. {
  4193. return Ok(JsonView(false, "删除失败"));
  4194. }
  4195. return Ok(JsonView(true, "删除成功!"));
  4196. }
  4197. catch (Exception ex)
  4198. {
  4199. return Ok(JsonView(false, "程序错误!"));
  4200. throw;
  4201. }
  4202. }
  4203. #endregion
  4204. #region 导出邀请函
  4205. /// <summary>
  4206. /// 导出邀请函页面初始化
  4207. /// </summary>
  4208. /// <param name="dto"></param>
  4209. /// <returns></returns>
  4210. [HttpPost]
  4211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4212. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4213. {
  4214. try
  4215. {
  4216. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4217. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4218. if (dto.DiId == 0)
  4219. {
  4220. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4221. }
  4222. else
  4223. {
  4224. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4225. }
  4226. return Ok(JsonView(true, "查询成功!", new
  4227. {
  4228. deleClient = crm_Deles,
  4229. delegations = grp_Delegations
  4230. }));
  4231. }
  4232. catch (Exception ex)
  4233. {
  4234. return Ok(JsonView(false, "程序错误!"));
  4235. throw;
  4236. }
  4237. }
  4238. /// <summary>
  4239. /// 导出邀请函
  4240. /// </summary>
  4241. /// <param name="dto"></param>
  4242. /// <returns></returns>
  4243. [HttpPost]
  4244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4245. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4246. {
  4247. #region 参数验证
  4248. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4249. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4250. #endregion
  4251. try
  4252. {
  4253. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4254. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4255. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4256. From Grp_TourClientList tcl
  4257. Left Join
  4258. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4259. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4260. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4261. From Crm_DeleClient dc
  4262. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4263. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4264. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4265. Where dc.IsDel = 0) temp
  4266. On temp.DcId =tcl.ClientId
  4267. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4268. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4269. List<string> texts = new List<string>();
  4270. if (datas.Count != 0)
  4271. {
  4272. foreach (TourClientListDetailsView item in datas)
  4273. {
  4274. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4275. {
  4276. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4277. }
  4278. else
  4279. {
  4280. string name = item.LastName + item.FirstName;
  4281. texts.Add(name);
  4282. }
  4283. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4284. {
  4285. if (!transDic.ContainsKey(item.Job))
  4286. {
  4287. texts.Add(item.Job);
  4288. }
  4289. }
  4290. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4291. {
  4292. texts.Add(item.CompanyFullName);
  4293. }
  4294. }
  4295. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4296. if (transData.Count > 0)
  4297. {
  4298. foreach (TranslateResult item in transData)
  4299. {
  4300. if (!transDic.ContainsKey(item.Query))
  4301. {
  4302. transDic.Add(item.Query, item.Translation);
  4303. }
  4304. }
  4305. }
  4306. List<GuestList> list = new List<GuestList>();
  4307. foreach (TourClientListDetailsView dele in datas)
  4308. {
  4309. GuestList guestList = new GuestList();
  4310. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4311. {
  4312. guestList.Name = dele.Pinyin;
  4313. }
  4314. else
  4315. {
  4316. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4317. guestList.Name = Name;
  4318. }
  4319. if (dele.Sex == 0)
  4320. {
  4321. guestList.Sex = "Male";
  4322. }
  4323. else if (dele.Sex == 1)
  4324. {
  4325. guestList.Sex = "Female";
  4326. }
  4327. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4328. if (!string.IsNullOrEmpty(dele.Job))
  4329. {
  4330. guestList.Job = dele.Job;
  4331. }
  4332. list.Add(guestList);
  4333. }
  4334. //载入模板
  4335. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4336. DocumentBuilder builder = new DocumentBuilder(doc);
  4337. //获取word里所有表格
  4338. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4339. //获取所填表格的序数
  4340. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4341. var rowStart = tableOne.Rows[0]; //获取第1行
  4342. //循环赋值
  4343. for (int i = 0; i < list.Count; i++)
  4344. {
  4345. builder.MoveToCell(0, i + 1, 0, 0);
  4346. builder.Write(list[i].Name.ToString());
  4347. builder.MoveToCell(0, i + 1, 1, 0);
  4348. builder.Write(list[i].Sex.ToString());
  4349. builder.MoveToCell(0, i + 1, 2, 0);
  4350. builder.Write(list[i].DOB.ToString());
  4351. builder.MoveToCell(0, i + 1, 3, 0);
  4352. builder.Write(list[i].Job.ToString());
  4353. }
  4354. //删除多余行
  4355. while (tableOne.Rows.Count > list.Count + 1)
  4356. {
  4357. tableOne.Rows.RemoveAt(list.Count + 1);
  4358. }
  4359. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4360. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4361. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4362. doc.Save(filePath);
  4363. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4364. return Ok(JsonView(true, "操作成功!", Url));
  4365. }
  4366. else
  4367. {
  4368. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4369. }
  4370. }
  4371. catch (Exception ex)
  4372. {
  4373. return Ok(JsonView(false, ex.Message));
  4374. throw;
  4375. }
  4376. }
  4377. #endregion
  4378. #region 团组经理模块 出入境费用
  4379. ///// <summary>
  4380. ///// 团组模块 - 出入境费用
  4381. ///// </summary>
  4382. ///// <returns></returns>
  4383. //[HttpPost]
  4384. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4385. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4386. //{
  4387. // try
  4388. // {
  4389. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4390. // if (data.Code != 0)
  4391. // {
  4392. // return Ok(JsonView(false, data.Msg));
  4393. // }
  4394. // return Ok(JsonView(true, "查询成功!"));
  4395. // }
  4396. // catch (Exception ex)
  4397. // {
  4398. // return Ok(JsonView(false, ex.Message));
  4399. // throw;
  4400. // }
  4401. //}
  4402. /// <summary>
  4403. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4404. /// </summary>
  4405. /// <returns></returns>
  4406. [HttpPost]
  4407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4408. public async Task<IActionResult> SetDayAndCostAreaChange()
  4409. {
  4410. try
  4411. {
  4412. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4413. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4414. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4415. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4416. foreach (var item in unite) //处理交集数据
  4417. {
  4418. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4419. }
  4420. foreach (var item in merge) //处理差集数据
  4421. {
  4422. int nationalTravelFeeId = 0;
  4423. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4424. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4425. else
  4426. {
  4427. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4428. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4429. }
  4430. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4431. }
  4432. //只更新dayAndCost 的 nationalTravelFeeId;
  4433. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4434. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4435. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4436. }
  4437. catch (Exception ex)
  4438. {
  4439. return Ok(JsonView(false, ex.Message));
  4440. throw;
  4441. }
  4442. }
  4443. /// <summary>
  4444. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4445. /// </summary>
  4446. /// <returns></returns>
  4447. [HttpPost]
  4448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4449. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4450. {
  4451. try
  4452. {
  4453. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4454. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4455. //SetDataInfoView
  4456. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4457. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4458. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4459. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4460. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4461. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4462. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4463. //默认币种显示
  4464. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4465. {
  4466. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4467. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4468. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4469. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4470. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4471. };
  4472. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4473. if (_currencyRate.Count > 0)
  4474. {
  4475. foreach (var item in _currencyInfos)
  4476. {
  4477. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4478. if (rateInfo != null)
  4479. {
  4480. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4481. rate1 *= 1.035M;
  4482. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4483. }
  4484. }
  4485. }
  4486. return Ok(JsonView(true, "查询成功!", new
  4487. {
  4488. GroupNameData = groupNameData.Data,
  4489. CurrencyData = _CurrencyData,
  4490. WordTypeData = _WordTypeData,
  4491. ExcelTypeData = _ExcelTypeData,
  4492. CurrencyInit = _currencyInfos
  4493. }));
  4494. }
  4495. catch (Exception ex)
  4496. {
  4497. return Ok(JsonView(false, ex.Message));
  4498. throw;
  4499. }
  4500. }
  4501. /// <summary>
  4502. /// 团组模块 - 出入境费用
  4503. /// 实时汇率 tips
  4504. /// 签证费用 tips
  4505. /// </summary>
  4506. /// <returns></returns>
  4507. [HttpPost]
  4508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4509. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4510. {
  4511. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4512. //默认币种显示
  4513. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4514. {
  4515. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4516. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4517. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4518. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4519. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4520. };
  4521. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4522. List<dynamic> reteInfos = new List<dynamic>();
  4523. if (_currencyRate.Count > 0)
  4524. {
  4525. foreach (var item in _currencyInfos)
  4526. {
  4527. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4528. if (rateInfo != null)
  4529. {
  4530. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4531. decimal rate1 = item.Rate;
  4532. rate1 *= 1.03M;
  4533. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4534. reteInfos.Add(new
  4535. {
  4536. currCode = item.CurrencyCode,
  4537. currName = item.CurrencyName,
  4538. rate = rate2,
  4539. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4540. });
  4541. }
  4542. }
  4543. }
  4544. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4545. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4546. return Ok(JsonView(true, "查询成功!", new
  4547. {
  4548. //GroupNameData = groupNameData.Data,
  4549. visaData = visaData.Data,
  4550. airData = airData.Data,
  4551. reteInfos = reteInfos
  4552. }));
  4553. }
  4554. /// <summary>
  4555. /// 团组模块 - 出入境费用 - Info
  4556. /// </summary>
  4557. /// <returns></returns>
  4558. [HttpPost]
  4559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4560. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4561. {
  4562. try
  4563. {
  4564. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4565. if (data.Code != 0)
  4566. {
  4567. return Ok(JsonView(false, data.Msg));
  4568. }
  4569. return Ok(JsonView(true, "查询成功!", data.Data));
  4570. }
  4571. catch (Exception ex)
  4572. {
  4573. return Ok(JsonView(false, ex.Message));
  4574. }
  4575. }
  4576. /// <summary>
  4577. /// 团组模块 - 出入境费用 - Add And Update
  4578. /// </summary>
  4579. /// <returns></returns>
  4580. [HttpPost]
  4581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4582. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4583. {
  4584. try
  4585. {
  4586. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4587. if (data.Code != 0)
  4588. {
  4589. return Ok(JsonView(false, data.Msg));
  4590. }
  4591. //生成默认文件pdf并且通知人员
  4592. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4593. {
  4594. DiId = dto.DiId,
  4595. ExportType = 1,
  4596. SubTypeId = 1005
  4597. }, "pdf");
  4598. //发送通知
  4599. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4600. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4601. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4602. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4603. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4604. //汇率信息记录
  4605. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4606. return Ok(JsonView(true, data.Msg, data.Data));
  4607. }
  4608. catch (Exception ex)
  4609. {
  4610. return Ok(JsonView(false, ex.Message));
  4611. }
  4612. }
  4613. /// <summary>
  4614. /// 团组模块 - 出入境费用 - Confirm 费用
  4615. /// </summary>
  4616. /// <returns></returns>
  4617. [HttpPost]
  4618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4619. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4620. {
  4621. //TODO:测试完毕需把对应的用户ID更改
  4622. //1、数据表添加字段
  4623. //2、更改字段接口()
  4624. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4625. //3、确认成功 给财务发送消息
  4626. if (_view.Code == 200)
  4627. {
  4628. if (dto.Type == 1)
  4629. {
  4630. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4631. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4632. }
  4633. }
  4634. return Ok(_view);
  4635. }
  4636. /// <summary>
  4637. /// 团组模块 - 出入境费用 - File downlaod
  4638. /// </summary>
  4639. /// <param name="dto"></param>
  4640. /// <returns></returns>
  4641. [HttpPost]
  4642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4643. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4644. {
  4645. try
  4646. {
  4647. if (dto.DiId < 1)
  4648. {
  4649. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4650. }
  4651. if (dto.ExportType < 1)
  4652. {
  4653. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4654. }
  4655. if (dto.SubTypeId < 1)
  4656. {
  4657. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4658. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4659. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4660. 3 团组成员名单 1 团组成员名单", ""));
  4661. }
  4662. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4663. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4664. if (_EnterExitCosts == null)
  4665. {
  4666. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4667. }
  4668. //数据源
  4669. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4670. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4671. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4672. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4673. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4674. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4675. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4676. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4677. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4678. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4679. .Select((tcl, dc, cc) => new
  4680. {
  4681. Name = dc.LastName + dc.FirstName,
  4682. Sex = dc.Sex,
  4683. Birthday = dc.BirthDay,
  4684. Company = cc.CompanyFullName,
  4685. Job = dc.Job
  4686. })
  4687. .ToList();
  4688. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4689. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4690. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4691. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4692. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4693. if (dto.ExportType == 1) //明细表
  4694. {
  4695. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4696. {
  4697. //获取模板
  4698. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4699. //载入模板
  4700. Document doc = new Document(tempPath);
  4701. DocumentBuilder builder = new DocumentBuilder(doc);
  4702. //利用键值对存放数据
  4703. Dictionary<string, string> dic = new Dictionary<string, string>();
  4704. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4705. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4706. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4707. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4708. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4709. //境内费用(其他费用)
  4710. if (_EnterExitCosts.ChoiceOne == 1)
  4711. {
  4712. string row1_1 = "";
  4713. if (_EnterExitCosts.Visa > 0)
  4714. {
  4715. //insidePayTotal += _EnterExitCosts.Visa;
  4716. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4717. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4718. {
  4719. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4720. }
  4721. }
  4722. string row1_2 = "";
  4723. if (_EnterExitCosts.YiMiao > 0)
  4724. {
  4725. //insidePayTotal += _EnterExitCosts.YiMiao;
  4726. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4727. }
  4728. if (_EnterExitCosts.HeSuan > 0)
  4729. {
  4730. //insidePayTotal += _EnterExitCosts.HeSuan;
  4731. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4732. }
  4733. if (_EnterExitCosts.Service > 0)
  4734. {
  4735. //insidePayTotal += _EnterExitCosts.Service;
  4736. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4737. }
  4738. string row1_3 = "";
  4739. if (_EnterExitCosts.Safe > 0)
  4740. {
  4741. //insidePayTotal += _EnterExitCosts.Safe;
  4742. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4743. }
  4744. if (_EnterExitCosts.Ticket > 0)
  4745. {
  4746. //insidePayTotal += _EnterExitCosts.Ticket;
  4747. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4748. }
  4749. string row1 = "";
  4750. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4751. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4752. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4753. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4754. dic.Add("Row1Str", row1);
  4755. }
  4756. string airTotalStr = string.Empty,
  4757. airPriceStr = string.Empty;
  4758. //经济舱
  4759. if (_EnterExitCosts.SumJJC == 1)
  4760. {
  4761. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4762. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4763. }
  4764. //公务舱
  4765. if (_EnterExitCosts.SumGWC == 1)
  4766. {
  4767. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4768. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4769. }
  4770. //头等舱
  4771. if (_EnterExitCosts.SumTDC == 1)
  4772. {
  4773. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4774. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4775. }
  4776. dic.Add("AirTotalStr", airTotalStr);
  4777. dic.Add("AirPriceStr", airPriceStr);
  4778. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4779. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4780. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4781. int table1Row = 0,
  4782. table2Row = 0,
  4783. table3Row = 0,
  4784. table4Row = 0;
  4785. //住宿费
  4786. if (_EnterExitCosts.ChoiceThree == 1)
  4787. {
  4788. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4789. table1Row = dac1.Count;
  4790. #region 填充word表格内容
  4791. for (int i = 0; i < dac1.Count; i++)
  4792. {
  4793. Grp_DayAndCost dac = dac1[i];
  4794. if (dac == null) continue;
  4795. builder.MoveToCell(0, i, 0, 0);
  4796. builder.Write("第" + dac.Days.ToString() + "晚:");
  4797. builder.MoveToCell(0, i, 1, 0);
  4798. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4799. //builder.Write(dac.Place == null ? "" : dac.Place);
  4800. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4801. builder.MoveToCell(0, i, 2, 0);
  4802. builder.Write("费用标准:");
  4803. string curr = "";
  4804. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4805. if (currData != null)
  4806. {
  4807. curr = currData.Name;
  4808. }
  4809. builder.MoveToCell(0, i, 3, 0);
  4810. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4811. builder.MoveToCell(0, i, 4, 0);
  4812. builder.Write("费用小计:");
  4813. builder.MoveToCell(0, i, 5, 0);
  4814. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4815. }
  4816. #endregion
  4817. }
  4818. else dic.Add("SubZS", "0.00");
  4819. //删除多余行
  4820. while (table1.Rows.Count > table1Row)
  4821. {
  4822. table1.Rows.RemoveAt(table1Row);
  4823. }
  4824. //伙食费
  4825. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4826. if (_EnterExitCosts.ChoiceFour == 1)
  4827. {
  4828. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4829. table2Row = dac2.Count;
  4830. #region 填充word表格内容
  4831. for (int i = 0; i < dac2.Count; i++)
  4832. {
  4833. Grp_DayAndCost dac = dac2[i];
  4834. if (dac == null) continue;
  4835. builder.MoveToCell(1, i, 0, 0);
  4836. builder.Write("第" + dac.Days.ToString() + "天:");
  4837. builder.MoveToCell(1, i, 1, 0);
  4838. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4839. builder.MoveToCell(1, i, 2, 0);
  4840. builder.Write("费用标准:");
  4841. string curr = "";
  4842. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4843. if (currData != null)
  4844. {
  4845. curr = currData.Name;
  4846. }
  4847. builder.MoveToCell(1, i, 3, 0);
  4848. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4849. builder.MoveToCell(1, i, 4, 0);
  4850. builder.Write("费用小计:");
  4851. builder.MoveToCell(1, i, 5, 0);
  4852. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4853. }
  4854. #endregion
  4855. }
  4856. else dic.Add("SubHS", "0.00");
  4857. //删除多余行
  4858. while (table2.Rows.Count > table2Row)
  4859. {
  4860. table2.Rows.RemoveAt(table2Row);
  4861. }
  4862. //公杂费
  4863. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4864. if (_EnterExitCosts.ChoiceFive == 1)
  4865. {
  4866. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4867. table3Row = dac3.Count;
  4868. #region 填充word表格内容
  4869. for (int i = 0; i < dac3.Count; i++)
  4870. {
  4871. Grp_DayAndCost dac = dac3[i];
  4872. if (dac == null) continue;
  4873. builder.MoveToCell(2, i, 0, 0);
  4874. builder.Write("第" + dac.Days.ToString() + "天:");
  4875. builder.MoveToCell(2, i, 1, 0);
  4876. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4877. builder.MoveToCell(2, i, 2, 0);
  4878. builder.Write("费用标准:");
  4879. string curr = "";
  4880. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4881. if (currData != null)
  4882. {
  4883. curr = currData.Name;
  4884. }
  4885. builder.MoveToCell(2, i, 3, 0);
  4886. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4887. builder.MoveToCell(2, i, 4, 0);
  4888. builder.Write("费用小计:");
  4889. builder.MoveToCell(2, i, 5, 0);
  4890. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4891. }
  4892. //删除多余行
  4893. while (table3.Rows.Count > table3Row)
  4894. {
  4895. table3.Rows.RemoveAt(table3Row);
  4896. }
  4897. #endregion
  4898. }
  4899. else dic.Add("SubGZF", "0.00");
  4900. //删除多余行
  4901. while (table3.Rows.Count > table3Row)
  4902. {
  4903. table3.Rows.RemoveAt(table3Row);
  4904. }
  4905. //培训费
  4906. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4907. if (_EnterExitCosts.ChoiceSix == 1)
  4908. {
  4909. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4910. dic.Add("SubPX", pxStr);
  4911. table4Row = dac4.Count;
  4912. #region 填充word表格内容
  4913. for (int i = 0; i < dac4.Count; i++)
  4914. {
  4915. Grp_DayAndCost dac = dac4[i];
  4916. if (dac == null) continue;
  4917. builder.MoveToCell(3, i, 0, 0);
  4918. builder.Write("第" + dac.Days.ToString() + "天:");
  4919. builder.MoveToCell(3, i, 1, 0);
  4920. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4921. builder.MoveToCell(3, i, 2, 0);
  4922. builder.Write("费用标准:");
  4923. string curr = "";
  4924. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4925. if (currData != null)
  4926. {
  4927. curr = currData.Name;
  4928. }
  4929. builder.MoveToCell(3, i, 3, 0);
  4930. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4931. builder.MoveToCell(3, i, 4, 0);
  4932. builder.Write("费用小计:");
  4933. builder.MoveToCell(3, i, 5, 0);
  4934. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4935. }
  4936. #endregion
  4937. }
  4938. //else dic.Add("SubPX","0.00");
  4939. //删除多余行
  4940. while (table4.Rows.Count > table4Row)
  4941. {
  4942. table4.Rows.RemoveAt(table4Row);
  4943. }
  4944. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4945. decimal subJJC = 0.00M,
  4946. subGWC = 0.00M,
  4947. subTDC = 0.00M;
  4948. //经济舱
  4949. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4950. //公务舱
  4951. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4952. //头等舱
  4953. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4954. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4955. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4956. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4957. #region 填充word模板书签内容
  4958. foreach (var key in dic.Keys)
  4959. {
  4960. builder.MoveToBookmark(key);
  4961. builder.Write(dic[key]);
  4962. }
  4963. #endregion
  4964. //文件名
  4965. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4966. AsposeHelper.removewatermark_v2180();
  4967. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4968. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4969. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  4970. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  4971. }
  4972. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4973. {
  4974. //获取模板
  4975. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4976. //载入模板
  4977. Document doc = new Document(tempPath);
  4978. DocumentBuilder builder = new DocumentBuilder(doc);
  4979. Dictionary<string, string> dic = new Dictionary<string, string>();
  4980. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4981. {
  4982. List<string> list = new List<string>();
  4983. try
  4984. {
  4985. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4986. foreach (var item in spilitArr)
  4987. {
  4988. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4989. var depCode = spDotandEmpty[2].Substring(0, 3);
  4990. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4991. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4992. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4993. list.Add(depName);
  4994. list.Add(arrName);
  4995. }
  4996. list = list.Distinct().ToList();
  4997. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4998. }
  4999. catch (Exception)
  5000. {
  5001. dic.Add("ReturnCode", "行程录入不正确!");
  5002. }
  5003. }
  5004. else
  5005. {
  5006. dic.Add("ReturnCode", "未录入行程!");
  5007. }
  5008. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5009. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5010. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5011. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5012. {
  5013. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5014. dic.Add("Day", sp.Days.ToString());
  5015. }
  5016. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5017. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5018. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5019. //dic.Add("Names", Names);
  5020. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5021. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5022. decimal dac1totalPrice = 0.00M;
  5023. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5024. foreach (var dac in dac1)
  5025. {
  5026. if (dac.SubTotal == 0.00M)
  5027. {
  5028. continue;
  5029. }
  5030. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5031. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5032. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5033. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5034. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5035. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5036. builder.Write(currency);//币种
  5037. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5038. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5039. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5040. builder.Write("");//人数
  5041. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5042. builder.Write("");//天数
  5043. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5044. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5045. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5046. decimal rate = 0.00M;
  5047. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5048. builder.Write(rate.ToString("#0.0000"));//汇率
  5049. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5050. decimal rbmPrice = dac.SubTotal;
  5051. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5052. accommodationStartIndex++;
  5053. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5054. }
  5055. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5056. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5057. {
  5058. table1.Rows.RemoveAt(i - 1);
  5059. foodandotherStartIndex--;
  5060. }
  5061. if (dac2.Count == dac3.Count)//国家 币种 金额
  5062. {
  5063. for (int i = 0; i < dac2.Count; i++)
  5064. {
  5065. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5066. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5067. }
  5068. }
  5069. decimal dac2totalPrice = 0.00M;
  5070. foreach (var dac in dac2)
  5071. {
  5072. if (dac.SubTotal == 0)
  5073. {
  5074. continue;
  5075. }
  5076. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5077. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5078. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5079. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5080. builder.Write(currency);//币种
  5081. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5082. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5083. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5084. builder.Write("");//人数
  5085. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5086. builder.Write("");//天数
  5087. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5088. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5089. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5090. decimal rate = 0.00M;
  5091. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5092. builder.Write(rate.ToString("#0.0000"));//汇率
  5093. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5094. decimal rbmPrice = dac.SubTotal;
  5095. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5096. foodandotherStartIndex++;
  5097. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5098. }
  5099. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5100. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5101. {
  5102. table1.Rows.RemoveAt(i - 1);
  5103. }
  5104. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5105. string otherFeeStr = "";
  5106. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5107. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5108. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5109. if (otherFeeStr.Length > 0)
  5110. {
  5111. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5112. otherFeeStr = $"({otherFeeStr})";
  5113. dic.Add("OtherFeeStr", otherFeeStr);
  5114. }
  5115. //总计
  5116. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5117. //国际旅费
  5118. string outsideAir = string.Empty;
  5119. string allPriceAir = string.Empty;
  5120. if (_EnterExitCosts.SumJJC == 1)
  5121. {
  5122. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5123. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5124. }
  5125. if (_EnterExitCosts.SumGWC == 1)
  5126. {
  5127. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5128. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5129. }
  5130. if (_EnterExitCosts.SumTDC == 1)
  5131. {
  5132. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5133. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5134. }
  5135. dic.Add("InTravelPrice", $"({outsideAir})");
  5136. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5137. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5138. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5139. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5140. foreach (var key in dic.Keys)
  5141. {
  5142. builder.MoveToBookmark(key);
  5143. builder.Write(dic[key]);
  5144. }
  5145. //模板文件名
  5146. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5147. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5148. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5149. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5150. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5151. }
  5152. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5153. {
  5154. //获取模板
  5155. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5156. //载入模板
  5157. WorkbookDesigner designer = new WorkbookDesigner();
  5158. designer.Workbook = new Workbook(tempPath);
  5159. Dictionary<string, string> dic = new Dictionary<string, string>();
  5160. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5161. {
  5162. List<string> list = new List<string>();
  5163. try
  5164. {
  5165. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5166. foreach (var item in spilitArr)
  5167. {
  5168. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5169. var depCode = spDotandEmpty[2].Substring(0, 3);
  5170. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5171. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5172. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5173. list.Add(depName);
  5174. list.Add(arrName);
  5175. }
  5176. list = list.Distinct().ToList();
  5177. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5178. }
  5179. catch (Exception)
  5180. {
  5181. dic.Add("ReturnCode", "行程录入不正确!");
  5182. }
  5183. }
  5184. else
  5185. {
  5186. dic.Add("ReturnCode", "未录入行程!");
  5187. }
  5188. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5189. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5190. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5191. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5192. {
  5193. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5194. dic.Add("Day", sp.Days.ToString());
  5195. }
  5196. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5197. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5198. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5199. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5200. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5201. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5202. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5203. designer.SetDataSource("Name", Names);
  5204. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5205. designer.SetDataSource("Day", dic["Day"] + "天");
  5206. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5207. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5208. int startIndex = 10;
  5209. const int startIndexcopy = 10;
  5210. if (dac2.Count == dac3.Count)//国家 币种 金额
  5211. {
  5212. for (int i = 0; i < dac2.Count; i++)
  5213. {
  5214. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5215. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5216. }
  5217. }
  5218. DataTable dtdac1 = new DataTable();
  5219. List<string> place = new List<string>();
  5220. dtdac1.Columns.AddRange(new DataColumn[] {
  5221. new DataColumn(){ ColumnName = "city"},
  5222. new DataColumn(){ ColumnName = "curr"},
  5223. new DataColumn(){ ColumnName = "criterion"},
  5224. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5225. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5226. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5227. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5228. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5229. });
  5230. DataTable dtdac2 = new DataTable();
  5231. dtdac2.Columns.AddRange(new DataColumn[] {
  5232. new DataColumn(){ ColumnName = "city"},
  5233. new DataColumn(){ ColumnName = "curr"},
  5234. new DataColumn(){ ColumnName = "criterion"},
  5235. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5236. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5237. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5238. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5239. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5240. });
  5241. dtdac1.TableName = "tb1";
  5242. dtdac2.TableName = "tb2";
  5243. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5244. foreach (var item in dac1)
  5245. {
  5246. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5247. if (place.Contains(item.Place))
  5248. {
  5249. continue;
  5250. }
  5251. DataRow row = dtdac1.NewRow();
  5252. row["city"] = item.Place;
  5253. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5254. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5255. row["curr"] = currency;
  5256. row["rate"] = rate.ToString("#0.0000");
  5257. row["criterion"] = item.Cost.ToString("#0.00");
  5258. row["number"] = 1;
  5259. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5260. //row["costRMB"] = rbmPrice;
  5261. dtdac1.Rows.Add(row);
  5262. place.Add(item.Place);
  5263. }
  5264. place = new List<string>();
  5265. foreach (var item in dac2)
  5266. {
  5267. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5268. if (place.Contains(item.Place))
  5269. {
  5270. continue;
  5271. }
  5272. DataRow row = dtdac2.NewRow();
  5273. row["city"] = item.Place;
  5274. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5275. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5276. row["curr"] = currency;
  5277. row["rate"] = rate.ToString("#0.0000");
  5278. row["criterion"] = item.Cost.ToString("#0.00");
  5279. row["number"] = 1;
  5280. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5281. //row["cost"] = item.SubTotal;
  5282. //row["costRMB"] = rbmPrice;
  5283. dtdac2.Rows.Add(row);
  5284. place.Add(item.Place);
  5285. //dac2totalPrice += rbmPrice;
  5286. }
  5287. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5288. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5289. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5290. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5291. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5292. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5293. string cell4Str1 = string.Empty;
  5294. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5295. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5296. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5297. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5298. string cellStr = $" 5.其他费用(";
  5299. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5300. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5301. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5302. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5303. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5304. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5305. if (cellStr.Length > 8)
  5306. {
  5307. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5308. }
  5309. cellStr += ")";
  5310. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5311. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5312. decimal pxFee = dac4.Sum(it => it.Cost);
  5313. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5314. string celllastStr1 = "";
  5315. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5316. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5317. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5318. celllastStr1 += $",国际旅费 元";
  5319. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5320. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5321. designer.SetDataSource("cell4Str", cell4Str);
  5322. designer.SetDataSource("cellStr", cellStr);
  5323. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5324. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5325. designer.SetDataSource("celllastStr", celllastStr);
  5326. Workbook wb = designer.Workbook;
  5327. var sheet = wb.Worksheets[0];
  5328. //绑定datatable数据集
  5329. designer.SetDataSource(dtdac1);
  5330. designer.SetDataSource(dtdac2);
  5331. designer.Process();
  5332. var rowStart = dtdac1.Rows.Count;
  5333. while (rowStart > 0)
  5334. {
  5335. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5336. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5337. startIndex++;
  5338. rowStart--;
  5339. }
  5340. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5341. startIndex += 1; //总计行
  5342. rowStart = dtdac2.Rows.Count;
  5343. while (rowStart > 0)
  5344. {
  5345. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5346. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5347. startIndex++;
  5348. rowStart--;
  5349. }
  5350. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5351. wb.CalculateFormula(true);
  5352. //模板文件名
  5353. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5354. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5355. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5356. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5357. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5358. }
  5359. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5360. {
  5361. //获取模板
  5362. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5363. //载入模板
  5364. Document doc = new Document(tempPath);
  5365. DocumentBuilder builder = new DocumentBuilder(doc);
  5366. Dictionary<string, string> dic = new Dictionary<string, string>();
  5367. dic.Add("GroupName", _DelegationInfo.TeamName);
  5368. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5369. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5370. string missionLeaderJob = "";//负责人job
  5371. int groupNumber = 0; //团人数
  5372. if (DeleClientList.Count > 0)
  5373. {
  5374. missionLeader = DeleClientList[0]?.Name ?? "";
  5375. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5376. }
  5377. dic.Add("MissionLeader", missionLeader); //团负责人
  5378. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5379. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5380. #region MyRegion
  5381. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5382. //{
  5383. // List<string> list = new List<string>();
  5384. // try
  5385. // {
  5386. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5387. // foreach (var item in spilitArr)
  5388. // {
  5389. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5390. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5391. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5392. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5393. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5394. // list.Add(depName);
  5395. // list.Add(arrName);
  5396. // }
  5397. // list = list.Distinct().ToList();
  5398. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5399. // }
  5400. // catch (Exception)
  5401. // {
  5402. // dic.Add("ReturnCode", "行程录入不正确!");
  5403. // }
  5404. //}
  5405. //else
  5406. //{
  5407. // dic.Add("ReturnCode", "未录入行程!");
  5408. //}
  5409. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5410. dic.Add("ReturnCode", string.Join("、", countrys));
  5411. #endregion
  5412. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5413. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5414. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5415. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5416. //{
  5417. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5418. // dic.Add("Day", sp.Days.ToString());
  5419. //}
  5420. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5421. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5422. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5423. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5424. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5425. //培训人员名单
  5426. int cultivateRowIndex = 7;
  5427. foreach (var item in DeleClientList)
  5428. {
  5429. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5430. builder.Write(item.Name);
  5431. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5432. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5433. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5434. string birthDay = "";
  5435. if (item.Birthday != null)
  5436. {
  5437. DateTime dt = Convert.ToDateTime(item.Birthday);
  5438. birthDay = $"{dt.Year}.{dt.Month}";
  5439. }
  5440. builder.Write(birthDay);
  5441. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5442. builder.Write(item.Company);
  5443. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5444. builder.Write(item.Job);
  5445. cultivateRowIndex++;
  5446. }
  5447. //删除多余行
  5448. //cultivateRowIndex -= 2;
  5449. int delRows = 10 + 7 - cultivateRowIndex;
  5450. if (delRows > 0)
  5451. {
  5452. for (int i = 0; i < delRows; i++)
  5453. {
  5454. table1.Rows.RemoveAt(cultivateRowIndex);
  5455. //cultivateRowIndex++;
  5456. }
  5457. }
  5458. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5459. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5460. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5461. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5462. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5463. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5464. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5465. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5466. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5467. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5468. //其他费用
  5469. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5470. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5471. //其他费用合计
  5472. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5473. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5474. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5475. //公务舱合计
  5476. //国际旅费
  5477. string outsideJJ = "";
  5478. string allPriceJJ = "";
  5479. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5480. {
  5481. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5482. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5483. }
  5484. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5485. {
  5486. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5487. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5488. }
  5489. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5490. {
  5491. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5492. dic.Add("AirFeeTotal", airFeeTotalStr);
  5493. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5494. dic.Add("FeeTotal", feeTotalStr);
  5495. }
  5496. foreach (var key in dic.Keys)
  5497. {
  5498. builder.MoveToBookmark(key);
  5499. builder.Write(dic[key]);
  5500. }
  5501. //模板文件名
  5502. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5503. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5504. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5505. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5506. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5507. }
  5508. }
  5509. else if (dto.ExportType == 2) //表格
  5510. {
  5511. //利用键值对存放数据
  5512. Dictionary<string, string> dic = new Dictionary<string, string>();
  5513. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5514. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5515. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5516. dic.Add("Day", sp.Days.ToString());
  5517. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5518. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5519. {
  5520. //获取模板
  5521. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5522. //载入模板
  5523. Document doc = new Document(tempPath);
  5524. DocumentBuilder builder = new DocumentBuilder(doc);
  5525. dic.Add("TeamName", _DelegationInfo.TeamName);
  5526. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5527. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5528. string missionLeaderName = "",
  5529. missionLeaderJob = "";
  5530. if (DeleClientList.Count > 0)
  5531. {
  5532. missionLeaderName = DeleClientList[0].Name;
  5533. missionLeaderJob = DeleClientList[0].Job;
  5534. }
  5535. dic.Add("MissionLeaderName", missionLeaderName);
  5536. dic.Add("MissionLeaderJob", missionLeaderJob);
  5537. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5538. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5539. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5540. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5541. int rowCount = 10;//总人数行
  5542. int startRowIndex = 7; //起始行
  5543. for (int i = 0; i < DeleClientList.Count; i++)
  5544. {
  5545. builder.MoveToCell(0, startRowIndex, 0, 0);
  5546. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5547. builder.MoveToCell(0, startRowIndex, 1, 0);
  5548. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5549. builder.Write(sex);//性别
  5550. builder.MoveToCell(0, startRowIndex, 2, 0);
  5551. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5552. builder.MoveToCell(0, startRowIndex, 3, 0);
  5553. builder.Write(DeleClientList[i].Company);//工作单位
  5554. builder.MoveToCell(0, startRowIndex, 4, 0);
  5555. builder.Write(DeleClientList[i].Job);//职务及级别
  5556. builder.MoveToCell(0, startRowIndex, 5, 0);
  5557. builder.Write("");//人员属性
  5558. builder.MoveToCell(0, startRowIndex, 6, 0);
  5559. builder.Write("");//上次出国时间
  5560. startRowIndex++;
  5561. }
  5562. int nullRow = rowCount - DeleClientList.Count;//空行
  5563. for (int i = 0; i < nullRow; i++)
  5564. {
  5565. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5566. }
  5567. foreach (var key in dic.Keys)
  5568. {
  5569. builder.MoveToBookmark(key);
  5570. builder.Write(dic[key]);
  5571. }
  5572. //模板文件名
  5573. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5574. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5575. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5576. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5577. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5578. }
  5579. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5580. {
  5581. //获取模板
  5582. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5583. //载入模板
  5584. Document doc = new Document(tempPath);
  5585. DocumentBuilder builder = new DocumentBuilder(doc);
  5586. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5587. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5588. dic.Add("Names", Names);
  5589. int accommodationRows = 12, foodandotherRows = 12;
  5590. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5591. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5592. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5593. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5594. int accommodationStartIndex = 6;
  5595. decimal dac1totalPrice = 0.00M;
  5596. foreach (var dac in dac1)
  5597. {
  5598. if (dac.SubTotal == 0)
  5599. {
  5600. continue;
  5601. }
  5602. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5603. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5604. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5605. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5606. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5607. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5608. builder.Write(currency);//币种
  5609. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5610. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5611. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5612. builder.Write("");//人数
  5613. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5614. builder.Write("");//天数
  5615. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5616. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5617. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5618. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5619. builder.Write(rate.ToString("#0.0000"));//汇率
  5620. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5621. decimal rbmPrice = rate * dac.SubTotal;
  5622. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5623. accommodationStartIndex++;
  5624. dac1totalPrice += rbmPrice;
  5625. }
  5626. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5627. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5628. builder.Write("小计");
  5629. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5630. builder.Write(dac1totalPrice.ToString("#0.00"));
  5631. accommodationStartIndex++;
  5632. int nullRow = accommodationRows - dac1.Count;
  5633. //删除空行
  5634. //if (nullRow > 0)
  5635. //{
  5636. // int rowIndex = accommodationStartIndex;
  5637. // for (int i = 0; i < nullRow; i++)
  5638. // {
  5639. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5640. // row.Remove();
  5641. // rowIndex++;
  5642. // }
  5643. //}
  5644. if (dac2.Count == dac3.Count)//国家 币种 金额
  5645. {
  5646. for (int i = 0; i < dac2.Count; i++)
  5647. {
  5648. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5649. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5650. }
  5651. }
  5652. int foodandotherStartIndex = 19;//
  5653. decimal dac2totalPrice = 0.00M;
  5654. foreach (var dac in dac2)
  5655. {
  5656. if (dac.SubTotal == 0)
  5657. {
  5658. continue;
  5659. }
  5660. //foodandotherStartIndex = 12;
  5661. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5662. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5663. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5664. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5665. builder.Write(currency);//币种
  5666. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5667. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5668. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5669. builder.Write("");//人数
  5670. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5671. builder.Write("");//天数
  5672. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5673. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5674. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5675. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5676. builder.Write(rate.ToString("#0.0000"));//汇率
  5677. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5678. decimal rbmPrice = rate * dac.SubTotal;
  5679. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5680. foodandotherStartIndex++;
  5681. dac2totalPrice += rbmPrice;
  5682. }
  5683. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5684. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5685. //删除空行
  5686. //if (dac2.Count < foodandotherRows)
  5687. //{
  5688. // while (table2.Rows.Count > dac2.Count)
  5689. // {
  5690. // table2.Rows.RemoveAt(dac2.Count);
  5691. // }
  5692. //}
  5693. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5694. string otherFeeStr = "";
  5695. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5696. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5697. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5698. if (otherFeeStr.Length > 0)
  5699. {
  5700. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5701. otherFeeStr = $"({otherFeeStr})";
  5702. dic.Add("OtherFeeStr", otherFeeStr);
  5703. }
  5704. foreach (var key in dic.Keys)
  5705. {
  5706. builder.MoveToBookmark(key);
  5707. builder.Write(dic[key]);
  5708. }
  5709. //模板文件名
  5710. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5711. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5712. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5713. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5714. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5715. }
  5716. }
  5717. else if (dto.ExportType == 3)
  5718. {
  5719. if (dto.SubTypeId == 1) //团组成员名单
  5720. {
  5721. if (DeleClientList.Count < 1)
  5722. {
  5723. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5724. }
  5725. //获取模板
  5726. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5727. //载入模板
  5728. Document doc = new Document(tempPath);
  5729. DocumentBuilder builder = new DocumentBuilder(doc);
  5730. //获取word里所有表格
  5731. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5732. //获取所填表格的序数
  5733. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5734. var rowStart = tableOne.Rows[0]; //获取第1行
  5735. //循环赋值
  5736. for (int i = 0; i < DeleClientList.Count; i++)
  5737. {
  5738. builder.MoveToCell(0, i + 1, 0, 0);
  5739. builder.Write(DeleClientList[i].Name);
  5740. builder.MoveToCell(0, i + 1, 1, 0);
  5741. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5742. builder.Write(sex);
  5743. builder.MoveToCell(0, i + 1, 2, 0);
  5744. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5745. builder.MoveToCell(0, i + 1, 3, 0);
  5746. builder.Write(DeleClientList[i].Company);
  5747. builder.MoveToCell(0, i + 1, 4, 0);
  5748. builder.Write(DeleClientList[i].Job);
  5749. }
  5750. //删除多余行
  5751. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5752. {
  5753. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5754. }
  5755. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5756. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5757. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5758. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5759. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5760. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5761. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5762. }
  5763. }
  5764. return Ok(JsonView(400, "操作失败!", ""));
  5765. }
  5766. catch (Exception ex)
  5767. {
  5768. return Ok(JsonView(400, ex.Message, ""));
  5769. }
  5770. }
  5771. /// <summary>
  5772. /// 获取三公费用标准city
  5773. /// </summary>
  5774. /// <param name="placeData"></param>
  5775. /// <param name="nationalTravelFeeId"></param>
  5776. /// <returns></returns>
  5777. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5778. {
  5779. string _city = string.Empty;
  5780. if (placeData.Count < 1) return _city;
  5781. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5782. if (data == null) return _city;
  5783. string country = data.Country;
  5784. string city = data.City;
  5785. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5786. else _city = city;
  5787. return _city;
  5788. }
  5789. /// <summary>
  5790. /// 团组模块 - 出入境费用 - 明细表导出
  5791. /// </summary>
  5792. /// <returns></returns>
  5793. [HttpPost]
  5794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5795. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5796. {
  5797. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5798. if (data.Code != 0)
  5799. {
  5800. return Ok(JsonView(false, data.Msg));
  5801. }
  5802. return Ok(JsonView(true, data.Msg, data.Data));
  5803. }
  5804. /// <summary>
  5805. /// 团组模块 - 出入境费用 - 一键清空
  5806. /// </summary>
  5807. /// <returns></returns>
  5808. [HttpPost]
  5809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5810. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5811. {
  5812. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5813. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5814. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5815. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5816. if (_view.Code == 0)
  5817. {
  5818. return Ok(JsonView(true, "操作成功"));
  5819. }
  5820. return Ok(JsonView(false, "操作失败"));
  5821. }
  5822. /// <summary>
  5823. /// 团组模块 - 出入境费用 - 子项删除
  5824. /// </summary>
  5825. /// <returns></returns>
  5826. [HttpPost]
  5827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5828. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5829. {
  5830. try
  5831. {
  5832. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5833. if (data.Code != 0)
  5834. {
  5835. return Ok(JsonView(false, data.Msg));
  5836. }
  5837. return Ok(JsonView(true, "操作成功!", data.Data));
  5838. }
  5839. catch (Exception ex)
  5840. {
  5841. return Ok(JsonView(false, ex.Message));
  5842. }
  5843. }
  5844. /// <summary>
  5845. /// 团组模块 - 出入境国家费用标准 List
  5846. /// </summary>
  5847. /// <returns></returns>
  5848. [HttpPost]
  5849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5850. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5851. {
  5852. try
  5853. {
  5854. Stopwatch sw = new Stopwatch();
  5855. sw.Start();
  5856. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5857. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5858. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5859. Where gntf.Isdel = 0");
  5860. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5861. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5862. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5863. //foreach (var item in nationalTravel)
  5864. //{
  5865. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5866. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5867. // if (otherData != null)
  5868. // {
  5869. // cityData.Remove(otherData);
  5870. // cityData.Add(otherData);
  5871. // }
  5872. // nationalTravelFeeData1.Add(new
  5873. // {
  5874. // Country = item.Country,
  5875. // CityData = cityData
  5876. // });
  5877. //}
  5878. sw.Stop();
  5879. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5880. }
  5881. catch (Exception ex)
  5882. {
  5883. return Ok(JsonView(false, ex.Message));
  5884. throw;
  5885. }
  5886. }
  5887. /// <summary>
  5888. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5889. /// </summary>
  5890. /// <returns></returns>
  5891. [HttpPost]
  5892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5893. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5894. {
  5895. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5896. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5897. List<string> countryData = new List<string>();
  5898. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5899. countryData = countryData.Distinct().ToList();
  5900. List<dynamic> dataSource = new List<dynamic>();
  5901. foreach (var item in countryData)
  5902. {
  5903. List<string> cityData1 = new List<string>();
  5904. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5905. var countryData2 = new
  5906. {
  5907. CountryName = item,
  5908. CityData = cityData1
  5909. };
  5910. dataSource.Add(countryData2);
  5911. }
  5912. return Ok(JsonView(true, "查询成功!", dataSource));
  5913. }
  5914. /// <summary>
  5915. /// 团组模块 - 出入境国家费用标准 Page List
  5916. /// </summary>
  5917. /// <returns></returns>
  5918. [HttpPost]
  5919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5920. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5921. {
  5922. int portId = dto.PortType;
  5923. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5924. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5925. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5926. string whereSql = string.Empty;
  5927. if (!string.IsNullOrEmpty(dto.Country))
  5928. {
  5929. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5930. }
  5931. if (!string.IsNullOrEmpty(dto.City))
  5932. {
  5933. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5934. }
  5935. string pageSql = string.Format(@"Select * From (
  5936. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5937. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5938. From Grp_NationalTravelFee gntf
  5939. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5940. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5941. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5942. RefAsync<int> total = 0;
  5943. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5944. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5945. }
  5946. /// <summary>
  5947. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5948. /// </summary>
  5949. /// <returns></returns>
  5950. [HttpPost]
  5951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5952. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5953. {
  5954. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5955. int portId = dto.PortType;
  5956. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5957. string whereSql = string.Empty;
  5958. if (!string.IsNullOrEmpty(dto.Country))
  5959. {
  5960. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5961. }
  5962. if (!string.IsNullOrEmpty(dto.City))
  5963. {
  5964. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5965. }
  5966. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5967. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5968. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5969. From Grp_NationalTravelFee gntf
  5970. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5971. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5972. Where gntf.Isdel = 0 {0} ", whereSql);
  5973. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5974. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5975. }
  5976. /// <summary>
  5977. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5978. /// </summary>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5982. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5983. {
  5984. try
  5985. {
  5986. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5987. if (data.Code != 0)
  5988. {
  5989. return Ok(JsonView(false, data.Msg));
  5990. }
  5991. return Ok(JsonView(true, "操作成功!", data.Data));
  5992. }
  5993. catch (Exception ex)
  5994. {
  5995. return Ok(JsonView(false, ex.Message));
  5996. }
  5997. }
  5998. /// <summary>
  5999. /// 团组模块 - 出入境国家费用标准 - Del
  6000. /// </summary>
  6001. /// <returns></returns>
  6002. [HttpPost]
  6003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6004. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6005. {
  6006. try
  6007. {
  6008. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6009. {
  6010. Id = dto.Id,
  6011. DeleteUserId = dto.DeleteUserId,
  6012. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6013. IsDel = 1
  6014. };
  6015. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6016. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6017. .WhereColumns(it => new { it.Id })
  6018. .ExecuteCommandAsync();
  6019. if (delStatus <= 0)
  6020. {
  6021. return Ok(JsonView(false, "删除失败!"));
  6022. }
  6023. return Ok(JsonView(true, "操作成功!"));
  6024. }
  6025. catch (Exception ex)
  6026. {
  6027. return Ok(JsonView(false, ex.Message));
  6028. }
  6029. }
  6030. /// <summary>
  6031. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6032. /// 注:Get 请求Headers 加 Token
  6033. /// </summary>
  6034. /// <param name="groupId"></param>
  6035. /// <returns></returns>
  6036. [HttpGet("{groupId}")]
  6037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6038. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6039. {
  6040. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6041. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6042. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6043. data.ForEach(x =>
  6044. {
  6045. x.CreateUserId = _currUserInfo.UserId;
  6046. });
  6047. if (data.Count > 0)
  6048. {
  6049. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6050. if (add > 0)
  6051. {
  6052. return Ok(JsonView(true, "操作成功!"));
  6053. }
  6054. }
  6055. return Ok(JsonView(false, "未操作!"));
  6056. }
  6057. #endregion
  6058. #region 签证费用录入
  6059. /// <summary>
  6060. /// 根据diid查询签证费用列表
  6061. /// </summary>
  6062. /// <param name="dto"></param>
  6063. /// <returns></returns>
  6064. [HttpPost]
  6065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6066. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6067. {
  6068. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6069. if (groupData.Code != 0)
  6070. {
  6071. return Ok(JsonView(false, groupData.Msg));
  6072. }
  6073. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6074. }
  6075. /// <summary>
  6076. /// 根据签证费用Id查询单条数据及c表数据
  6077. /// </summary>
  6078. /// <param name="dto"></param>
  6079. /// <returns></returns>
  6080. [HttpPost]
  6081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6082. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6083. {
  6084. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6085. if (groupData.Code != 0)
  6086. {
  6087. return Ok(JsonView(false, groupData.Msg));
  6088. }
  6089. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6090. }
  6091. /// <summary>
  6092. /// 签证费用删除
  6093. /// </summary>
  6094. /// <param name="dto"></param>
  6095. /// <returns></returns>
  6096. [HttpPost]
  6097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6098. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6099. {
  6100. _sqlSugar.BeginTran();
  6101. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6102. if (!res)
  6103. {
  6104. _sqlSugar.RollbackTran();
  6105. return Ok(JsonView(false, "删除失败"));
  6106. }
  6107. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6108. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6109. .SetColumns(a => new Grp_CreditCardPayment()
  6110. {
  6111. IsDel = 1,
  6112. DeleteUserId = dto.DeleteUserId,
  6113. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6114. })
  6115. .ExecuteCommand();
  6116. if (resSub < 1)
  6117. {
  6118. _sqlSugar.RollbackTran();
  6119. return Ok(JsonView(false, "删除失败"));
  6120. }
  6121. _sqlSugar.CommitTran();
  6122. return Ok(JsonView(true, "删除成功!"));
  6123. }
  6124. /// <summary>
  6125. /// 签证费用录入下拉框初始化
  6126. /// </summary>
  6127. /// <returns></returns>
  6128. [HttpPost]
  6129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6130. public async Task<IActionResult> VisaPriceAddSelect()
  6131. {
  6132. //支付方式
  6133. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6134. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6135. //币种
  6136. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6137. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6138. //乘客类型
  6139. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6140. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6141. //卡类型
  6142. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6143. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6144. //代办费类型
  6145. var agencyFeeTypeData = new List<dynamic>() {
  6146. new { id = 0 , Text = "未选择" },
  6147. new { id = 1 , Text = "小公务" },
  6148. new { id = 2 , Text = "大公务" },
  6149. };
  6150. //签证费用标准国家Data
  6151. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  6152. var data = new
  6153. {
  6154. Payment = _Payment,
  6155. CurrencyList = _CurrencyList,
  6156. PassengerType = _PassengerType,
  6157. BankCard = _BankCard,
  6158. AgencyFeeType = agencyFeeTypeData,
  6159. CountryFeeData = visaCountryFeeData
  6160. };
  6161. return Ok(JsonView(true, "查询成功!", data));
  6162. }
  6163. /// <summary>
  6164. /// 签证费用录入操作(Status:1.新增,2.修改)
  6165. /// </summary>
  6166. /// <param name="dto"></param>
  6167. /// <returns></returns>
  6168. [HttpPost]
  6169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6170. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6171. {
  6172. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6173. if (groupData.Code != 0)
  6174. {
  6175. return Ok(JsonView(false, groupData.Msg));
  6176. }
  6177. #region 应用推送
  6178. try
  6179. {
  6180. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6181. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6182. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6183. //2024-10-21 新增LZ UID
  6184. var userIds = new List<int>() { 21 };
  6185. string title = $"系统通知";
  6186. string content = "";
  6187. var diId = dto.DiId;
  6188. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6189. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6190. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6191. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6192. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6193. await GeneralMethod.iOS_PushNotifications("051", $"签证费用审核", "", content);
  6194. }
  6195. catch (Exception ex)
  6196. {
  6197. }
  6198. #endregion
  6199. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6200. }
  6201. #endregion
  6202. #region 签证提成录入
  6203. /// <summary>
  6204. /// 签证提成录入
  6205. /// 基础数据
  6206. /// </summary>
  6207. /// <param name="_dto"></param>
  6208. /// <returns></returns>
  6209. [HttpGet]
  6210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6211. public async Task<IActionResult> VisaCommissionInit()
  6212. {
  6213. return Ok(await _visaCommissionRep.Init());
  6214. }
  6215. /// <summary>
  6216. /// 签证提成录入
  6217. /// Item
  6218. /// </summary>
  6219. /// <param name="_dto"></param>
  6220. /// <returns></returns>
  6221. [HttpPost]
  6222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6223. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6224. {
  6225. var validator = new VisaCommissionItemDtoValidator();
  6226. var validatorRes = await validator.ValidateAsync(_dto);
  6227. if (!validatorRes.IsValid)
  6228. {
  6229. StringBuilder sb = new StringBuilder();
  6230. foreach (var item in validatorRes.Errors)
  6231. {
  6232. sb.AppendLine(item.ErrorMessage);
  6233. }
  6234. return Ok(JsonView(false, sb.ToString()));
  6235. }
  6236. return Ok(await _visaCommissionRep.Item(_dto));
  6237. }
  6238. /// <summary>
  6239. /// 签证提成录入
  6240. /// Save
  6241. /// </summary>
  6242. /// <param name="_dto"></param>
  6243. /// <returns></returns>
  6244. [HttpPost]
  6245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6246. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6247. {
  6248. //参数验证
  6249. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6250. foreach (var item in _dto.Items)
  6251. {
  6252. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6253. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6254. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6255. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6256. }
  6257. return Ok(await _visaCommissionRep.Save(_dto));
  6258. }
  6259. /// <summary>
  6260. /// 签证提成录入
  6261. /// Create
  6262. /// </summary>
  6263. /// <param name="_dto"></param>
  6264. /// <returns></returns>
  6265. [HttpPost]
  6266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6267. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6268. {
  6269. var validator = new VisaCommissionCreateDtoValidator();
  6270. var validatorRes = await validator.ValidateAsync(_dto);
  6271. if (!validatorRes.IsValid)
  6272. {
  6273. StringBuilder sb = new StringBuilder();
  6274. foreach (var item in validatorRes.Errors)
  6275. {
  6276. sb.AppendLine(item.ErrorMessage);
  6277. }
  6278. return Ok(JsonView(false, sb.ToString()));
  6279. }
  6280. return Ok(await _visaCommissionRep.Create(_dto));
  6281. }
  6282. /// <summary>
  6283. /// 签证提成录入
  6284. /// Put(编辑)
  6285. /// </summary>
  6286. /// <param name="id"></param>
  6287. /// <param name="_dto"></param>
  6288. /// <returns></returns>
  6289. [HttpPut]
  6290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6291. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6292. {
  6293. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6294. var validator = new VisaCommissionCreateDtoValidator();
  6295. var validatorRes = await validator.ValidateAsync(_dto);
  6296. if (!validatorRes.IsValid)
  6297. {
  6298. StringBuilder sb = new StringBuilder();
  6299. foreach (var item in validatorRes.Errors)
  6300. {
  6301. sb.AppendLine(item.ErrorMessage);
  6302. }
  6303. return Ok(JsonView(false, sb.ToString()));
  6304. }
  6305. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6306. }
  6307. /// <summary>
  6308. /// 签证提成录入
  6309. /// Del
  6310. /// </summary>
  6311. /// <param name="id"></param>
  6312. /// <param name="currUserId"></param>
  6313. /// <returns></returns>
  6314. [HttpPost]
  6315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6316. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6317. {
  6318. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6319. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6320. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6321. }
  6322. #endregion
  6323. #region op费用录入
  6324. /// <summary>
  6325. /// 根据diid查询op费用列表
  6326. /// </summary>
  6327. /// <param name="dto"></param>
  6328. /// <returns></returns>
  6329. [HttpPost]
  6330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6331. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6332. {
  6333. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6334. if (groupData.Code != 0)
  6335. {
  6336. return Ok(JsonView(false, groupData.Msg));
  6337. }
  6338. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6339. }
  6340. /// <summary>
  6341. /// 根据op费用Id查询单条数据及c表数据
  6342. /// </summary>
  6343. /// <param name="dto"></param>
  6344. /// <returns></returns>
  6345. [HttpPost]
  6346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6347. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6348. {
  6349. try
  6350. {
  6351. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6352. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6353. var data = new
  6354. {
  6355. CarTouristGuideGround = _groupData,
  6356. CreditCardPayment = _creditCardPayment
  6357. };
  6358. return Ok(JsonView(true, "查询成功!", data));
  6359. }
  6360. catch (Exception ex)
  6361. {
  6362. return Ok(JsonView(false, "程序错误!"));
  6363. }
  6364. }
  6365. /// <summary>
  6366. /// op费用删除
  6367. /// </summary>
  6368. /// <param name="dto"></param>
  6369. /// <returns></returns>
  6370. [HttpPost]
  6371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6372. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6373. {
  6374. try
  6375. {
  6376. _sqlSugar.BeginTran();
  6377. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6378. if (!res)
  6379. {
  6380. return Ok(JsonView(false, "删除失败"));
  6381. }
  6382. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6383. {
  6384. IsDel = 1,
  6385. DeleteUserId = dto.DeleteUserId,
  6386. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6387. }).ExecuteCommandAsync();
  6388. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6389. {
  6390. IsDel = 1,
  6391. DeleteUserId = dto.DeleteUserId,
  6392. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6393. }).ExecuteCommandAsync();
  6394. #region 删除超支相关数据
  6395. //删除导入的超支数据
  6396. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6397. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6398. {
  6399. IsDel = 1,
  6400. DeleteUserId = dto.DeleteUserId,
  6401. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6402. }).ExecuteCommand();
  6403. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6404. {
  6405. IsDel = 1,
  6406. DeleteUserId = dto.DeleteUserId,
  6407. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6408. }).ExecuteCommand();
  6409. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6410. {
  6411. IsDel = 1,
  6412. DeleteUserId = dto.DeleteUserId,
  6413. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6414. }).ExecuteCommand();
  6415. #endregion
  6416. _sqlSugar.CommitTran();
  6417. return Ok(JsonView(true, "删除成功!"));
  6418. }
  6419. catch (Exception ex)
  6420. {
  6421. _sqlSugar.RollbackTran();
  6422. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6423. }
  6424. }
  6425. /// <summary>
  6426. /// op费用录入操作(Status:1.新增,2.修改)
  6427. /// </summary>
  6428. /// <param name="dto"></param>
  6429. /// <returns></returns>
  6430. [HttpPost]
  6431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6432. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6433. {
  6434. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6435. if (groupData.Code != 0)
  6436. {
  6437. return Ok(JsonView(false, groupData.Msg));
  6438. }
  6439. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6440. }
  6441. /// <summary>
  6442. /// 填写费用详细页面初始化绑定
  6443. /// </summary>
  6444. /// <param name="dto"></param>
  6445. /// <returns></returns>
  6446. [HttpPost]
  6447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6448. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6449. {
  6450. try
  6451. {
  6452. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6453. if (groupData.Code != 0)
  6454. {
  6455. return Ok(JsonView(false, groupData.Msg));
  6456. }
  6457. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6458. }
  6459. catch (Exception ex)
  6460. {
  6461. return Ok(JsonView(false, ex.Message));
  6462. }
  6463. }
  6464. /// <summary>
  6465. /// 根据op费用Id查询详细数据
  6466. /// </summary>
  6467. /// <param name="dto"></param>
  6468. /// <returns></returns>
  6469. [HttpPost]
  6470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6471. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6472. {
  6473. try
  6474. {
  6475. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6476. if (groupData.Code != 0)
  6477. {
  6478. return Ok(JsonView(false, groupData.Msg));
  6479. }
  6480. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6481. }
  6482. catch (Exception ex)
  6483. {
  6484. return Ok(JsonView(false, ex.Message));
  6485. }
  6486. }
  6487. /// <summary>
  6488. /// OP费用录入填写详情
  6489. /// </summary>
  6490. /// <param name="dto"></param>
  6491. /// <returns></returns>
  6492. [HttpPost]
  6493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6494. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6495. {
  6496. try
  6497. {
  6498. #region 参数校验
  6499. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6500. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6501. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6502. #endregion
  6503. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6504. if (groupData.Code != 0)
  6505. {
  6506. return Ok(JsonView(false, groupData.Msg));
  6507. }
  6508. //自动审核
  6509. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6510. #region 应用推送
  6511. try
  6512. {
  6513. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6514. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6515. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6516. //2024-10-21 新增LZ UID
  6517. var userIds = new List<int>() { 21 };
  6518. string title = $"系统通知";
  6519. var diId = dto.DiId;
  6520. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6521. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6522. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6523. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6524. await GeneralMethod.iOS_PushNotifications("051", "OP费用审核", "", content);
  6525. }
  6526. catch (Exception ex)
  6527. {
  6528. }
  6529. #endregion
  6530. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6531. }
  6532. catch (Exception ex)
  6533. {
  6534. return Ok(JsonView(false, ex.Message));
  6535. }
  6536. }
  6537. /// <summary>
  6538. /// 获取三公详细所有城市
  6539. /// </summary>
  6540. /// <returns></returns>
  6541. [HttpGet]
  6542. public IActionResult OpCarCityResult()
  6543. {
  6544. var jw = JsonView(false);
  6545. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6546. {
  6547. x.Id,
  6548. x.Country,
  6549. x.City,
  6550. }).ToList();
  6551. if (data.Count > 0)
  6552. {
  6553. jw = JsonView(true, "获取成功!", data);
  6554. }
  6555. else
  6556. {
  6557. jw.Msg = "城市数据为空!";
  6558. jw.Data = new string[0];
  6559. }
  6560. return Ok(jw);
  6561. }
  6562. /// <summary>
  6563. /// 导出地接费用明细
  6564. /// </summary>
  6565. /// <param name="dto"></param>
  6566. /// <returns></returns>
  6567. [HttpPost]
  6568. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6569. {
  6570. var jw = JsonView(false);
  6571. if (dto.Diid < 1)
  6572. {
  6573. jw.Msg = "请输入正确的diid!";
  6574. return Ok(jw);
  6575. }
  6576. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6577. if (group == null)
  6578. {
  6579. jw.Msg = "未找到团组信息!";
  6580. return Ok(jw);
  6581. }
  6582. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6583. if (localGuideArr.Count == 0)
  6584. {
  6585. jw.Msg = "该团组暂无地接信息!";
  6586. return Ok(jw);
  6587. }
  6588. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6589. var overspendSoure = new Dictionary<int, int>
  6590. {
  6591. { 91, 982 }, //车
  6592. { 92 , 1059} ,//导游
  6593. { 994 , 1073}, //翻译
  6594. { 988 , 1074 }, //早餐
  6595. { 93 , 1075 }, //午餐
  6596. { 989 , 1076 }, //晚餐
  6597. };
  6598. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6599. foreach (var groupArr in localGroup)
  6600. {
  6601. var keyValue = groupArr.Key;
  6602. if (int.TryParse(keyValue, out int cityid))
  6603. {
  6604. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6605. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6606. }
  6607. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6608. foreach (var item in groupArr)
  6609. {
  6610. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6611. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6612. new Grp_CarTouristGuideGroundReservationsContentExtend
  6613. {
  6614. Count = a.Count,
  6615. CreateTime = a.CreateTime,
  6616. CreateUserId = a.CreateUserId,
  6617. CTGGRId = a.CTGGRId,
  6618. Currency = a.Currency,
  6619. DatePrice = a.DatePrice,
  6620. DeleteTime = a.DeleteTime,
  6621. DeleteUserId = a.DeleteUserId,
  6622. DiId = a.DiId,
  6623. Id = a.Id,
  6624. IsDel = a.IsDel,
  6625. Price = a.Price,
  6626. PriceContent = a.PriceContent,
  6627. Remark = a.Remark,
  6628. SId = a.SId,
  6629. SidName = b.Name,
  6630. Units = a.Units,
  6631. }
  6632. ).ToList();
  6633. if (content.Count > 0)
  6634. {
  6635. contentArr.Add(content);
  6636. }
  6637. }
  6638. //open excel
  6639. //set excel
  6640. //save excel
  6641. try
  6642. {
  6643. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6644. IWorkbook workbook;
  6645. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6646. {
  6647. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6648. }
  6649. else
  6650. {
  6651. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6652. }
  6653. ISheet sheet = workbook.GetSheetAt(0);
  6654. var rowStartIndex = 2;
  6655. var clounmCount = 10;
  6656. var initStyleRow = sheet.GetRow(2);
  6657. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6658. //var overspendArrDetail =
  6659. var existsId = new List<CarCompare>();
  6660. var lastElem = arr.Last();
  6661. var thisSid = -1;
  6662. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6663. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6664. {
  6665. Name = "未知币种!",
  6666. Remark = "未知币种!",
  6667. };
  6668. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6669. Action cloneRowFn = () =>
  6670. {
  6671. rowStartIndex++;
  6672. var cloneRow = sheet.CreateRow(rowStartIndex);
  6673. // 复制样式
  6674. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6675. {
  6676. ICell sourceCell = initStyleRow.GetCell(i);
  6677. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6678. // 确保单元格存在样式
  6679. if (sourceCell.CellStyle != null)
  6680. {
  6681. targetCell.CellStyle = sourceCell.CellStyle;
  6682. }
  6683. }
  6684. };
  6685. var mergeRow = () =>
  6686. {
  6687. for (int i = 2; i < sheet.LastRowNum; i++)
  6688. {
  6689. var row = sheet.GetRow(i);
  6690. var cellFirst = row.GetCell(0);
  6691. var thisIndex = i + 1;
  6692. while (thisIndex < sheet.LastRowNum)
  6693. {
  6694. var nextRow = sheet.GetRow(thisIndex);
  6695. var nextCellFirst = nextRow.GetCell(0);
  6696. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6697. {
  6698. thisIndex++;
  6699. }
  6700. else
  6701. {
  6702. break;
  6703. }
  6704. }
  6705. thisIndex--;
  6706. if (thisIndex != i)
  6707. {
  6708. //合并row
  6709. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6710. i, // 起始行索引(0-based)
  6711. thisIndex, // 结束行索引(0-based)
  6712. 0, // 起始列索引(0-based)
  6713. 0 // 结束列索引(0-based)
  6714. );
  6715. sheet.AddMergedRegion(cellRangeAddress);
  6716. i = thisIndex;
  6717. }
  6718. }
  6719. };
  6720. var chaoshiNumber = 0;
  6721. var totalNumber = 0.00M;
  6722. string lastStr = "";
  6723. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6724. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6725. {
  6726. b.IsAuditGM,
  6727. x.Id,
  6728. x.Area,
  6729. b.PayPercentage,
  6730. b.PayMoney,
  6731. }).ToList();
  6732. string yesPayment = "", noPayment = "";
  6733. foreach (var item in queryCarArrByCityAndDiid)
  6734. {
  6735. if (item.IsAuditGM == 1)
  6736. {
  6737. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6738. }
  6739. else
  6740. {
  6741. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6742. }
  6743. }
  6744. lastStr = yesPayment + noPayment;
  6745. foreach (var item in arr)
  6746. {
  6747. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6748. {
  6749. if (thisSid != item.SId)
  6750. {
  6751. if (thisSid == -1)
  6752. {
  6753. thisSid = item.SId;
  6754. }
  6755. else
  6756. {
  6757. //合并小计行
  6758. //创建合并区域的实例
  6759. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6760. rowStartIndex, // 起始行索引(0-based)
  6761. rowStartIndex, // 结束行索引(0-based)
  6762. 0, // 起始列索引(0-based)
  6763. 3 // 结束列索引(0-based)
  6764. );
  6765. sheet.AddMergedRegion(cellRangeAddress);
  6766. var CellStyle = workbook.CreateCellStyle();
  6767. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6768. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6769. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6770. for (int i = 0; i <= clounmCount; i++)
  6771. {
  6772. if (i > 6)
  6773. {
  6774. var CellStyle1 = workbook.CreateCellStyle();
  6775. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6776. IFont Font = workbook.CreateFont(); // 创建字体
  6777. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6778. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6779. CellStyle1.SetFont(Font);
  6780. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6781. }
  6782. else
  6783. {
  6784. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6785. }
  6786. }
  6787. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6788. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6789. //超时合计
  6790. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6791. //超时数
  6792. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6793. //超时合计费用
  6794. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6795. thisSid = item.SId;
  6796. cloneRowFn();
  6797. chaoshiNumber = 0;
  6798. totalNumber = 0;
  6799. }
  6800. }
  6801. IRow row = sheet.GetRow(rowStartIndex);
  6802. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6803. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6804. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6805. if (isOpenOverspendSoure)
  6806. {
  6807. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6808. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6809. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6810. }
  6811. for (int i = 0; i <= clounmCount; i++)
  6812. {
  6813. var cell = row.GetCell(i);
  6814. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6815. if (cell == null)
  6816. {
  6817. cell = row.CreateCell(i);
  6818. }
  6819. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6820. fontRed.CloneStyleFrom(cell.CellStyle);
  6821. IFont Font = workbook.CreateFont(); // 创建字体
  6822. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6823. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6824. fontRed.SetFont(Font);
  6825. byte[] rgb = new byte[3] { 255, 242, 204 };
  6826. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6827. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6828. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6829. if (workbook is XSSFWorkbook)
  6830. {
  6831. BackgroundColor255_242_204.FillForegroundColor = 0;
  6832. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6833. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6834. }
  6835. else
  6836. {
  6837. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6838. }
  6839. if (i == 1 || i > 6)
  6840. {
  6841. if (i > 6)
  6842. {
  6843. fontRed.FillForegroundColor = 0;
  6844. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6845. fontRed.FillPattern = FillPattern.SolidForeground;
  6846. }
  6847. cell.CellStyle = fontRed;
  6848. }
  6849. if (i > 2 && i < 7)
  6850. {
  6851. cell.CellStyle = BackgroundColor255_242_204;
  6852. }
  6853. cell.SetCellValue(setCellValue); //写入单元格
  6854. }
  6855. if (overspendSoure.ContainsKey(thisSid))
  6856. {
  6857. var overspendId = overspendSoure[thisSid];
  6858. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6859. }
  6860. cloneRowFn();
  6861. existsId.Add(new CarCompare
  6862. {
  6863. DataPrice = item.DatePrice.ObjToDate(),
  6864. Sid = item.SId
  6865. });
  6866. }
  6867. if (item.Equals(lastElem))
  6868. {
  6869. //合并小计行
  6870. //创建合并区域的实例
  6871. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6872. rowStartIndex, // 起始行索引(0-based)
  6873. rowStartIndex, // 结束行索引(0-based)
  6874. 0, // 起始列索引(0-based)
  6875. 3 // 结束列索引(0-based)
  6876. );
  6877. sheet.AddMergedRegion(cellRangeAddress);
  6878. var CellStyle = workbook.CreateCellStyle();
  6879. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6880. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6881. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6882. for (int i = 0; i <= clounmCount; i++)
  6883. {
  6884. if (i > 6)
  6885. {
  6886. var CellStyle1 = workbook.CreateCellStyle();
  6887. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6888. IFont Font = workbook.CreateFont(); // 创建字体
  6889. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6890. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6891. CellStyle1.SetFont(Font);
  6892. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6893. }
  6894. else
  6895. {
  6896. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6897. }
  6898. }
  6899. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6900. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6901. //超时合计
  6902. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6903. //超时数
  6904. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6905. //超时合计费用
  6906. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6907. cloneRowFn();
  6908. // 创建合并区域的实例
  6909. cellRangeAddress = new CellRangeAddress(
  6910. rowStartIndex, // 起始行索引(0-based)
  6911. rowStartIndex, // 结束行索引(0-based)
  6912. 0, // 起始列索引(0-based)
  6913. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6914. );
  6915. // 添加合并区域
  6916. sheet.AddMergedRegion(cellRangeAddress);
  6917. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6918. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6919. }
  6920. }
  6921. mergeRow();
  6922. // 保存修改后的Excel文件到新文件
  6923. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6924. // new FileStream(newFilePath, FileMode.CreateNew)
  6925. using (var stream = new MemoryStream())
  6926. {
  6927. workbook.Write(stream, true);
  6928. stream.Flush();
  6929. stream.Seek(0, SeekOrigin.Begin);
  6930. MemoryStream memoryStream = new MemoryStream();
  6931. stream.CopyTo(memoryStream);
  6932. memoryStream.Seek(0, SeekOrigin.Begin);
  6933. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6934. }
  6935. workbook.Close();
  6936. workbook.Dispose();
  6937. }
  6938. catch (Exception ex)
  6939. {
  6940. jw.Msg = "出现异常!" + ex.Message;
  6941. return Ok(jw);
  6942. }
  6943. }
  6944. if (Zips.Count > 0)
  6945. {
  6946. IOOperatorHelper io = new IOOperatorHelper();
  6947. var byts = io.ConvertZipStream(Zips);
  6948. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6949. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6950. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6951. }
  6952. else
  6953. {
  6954. jw.Msg = "暂无生成文件!";
  6955. }
  6956. return Ok(jw);
  6957. }
  6958. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6959. {
  6960. string outStr = string.Empty;
  6961. switch (i)
  6962. {
  6963. case 0:
  6964. outStr = arr[0].SidName;
  6965. break;
  6966. case 1:
  6967. outStr = arr[0].DataPriceStr;
  6968. break;
  6969. case 2:
  6970. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6971. break;
  6972. case 4:
  6973. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6974. break;
  6975. case 7:
  6976. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6977. {
  6978. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6979. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6980. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6981. }
  6982. break;
  6983. case 8:
  6984. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6985. {
  6986. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6987. }
  6988. break;
  6989. case 9:
  6990. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6991. {
  6992. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6993. }
  6994. break;
  6995. case 10:
  6996. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6997. {
  6998. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6999. }
  7000. break;
  7001. }
  7002. return outStr;
  7003. }
  7004. #region OP行程单
  7005. /// <summary>
  7006. /// OP行程单初始化
  7007. /// </summary>
  7008. /// <param name="dto"></param>
  7009. /// <returns></returns>
  7010. [HttpPost]
  7011. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7012. {
  7013. var jw = JsonView(false);
  7014. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7015. var group = groupList.First();
  7016. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7017. if (group == null)
  7018. {
  7019. jw.Msg = "暂无团组!";
  7020. return Ok(jw);
  7021. }
  7022. group = groupList.Find(x => x.Id == diid);
  7023. if (group == null)
  7024. {
  7025. jw.Msg = "请输入正确的团组ID!";
  7026. return Ok(jw);
  7027. }
  7028. string city = string.Empty;
  7029. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7030. if (blackCode.Count > 0)
  7031. {
  7032. var black = blackCode.First();
  7033. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7034. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7035. if (blackSp.Length > 0)
  7036. {
  7037. try
  7038. {
  7039. var cityArrCode = new List<string>(20);
  7040. foreach (var item in blackSp)
  7041. {
  7042. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7043. var IndexSelect = itemSp[2];
  7044. var cityArrCodeLength = cityArrCode.Count - 1;
  7045. var startCity = IndexSelect.Substring(0, 3);
  7046. if (cityArrCodeLength > 0)
  7047. {
  7048. var arrEndCity = cityArrCode[cityArrCodeLength];
  7049. if (arrEndCity != startCity)
  7050. {
  7051. cityArrCode.Add(startCity.ToUpper());
  7052. }
  7053. }
  7054. else
  7055. {
  7056. cityArrCode.Add(startCity.ToUpper());
  7057. }
  7058. var endCity = IndexSelect.Substring(3, 3);
  7059. cityArrCode.Add(endCity.ToUpper());
  7060. }
  7061. var cityThree = string.Empty;
  7062. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7063. cityThree = cityThree.TrimEnd(',');
  7064. if (string.IsNullOrWhiteSpace(cityThree))
  7065. {
  7066. throw new
  7067. Exception("error");
  7068. }
  7069. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7070. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7071. foreach (var item in cityArrCode)
  7072. {
  7073. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7074. if (find != null)
  7075. {
  7076. city += find.City + "/";
  7077. }
  7078. else
  7079. {
  7080. city += item + "三字码未收入/";
  7081. }
  7082. }
  7083. city = city.TrimEnd('/');
  7084. }
  7085. catch (Exception e)
  7086. {
  7087. city = "黑屏代码格式不正确!";
  7088. }
  7089. }
  7090. }
  7091. else
  7092. {
  7093. city = "未录入黑屏代码";
  7094. }
  7095. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7096. {
  7097. Date = x.Date,
  7098. Days = x.Days,
  7099. Diffgroup = x.Diffgroup,
  7100. Diid = x.Diid,
  7101. Traffic_First = x.Traffic_First,
  7102. Traffic_Second = x.Traffic_Second,
  7103. Trip = x.Trip,
  7104. WeekDay = x.WeekDay,
  7105. Id = x.Id
  7106. }).ToList();
  7107. jw.Data = new
  7108. {
  7109. groupList = groupList.Select(x => new
  7110. {
  7111. x.Id,
  7112. x.TeamName,
  7113. x.TourCode
  7114. }).ToList(),
  7115. groupInfo = new
  7116. {
  7117. group.VisitDays,
  7118. group.TourCode,
  7119. group.VisitPNumber,
  7120. group.TeamName,
  7121. city
  7122. },
  7123. OpTravelList
  7124. };
  7125. jw.Code = 200;
  7126. jw.Msg = "操作成功!";
  7127. return Ok(jw);
  7128. }
  7129. /// <summary>
  7130. /// 删除团组行程单
  7131. /// </summary>
  7132. /// <returns></returns>
  7133. [HttpPost]
  7134. public IActionResult DelTravel(DelOpTravelDto dto)
  7135. {
  7136. var jw = JsonView(false);
  7137. if (dto.UserId <= 0 || dto.Diid <= 0)
  7138. {
  7139. jw.Msg = "请输入正确的参数!";
  7140. return Ok(jw);
  7141. }
  7142. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7143. .SetColumns(x => new Grp_TravelList
  7144. {
  7145. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7146. DeleteUserId = dto.UserId,
  7147. IsDel = 1,
  7148. }).ExecuteCommand();
  7149. jw = JsonView(true);
  7150. return Ok(jw);
  7151. }
  7152. /// <summary>
  7153. /// 行程单保存
  7154. /// </summary>
  7155. /// <returns></returns>
  7156. [HttpPost]
  7157. public IActionResult TravelSave(TravelSaveDto dto)
  7158. {
  7159. var jw = JsonView(false);
  7160. if (dto.Arr.Count > 0)
  7161. {
  7162. try
  7163. {
  7164. _sqlSugar.BeginTran();
  7165. foreach (var item in dto.Arr)
  7166. {
  7167. if (item.Id == 0)
  7168. {
  7169. throw new Exception("请传入正确的Id");
  7170. }
  7171. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7172. .SetColumns(x => new Grp_TravelList
  7173. {
  7174. Trip = item.Trip
  7175. }).ExecuteCommand();
  7176. }
  7177. _sqlSugar.CommitTran();
  7178. jw = JsonView(true);
  7179. }
  7180. catch (Exception ex)
  7181. {
  7182. _sqlSugar.RollbackTran();
  7183. jw.Msg = "程序异常!" + ex.Message;
  7184. }
  7185. }
  7186. else
  7187. {
  7188. jw.Msg = "请传入正确的参数!";
  7189. }
  7190. return Ok(jw);
  7191. }
  7192. /// <summary>
  7193. /// 导出行程单
  7194. /// </summary>
  7195. /// <param name="dto"></param>
  7196. /// <returns></returns>
  7197. [HttpPost]
  7198. public IActionResult ExportTravel(ExportTravelDto dto)
  7199. {
  7200. var jw = JsonView(false);
  7201. jw.Data = "";
  7202. int diid = 0;
  7203. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7204. if (Find == null)
  7205. {
  7206. jw.Msg = "请选择正确的团组!";
  7207. return Ok(jw);
  7208. }
  7209. else
  7210. {
  7211. diid = Find.Id;
  7212. }
  7213. //数据源
  7214. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7215. DataTable dtBlack = null;
  7216. try
  7217. {
  7218. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7219. }
  7220. catch (Exception)
  7221. {
  7222. jw.Msg = "机票黑屏代码有误!";
  7223. return Ok(jw);
  7224. }
  7225. string CityStr = string.Empty;
  7226. if (dtBlack.Rows.Count == 0)
  7227. {
  7228. jw.Msg = "机票黑屏代码有误!";
  7229. return Ok(jw);
  7230. }
  7231. else
  7232. {
  7233. foreach (DataRow row in dtBlack.Rows)
  7234. {
  7235. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7236. {
  7237. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7238. return Ok(jw);
  7239. }
  7240. }
  7241. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7242. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7243. }
  7244. //创建数据源Table
  7245. DataTable dtSource = new DataTable();
  7246. dtSource.Columns.Add("Days", typeof(string));
  7247. dtSource.Columns.Add("Date", typeof(string));
  7248. dtSource.Columns.Add("Week", typeof(string));
  7249. dtSource.Columns.Add("Traffic", typeof(string));
  7250. dtSource.Columns.Add("Trip", typeof(string));
  7251. //获取数据,放到datatable
  7252. foreach (var item in _travelList)
  7253. {
  7254. DataRow dr = dtSource.NewRow();
  7255. dr["Days"] = item.Days;
  7256. dr["Date"] = item.Date;
  7257. dr["Week"] = item.WeekDay;
  7258. dr["Traffic"] = item.Traffic_First
  7259. + "\r\n"
  7260. + item.Traffic_Second;
  7261. dr["Trip"] = item.Trip;
  7262. dtSource.Rows.Add(dr);
  7263. }
  7264. Dictionary<string, string> dic = new Dictionary<string, string>();
  7265. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7266. dic.Add("City", CityStr);
  7267. dic.Add("Days", Find.VisitDays.ToString());
  7268. dic.Add("DeleCode", Find.TourCode);
  7269. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7270. //模板路径
  7271. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7272. //载入模板
  7273. Document doc = null;
  7274. DocumentBuilder builder = null;
  7275. try
  7276. {
  7277. //载入模板
  7278. doc = new Document(tempPath);
  7279. builder = new DocumentBuilder(doc);
  7280. }
  7281. catch (Exception)
  7282. {
  7283. jw.Msg = "模板位置不存在!";
  7284. return Ok(jw);
  7285. }
  7286. foreach (var key in dic.Keys)
  7287. {
  7288. Bookmark bookmark = doc.Range.Bookmarks[key];
  7289. if (bookmark != null)
  7290. {
  7291. builder.MoveToBookmark(key);
  7292. builder.Write(dic[key]);
  7293. }
  7294. }
  7295. //获取word里所有表格
  7296. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7297. //获取所填表格的序数
  7298. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7299. try
  7300. {
  7301. //循环赋值
  7302. for (int i = 0; i < dtSource.Rows.Count; i++)
  7303. {
  7304. builder.MoveToCell(0, i + 1, 0, 0);
  7305. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7306. builder.MoveToCell(0, i + 1, 1, 0);
  7307. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7308. builder.MoveToCell(0, i + 1, 2, 0);
  7309. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7310. var trip = dtSource.Rows[i]["Trip"].ToString();
  7311. builder.MoveToCell(0, i + 1, 3, 0);
  7312. builder.Write(trip);
  7313. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7314. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7315. // 获取特定索引的段落
  7316. Paragraph paragraph = (Paragraph)paragraphs[0];
  7317. Run run = paragraph.Runs[0];
  7318. Aspose.Words.Font font = run.Font;
  7319. font.Name = "黑体";
  7320. //设置双休红色
  7321. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7322. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7323. paragraph = (Paragraph)paragraphs[1];
  7324. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7325. {
  7326. run = paragraph.Runs[0];
  7327. font = run.Font;
  7328. font.Color = Color.Red;
  7329. }
  7330. }
  7331. }
  7332. catch (Exception ex)
  7333. {
  7334. }
  7335. //删除多余行
  7336. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7337. {
  7338. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7339. }
  7340. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7341. if (!Directory.Exists(savePath))
  7342. {
  7343. try
  7344. {
  7345. Directory.CreateDirectory(savePath);
  7346. }
  7347. catch
  7348. {
  7349. }
  7350. }
  7351. string path = savePath + Find.TeamName + "出访日程";
  7352. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7353. try
  7354. {
  7355. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7356. string postfix = ".docx";
  7357. if (dto.IsPDF == 1)
  7358. {
  7359. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7360. postfix = ".pdf";
  7361. }
  7362. doc.Save(path + postfix, saveFormat);
  7363. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7364. }
  7365. catch (Exception)
  7366. {
  7367. jw = JsonView(false);
  7368. }
  7369. return Ok(jw);
  7370. }
  7371. /// <summary>
  7372. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7373. /// </summary>
  7374. /// <param name="num"></param>
  7375. /// <returns></returns>
  7376. string GetNum(string num)
  7377. {
  7378. string str = "";
  7379. switch (num)
  7380. {
  7381. case "1":
  7382. str = "一";
  7383. break;
  7384. case "2":
  7385. str = "二";
  7386. break;
  7387. case "3":
  7388. str = "三";
  7389. break;
  7390. case "4":
  7391. str = "四";
  7392. break;
  7393. case "5":
  7394. str = "五";
  7395. break;
  7396. case "6":
  7397. str = "六";
  7398. break;
  7399. case "7":
  7400. str = "七";
  7401. break;
  7402. case "8":
  7403. str = "八";
  7404. break;
  7405. case "9":
  7406. str = "九";
  7407. break;
  7408. case "10":
  7409. str = "十";
  7410. break;
  7411. case "11":
  7412. str = "十一";
  7413. break;
  7414. case "12":
  7415. str = "十二";
  7416. break;
  7417. case "一":
  7418. str = "1";
  7419. break;
  7420. case "二":
  7421. str = "2";
  7422. break;
  7423. case "三":
  7424. str = "3";
  7425. break;
  7426. case "四":
  7427. str = "4";
  7428. break;
  7429. case "五":
  7430. str = "5";
  7431. break;
  7432. case "六":
  7433. str = "6";
  7434. break;
  7435. case "七":
  7436. str = "7";
  7437. break;
  7438. case "八":
  7439. str = "8";
  7440. break;
  7441. case "九":
  7442. str = "9";
  7443. break;
  7444. case "十":
  7445. str = "10";
  7446. break;
  7447. case "十一":
  7448. str = "11";
  7449. break;
  7450. case "十二":
  7451. str = "12";
  7452. break;
  7453. }
  7454. return str;
  7455. }
  7456. #endregion
  7457. #endregion
  7458. #region 团组成本
  7459. /// <summary>
  7460. /// 团组成本数据初始化
  7461. /// </summary>
  7462. /// <param name="dto"></param>
  7463. /// <returns></returns>
  7464. [HttpPost]
  7465. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7466. {
  7467. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7468. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7469. WHEN COUNT(*) >= 0 THEN 'True'
  7470. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7471. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7472. ").ToList(); //团组列表
  7473. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7474. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7475. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7476. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7477. if (groupinfoValue != null)
  7478. {
  7479. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7480. var spArr = new string[1] { countryArr };
  7481. if (countryArr.Contains("|"))
  7482. {
  7483. spArr = countryArr.Split("|");
  7484. }
  7485. else if (countryArr.Contains("、"))
  7486. {
  7487. spArr = countryArr.Split("、");
  7488. }
  7489. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7490. {
  7491. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7492. if (dbQueryCountry != null)
  7493. {
  7494. visaCountryInfoArr.Add(dbQueryCountry);
  7495. }
  7496. }
  7497. }
  7498. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7499. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7500. var create = _GroupCostRepository.
  7501. CreateGroupCostByBlackCode(dto.Diid);
  7502. if (groupCost.Count == 0 && create.Code == 0)
  7503. {
  7504. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7505. }
  7506. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7507. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7508. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7509. groupCostMap = groupCostMap.Select(x =>
  7510. {
  7511. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7512. {
  7513. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7514. }
  7515. return x;
  7516. }).ToList();
  7517. //GroupCostParameter.Add(new
  7518. // Grp_GroupCostParameter());
  7519. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7520. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7521. return Ok(JsonView(new
  7522. {
  7523. groupList,
  7524. groupInfo,
  7525. groupChecks,
  7526. groupCost = groupCostMap,
  7527. hotelNumber,
  7528. GroupCostParameter = GroupCostParameterMap,
  7529. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7530. {
  7531. x.VisaCountry,
  7532. x.VisaPrice,
  7533. x.Id,
  7534. }).ToList(),
  7535. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7536. blackCodeIsTrue = create.Code == 0 ? true : false,
  7537. hotelIsTrue = hotelIsTrue,
  7538. }));
  7539. }
  7540. /// <summary>
  7541. /// 团组成本信息保存
  7542. /// </summary>
  7543. /// <param name="dto"></param>
  7544. /// <returns></returns>
  7545. [HttpPost]
  7546. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7547. {
  7548. if (dto.Diid <= 0 || dto.Userid <= 0)
  7549. {
  7550. return Ok(JsonView(false));
  7551. }
  7552. JsonView jw = null;
  7553. bool isTrue = false;
  7554. #region 复制团组成本
  7555. //if (dto.Diid == 2581)
  7556. //{
  7557. // dto.Diid = 2599;
  7558. // dto.CheckBoxs.ForEach(x =>
  7559. // {
  7560. // x.Diid = 2599;
  7561. // });
  7562. // dto.GroupCosts.ForEach(x =>
  7563. // {
  7564. // x.Diid = 2599;
  7565. // });
  7566. // dto.CostTypeHotelNumbers.ForEach(x =>
  7567. // {
  7568. // x.Diid = 2599;
  7569. // });
  7570. // dto.GroupCostParameters.ForEach(x =>
  7571. // {
  7572. // x.DiId = 2599;
  7573. // });
  7574. //}
  7575. #endregion
  7576. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7577. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7578. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7579. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7580. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7581. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7582. try
  7583. {
  7584. _sqlSugar.BeginTran();
  7585. isTrue = await _GroupCostRepository.
  7586. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7587. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7588. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7589. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7590. _sqlSugar.CommitTran();
  7591. jw = JsonView(true, "保存成功!", isTrue);
  7592. }
  7593. catch (Exception)
  7594. {
  7595. _sqlSugar.RollbackTran();
  7596. jw = JsonView(false);
  7597. }
  7598. return Ok(jw);
  7599. }
  7600. /// <summary>
  7601. /// 司兼导数据
  7602. /// </summary>
  7603. /// <param name="dto"></param>
  7604. /// <returns></returns>
  7605. [HttpPost]
  7606. public IActionResult GetCarGuides(CarGuidesDto dto)
  7607. {
  7608. JsonView jw = null;
  7609. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7610. jw = JsonView(true, "获取成功!", Data);
  7611. return Ok(jw);
  7612. }
  7613. /// <summary>
  7614. /// 导游数据
  7615. /// </summary>
  7616. /// <param name="dto"></param>
  7617. /// <returns></returns>
  7618. [HttpPost]
  7619. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7620. {
  7621. JsonView jw = null;
  7622. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7623. // SELECT*,ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber FROM Grp_GuidesInfo where (city like '%{dto.City}%' or country like '%{dto.City}%' ) and isdel = 0 ) as b
  7624. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7625. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7626. jw = JsonView(true, "获取成功!", Data);
  7627. return Ok(jw);
  7628. }
  7629. /// <summary>
  7630. /// 成本车数据
  7631. /// </summary>
  7632. /// <param name="dto"></param>
  7633. /// <returns></returns>
  7634. [HttpPost]
  7635. public IActionResult GetCarInfo(CarGuidesDto dto)
  7636. {
  7637. JsonView jw = null;
  7638. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7639. jw = JsonView(true, "获取成功!", Data);
  7640. return Ok(jw);
  7641. }
  7642. /// <summary>
  7643. /// 景点数据
  7644. /// </summary>
  7645. /// <param name="dto"></param>
  7646. /// <returns></returns>
  7647. [HttpPost]
  7648. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7649. {
  7650. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7651. return Ok(JsonView(true, "获取成功!", Data));
  7652. }
  7653. /// <summary>
  7654. /// 成本通知
  7655. /// </summary>
  7656. /// <param name="dto"></param>
  7657. /// <returns></returns>
  7658. [HttpPost]
  7659. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7660. {
  7661. if (dto.Diid < 0)
  7662. {
  7663. return Ok(JsonView(false));
  7664. }
  7665. JsonView jw = null;
  7666. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7667. if (GroupCostParameter != null)
  7668. {
  7669. int IsShare = 0;
  7670. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7671. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7672. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7673. string msg = string.Empty;
  7674. if (isTrue)
  7675. {
  7676. if (IsShare == 0)
  7677. {
  7678. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7679. }
  7680. else
  7681. {
  7682. #region 企微通知对应岗位用户
  7683. try
  7684. {
  7685. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7686. }
  7687. catch (Exception ex)
  7688. {
  7689. }
  7690. #endregion
  7691. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7692. }
  7693. jw = JsonView(isTrue, msg, new { IsShare });
  7694. }
  7695. else
  7696. {
  7697. msg = "修改失败!";
  7698. jw = JsonView(isTrue, msg);
  7699. }
  7700. }
  7701. else
  7702. {
  7703. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7704. }
  7705. return Ok(jw);
  7706. }
  7707. /// <summary>
  7708. /// 导出报价单
  7709. /// </summary>
  7710. /// <param name="dto"></param>
  7711. /// <returns></returns>
  7712. [HttpPost]
  7713. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7714. {
  7715. if (dto.Diid == 0)
  7716. {
  7717. return Ok(JsonView(false, "请传递团组id"));
  7718. }
  7719. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7720. if (deleInfo.Code != 0)
  7721. {
  7722. return Ok(JsonView(false, "团组信息查询失败!"));
  7723. }
  7724. var di = deleInfo.Data as DelegationInfoWebView;
  7725. if (di != null)
  7726. {
  7727. di.TeamName = di.TeamName.Replace("|", "、");
  7728. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7729. //文件名
  7730. string strFileName = di.TeamName + "-收款账单.doc";
  7731. //获取模板
  7732. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7733. //载入模板
  7734. Document doc = new Document(tmppath);
  7735. decimal TotalPrice = 0.00M;
  7736. string itemStr = string.Empty;
  7737. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7738. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7739. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7740. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7741. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7742. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7743. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7744. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7745. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7746. foreach (var cost in groupCostType)
  7747. {
  7748. var List = cost.ToList();
  7749. if (cost.Key == "A")
  7750. {
  7751. foreach (var ListItem in List)
  7752. {
  7753. if (ListItem.number > 0)
  7754. {
  7755. if (ListItem.code.Contains("TBR"))
  7756. {
  7757. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7758. }
  7759. else
  7760. {
  7761. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7762. }
  7763. TotalPrice += (ListItem.number * ListItem.price);
  7764. }
  7765. }
  7766. }
  7767. else
  7768. {
  7769. itemStr = itemStr.Insert(0, "A段\r\n");
  7770. itemStr += "B段\r\n";
  7771. foreach (var ListItem in List)
  7772. {
  7773. if (ListItem.number > 0)
  7774. {
  7775. if (ListItem.code.Contains("TBR"))
  7776. {
  7777. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7778. }
  7779. else
  7780. {
  7781. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7782. }
  7783. TotalPrice += (ListItem.number * ListItem.price);
  7784. }
  7785. }
  7786. }
  7787. }
  7788. #region 替换Word模板书签内容
  7789. Dictionary<string, string> marks = new Dictionary<string, string>();
  7790. marks.Add("To", di.ClientUnit);//付款方
  7791. marks.Add("ToTel", di.TellPhone);//付款方电话
  7792. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7793. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7794. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7795. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7796. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7797. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7798. marks.Add("PayItemContent", itemStr);//详细信息
  7799. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7800. #endregion
  7801. ////注
  7802. //if (doc.Range.Bookmarks["Attention"] != null)
  7803. //{
  7804. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7805. // mark.Text = frList[0].Attention;
  7806. //}
  7807. foreach (var item in marks.Keys)
  7808. {
  7809. if (doc.Range.Bookmarks[item] != null)
  7810. {
  7811. Bookmark mark = doc.Range.Bookmarks[item];
  7812. mark.Text = marks[item];
  7813. }
  7814. }
  7815. byte[] bytes = null;
  7816. using (MemoryStream stream = new MemoryStream())
  7817. {
  7818. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7819. bytes = stream.ToArray();
  7820. }
  7821. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7822. return Ok(JsonView(true, "", new
  7823. {
  7824. Data = bytes,
  7825. strFileName,
  7826. }));
  7827. }
  7828. else
  7829. {
  7830. return Ok(JsonView(false, "团组信息不存在!"));
  7831. }
  7832. }
  7833. /// <summary>
  7834. /// 导出团组成本
  7835. /// </summary>
  7836. /// <param name="dto"></param>
  7837. /// <returns></returns>
  7838. [HttpPost]
  7839. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7840. {
  7841. var jw = JsonView(false);
  7842. if (dto.Diid == 0)
  7843. {
  7844. return Ok(JsonView(false, "请传递团组id"));
  7845. }
  7846. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7847. if (deleInfo.Code != 0)
  7848. {
  7849. return Ok(JsonView(false, "团组信息查询失败!"));
  7850. }
  7851. var di = deleInfo.Data as DelegationInfoWebView;
  7852. if (di == null)
  7853. {
  7854. return Ok(JsonView(false, "团组信息查询失败!"));
  7855. }
  7856. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7857. WorkbookDesigner designer = new WorkbookDesigner();
  7858. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7859. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7860. for (int i = 0; i < List_GC.Count; i++)
  7861. {
  7862. GroupCost_Excel gc = new GroupCost_Excel();
  7863. gc.Id = List_GC[i].Id;
  7864. gc.Diid = List_GC[i].Diid.ToString();
  7865. gc.DAY = List_GC[i].DAY;
  7866. string week = "";
  7867. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7868. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7869. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7870. gc.ITIN = List_GC[i].ITIN;
  7871. gc.CarType = List_GC[i].CarType;
  7872. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7873. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7874. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7875. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7876. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7877. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7878. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7879. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7880. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7881. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7882. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7883. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7884. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7885. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7886. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7887. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7888. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7889. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7890. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7891. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7892. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7893. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7894. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7895. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7896. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7897. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7898. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7899. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7900. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7901. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7902. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7903. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7904. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7905. List_GC1.Add(gc);
  7906. }
  7907. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7908. dt.TableName = "TB";
  7909. //报表标题等不用dt的值
  7910. designer.SetDataSource("TeamName", dto.title.TeamName);
  7911. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7912. designer.SetDataSource("Tax", dto.title.Tax);
  7913. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7914. designer.SetDataSource("Currency", dto.title.Currency);
  7915. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7916. designer.SetDataSource("Rate", dto.title.Rate);
  7917. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7918. var Aparams = hotels.Find(x => x.Type == "Default");
  7919. if (Aparams == null)
  7920. {
  7921. return Ok(jw);
  7922. }
  7923. //酒店数量
  7924. var txtSGRNumber = Aparams.SGR.ToString();
  7925. var txtTBRNumber = Aparams.TBR.ToString();
  7926. var txtJSESNumber = Aparams.JSES.ToString();
  7927. var txtSUITENumbe = Aparams.SUITE.ToString();
  7928. if (dto.costType == "B")
  7929. {
  7930. Aparams = hotels.Find(x => x.Type == "A");
  7931. var Bparams = hotels.Find(x => x.Type == "B");
  7932. if (Aparams == null || Bparams == null)
  7933. {
  7934. return Ok(jw);
  7935. }
  7936. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7937. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7938. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7939. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7940. }
  7941. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7942. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7943. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7944. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7945. var ws = designer.Workbook.Worksheets[0];
  7946. int Row = List_GC.Count;
  7947. int startIndex = 11;
  7948. int HideRows = 0;
  7949. List<int> hideRowsList = new List<int>();
  7950. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7951. #region A段left数据
  7952. var left = dto.leftInfo.Find(x => x.Type == "A");
  7953. if (left == null)
  7954. {
  7955. return Ok(jw);
  7956. }
  7957. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7958. if (leftBindData != null)
  7959. {
  7960. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7961. designer.SetDataSource("VisaRS", leftBindData.rs);
  7962. designer.SetDataSource("VisaXS", leftBindData.xs);
  7963. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7964. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7965. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7966. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7967. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7968. }
  7969. else
  7970. {
  7971. hideRowsList.Add(Row + startIndex + HideRows);
  7972. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7973. }
  7974. HideRows += 2;
  7975. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7976. if (leftBindData != null)
  7977. {
  7978. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7979. designer.SetDataSource("BXRS", leftBindData.rs);
  7980. designer.SetDataSource("BXXS", leftBindData.xs);
  7981. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7982. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7983. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7984. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7985. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7986. }
  7987. else
  7988. {
  7989. hideRowsList.Add(Row + startIndex + HideRows);
  7990. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7991. }
  7992. HideRows += 2;
  7993. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7994. if (leftBindData != null)
  7995. {
  7996. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7997. designer.SetDataSource("HSRS", leftBindData.rs);
  7998. designer.SetDataSource("HSXS", leftBindData.xs);
  7999. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8000. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8001. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8002. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8003. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8004. }
  8005. else
  8006. {
  8007. hideRowsList.Add(Row + startIndex + HideRows);
  8008. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8009. }
  8010. HideRows += 2;
  8011. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8012. if (leftBindData != null)
  8013. {
  8014. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8015. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8016. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8017. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8018. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8019. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8020. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8021. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8022. }
  8023. else
  8024. {
  8025. hideRowsList.Add(Row + startIndex + HideRows);
  8026. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8027. }
  8028. HideRows += 2;
  8029. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8030. if (leftBindData != null)
  8031. {
  8032. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8033. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8034. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8035. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8036. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8037. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8038. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8039. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8040. }
  8041. else
  8042. {
  8043. hideRowsList.Add(Row + startIndex + HideRows);
  8044. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8045. }
  8046. HideRows += 2;
  8047. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8048. if (leftBindData != null)
  8049. {
  8050. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8051. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8052. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8053. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8054. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8055. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8056. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8057. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8058. }
  8059. else
  8060. {
  8061. hideRowsList.Add(Row + startIndex + HideRows);
  8062. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8063. }
  8064. HideRows += 2;
  8065. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8066. if (leftBindData != null)
  8067. {
  8068. ////TBR
  8069. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8070. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8071. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8072. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8073. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8074. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8075. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8076. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8077. }
  8078. else
  8079. {
  8080. hideRowsList.Add(Row + startIndex + HideRows);
  8081. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8082. }
  8083. HideRows += 2;
  8084. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8085. if (leftBindData != null)
  8086. {
  8087. ////SGR
  8088. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8089. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8090. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8091. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8092. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8093. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8094. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8095. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8096. }
  8097. else
  8098. {
  8099. hideRowsList.Add(Row + startIndex + HideRows);
  8100. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8101. }
  8102. HideRows += 2;
  8103. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8104. if (leftBindData != null)
  8105. {
  8106. ////JS/ES
  8107. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8108. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8109. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8110. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8111. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8112. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8113. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8114. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8115. }
  8116. else
  8117. {
  8118. hideRowsList.Add(Row + startIndex + HideRows);
  8119. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8120. }
  8121. HideRows += 2;
  8122. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8123. if (leftBindData != null)
  8124. {
  8125. ////SUITE
  8126. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8127. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8128. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8129. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8130. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8131. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8132. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8133. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8134. }
  8135. else
  8136. {
  8137. hideRowsList.Add(Row + startIndex + HideRows);
  8138. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8139. }
  8140. HideRows += 2;
  8141. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8142. if (leftBindData != null)
  8143. {
  8144. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8145. designer.SetDataSource("DJRS", leftBindData.rs);
  8146. designer.SetDataSource("DJXS", leftBindData.xs);
  8147. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8148. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8149. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8150. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8151. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8152. }
  8153. else
  8154. {
  8155. hideRowsList.Add(Row + startIndex + HideRows);
  8156. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8157. }
  8158. HideRows += 2;
  8159. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8160. if (leftBindData != null)
  8161. {
  8162. designer.SetDataSource("HCPCB", leftBindData.cb);
  8163. designer.SetDataSource("HCPRS", leftBindData.rs);
  8164. designer.SetDataSource("HCPXS", leftBindData.xs);
  8165. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8166. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8167. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8168. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8169. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8170. }
  8171. else
  8172. {
  8173. hideRowsList.Add(Row + startIndex + HideRows);
  8174. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8175. }
  8176. HideRows += 2;
  8177. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8178. if (leftBindData != null)
  8179. {
  8180. designer.SetDataSource("CPCB", leftBindData.cb);
  8181. designer.SetDataSource("CPRS", leftBindData.rs);
  8182. designer.SetDataSource("CPXS", leftBindData.xs);
  8183. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8184. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8185. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8186. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8187. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8188. }
  8189. else
  8190. {
  8191. hideRowsList.Add(Row + startIndex + HideRows);
  8192. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8193. }
  8194. HideRows += 2;
  8195. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8196. if (leftBindData != null)
  8197. {
  8198. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8199. designer.SetDataSource("GWRS", leftBindData.rs);
  8200. designer.SetDataSource("GWXS", leftBindData.xs);
  8201. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8202. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8203. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8204. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8205. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8206. }
  8207. else
  8208. {
  8209. hideRowsList.Add(Row + startIndex + HideRows);
  8210. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8211. }
  8212. HideRows += 2;
  8213. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8214. if (leftBindData != null)
  8215. {
  8216. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8217. designer.SetDataSource("LYJRS", leftBindData.rs);
  8218. designer.SetDataSource("LYJXS", leftBindData.xs);
  8219. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8220. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8221. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8222. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8223. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8224. }
  8225. else
  8226. {
  8227. hideRowsList.Add(Row + startIndex + HideRows);
  8228. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8229. }
  8230. #endregion
  8231. #region A段Right信息
  8232. var right = dto.rightInfo.Find(x => x.Type == "A");
  8233. if (right == null)
  8234. {
  8235. return Ok(jw);
  8236. }
  8237. HideRows += 4;
  8238. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8239. if (rightBindData != null)
  8240. {
  8241. //经济舱 + 双人间 TBR
  8242. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8243. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8244. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8245. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8246. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8247. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8248. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8249. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8250. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8251. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8252. }
  8253. else
  8254. {
  8255. hideRowsList.Add(Row + startIndex + HideRows);
  8256. }
  8257. HideRows += 2;
  8258. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8259. if (rightBindData != null)
  8260. {
  8261. //经济舱 + 单人间 SGR
  8262. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8263. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8264. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8265. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8266. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8267. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8268. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8269. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8270. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8271. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8272. }
  8273. else
  8274. {
  8275. hideRowsList.Add(Row + startIndex + HideRows);
  8276. }
  8277. HideRows += 2;
  8278. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8279. if (rightBindData != null)
  8280. {
  8281. //公务舱 + 单人间 SGR
  8282. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8283. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8284. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8285. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8286. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8287. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8288. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8289. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8290. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8291. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8292. }
  8293. else
  8294. {
  8295. hideRowsList.Add(Row + startIndex + HideRows);
  8296. }
  8297. HideRows += 2;
  8298. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8299. if (rightBindData != null)
  8300. {
  8301. //公务舱 + 小套房 JSES
  8302. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8303. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8304. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8305. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8306. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8307. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8308. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8309. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8310. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8311. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8312. }
  8313. else
  8314. {
  8315. hideRowsList.Add(Row + startIndex + HideRows);
  8316. }
  8317. HideRows += 2;
  8318. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8319. if (rightBindData != null)
  8320. {
  8321. //公务舱 + 小套房 JSES
  8322. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8323. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8324. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8325. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8326. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8327. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8328. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8329. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8330. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8331. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8332. }
  8333. else
  8334. {
  8335. hideRowsList.Add(Row + startIndex + HideRows);
  8336. }
  8337. HideRows += 2;
  8338. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8339. if (rightBindData != null)
  8340. {
  8341. //经济舱 + 大套房
  8342. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8343. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8344. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8345. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8346. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8347. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8348. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8349. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8350. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8351. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8352. }
  8353. else
  8354. {
  8355. hideRowsList.Add(Row + startIndex + HideRows);
  8356. }
  8357. HideRows += 2;
  8358. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8359. if (rightBindData != null)
  8360. {
  8361. //头等舱 + 小套房 JSES
  8362. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8363. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8364. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8365. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8366. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8367. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8368. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8369. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8370. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8371. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8372. }
  8373. else
  8374. {
  8375. hideRowsList.Add(Row + startIndex + HideRows);
  8376. }
  8377. HideRows += 2;
  8378. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8379. if (rightBindData != null)
  8380. {
  8381. //头等舱 + 大套房
  8382. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8383. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8384. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8385. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8386. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8387. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8388. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8389. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8390. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8391. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8392. }
  8393. else
  8394. {
  8395. hideRowsList.Add(Row + startIndex + HideRows);
  8396. }
  8397. #endregion
  8398. #region B段标题清空
  8399. designer.SetDataSource("CostBDRCB", "");
  8400. designer.SetDataSource("CostBRS", "");
  8401. designer.SetDataSource("CostBXS", "");
  8402. designer.SetDataSource("CostBZCB", "");
  8403. designer.SetDataSource("CostBDRBJ", "");
  8404. designer.SetDataSource("CostBZBJ", "");
  8405. designer.SetDataSource("CostBDRLR", "");
  8406. designer.SetDataSource("CostBZLR", "");
  8407. designer.SetDataSource("CostBDRCBOM", "");
  8408. designer.SetDataSource("CostBRSOM", "");
  8409. designer.SetDataSource("CostBZCBOM", "");
  8410. designer.SetDataSource("CostBDRBJOM", "");
  8411. designer.SetDataSource("CostBZBJOM", "");
  8412. designer.SetDataSource("CostBDRLROM", "");
  8413. designer.SetDataSource("CostBZLROM", "");
  8414. #endregion
  8415. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8416. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8417. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8418. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8419. designer.SetDataSource("DJName", "地接(CNY)");
  8420. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8421. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8422. designer.SetDataSource("GWName", "公务(CNY)");
  8423. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8424. designer.SetDataSource("LYJName", "零用金(CNY)");
  8425. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8426. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8427. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8428. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8429. designer.SetDataSource("BXName", "保险(CNY)");
  8430. designer.SetDataSource("VisaName", "签证(CNY)");
  8431. #region B段基本数据
  8432. if (dto.costType == "B")
  8433. {
  8434. left = dto.leftInfo.Find(x => x.Type == "B");
  8435. if (left == null)
  8436. {
  8437. return Ok(jw);
  8438. }
  8439. #region B段left数据
  8440. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8441. if (leftBindData != null)
  8442. {
  8443. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8444. designer.SetDataSource("BHSRS", leftBindData.rs);
  8445. designer.SetDataSource("BHSXS", leftBindData.xs);
  8446. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8447. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8448. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8449. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8450. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8451. }
  8452. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8453. if (leftBindData != null)
  8454. {
  8455. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8456. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8457. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8458. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8459. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8460. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8461. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8462. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8463. }
  8464. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8465. if (leftBindData != null)
  8466. {
  8467. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8468. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8469. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8470. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8471. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8472. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8473. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8474. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8475. }
  8476. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8477. if (leftBindData != null)
  8478. {
  8479. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8480. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8481. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8482. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8483. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8484. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8485. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8486. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8487. }
  8488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8489. if (leftBindData != null)
  8490. {
  8491. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8492. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8493. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8494. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8495. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8496. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8497. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8498. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8499. }
  8500. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8501. if (leftBindData != null)
  8502. {
  8503. designer.SetDataSource("BCPCB", leftBindData.cb);
  8504. designer.SetDataSource("BCPRS", leftBindData.rs);
  8505. designer.SetDataSource("BCPXS", leftBindData.xs);
  8506. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8507. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8508. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8509. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8510. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8511. }
  8512. //TBR
  8513. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8514. if (leftBindData != null)
  8515. {
  8516. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8517. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8518. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8519. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8520. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8521. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8522. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8523. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8524. }
  8525. //SGR
  8526. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8527. if (leftBindData != null)
  8528. {
  8529. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8530. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8531. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8532. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8533. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8534. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8535. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8536. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8537. }
  8538. //JS/ES
  8539. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8540. if (leftBindData != null)
  8541. {
  8542. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8543. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8544. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8545. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8546. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8547. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8548. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8549. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8550. }
  8551. //SUITE
  8552. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8553. if (leftBindData != null)
  8554. {
  8555. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8556. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8557. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8558. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8559. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8560. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8561. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8562. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8563. }
  8564. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8565. if (leftBindData != null)
  8566. {
  8567. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8568. designer.SetDataSource("BDJRS", leftBindData.rs);
  8569. designer.SetDataSource("BDJXS", leftBindData.xs);
  8570. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8571. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8572. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8573. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8574. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8575. }
  8576. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8577. if (leftBindData != null)
  8578. {
  8579. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8580. designer.SetDataSource("BGWRS", leftBindData.rs);
  8581. designer.SetDataSource("BGWXS", leftBindData.xs);
  8582. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8583. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8584. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8585. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8586. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8587. }
  8588. #region 优化方案
  8589. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8590. //excelBind.Add("零用金", new {
  8591. //cb="",
  8592. //rs="",
  8593. //xs ="",
  8594. //zcb = "",
  8595. //});
  8596. #endregion
  8597. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8598. if (leftBindData != null)
  8599. {
  8600. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8601. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8602. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8603. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8604. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8605. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8606. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8607. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8608. }
  8609. #endregion
  8610. #region B段Right信息
  8611. right = dto.rightInfo.Find(x => x.Type == "B");
  8612. if (right == null)
  8613. {
  8614. return Ok(jw);
  8615. }
  8616. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8617. if (rightBindData != null)
  8618. {
  8619. //经济舱 + 双人间 TBR
  8620. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8621. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8622. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8623. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8624. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8625. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8626. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8627. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8628. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8629. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8630. }
  8631. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8632. if (rightBindData != null)
  8633. {
  8634. //经济舱 + 单人间 SGR
  8635. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8636. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8637. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8638. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8639. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8640. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8641. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8642. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8643. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8644. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8645. }
  8646. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8647. if (rightBindData != null)
  8648. {
  8649. //公务舱 + 单人间 SGR
  8650. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8651. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8652. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8653. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8654. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8655. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8656. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8657. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8658. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8659. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8660. }
  8661. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8662. if (rightBindData != null)
  8663. {
  8664. //公务舱 + 小套房 JSES
  8665. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8666. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8667. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8668. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8669. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8670. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8671. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8672. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8673. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8674. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8675. }
  8676. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8677. if (rightBindData != null)
  8678. {
  8679. //公务舱 + 小套房 JSES
  8680. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8681. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8682. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8683. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8684. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8685. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8686. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8687. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8688. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8689. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8690. }
  8691. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8692. if (rightBindData != null)
  8693. {
  8694. //经济舱 + 大套房
  8695. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8696. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8697. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8698. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8699. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8700. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8701. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8702. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8703. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8704. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8705. }
  8706. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8707. if (rightBindData != null)
  8708. {
  8709. //头等舱 + 小套房 JSES
  8710. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8711. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8712. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8713. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8714. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8715. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8716. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8717. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8718. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8719. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8720. }
  8721. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8722. if (rightBindData != null)
  8723. {
  8724. //头等舱 + 大套房
  8725. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8726. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8727. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8728. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8729. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8730. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8731. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8732. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8733. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8734. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8735. }
  8736. #endregion
  8737. #region 标题
  8738. designer.SetDataSource("CostBDRCB", "单人成本");
  8739. designer.SetDataSource("CostBRS", "人数");
  8740. designer.SetDataSource("CostBXS", "系数");
  8741. designer.SetDataSource("CostBZCB", "总成本");
  8742. designer.SetDataSource("CostBDRBJ", "单人报价");
  8743. designer.SetDataSource("CostBZBJ", "总报价");
  8744. designer.SetDataSource("CostBDRLR", "单人利润");
  8745. designer.SetDataSource("CostBZLR", "总利润");
  8746. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8747. designer.SetDataSource("CostBRSOM", "人数");
  8748. designer.SetDataSource("CostBZCBOM", "总成本");
  8749. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8750. designer.SetDataSource("CostBZBJOM", "总报价");
  8751. designer.SetDataSource("CostBDRLROM", "单人利润");
  8752. designer.SetDataSource("CostBZLROM", "总利润");
  8753. #endregion
  8754. }
  8755. #endregion
  8756. designer.SetDataSource("TzZCB2", TzZCB2);
  8757. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8758. designer.SetDataSource("TzZLR2", TzZLR2);
  8759. string[] dataSourceKeys = new string[]
  8760. {
  8761. "VF",
  8762. "TGS",
  8763. "TGOF",
  8764. "TGM",
  8765. "TGA",
  8766. "TGTF",
  8767. "TGEF",
  8768. "CFM",
  8769. "CFOF",
  8770. "B",
  8771. "L",
  8772. "D",
  8773. "TBR",
  8774. "SGR",
  8775. "JSES",
  8776. "Suite",
  8777. "TV",
  8778. "1L",
  8779. "IF",
  8780. "EF",
  8781. "BRF",
  8782. "TE",
  8783. "TGT",
  8784. "DRVT",
  8785. "PC",
  8786. "TLF",
  8787. "ECT"
  8788. };
  8789. foreach (var item in dataSourceKeys)
  8790. {
  8791. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8792. if (find != null)
  8793. {
  8794. designer.SetDataSource(item, find.text);
  8795. }
  8796. else
  8797. {
  8798. designer.SetDataSource(item, 0);
  8799. }
  8800. }
  8801. designer.SetDataSource(dt);
  8802. //根据数据源处理生成报表内容
  8803. designer.Process();
  8804. designer.Workbook.Worksheets[0].Name = "清单";
  8805. Worksheet sheet = designer.Workbook.Worksheets[0];
  8806. foreach (var Rowindex in hideRowsList)
  8807. {
  8808. ws.Cells.HideRows(Rowindex, 2);
  8809. }
  8810. byte[] bytes = null;
  8811. string strFileName = di.TeamName + "-团组-成本.xls";
  8812. using (MemoryStream stream = new MemoryStream())
  8813. {
  8814. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8815. bytes = stream.ToArray();
  8816. }
  8817. return Ok(JsonView(true, "", new
  8818. {
  8819. Data = bytes,
  8820. strFileName,
  8821. }));
  8822. }
  8823. /// <summary>
  8824. /// 导出客户报表
  8825. /// </summary>
  8826. /// <returns></returns>
  8827. [HttpPost]
  8828. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8829. {
  8830. var jw = JsonView(false);
  8831. if (dto.Diid == 0)
  8832. {
  8833. return Ok(JsonView(false, "请传递团组id"));
  8834. }
  8835. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8836. if (deleInfo.Code != 0)
  8837. {
  8838. return Ok(JsonView(false, "团组信息查询失败!"));
  8839. }
  8840. var di = deleInfo.Data as DelegationInfoWebView;
  8841. if (di == null)
  8842. {
  8843. return Ok(JsonView(false, "团组信息查询失败!"));
  8844. }
  8845. //文件名
  8846. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8847. //获取模板
  8848. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8849. //载入模板
  8850. Document doc = new Document(tmppath);
  8851. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8852. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8853. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8854. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8855. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8856. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8857. if (AParameter == null)
  8858. {
  8859. return Ok(JsonView(false, "系数不存在!"));
  8860. }
  8861. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8862. , TzAirDesc, TzZCost;
  8863. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8864. = TzAirDesc = TzZCost = string.Empty;
  8865. TzNumber = AParameter.CostTypenumber.ToString();
  8866. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8867. CarGuides1 = dto.CarGuides1;
  8868. Meal = dto.Meal;
  8869. SubsidizedMeals = dto.SubsidizedMeals;
  8870. NightRepair = dto.NightRepair;
  8871. AttractionsTickets = dto.AttractionsTickets;
  8872. MiscellaneousFees = dto.MiscellaneousFees;
  8873. ATip = dto.ATip;
  8874. TzHotelDesc = "";
  8875. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8876. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8877. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8878. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8879. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8880. TzAirDesc = "";
  8881. TzZCost = dto.TzZCost;
  8882. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8883. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8884. var index = 1;
  8885. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8886. foreach (var item in TzHotelDescArr)
  8887. {
  8888. if (AinfoArr != null)
  8889. {
  8890. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8891. if (Ainfo != null)
  8892. {
  8893. if (int.Parse(Ainfo.rs) <= 0)
  8894. {
  8895. continue;
  8896. }
  8897. var hotelText = string.Empty;
  8898. switch (item)
  8899. {
  8900. case "SGR":
  8901. hotelText = "单人间";
  8902. break;
  8903. case "JSES":
  8904. hotelText = "小套房";
  8905. break;
  8906. case "SUITE":
  8907. hotelText = "套房";
  8908. break;
  8909. case "TBR":
  8910. hotelText = "双人间";
  8911. break;
  8912. }
  8913. if (item != "TBR")
  8914. {
  8915. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8916. }
  8917. else
  8918. {
  8919. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8920. }
  8921. index++;
  8922. }
  8923. }
  8924. }
  8925. index = 1;
  8926. foreach (var item in TzAirDescArr)
  8927. {
  8928. if (AinfoArr != null)
  8929. {
  8930. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8931. if (Ainfo != null)
  8932. {
  8933. if (int.Parse(Ainfo.rs) <= 0)
  8934. {
  8935. continue;
  8936. }
  8937. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8938. index++;
  8939. }
  8940. }
  8941. }
  8942. if (dto.costType == "B")
  8943. {
  8944. if (BParameter == null)
  8945. {
  8946. return Ok(JsonView(false, "B段系数不存在!"));
  8947. }
  8948. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8949. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8950. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8951. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8952. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8953. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8954. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8955. foreach (var item in TzHotelDescArr)
  8956. {
  8957. if (AinfoArr != null)
  8958. {
  8959. TzHotelDesc += "B段信息 \r\n";
  8960. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8961. if (Ainfo != null)
  8962. {
  8963. if (int.Parse(Ainfo.rs) <= 0)
  8964. {
  8965. continue;
  8966. }
  8967. var hotelText = string.Empty;
  8968. switch (item)
  8969. {
  8970. case "SGR":
  8971. hotelText = "单人间";
  8972. break;
  8973. case "JSES":
  8974. hotelText = "小套房";
  8975. break;
  8976. case "SUITE":
  8977. hotelText = "套房";
  8978. break;
  8979. case "TBR":
  8980. hotelText = "双人间";
  8981. break;
  8982. }
  8983. if (item != "TBR")
  8984. {
  8985. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8986. }
  8987. else
  8988. {
  8989. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8990. }
  8991. index++;
  8992. }
  8993. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8994. }
  8995. }
  8996. index = 1;
  8997. foreach (var item in TzAirDescArr)
  8998. {
  8999. if (AinfoArr != null)
  9000. {
  9001. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9002. if (Ainfo != null)
  9003. {
  9004. if (int.Parse(Ainfo.rs) <= 0)
  9005. {
  9006. continue;
  9007. }
  9008. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  9009. index++;
  9010. }
  9011. }
  9012. }
  9013. }
  9014. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9015. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9016. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9017. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9018. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9019. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9020. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9021. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9022. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9023. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9024. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9025. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9026. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9027. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9028. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9029. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9030. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9031. DickeyValue.Add("TzZCost", TzZCost);
  9032. foreach (var key in DickeyValue.Keys)
  9033. {
  9034. if (doc.Range.Bookmarks[key] != null)
  9035. {
  9036. Bookmark mark = doc.Range.Bookmarks[key];
  9037. mark.Text = DickeyValue[key];
  9038. }
  9039. }
  9040. byte[] bytes = null;
  9041. string strFileName = di.TeamName + "-客户报价.doc";
  9042. using (MemoryStream stream = new MemoryStream())
  9043. {
  9044. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9045. bytes = stream.ToArray();
  9046. }
  9047. return Ok(JsonView(true, "", new
  9048. {
  9049. Data = bytes,
  9050. strFileName,
  9051. }));
  9052. }
  9053. /// <summary>
  9054. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9055. /// </summary>
  9056. /// <param name="dto"></param>
  9057. /// <returns></returns>
  9058. [HttpPost]
  9059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9060. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9061. {
  9062. try
  9063. {
  9064. #region 参数验证
  9065. if (dto.DiId < 0)
  9066. {
  9067. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9068. }
  9069. List<int> cTableIds = new List<int>() {
  9070. 76 ,//酒店预订
  9071. 77 ,//行程
  9072. 79 ,//车/导游地接
  9073. 80 ,//签证
  9074. 81 ,//邀请/公务活
  9075. 82 ,//团组客户保险
  9076. 85 ,//机票预订
  9077. 98 ,//其他款项
  9078. 285 ,//收款退还
  9079. 751 ,//酒店早餐
  9080. 1015 // 超支费用
  9081. };
  9082. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9083. {
  9084. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9085. }
  9086. #endregion
  9087. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9088. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9089. if (_GroupCostParameters.Count <= 0)
  9090. {
  9091. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9092. }
  9093. if (_GroupCostParameters[0].IsShare == 0)
  9094. {
  9095. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9096. }
  9097. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9098. //处理date为空问题
  9099. if (_GroupCosts.Count > 0)
  9100. {
  9101. for (int i = 0; i < _GroupCosts.Count; i++)
  9102. {
  9103. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9104. {
  9105. if (i > 0)
  9106. {
  9107. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9108. }
  9109. }
  9110. }
  9111. }
  9112. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9113. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9114. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9115. string currCode = "";
  9116. #region currCode 验证
  9117. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9118. if (isInt)
  9119. {
  9120. var currData = currDatas.Find(it => it.Id == intCurrency);
  9121. if (currData != null)
  9122. {
  9123. currCode = currData.Name;
  9124. }
  9125. }
  9126. else
  9127. {
  9128. currCode = _GroupCostParameters[0].Currency.Trim();
  9129. }
  9130. #endregion
  9131. //op,酒店单段模式存储
  9132. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9133. {
  9134. CurrencyCode = currCode,
  9135. Rate = _GroupCostParameters[0].Rate,
  9136. CostType = _GroupCostParameters[0].CostType,
  9137. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9138. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9139. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9140. };
  9141. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9142. if (_GroupCostParameters.Count == 2)
  9143. {
  9144. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9145. }
  9146. foreach (var item in _GroupCostParameters)
  9147. {
  9148. decimal _rate = 1;
  9149. decimal _rate1 = item.Rate;
  9150. decimal _scale = 1;
  9151. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9152. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9153. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9154. //if (userInfo != null)
  9155. //{
  9156. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9157. // {
  9158. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9159. // {
  9160. // _scale = 1.00M;
  9161. // }
  9162. // }
  9163. //}
  9164. #endregion
  9165. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9166. {
  9167. CurrencyCode = currCode,
  9168. Rate = _rate1,
  9169. CostType = item.CostType,
  9170. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9171. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9172. CostTypeNumber = item.CostTypenumber
  9173. };
  9174. if (_GroupCostParameters.Count > 1)
  9175. {
  9176. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9177. }
  9178. else
  9179. {
  9180. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9181. }
  9182. if (dto.CTable == 79)//
  9183. {
  9184. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9185. modulePromptInfo.TotalCost = item.DJCB;
  9186. }
  9187. List<string> costTypes = new List<string>() { "A", "B" };
  9188. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9189. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9190. if (_GroupCostsDuplicates.Count() == 1)
  9191. {
  9192. _GroupCostsTypeData = _GroupCosts;
  9193. }
  9194. else
  9195. {
  9196. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9197. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9198. }
  9199. /*
  9200. * 76 酒店预订
  9201. * 77 行程
  9202. * 79 车/导游地接
  9203. * 80 签证
  9204. * 81 邀请/公务活动
  9205. * 82 团组客户保险
  9206. * 85 机票预订
  9207. * 98 其他款项
  9208. * 285 收款退还
  9209. * 751 酒店早餐
  9210. * 1015 超支费用
  9211. */
  9212. switch (dto.CTable)
  9213. {
  9214. case 76: // 酒店预订
  9215. _ModuleSubPromptInfo.AddRange(
  9216. _GroupCostsTypeData.Select(it => new
  9217. {
  9218. it.DAY,
  9219. it.Date,
  9220. it.ACCON,
  9221. it.ITIN,
  9222. it.SGR,
  9223. it.TBR,
  9224. it.JS_ES,
  9225. it.Suite
  9226. })
  9227. );
  9228. break;
  9229. case 79: // 车/导游地接
  9230. _ModuleSubPromptInfo.AddRange(
  9231. _GroupCostsTypeData.Select(it => new
  9232. {
  9233. Date = it.Date, //日期
  9234. CarFee = it.CarCost * _rate * _scale, //车费用
  9235. CarType = it.CarType, //车型
  9236. DriverFee = it.CFS * _rate * _scale, //司机工资
  9237. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9238. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9239. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9240. GuideFee = it.TGS * _rate * _scale, //导游费用
  9241. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9242. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9243. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9244. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9245. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9246. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9247. Breakfast = it.B * _rate * _scale, //早餐费
  9248. Lunch = it.L * _rate * _scale, //午餐费
  9249. Dinner = it.D * _rate * _scale, //晚餐费
  9250. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9251. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9252. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9253. TicketFee = it.EF * _rate * _scale, //门票费
  9254. TicketRemark = it.EFR, //门票费描述
  9255. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9256. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9257. SpentCash = it.PC * _rate * _scale, //零用金
  9258. LeadersFee = it.TLF * _rate * _scale, //领队费
  9259. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9260. })
  9261. );
  9262. break;
  9263. case 85: // 机票
  9264. List<dynamic> datas = new List<dynamic>();
  9265. datas.Add(
  9266. new
  9267. {
  9268. AirType = "经济舱",
  9269. AirNum = item.JJCRS,
  9270. AirDRCB = item.JJCCB,
  9271. AirZCB = (item.JJCRS * item.JJCCB)
  9272. }
  9273. );
  9274. datas.Add(
  9275. new
  9276. {
  9277. AirType = "公务舱",
  9278. AirNum = item.GWCRS,
  9279. AirDRCB = item.GWCCB,
  9280. AirZCB = (item.GWCRS * item.GWCCB)
  9281. }
  9282. );
  9283. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9284. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9285. modulePromptInfo.Data = new
  9286. {
  9287. airFeeData = datas,
  9288. airInitData = initDatas
  9289. };
  9290. _ModulePromptInfos.Add(modulePromptInfo);
  9291. break;
  9292. default:
  9293. break;
  9294. }
  9295. }
  9296. if (dto.CTable != 85)
  9297. {
  9298. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9299. _ModulePromptInfos.Add(_ModulePromptInfo);
  9300. }
  9301. _view.ModulePromptInfos = _ModulePromptInfos;
  9302. return Ok(JsonView(true, "操作成功!", _view));
  9303. }
  9304. catch (Exception ex)
  9305. {
  9306. return Ok(JsonView(false, ex.Message));
  9307. }
  9308. }
  9309. /// <summary>
  9310. /// 根据黑屏代码重新生成行程
  9311. /// </summary>
  9312. /// <param name="dto"></param>
  9313. /// <returns></returns>
  9314. [HttpPost]
  9315. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9316. {
  9317. var jw = JsonView(false);
  9318. var Create = _GroupCostRepository.
  9319. CreateGroupCostByBlackCode(dto.Diid);
  9320. jw.Msg = Create.Msg;
  9321. if (Create.Code == 0)
  9322. {
  9323. jw.Code = 200;
  9324. jw.Data = new
  9325. {
  9326. groupCost = Create.Data,
  9327. blackCodeIsTrue = true
  9328. };
  9329. }
  9330. else
  9331. {
  9332. jw.Code = 400;
  9333. jw.Data = new
  9334. {
  9335. groupCost = Create.Data,
  9336. blackCodeIsTrue = false,
  9337. };
  9338. }
  9339. return Ok(jw);
  9340. }
  9341. /// <summary>
  9342. /// 成本获取OP历史车费用
  9343. /// </summary>
  9344. /// <param name="dto"></param>
  9345. /// <returns></returns>
  9346. [HttpPost]
  9347. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9348. {
  9349. var jw = JsonView(false);
  9350. try
  9351. {
  9352. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9353. //获取现有所有车的数据
  9354. if (!dto.Param.IsNullOrWhiteSpace())
  9355. {
  9356. string sql = $@"
  9357. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9358. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9359. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9360. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  9361. AND gctggr.ServiceEndTime is not NULL
  9362. ORDER by gctggrc.id DESC
  9363. ";
  9364. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9365. var numeberResult = await Task.Run(() =>
  9366. {
  9367. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9368. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9369. return numberArr;
  9370. });
  9371. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9372. foreach (var item in numeberResult)
  9373. {
  9374. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9375. {
  9376. Country = "数据异常!",
  9377. City = string.Empty,
  9378. };
  9379. item.Area = find.Country + " " + find.City;
  9380. }
  9381. dbResult.AddRange(numeberResult);
  9382. if (dto.Param.Contains("、"))
  9383. {
  9384. var sp = dto.Param.Split("、");
  9385. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9386. .Where(x =>
  9387. {
  9388. return System.Array.Exists(sp, e =>
  9389. {
  9390. bool where = false;
  9391. if (x.Area != null)
  9392. {
  9393. where = x.Area.Contains(e);
  9394. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9395. {
  9396. return false;
  9397. }
  9398. }
  9399. if (x.PriceName != null && !where)
  9400. {
  9401. where = x.PriceName.Contains(e);
  9402. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9403. {
  9404. return false;
  9405. }
  9406. }
  9407. return where;
  9408. });
  9409. }).ToList();
  9410. }
  9411. else
  9412. {
  9413. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9414. .Where(x =>
  9415. {
  9416. bool where = false;
  9417. if (x.Area != null)
  9418. {
  9419. where = x.Area.Contains(dto.Param);
  9420. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9421. {
  9422. return false;
  9423. }
  9424. }
  9425. if (x.PriceName != null && !where)
  9426. {
  9427. where = x.PriceName.Contains(dto.Param);
  9428. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9429. {
  9430. return false;
  9431. }
  9432. }
  9433. return where;
  9434. }
  9435. )
  9436. .ToList();
  9437. }
  9438. }
  9439. var view = dbResult.Select(x =>
  9440. {
  9441. decimal dp = 0.00M;
  9442. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9443. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9444. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9445. {
  9446. if (startB && endB)
  9447. {
  9448. var timesp = endD.Subtract(startD);
  9449. if ((timesp.Days + 1) != 0)
  9450. {
  9451. dp = x.Price / (timesp.Days + 1);
  9452. }
  9453. }
  9454. }
  9455. else
  9456. {
  9457. dp = x.Price;
  9458. }
  9459. return new
  9460. {
  9461. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9462. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9463. x.Area,
  9464. x.id,
  9465. price = x.Price.ToString("F2"),
  9466. x.PriceName,
  9467. x.PriceContent,
  9468. x.TeamName,
  9469. x.DatePrice,
  9470. dayPrice = dp.ToString("F2"),
  9471. };
  9472. }).OrderByDescending(x => x.id).ToList();
  9473. jw = JsonView(true, "获取成功!", view);
  9474. }
  9475. catch (Exception e)
  9476. {
  9477. jw = JsonView(false, e.Message);
  9478. }
  9479. return Ok(jw);
  9480. }
  9481. #endregion
  9482. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9483. /// <summary>
  9484. /// 酒店预订
  9485. /// 酒店费用列表 根据团组Id查询
  9486. /// </summary>
  9487. /// <param name="_dto"></param>
  9488. /// <returns></returns>
  9489. [HttpPost]
  9490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9491. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9492. {
  9493. #region 参数验证
  9494. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9495. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9496. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9497. #region 团组操作权限验证 76 酒店预定模块
  9498. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9499. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9500. #endregion
  9501. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9502. #region 页面操作权限验证
  9503. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9504. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9505. #endregion
  9506. #endregion
  9507. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9508. }
  9509. /// <summary>
  9510. /// 酒店预订
  9511. /// 基础数据
  9512. /// </summary>
  9513. /// <param name="_dto"></param>
  9514. /// <returns></returns>
  9515. [HttpPost]
  9516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9517. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9518. {
  9519. #region 参数验证
  9520. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9521. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9522. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9523. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9524. #region 页面操作权限验证
  9525. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9526. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9527. #endregion
  9528. #region 团组操作权限验证 76 酒店预定模块
  9529. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9530. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9531. #endregion
  9532. #endregion
  9533. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9534. }
  9535. /// <summary>
  9536. /// 酒店预订
  9537. /// 创建 入住卷号码
  9538. /// </summary>
  9539. /// <param name="_dto"></param>
  9540. /// <returns></returns>
  9541. [HttpPost]
  9542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9543. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9544. {
  9545. #region 参数验证
  9546. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9547. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9548. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9549. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9550. #region 页面操作权限验证
  9551. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9552. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9553. #endregion
  9554. #region 团组操作权限验证 76 酒店预定模块
  9555. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9556. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9557. #endregion
  9558. #endregion
  9559. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9560. if (data.Code != 0)
  9561. {
  9562. return Ok(JsonView(false, data.Msg));
  9563. }
  9564. return Ok(JsonView(true, data.Msg, data.Data));
  9565. }
  9566. /// <summary>
  9567. /// 酒店预订
  9568. /// 详情
  9569. /// </summary>
  9570. /// <param name="_dto"></param>
  9571. /// <returns></returns>
  9572. [HttpPost]
  9573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9574. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9575. {
  9576. #region 参数验证
  9577. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9578. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9579. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9580. #region 团组操作权限验证 76 酒店预定模块
  9581. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9582. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9583. #endregion
  9584. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9585. #region 页面操作权限验证
  9586. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9587. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9588. #endregion
  9589. #endregion
  9590. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9591. }
  9592. /// <summary>
  9593. /// 酒店预订
  9594. /// Add Or Edit
  9595. /// </summary>
  9596. /// <param name="_dto"></param>
  9597. /// <returns></returns>
  9598. [HttpPost]
  9599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9600. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9601. {
  9602. #region 参数验证
  9603. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9604. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9605. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9606. #region 团组操作权限验证 76 酒店预定模块
  9607. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9608. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9609. #endregion
  9610. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9611. #region 页面操作权限验证
  9612. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9613. if (_dto.Id == 0) // Add
  9614. {
  9615. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9616. }
  9617. else if (_dto.Id > 1) // Edit
  9618. {
  9619. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9620. }
  9621. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9622. #endregion
  9623. #endregion
  9624. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9625. if (_view.Code != 200)
  9626. {
  9627. return Ok(_view);
  9628. }
  9629. #region 应用推送
  9630. try
  9631. {
  9632. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9633. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9634. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9635. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  9636. //2024-10-21 新增LZ UID
  9637. var userIds = new List<int>() { 21 };
  9638. string title = $"费用审核";
  9639. var diId = _dto.DiId;
  9640. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9641. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9642. string content = "";
  9643. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9644. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9645. Logs($"【iOS推送通知Exceptio1】Start");
  9646. try
  9647. {
  9648. var iosRes = await GeneralMethod.iOS_PushNotifications("051", title, "", content);
  9649. Logs($"【iOS推送通知Exception2】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  9650. }
  9651. catch (Exception ex )
  9652. {
  9653. Logs($"【iOS推送通知Exception2-1】[{ex.Message}]");
  9654. }
  9655. }
  9656. catch (Exception ex)
  9657. {
  9658. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  9659. }
  9660. try
  9661. {
  9662. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9663. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9664. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9665. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9666. //自动审核
  9667. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9668. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9669. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9670. //2024-10-21 新增LZ UID
  9671. var userIds = new List<int>() { 21 };
  9672. string title = $"系统通知";
  9673. var diId = _dto.DiId;
  9674. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9675. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9676. string content = "";
  9677. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9678. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9679. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9680. //await GeneralMethod.iOS_PushNotifications("051", "费用审核", "", content);
  9681. }
  9682. catch (Exception ex)
  9683. {
  9684. }
  9685. #endregion
  9686. return Ok(_view);
  9687. }
  9688. /// <summary>
  9689. /// 酒店自动审核测试
  9690. /// Add Or Edit
  9691. /// </summary>
  9692. /// <param name="_dto"></param>
  9693. /// <returns></returns>
  9694. [HttpPost]
  9695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9696. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9697. {
  9698. #region 应用推送
  9699. try
  9700. {
  9701. //自动审核
  9702. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9703. }
  9704. catch (Exception ex)
  9705. {
  9706. return Ok(JsonView(false, "操作失败"));
  9707. }
  9708. #endregion
  9709. return Ok(JsonView(false, "操作成功"));
  9710. }
  9711. /// <summary>
  9712. /// 酒店预订
  9713. /// Del
  9714. /// </summary>
  9715. /// <param name="_dto"></param>
  9716. /// <returns></returns>
  9717. [HttpPost]
  9718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9719. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9720. {
  9721. #region 参数验证
  9722. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9723. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9724. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9725. #region 团组操作权限验证 76 酒店预定模块
  9726. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9727. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9728. #endregion
  9729. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9730. #region 页面操作权限验证
  9731. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9732. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9733. #endregion
  9734. #endregion
  9735. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9736. }
  9737. /// <summary>
  9738. /// 酒店预订
  9739. /// 生成VOUCHER
  9740. /// 2024.05.06 之前版本
  9741. /// </summary>
  9742. /// <param name="_dto"></param>
  9743. /// <returns></returns>
  9744. [HttpPost]
  9745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9746. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9747. {
  9748. try
  9749. {
  9750. #region 参数验证
  9751. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9752. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9753. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9754. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9755. #region 团组操作权限验证 76 酒店预定模块
  9756. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9757. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9758. #endregion
  9759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9760. #region 页面操作权限验证
  9761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9762. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9763. #endregion
  9764. #endregion
  9765. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9766. //判断数据是否完整
  9767. if (hr != null)
  9768. {
  9769. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9770. {
  9771. string strFileName = "HotelStatement/";
  9772. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9773. if (dele != null)
  9774. strFileName += dele.TourCode;
  9775. //载入模板
  9776. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9777. Document doc = new Document(sss);
  9778. DocumentBuilder builder = new DocumentBuilder(doc);
  9779. #region 替换Word模板书签内容
  9780. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9781. //入住卷预定号码
  9782. if (doc.Range.Bookmarks["VNO"] != null)
  9783. {
  9784. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9785. mark.Text = hr.CheckNumber;
  9786. }
  9787. //酒店时间
  9788. if (doc.Range.Bookmarks["Date"] != null)
  9789. {
  9790. Bookmark mark = doc.Range.Bookmarks["Date"];
  9791. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9792. }
  9793. //团号
  9794. if (doc.Range.Bookmarks["TNo"] != null)
  9795. {
  9796. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9797. mark.Text = dele.TourCode;
  9798. }
  9799. //预定号码
  9800. if (doc.Range.Bookmarks["BookingId"] != null)
  9801. {
  9802. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9803. mark.Text = hr.ReservationsNo;
  9804. }
  9805. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9806. {
  9807. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9808. mark.Text = hr.DetermineNo;
  9809. }
  9810. //酒店城市
  9811. if (doc.Range.Bookmarks["City"] != null)
  9812. {
  9813. Bookmark mark = doc.Range.Bookmarks["City"];
  9814. mark.Text = hr.City;
  9815. }
  9816. //酒店名称
  9817. if (doc.Range.Bookmarks["HName"] != null)
  9818. {
  9819. Bookmark mark = doc.Range.Bookmarks["HName"];
  9820. mark.Text = hr.HotelName;
  9821. }
  9822. //酒店地址
  9823. if (doc.Range.Bookmarks["Address"] != null)
  9824. {
  9825. Bookmark mark = doc.Range.Bookmarks["Address"];
  9826. mark.Text = hr.HotelAddress;
  9827. }
  9828. //酒店电话
  9829. if (doc.Range.Bookmarks["Tel"] != null)
  9830. {
  9831. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9832. mark.Text = hr.HotelTel;
  9833. }
  9834. //酒店传真
  9835. if (doc.Range.Bookmarks["Fax"] != null)
  9836. {
  9837. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9838. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9839. {
  9840. mark.Text = hr.HotelFax;
  9841. }
  9842. }
  9843. //入住时间
  9844. if (doc.Range.Bookmarks["CIn"] != null)
  9845. {
  9846. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9847. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9848. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9849. }
  9850. //退房时间
  9851. if (doc.Range.Bookmarks["COut"] != null)
  9852. {
  9853. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9854. Bookmark mark = doc.Range.Bookmarks["COut"];
  9855. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9856. }
  9857. //客户名称
  9858. if (doc.Range.Bookmarks["GName"] != null)
  9859. {
  9860. string guestName = "";
  9861. string[] clients = new string[] { };
  9862. if (hr.GuestName.Contains(","))
  9863. {
  9864. clients = hr.GuestName.Split(",");
  9865. }
  9866. else
  9867. {
  9868. clients = new string[] { hr.GuestName };
  9869. }
  9870. List<int> clientIds_int = new List<int>();
  9871. if (clients.Length > 0)
  9872. {
  9873. foreach (var item in clients)
  9874. {
  9875. if (item.IsNumeric())
  9876. {
  9877. clientIds_int.Add(int.Parse(item));
  9878. }
  9879. }
  9880. }
  9881. if (clientIds_int.Count > 0)
  9882. {
  9883. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9884. foreach (var client in _clientDatas)
  9885. {
  9886. //男
  9887. if (client.Sex == 0) guestName += $"Mr.";
  9888. //女
  9889. else if (client.Sex == 1) guestName += $"Ms.";
  9890. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9891. {
  9892. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9893. }
  9894. //guestName += $"{client.Pinyin},";
  9895. }
  9896. if (guestName.Length > 0)
  9897. {
  9898. guestName = guestName.Substring(0, guestName.Length - 1);
  9899. }
  9900. }
  9901. else
  9902. {
  9903. guestName = hr.GuestName;
  9904. }
  9905. Bookmark mark = doc.Range.Bookmarks["GName"];
  9906. mark.Text = guestName;
  9907. }
  9908. //房间介绍
  9909. if (doc.Range.Bookmarks["ROOM"] != null)
  9910. {
  9911. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9912. mark.Text = hr.RoomExplanation;
  9913. }
  9914. //报价描述
  9915. if (doc.Range.Bookmarks["NOTE"] != null)
  9916. {
  9917. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9918. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9919. if (ss != null)
  9920. mark.Text = ss.Name;
  9921. }
  9922. //入住时间
  9923. if (doc.Range.Bookmarks["CheckIn"] != null)
  9924. {
  9925. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9926. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9927. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9928. }
  9929. //退房时间
  9930. if (doc.Range.Bookmarks["CheckOut"] != null)
  9931. {
  9932. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9933. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9934. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9935. }
  9936. //日期
  9937. if (doc.Range.Bookmarks["DT"] != null)
  9938. {
  9939. Bookmark mark = doc.Range.Bookmarks["DT"];
  9940. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9941. }
  9942. //名称
  9943. if (doc.Range.Bookmarks["VName"] != null)
  9944. {
  9945. Bookmark mark = doc.Range.Bookmarks["VName"];
  9946. mark.Text = hr.HotelName;
  9947. }
  9948. //号码
  9949. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9950. {
  9951. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9952. mark.Text = hr.CheckNumber;
  9953. }
  9954. #endregion
  9955. strFileName += "VOUCHER.doc";
  9956. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9957. doc.Save(fileDir);
  9958. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9959. return Ok(JsonView(true, "操作成功!", Url));
  9960. }
  9961. else
  9962. {
  9963. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9964. }
  9965. }
  9966. else
  9967. {
  9968. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9969. }
  9970. }
  9971. catch (Exception ex)
  9972. {
  9973. return Ok(JsonView(false, ex.Message));
  9974. }
  9975. }
  9976. /// <summary>
  9977. /// 酒店预订
  9978. /// 生成VOUCHER
  9979. /// 2024.05.06 之后版本
  9980. /// </summary>
  9981. /// <param name="_dto"></param>
  9982. /// <returns></returns>
  9983. [HttpPost]
  9984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9985. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9986. {
  9987. #region 参数验证
  9988. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9989. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9990. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9991. #region 团组操作权限验证 76 酒店预定模块
  9992. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9993. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9994. #endregion
  9995. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9996. #region 页面操作权限验证
  9997. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9998. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9999. #endregion
  10000. #endregion
  10001. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10002. //判断数据是否完整
  10003. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10004. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10005. string strFileName = "HotelStatement/";
  10006. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10007. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  10008. #region 数据处理
  10009. List<int> guestIds = new List<int>();
  10010. int index = 0;
  10011. foreach (var item in hrDtas)
  10012. {
  10013. if (item.GuestName.Contains(","))
  10014. {
  10015. string[] guestIdArr = item.GuestName.Split(',');
  10016. foreach (var guestIdStr in guestIdArr)
  10017. {
  10018. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  10019. if (guestBool)
  10020. {
  10021. guestIds.Add(guestId);
  10022. }
  10023. }
  10024. }
  10025. else guestNames += item.GuestName;
  10026. var voucherInfo = new HotelVoucherInfoView()
  10027. {
  10028. HotelName = item.HotelName,
  10029. CheckInDate = item.CheckInDate,
  10030. CheckOutDate = item.CheckOutDate,
  10031. ConfirmationNumber = item.DetermineNo.Trim(),
  10032. RoomType = item.RoomExplanation
  10033. };
  10034. vouchers.Add(voucherInfo);
  10035. }
  10036. if (guestIds.Count > 0)
  10037. {
  10038. guestIds = guestIds.Distinct().ToList();
  10039. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  10040. if (guestDatas.Count > 0)
  10041. {
  10042. guestNames = "";
  10043. foreach (var guest in guestDatas)
  10044. {
  10045. string guestName = "";
  10046. if (guest.Sex == 0) guestName += @"MR.";
  10047. else if (guest.Sex == 1) guestName += @"MS.";
  10048. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10049. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10050. guestNames += @$"{guestName.Trim()}、";
  10051. }
  10052. if (guestNames.Length > 0)
  10053. {
  10054. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10055. }
  10056. }
  10057. }
  10058. #endregion
  10059. //载入模板
  10060. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10061. Document doc = new Document(sss);
  10062. DocumentBuilder builder = new DocumentBuilder(doc);
  10063. if (doc.Range.Bookmarks["GuestName"] != null)
  10064. {
  10065. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10066. mark.Text = guestNames;
  10067. }
  10068. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10069. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10070. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10071. for (int i = 1; i <= vouchers.Count; i++)
  10072. {
  10073. HotelVoucherInfoView hviv = vouchers[i - 1];
  10074. builder.MoveToCell(0, i, 0, 0);
  10075. builder.Write(hviv.HotelName);
  10076. builder.MoveToCell(0, i, 1, 0);
  10077. builder.Write(hviv.CheckInDate);
  10078. builder.MoveToCell(0, i, 2, 0);
  10079. builder.Write(hviv.CheckOutDate);
  10080. builder.MoveToCell(0, i, 3, 0);
  10081. builder.Write(hviv.RoomType);
  10082. builder.MoveToCell(0, i, 4, 0);
  10083. builder.Write(hviv.ConfirmationNumber);
  10084. }
  10085. //删除多余行
  10086. int currRowIndex = vouchers.Count + 1;
  10087. int delRows = 21 - currRowIndex;
  10088. if (delRows > 0)
  10089. {
  10090. for (int i = 0; i < delRows; i++)
  10091. {
  10092. table.Rows.RemoveAt(currRowIndex);
  10093. //cultivateRowIndex++;
  10094. }
  10095. }
  10096. strFileName += "VOUCHER.docx";
  10097. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10098. doc.Save(fileDir);
  10099. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10100. return Ok(JsonView(true, "操作成功!", Url));
  10101. }
  10102. /// <summary>
  10103. /// 酒店预订
  10104. /// 生成VOUCHER 批量生成
  10105. /// New
  10106. /// </summary>
  10107. /// <param name="_dto"></param>
  10108. /// <returns></returns>
  10109. [HttpPost]
  10110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10111. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10112. {
  10113. #region 参数验证
  10114. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10115. if (_dto.PageId < 1) _dto.PageId = 28;
  10116. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10117. #region 团组操作权限验证 76 酒店预定模块
  10118. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10119. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10120. #endregion
  10121. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10122. #region 页面操作权限验证
  10123. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10124. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10125. #endregion
  10126. #endregion
  10127. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10128. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10129. .OrderBy(x => x.CheckInDate)
  10130. .ToListAsync();
  10131. //判断数据是否完整
  10132. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10133. string strFileName = "HotelStatement/";
  10134. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10135. if (dele != null)
  10136. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10137. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10138. for (int i = 0; i < hrDtas.Count; i++)
  10139. {
  10140. string guestNames = string.Empty;
  10141. List<int> guestIds = new List<int>();
  10142. var item = hrDtas[i];
  10143. //处理客户姓名
  10144. if (item.GuestName.Contains(","))
  10145. {
  10146. string[] guestIdArr = item.GuestName.Split(',');
  10147. foreach (var guestIdStr in guestIdArr)
  10148. if (int.TryParse(guestIdStr, out int guestId))
  10149. guestIds.Add(guestId);
  10150. }
  10151. else
  10152. {
  10153. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10154. if (guestIdBool)
  10155. {
  10156. guestIds.Add(guestId);
  10157. }
  10158. //NaN
  10159. if (item.GuestName.Contains("NaN"))
  10160. {
  10161. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10162. }
  10163. }
  10164. if (guestIds.Count > 0)
  10165. {
  10166. guestIds = guestIds.Distinct().ToList();
  10167. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10168. if (guestDatas1.Count > 0)
  10169. {
  10170. guestNames = "";
  10171. foreach (var guest in guestDatas1)
  10172. {
  10173. string guestName = "";
  10174. if (guest.Sex == 0) guestName += @"MR.";
  10175. else if (guest.Sex == 1) guestName += @"MS.";
  10176. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10177. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10178. guestNames += @$"{guestName.Trim()}、";
  10179. }
  10180. if (guestNames.Length > 0)
  10181. {
  10182. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10183. }
  10184. }
  10185. }
  10186. //if (!string.IsNullOrEmpty(guestNames))
  10187. //{
  10188. hrDtas[i].GuestName = guestNames;
  10189. //}
  10190. }
  10191. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10192. Document doc = new Document();
  10193. DocumentBuilder builder = new DocumentBuilder(doc);
  10194. try
  10195. {
  10196. builder.MoveToDocumentStart();
  10197. foreach (var item in hrDtas)
  10198. {
  10199. //标题
  10200. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10201. builder.ParagraphFormat.LineSpacing = 1;
  10202. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10203. builder.ParagraphFormat.Style.Font.Size = 9;
  10204. builder.ParagraphFormat.Style.Font.Bold = true;
  10205. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10206. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10207. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10208. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10209. builder.ParagraphFormat.LineSpacing = 1;
  10210. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10211. builder.ParagraphFormat.Style.Font.Size = 9;
  10212. builder.ParagraphFormat.Style.Font.Bold = true;
  10213. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10214. builder.StartTable();
  10215. // 设置边框颜色
  10216. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10217. //设置边框样式
  10218. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10219. //表格
  10220. #region 第一行
  10221. builder.InsertCell();
  10222. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10223. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10224. //builder.CellFormat.AllowAutoFit = false;
  10225. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10226. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10227. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10228. builder.CellFormat.WrapText = true; //自动换行
  10229. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10230. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10231. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10232. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10233. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10234. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10235. builder.Write("TOUR NO:");
  10236. builder.InsertCell();
  10237. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10238. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10239. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10240. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10241. builder.ParagraphFormat.Style.Font.Bold = false;
  10242. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10243. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10244. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10245. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10246. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10247. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10248. builder.Write($"{dele?.TourCode ?? "-"}");
  10249. builder.InsertCell();
  10250. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10251. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10252. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10253. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10254. builder.ParagraphFormat.Style.Font.Bold = false;
  10255. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10256. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10257. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10258. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10259. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10260. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10261. builder.Write($"CITY:");
  10262. builder.InsertCell();
  10263. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10264. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10265. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10266. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10267. builder.ParagraphFormat.Style.Font.Bold = false;
  10268. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10269. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10270. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10271. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10272. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10273. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10274. builder.Write($"{item.City}");
  10275. builder.EndRow();
  10276. #endregion
  10277. #region 第二行
  10278. builder.InsertCell();
  10279. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10280. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10281. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10282. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10283. builder.ParagraphFormat.Style.Font.Bold = false;
  10284. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10285. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10286. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10287. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10288. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10289. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10290. builder.Write("CONFIRMATION NO:");
  10291. builder.InsertCell();
  10292. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10293. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10294. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10295. builder.ParagraphFormat.Style.Font.Bold = false;
  10296. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10297. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10298. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10299. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10300. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10301. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10302. builder.CellFormat.VerticalMerge = CellMerge.None;
  10303. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10304. builder.Write($"{item.DetermineNo}");
  10305. builder.InsertCell();
  10306. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10307. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10308. builder.InsertCell();
  10309. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10310. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10311. builder.EndRow();
  10312. #endregion
  10313. #region 第三行
  10314. builder.InsertCell();
  10315. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10316. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10317. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10318. builder.ParagraphFormat.Style.Font.Bold = false;
  10319. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10320. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10321. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10322. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10323. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10324. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10325. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10326. builder.Write($"HOTEL NAME:");
  10327. builder.InsertCell();
  10328. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10329. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10330. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10331. builder.ParagraphFormat.Style.Font.Bold = false;
  10332. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10333. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10334. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10335. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10336. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10337. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10338. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10339. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10340. builder.Write($"{item.HotelName}");
  10341. builder.InsertCell();
  10342. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10343. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10344. builder.InsertCell();
  10345. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10346. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10347. builder.EndRow();
  10348. #endregion
  10349. #region 第四行
  10350. builder.InsertCell();
  10351. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10352. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10353. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10354. builder.ParagraphFormat.Style.Font.Bold = false;
  10355. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10356. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10357. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10358. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10359. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10360. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10361. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10362. builder.Write($"HOTEL ADDRESS:");
  10363. builder.InsertCell();
  10364. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10365. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10366. builder.ParagraphFormat.Style.Font.Size = 8;
  10367. builder.ParagraphFormat.Style.Font.Bold = false;
  10368. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10369. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10370. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10371. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10372. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10373. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10374. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10375. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10376. builder.Write($"{item.HotelAddress}");
  10377. builder.InsertCell();
  10378. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10379. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10380. builder.InsertCell();
  10381. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10382. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10383. builder.EndRow();
  10384. #endregion
  10385. #region 第五行
  10386. builder.InsertCell();
  10387. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10388. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10389. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10390. builder.ParagraphFormat.Style.Font.Bold = false;
  10391. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10392. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10393. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10394. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10395. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10396. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10397. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10398. builder.Write("TEL:");
  10399. builder.InsertCell();
  10400. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10401. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10402. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10403. builder.ParagraphFormat.Style.Font.Bold = false;
  10404. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10405. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10406. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10407. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10408. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10409. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10410. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10411. builder.Write($"{item.HotelTel}");
  10412. builder.InsertCell();
  10413. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10414. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10415. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10416. builder.ParagraphFormat.Style.Font.Bold = false;
  10417. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10418. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10419. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10420. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10421. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10422. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10423. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10424. builder.Write($"FAX:");
  10425. builder.InsertCell();
  10426. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10427. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10428. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10429. builder.ParagraphFormat.Style.Font.Bold = false;
  10430. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10431. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10432. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10433. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10434. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10435. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10436. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10437. builder.Write($"{item.HotelFax}");
  10438. builder.EndRow();
  10439. #endregion
  10440. #region 第六行
  10441. builder.InsertCell();
  10442. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10443. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10444. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10445. builder.ParagraphFormat.Style.Font.Bold = false;
  10446. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10447. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10448. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10449. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10450. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10451. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10452. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10453. builder.Write("CHECK IN:");
  10454. builder.InsertCell();
  10455. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10456. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10457. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10458. builder.ParagraphFormat.Style.Font.Bold = false;
  10459. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10460. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10461. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10462. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10463. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10464. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10465. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10466. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10467. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10468. builder.Write($"{checkInStr}");
  10469. builder.InsertCell();
  10470. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10471. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10472. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10473. builder.ParagraphFormat.Style.Font.Bold = false;
  10474. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10475. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10476. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10477. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10478. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10479. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10480. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10481. builder.Write($"CHECK OUT:");
  10482. builder.InsertCell();
  10483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10484. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10485. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10486. builder.ParagraphFormat.Style.Font.Bold = false;
  10487. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10490. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10491. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10492. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10493. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10494. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10495. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10496. builder.Write($"{checkOutStr}");
  10497. builder.EndRow();
  10498. #endregion
  10499. #region 第七行
  10500. builder.InsertCell();
  10501. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10502. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10503. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10504. builder.ParagraphFormat.Style.Font.Bold = false;
  10505. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10506. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10508. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10509. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10510. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10511. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10512. builder.Write($"GUEST NAME:");
  10513. builder.InsertCell();
  10514. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10515. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10516. builder.ParagraphFormat.Style.Font.Size = 8;
  10517. builder.ParagraphFormat.Style.Font.Bold = false;
  10518. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10519. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10520. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10521. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10522. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10523. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10524. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10525. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10526. builder.Write($"{item.GuestName}");
  10527. builder.InsertCell();
  10528. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10529. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10530. builder.InsertCell();
  10531. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10532. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10533. builder.EndRow();
  10534. #endregion
  10535. #region 第八行
  10536. builder.InsertCell();
  10537. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10538. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10539. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10540. builder.ParagraphFormat.Style.Font.Bold = false;
  10541. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10542. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10543. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10544. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10545. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10546. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10547. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10548. builder.Write($"ROOM TYPE:");
  10549. builder.InsertCell();
  10550. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10551. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10552. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10553. builder.ParagraphFormat.Style.Font.Bold = false;
  10554. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10555. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10557. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10558. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10559. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10560. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10561. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10562. builder.Write($"{item.RoomExplanation}");
  10563. builder.InsertCell();
  10564. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10565. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10566. builder.InsertCell();
  10567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10568. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10569. builder.EndRow();
  10570. #endregion
  10571. #region 第九行
  10572. builder.InsertCell();
  10573. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10574. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10575. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10576. builder.ParagraphFormat.Style.Font.Bold = false;
  10577. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10578. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10579. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10580. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10581. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10582. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10583. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10584. builder.Write($"NOTE:");
  10585. builder.InsertCell();
  10586. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10587. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10588. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10589. builder.ParagraphFormat.Style.Font.Bold = false;
  10590. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10591. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10592. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10593. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10594. 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.");
  10595. builder.InsertCell();
  10596. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10597. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10598. builder.InsertCell();
  10599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10600. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10601. builder.EndRow();
  10602. #endregion
  10603. builder.EndTable();
  10604. //换行
  10605. builder.Writeln("");
  10606. builder.Writeln("");
  10607. }
  10608. #region 获取文档中的所有表格 设置文字自适应
  10609. // 获取文档中的所有表格。
  10610. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10611. {
  10612. // 遍历表格中的所有行。
  10613. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10614. {
  10615. foreach (Cell cell in row.Cells)
  10616. {
  10617. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10618. cellFormat.Width = 0;
  10619. }
  10620. }
  10621. }
  10622. #endregion
  10623. #region 设置页眉
  10624. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10625. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10626. if (System.IO.File.Exists(voucherHeaderPath))
  10627. {
  10628. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10629. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10630. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10631. Shape shape = builder.InsertImage(imageBytes);
  10632. // 调整图片位置
  10633. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10634. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10635. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10636. shape.Left = 0; // 将图片距离页面左边缘的距离
  10637. shape.Width = 81; // 设置图片宽度
  10638. shape.Height = 36; // 设置图片高度
  10639. }
  10640. //靠右
  10641. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10642. //// 设置页脚上下边距
  10643. //builder.PageSetup.HeaderDistance = 42;
  10644. // 添加页眉线
  10645. Aspose.Words.Border borderHeader = null;
  10646. try
  10647. {
  10648. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10649. }
  10650. catch (Exception e)
  10651. {
  10652. // TODO Auto-generated catch block
  10653. //e.printStackTrace();
  10654. }
  10655. borderHeader.Shadow = true;
  10656. borderHeader.DistanceFromText = 2;
  10657. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10658. #endregion
  10659. }
  10660. catch (Exception ex)
  10661. {
  10662. }
  10663. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10664. doc.Save(fileDir);
  10665. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10666. return Ok(JsonView(true, "操作成功!", Url));
  10667. }
  10668. /// <summary>
  10669. /// 酒店预订
  10670. /// 生成 预定成本 Excel
  10671. /// </summary>
  10672. /// <param name="_dto"></param>
  10673. /// <returns></returns>
  10674. [HttpPost]
  10675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10676. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10677. {
  10678. #region 参数验证
  10679. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10680. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10681. if (!vadalitorRes.IsValid)
  10682. {
  10683. var errors = new StringBuilder();
  10684. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10685. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10686. }
  10687. #region 团组操作权限验证 76 酒店预定模块
  10688. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10689. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10690. #endregion
  10691. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10692. #region 页面操作权限验证
  10693. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10694. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10695. #endregion
  10696. #endregion
  10697. decimal _rate = 1.00M;
  10698. string _currency = string.Empty;
  10699. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10700. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10701. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10702. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10703. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10704. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  10705. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10706. if (_GroupCostParameter == null)
  10707. {
  10708. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10709. bool isIntType = int.TryParse(_currency, out int currId);
  10710. if (isIntType)
  10711. {
  10712. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10713. }
  10714. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10715. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10716. if (currInfo == null)
  10717. {
  10718. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10719. }
  10720. else _rate = currInfo.Rate;
  10721. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  10722. {
  10723. _rate = _GroupCostParameter.Rate;
  10724. }
  10725. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10726. string strFileName = "HotelStatement/";
  10727. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10728. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10729. var rateDatas = new List<dynamic>();
  10730. #region 数据处理
  10731. foreach (var item in hrDtas)
  10732. {
  10733. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10734. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10735. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10736. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10737. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10738. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  10739. {
  10740. continue;
  10741. }
  10742. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10743. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  10744. string singleRoomFeeStr = string.Empty,
  10745. doubleRoomFeeStr = string.Empty,
  10746. suiteRoomFeeStr = string.Empty,
  10747. otherRoomFeeStr = string.Empty,
  10748. payMoneyStr = string.Empty,
  10749. cardPriceStr = string.Empty;
  10750. if (roomCurr.Equals("CNY"))
  10751. {
  10752. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  10753. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10754. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10755. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10756. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10757. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  10758. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  10759. }
  10760. else
  10761. {
  10762. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10763. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10764. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10765. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10766. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10767. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10768. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10769. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10770. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10771. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10772. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  10773. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  10774. if (ccpPaymentCurrency.Equals("CNY"))
  10775. {
  10776. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  10777. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10778. }
  10779. else
  10780. {
  10781. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  10782. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  10783. }
  10784. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  10785. if (hotelcardPriceCurrency.Equals("CNY"))
  10786. {
  10787. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10788. }
  10789. else
  10790. {
  10791. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  10792. }
  10793. }
  10794. string breakfastPriceStr = string.Empty,
  10795. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10796. governmentRentStr = string.Empty,
  10797. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10798. cityTaxStr = string.Empty,
  10799. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10800. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  10801. if (!string.IsNullOrEmpty(breakfastCurrency1))
  10802. {
  10803. if (breakfastCurrency1.Equals("CNY"))
  10804. {
  10805. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10806. }
  10807. else
  10808. {
  10809. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  10810. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  10811. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  10812. }
  10813. }
  10814. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10815. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  10816. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  10817. {
  10818. if (governmentRentCurrency.Equals("CNY"))
  10819. {
  10820. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10821. }
  10822. else
  10823. {
  10824. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  10825. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  10826. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  10827. }
  10828. }
  10829. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10830. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  10831. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  10832. {
  10833. if (cityTaxStrCurrency1.Equals("CNY"))
  10834. {
  10835. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10836. }
  10837. else
  10838. {
  10839. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  10840. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  10841. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  10842. }
  10843. }
  10844. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10845. int payDId = roomInfo?.PayDId ?? 0;
  10846. pcfds.Add(new HotelReservations_PCFD_View()
  10847. {
  10848. City = item.City,
  10849. HotelName = item.HotelName,
  10850. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10851. // SingleRoomCount = item.SingleRoomCount,
  10852. SingleRoomPrice = singleRoomFeeStr,
  10853. // DoubleRoomCount = item.DoubleRoomCount,
  10854. DoubleRoomPrice = doubleRoomFeeStr,
  10855. //SuiteRoomCount = item.SuiteRoomCount,
  10856. SuiteRoomPrice = suiteRoomFeeStr,
  10857. OtherRoomPrice = otherRoomFeeStr,
  10858. //OtherRoomCount = item.OtherRoomCount,
  10859. BreakfastPrice = breakfastPriceStr,
  10860. GovernmentRent = governmentRentStr,
  10861. CityTax = cityTaxStr,
  10862. RoomExplanation = item.RoomExplanation,
  10863. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10864. PayTime = roomInfo?.ConsumptionDate,
  10865. BankNo = roomInfo?.BankNo,
  10866. PayMoney = payMoneyStr,
  10867. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10868. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10869. CardPrice = cardPriceStr,
  10870. Remark = ccpInfo.Remark
  10871. });
  10872. }
  10873. #endregion
  10874. //载入模板
  10875. WorkbookDesigner designer = new WorkbookDesigner();
  10876. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10877. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10878. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10879. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10880. var rateDatas1 = rateDatas.Distinct();
  10881. var rateStr = string.Empty;
  10882. foreach (var item in rateDatas1)
  10883. {
  10884. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  10885. }
  10886. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  10887. designer.SetDataSource("Opertor", userInfo.CnName);
  10888. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10889. dt.TableName = "ViewMyHotelReservations";
  10890. designer.SetDataSource(dt);
  10891. designer.Process();
  10892. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10893. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10894. designer.Workbook.Save(serverPath);
  10895. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10896. #region 删除指定行
  10897. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10898. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10899. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10900. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10901. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10902. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10903. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10904. cssIndex = dt.Columns["CityTax"].Ordinal,
  10905. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10906. remarkIndex = dt.Columns["Remark"].Ordinal;
  10907. //删除指定列
  10908. foreach (DataRow item in dt.Rows)
  10909. {
  10910. string singleStr = item["SingleRoomPrice"].ToString();
  10911. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10912. if (containsDigitButNotZero1) singleDel = false;
  10913. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10914. string doubleStr = item["DoubleRoomPrice"].ToString();
  10915. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10916. if (containsDigitButNotZero2) doubleDel = false;
  10917. string suiteStr = item["SuiteRoomPrice"].ToString();
  10918. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10919. if (containsDigitButNotZero3) suiteDel = false;
  10920. string otherStr = item["OtherRoomPrice"].ToString();
  10921. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10922. if (containsDigitButNotZero4) otherDel = false;
  10923. string zcStr = item["BreakfastPrice"].ToString();
  10924. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10925. if (containsDigitButNotZero5) zcDel = false;
  10926. string dsStr = item["GovernmentRent"].ToString();
  10927. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10928. if (containsDigitButNotZero6) dsDel = false;
  10929. string cssStr = item["CityTax"].ToString();
  10930. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10931. if (containsDigitButNotZero7) cssDel = false;
  10932. string cpStr = item["ConsumptionPatterns"].ToString();
  10933. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10934. string remarkStr = item["Remark"].ToString();
  10935. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10936. }
  10937. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10938. DeleteColumn(serverPath, cpIndex, cpDel);
  10939. DeleteColumn(serverPath, dsIndex, dsDel);
  10940. DeleteColumn(serverPath, cssIndex, cssDel);
  10941. DeleteColumn(serverPath, zcIndex, zcDel);
  10942. DeleteColumn(serverPath, otherIndex, otherDel);
  10943. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10944. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10945. DeleteColumn(serverPath, singleIndex, singleDel);
  10946. #endregion
  10947. //只保留第一个表格
  10948. DeleteSheet(serverPath);
  10949. return Ok(JsonView(true, "操作成功", url = rst));
  10950. }
  10951. else
  10952. {
  10953. _currency = _GroupCostParameter.Currency;
  10954. bool isIntType = int.TryParse(_currency, out int currId);
  10955. if (isIntType)
  10956. {
  10957. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10958. }
  10959. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10960. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10961. if (currInfo == null)
  10962. {
  10963. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10964. }
  10965. if (!_currency.ToUpper().Equals("CNY"))
  10966. {
  10967. _rate = _GroupCostParameter.Rate;
  10968. }
  10969. _rate = currInfo.Rate;
  10970. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10971. string strFileName = "HotelStatement/";
  10972. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10973. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10974. #region 数据处理
  10975. foreach (var item in hrDtas)
  10976. {
  10977. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10978. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10979. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10980. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10981. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10982. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10983. string singleRoomFeeStr = string.Empty,
  10984. doubleRoomFeeStr = string.Empty,
  10985. suiteRoomFeeStr = string.Empty,
  10986. otherRoomFeeStr = string.Empty,
  10987. payMoneyStr = string.Empty,
  10988. cardPriceStr = string.Empty;
  10989. if (roomCurr.Equals(_currency))
  10990. {
  10991. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10992. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10993. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10994. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10995. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10996. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10997. }
  10998. else
  10999. {
  11000. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11001. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11002. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11003. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11004. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  11005. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11006. }
  11007. string breakfastPriceStr = string.Empty,
  11008. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11009. governmentRentStr = string.Empty,
  11010. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11011. cityTaxStrStr = string.Empty,
  11012. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11013. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  11014. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  11015. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  11016. int payDId = roomInfo?.PayDId ?? 0;
  11017. pcfds.Add(new HotelReservations_PCFD_View()
  11018. {
  11019. City = item.City,
  11020. HotelName = item.HotelName,
  11021. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11022. // SingleRoomCount = item.SingleRoomCount,
  11023. SingleRoomPrice = singleRoomFeeStr,
  11024. // DoubleRoomCount = item.DoubleRoomCount,
  11025. DoubleRoomPrice = doubleRoomFeeStr,
  11026. //SuiteRoomCount = item.SuiteRoomCount,
  11027. SuiteRoomPrice = suiteRoomFeeStr,
  11028. OtherRoomPrice = otherRoomFeeStr,
  11029. //OtherRoomCount = item.OtherRoomCount,
  11030. BreakfastPrice = breakfastPriceStr,
  11031. GovernmentRent = governmentRentStr,
  11032. CityTax = cityTaxStrStr,
  11033. RoomExplanation = item.RoomExplanation,
  11034. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11035. PayTime = roomInfo?.ConsumptionDate,
  11036. BankNo = roomInfo?.BankNo,
  11037. PayMoney = payMoneyStr,
  11038. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11039. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11040. CardPrice = cardPriceStr,
  11041. Remark = ccpInfo.Remark
  11042. });
  11043. }
  11044. #endregion
  11045. //载入模板
  11046. WorkbookDesigner designer = new WorkbookDesigner();
  11047. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11048. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11049. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11050. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11051. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  11052. designer.SetDataSource("Opertor", userInfo.CnName);
  11053. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11054. dt.TableName = "ViewMyHotelReservations";
  11055. designer.SetDataSource(dt);
  11056. designer.Process();
  11057. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11058. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11059. designer.Workbook.Save(serverPath);
  11060. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11061. #region 删除指定行
  11062. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11063. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11064. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11065. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11066. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11067. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11068. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11069. cssIndex = dt.Columns["CityTax"].Ordinal,
  11070. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11071. remarkIndex = dt.Columns["Remark"].Ordinal;
  11072. //删除指定列
  11073. foreach (DataRow item in dt.Rows)
  11074. {
  11075. string singleStr = item["SingleRoomPrice"].ToString();
  11076. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11077. if (containsDigitButNotZero1) singleDel = false;
  11078. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11079. string doubleStr = item["DoubleRoomPrice"].ToString();
  11080. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11081. if (containsDigitButNotZero2) doubleDel = false;
  11082. string suiteStr = item["SuiteRoomPrice"].ToString();
  11083. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11084. if (containsDigitButNotZero3) suiteDel = false;
  11085. string otherStr = item["OtherRoomPrice"].ToString();
  11086. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11087. if (containsDigitButNotZero4) otherDel = false;
  11088. string zcStr = item["BreakfastPrice"].ToString();
  11089. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11090. if (containsDigitButNotZero5) zcDel = false;
  11091. string dsStr = item["GovernmentRent"].ToString();
  11092. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11093. if (containsDigitButNotZero6) dsDel = false;
  11094. string cssStr = item["CityTax"].ToString();
  11095. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11096. if (containsDigitButNotZero7) cssDel = false;
  11097. string cpStr = item["ConsumptionPatterns"].ToString();
  11098. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11099. string remarkStr = item["Remark"].ToString();
  11100. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11101. }
  11102. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11103. DeleteColumn(serverPath, cpIndex, cpDel);
  11104. DeleteColumn(serverPath, dsIndex, dsDel);
  11105. DeleteColumn(serverPath, cssIndex, cssDel);
  11106. DeleteColumn(serverPath, zcIndex, zcDel);
  11107. DeleteColumn(serverPath, otherIndex, otherDel);
  11108. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11109. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11110. DeleteColumn(serverPath, singleIndex, singleDel);
  11111. #endregion
  11112. //只保留第一个表格
  11113. DeleteSheet(serverPath);
  11114. return Ok(JsonView(true, "操作成功", url = rst));
  11115. }
  11116. return Ok(JsonView(false));
  11117. }
  11118. /// <summary>
  11119. /// 删除指定列
  11120. /// </summary>
  11121. /// <param name="file"></param>
  11122. /// <param name="columnIndex"></param>
  11123. /// <param name="isDel"></param>
  11124. private void DeleteColumn(string file, int columnIndex, bool isDel)
  11125. {
  11126. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11127. //wb.Save(file);
  11128. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  11129. if (sheet1 != null)
  11130. {
  11131. if (isDel)
  11132. {
  11133. Cells cells = sheet1.Cells;
  11134. cells.DeleteColumn(columnIndex);
  11135. }
  11136. }
  11137. wb.Save(file);
  11138. }
  11139. /// <summary>
  11140. /// 删除sheet
  11141. /// </summary>
  11142. /// <param name="file"></param>
  11143. /// <param name="sheetName"></param>
  11144. private void DeleteSheet(string file, string sheetName = "")
  11145. {
  11146. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11147. //wb.Save(file);
  11148. List<string> sheets = new List<string>();
  11149. foreach (var item in wb.Worksheets)
  11150. {
  11151. sheets.Add(item.Name);
  11152. }
  11153. if (sheets.Count > 0)
  11154. {
  11155. sheets.RemoveAt(0);//不删除第一个sheet
  11156. foreach (var item in sheets)
  11157. {
  11158. wb.Worksheets.RemoveAt(item);
  11159. }
  11160. }
  11161. wb.Save(file);
  11162. }
  11163. /// <summary>
  11164. /// 酒店预订
  11165. /// 确认单
  11166. /// </summary>
  11167. /// <param name="_dto"></param>
  11168. /// <returns></returns>
  11169. [HttpPost]
  11170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11171. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  11172. {
  11173. try
  11174. {
  11175. #region 参数验证
  11176. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11177. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11178. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11179. #region 团组操作权限验证 76 酒店预定模块
  11180. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11181. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11182. #endregion
  11183. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11184. #region 页面操作权限验证
  11185. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11186. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11187. #endregion
  11188. #endregion
  11189. //团组信息
  11190. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  11191. //酒店数据
  11192. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  11193. if (listhoteldata.Count < 0)
  11194. {
  11195. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  11196. }
  11197. //利datatable存储
  11198. DataTable dt = new DataTable();
  11199. dt.Columns.Add("CheckInDate", typeof(string));
  11200. dt.Columns.Add("City", typeof(string));
  11201. dt.Columns.Add("Hotel", typeof(string));
  11202. dt.Columns.Add("Room", typeof(string));
  11203. for (int i = 0; i < listhoteldata.Count; i++)
  11204. {
  11205. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  11206. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  11207. while (dayStart < dayEnd)
  11208. {
  11209. string temp = "";
  11210. DataRow row = dt.NewRow();
  11211. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  11212. row["City"] = listhoteldata[i].City;
  11213. row["Hotel"] = listhoteldata[i].HotelName;
  11214. if (listhoteldata[i].SingleRoomCount > 0)
  11215. {
  11216. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  11217. }
  11218. if (listhoteldata[i].DoubleRoomCount > 0)
  11219. {
  11220. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  11221. }
  11222. if (listhoteldata[i].SuiteRoomCount > 0)
  11223. {
  11224. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  11225. }
  11226. if (listhoteldata[i].OtherRoomCount > 0)
  11227. {
  11228. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  11229. }
  11230. row["Room"] = temp;
  11231. dt.Rows.Add(row);
  11232. dayStart = dayStart.AddDays(1);
  11233. }
  11234. }
  11235. Dictionary<string, string> dic = new Dictionary<string, string>();
  11236. dic.Add("Dele", di.TeamName);
  11237. dic.Add("City", di.VisitCountry);
  11238. //模板路径
  11239. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  11240. //载入模板
  11241. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  11242. DocumentBuilder builder = new DocumentBuilder(doc);
  11243. foreach (var key in dic.Keys)
  11244. {
  11245. builder.MoveToBookmark(key);
  11246. builder.Write(dic[key]);
  11247. }
  11248. //获取word里所有表格
  11249. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11250. //获取所填表格的序数
  11251. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11252. var rowStart = tableOne.Rows[0]; //获取第1行
  11253. //循环赋值
  11254. for (int i = 0; i < dt.Rows.Count; i++)
  11255. {
  11256. builder.MoveToCell(0, i + 1, 0, 0);
  11257. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  11258. builder.MoveToCell(0, i + 1, 1, 0);
  11259. builder.Write(dt.Rows[i]["City"].ToString());
  11260. builder.MoveToCell(0, i + 1, 2, 0);
  11261. builder.Write(dt.Rows[i]["Hotel"].ToString());
  11262. builder.MoveToCell(0, i + 1, 3, 0);
  11263. builder.Write(dt.Rows[i]["Room"].ToString());
  11264. }
  11265. //删除多余行
  11266. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  11267. {
  11268. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  11269. }
  11270. string strFileName = di.TeamName + "酒店确认单.doc";
  11271. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  11272. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  11273. return Ok(JsonView(true, "成功", url));
  11274. }
  11275. catch (Exception ex)
  11276. {
  11277. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  11278. }
  11279. }
  11280. #endregion
  11281. #region 团组状态
  11282. /// <summary>
  11283. /// 团组状态列表 Page
  11284. /// </summary>
  11285. /// <param name="dto">团组列表请求dto</param>
  11286. /// <returns></returns>
  11287. [HttpPost]
  11288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11289. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11290. {
  11291. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11292. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11293. {
  11294. string sqlWhere = string.Empty;
  11295. if (dto.IsSure == 0) //未完成
  11296. {
  11297. sqlWhere += string.Format(@" And IsSure = 0");
  11298. }
  11299. else if (dto.IsSure == 1) //已完成
  11300. {
  11301. sqlWhere += string.Format(@" And IsSure = 1");
  11302. }
  11303. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11304. {
  11305. string tj = dto.SearchCriteria;
  11306. 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}%')",
  11307. tj, tj, tj, tj, tj);
  11308. }
  11309. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11310. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11311. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11312. From (
  11313. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11314. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11315. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11316. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11317. From Grp_DelegationInfo gdi
  11318. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11319. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11320. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11321. Where gdi.IsDel = 0 {0}
  11322. ) temp ", sqlWhere);
  11323. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11324. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11325. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11326. }
  11327. else
  11328. {
  11329. return Ok(JsonView(false, "查询失败"));
  11330. }
  11331. }
  11332. /// <summary>
  11333. /// 团组状态
  11334. /// 设置操作完成
  11335. /// </summary>
  11336. /// <param name="dto">团组列表请求dto</param>
  11337. /// <returns></returns>
  11338. [HttpPost]
  11339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11340. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11341. {
  11342. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11343. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11344. {
  11345. Id = dto.Id,
  11346. IsSure = 1
  11347. };
  11348. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11349. .UpdateColumns(it => new { it.IsSure })
  11350. .WhereColumns(it => new { it.Id })
  11351. .ExecuteCommandAsync();
  11352. if (result > 0)
  11353. {
  11354. return Ok(JsonView(true, "操作完成!"));
  11355. }
  11356. return Ok(JsonView(false, "操作失败!"));
  11357. }
  11358. #endregion
  11359. #region 保险费用录入
  11360. /// <summary>
  11361. /// 根据团组Id查询保险费用列表
  11362. /// </summary>
  11363. /// <param name="dto"></param>
  11364. /// <returns></returns>
  11365. [HttpPost]
  11366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11367. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11368. {
  11369. Result groupData = await _customersRep.CustomersByDiId(dto);
  11370. if (groupData.Code != 0)
  11371. {
  11372. return Ok(JsonView(false, groupData.Msg));
  11373. }
  11374. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11375. }
  11376. /// <summary>
  11377. /// 根据保险费用Id查询保险费用详细
  11378. /// </summary>
  11379. /// <param name="dto"></param>
  11380. /// <returns></returns>
  11381. [HttpPost]
  11382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11383. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11384. {
  11385. try
  11386. {
  11387. Result groupData = await _customersRep.CustomersById(dto);
  11388. if (groupData.Code != 0)
  11389. {
  11390. return Ok(JsonView(false, groupData.Msg));
  11391. }
  11392. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11393. }
  11394. catch (Exception ex)
  11395. {
  11396. return Ok(JsonView(false, ex.Message));
  11397. }
  11398. }
  11399. /// <summary>
  11400. /// 保险费用录入页面初始化绑定
  11401. /// </summary>
  11402. /// <param name="dto"></param>
  11403. /// <returns></returns>
  11404. [HttpPost]
  11405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11406. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11407. {
  11408. try
  11409. {
  11410. Result groupData = await _customersRep.CustomersInitialize(dto);
  11411. if (groupData.Code != 0)
  11412. {
  11413. return Ok(JsonView(false, groupData.Msg));
  11414. }
  11415. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11416. }
  11417. catch (Exception ex)
  11418. {
  11419. return Ok(JsonView(false, ex.Message));
  11420. }
  11421. }
  11422. /// <summary>
  11423. /// 保险费用操作(Status:1.新增,2.修改)
  11424. /// </summary>
  11425. /// <param name="dto"></param>
  11426. /// <returns></returns>
  11427. [HttpPost]
  11428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11429. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11430. {
  11431. Result groupData = await _customersRep.OpCustomers(dto);
  11432. if (groupData.Code != 0)
  11433. {
  11434. return Ok(JsonView(false, groupData.Msg));
  11435. }
  11436. #region 应用推送
  11437. try
  11438. {
  11439. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11440. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11441. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11442. //2024-10-21 新增LZ UID
  11443. var userIds = new List<int>() { 21 };
  11444. string title = $"系统通知";
  11445. var diId = dto.DiId;
  11446. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11447. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11448. string content = "";
  11449. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11450. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11451. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11452. await GeneralMethod.iOS_PushNotifications("051", $"保险费用审核", "", content);
  11453. }
  11454. catch (Exception ex)
  11455. {
  11456. }
  11457. #endregion
  11458. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11459. }
  11460. /// <summary>
  11461. /// 保险文件上传
  11462. /// </summary>
  11463. /// <param name="file"></param>
  11464. /// <returns></returns>
  11465. [HttpPost]
  11466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11467. public async Task<IActionResult> UploadCus(IFormFile file)
  11468. {
  11469. try
  11470. {
  11471. if (file != null)
  11472. {
  11473. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11474. //文件名称
  11475. string projectFileName = file.FileName;
  11476. //上传的文件的路径
  11477. string filePath = "";
  11478. if (!Directory.Exists(fileDir))
  11479. {
  11480. Directory.CreateDirectory(fileDir);
  11481. }
  11482. //上传的文件的路径
  11483. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11484. using (FileStream fs = System.IO.File.Create(filePath))
  11485. {
  11486. file.CopyTo(fs);
  11487. fs.Flush();
  11488. }
  11489. return Ok(JsonView(true, "上传成功!", projectFileName));
  11490. }
  11491. else
  11492. {
  11493. return Ok(JsonView(false, "上传失败!"));
  11494. }
  11495. }
  11496. catch (Exception ex)
  11497. {
  11498. return Ok(JsonView(false, "程序错误!"));
  11499. throw;
  11500. }
  11501. }
  11502. /// <summary>
  11503. /// 保险删除指定文件
  11504. /// </summary>
  11505. /// <param name="dto"></param>
  11506. /// <returns></returns>
  11507. [HttpPost]
  11508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11509. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11510. {
  11511. try
  11512. {
  11513. string filePath = "";
  11514. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11515. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11516. //int id = 0;
  11517. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11518. // 删除该文件
  11519. try
  11520. {
  11521. System.IO.File.Delete(filePath);
  11522. 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()
  11523. {
  11524. Attachment = "",
  11525. }).ExecuteCommandAsync();
  11526. if (result != 0)
  11527. {
  11528. return Ok(JsonView(true, "成功!"));
  11529. }
  11530. else
  11531. {
  11532. return Ok(JsonView(false, "失败!"));
  11533. }
  11534. }
  11535. catch (Exception)
  11536. {
  11537. 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()
  11538. {
  11539. Attachment = "",
  11540. }).ExecuteCommandAsync();
  11541. if (result != 0)
  11542. {
  11543. return Ok(JsonView(true, "成功!"));
  11544. }
  11545. else
  11546. {
  11547. return Ok(JsonView(false, "失败!"));
  11548. }
  11549. }
  11550. }
  11551. catch (Exception ex)
  11552. {
  11553. return Ok(JsonView(false, "程序错误!"));
  11554. throw;
  11555. }
  11556. }
  11557. /// <summary>
  11558. /// 保险费用操作(删除)
  11559. /// </summary>
  11560. /// <param name="dto"></param>
  11561. /// <returns></returns>
  11562. [HttpPost]
  11563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11564. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11565. {
  11566. try
  11567. {
  11568. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11569. if (!res)
  11570. {
  11571. return Ok(JsonView(false, "删除失败"));
  11572. }
  11573. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11574. {
  11575. IsDel = 1,
  11576. DeleteUserId = dto.DeleteUserId,
  11577. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11578. }).ExecuteCommandAsync();
  11579. return Ok(JsonView(true, "删除成功!"));
  11580. }
  11581. catch (Exception ex)
  11582. {
  11583. return Ok(JsonView(false, "程序错误!"));
  11584. throw;
  11585. }
  11586. }
  11587. #endregion
  11588. #region 接团客户名单 PageId 104
  11589. /// <summary>
  11590. /// 接团客户名单
  11591. /// 迁移数据(慎用!)
  11592. /// </summary>
  11593. /// <param name="dto"></param>
  11594. /// <returns></returns>
  11595. [HttpPost]
  11596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11597. public async Task<IActionResult> PostTourClientListChange()
  11598. {
  11599. try
  11600. {
  11601. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11602. //var groupClinetData1
  11603. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11604. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11605. int updateCount = 0;
  11606. if (oldOAClientList.Count > 0)
  11607. {
  11608. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11609. _sqlSugar.BeginTran();
  11610. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11611. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11612. foreach (var item in oldOAClientList)
  11613. {
  11614. int comId = 0;
  11615. string format = "yyyy-MM-dd HH:mm:ss";
  11616. string data11 = "1990-01-01 00:00";
  11617. var data1 = IsValidDate(item.OPdate, format);
  11618. if (data1) data11 = item.OPdate;
  11619. //客户公司验证
  11620. if (!string.IsNullOrEmpty(item.Company))
  11621. {
  11622. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11623. if (clientComInfo == null) // add
  11624. {
  11625. var addInfo = new Crm_CustomerCompany()
  11626. {
  11627. CompanyAbbreviation = "",
  11628. CompanyFullName = item.Company,
  11629. Address = "",
  11630. PostCodes = "",
  11631. LastedOpUserId = item.OPer,
  11632. LastedOpDt = Convert.ToDateTime(data11),
  11633. CreateUserId = item.OPer,
  11634. CreateTime = Convert.ToDateTime(data11),
  11635. IsDel = 0
  11636. };
  11637. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11638. if (comId1 > 0) comId = comId1;
  11639. }
  11640. else comId = clientComInfo.Id;
  11641. }
  11642. //客户人员验证
  11643. int clientId = 0;
  11644. string name = item.LastName + item.Name;
  11645. if (!string.IsNullOrEmpty(name))
  11646. {
  11647. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11648. if (clientInfo == null)
  11649. {
  11650. DateTime? dateTime = null;
  11651. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11652. if (isDt) dateTime = birthDayDt;
  11653. var addInfo1 = new Crm_DeleClient()
  11654. {
  11655. CrmCompanyId = comId,
  11656. DiId = -1,
  11657. LastName = item.LastName,
  11658. FirstName = item.Name,
  11659. OldName = "",
  11660. Pinyin = item.Pinyin,
  11661. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11662. Marriage = 0,
  11663. Phone = item.Phone,
  11664. Job = item.Job,
  11665. BirthDay = dateTime
  11666. };
  11667. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11668. if (clientId1 > 0) clientId = clientId1;
  11669. }
  11670. else clientId = clientInfo.Id;
  11671. }
  11672. if (clientId < 1)
  11673. {
  11674. continue;
  11675. }
  11676. int airType = 0;
  11677. if (item.AirType == "超经舱") airType = 459;
  11678. else if (item.AirType == "公务舱") airType = 458;
  11679. else if (item.AirType == "经济舱") airType = 460;
  11680. else if (item.AirType == "其他") airType = 565;
  11681. else if (item.AirType == "头等舱") airType = 457;
  11682. var _TourClientListEntity = new Grp_TourClientList()
  11683. {
  11684. DiId = item.Diid,
  11685. ClientId = clientId,
  11686. CreateUserId = item.OPer,
  11687. CreateTime = Convert.ToDateTime(data11),
  11688. Remark = item.Remark,
  11689. IsDel = item.Isdel,
  11690. ShippingSpaceTypeId = airType,
  11691. ShippingSpaceSpecialNeeds = item.AirRemark,
  11692. HotelSpecialNeeds = item.RoomType
  11693. };
  11694. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11695. if (_TourClientList > 0)
  11696. {
  11697. updateCount++;
  11698. }
  11699. }
  11700. _sqlSugar.CommitTran();
  11701. }
  11702. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11703. }
  11704. catch (Exception ex)
  11705. {
  11706. _sqlSugar.RollbackTran();
  11707. return Ok(JsonView(false, ex.Message));
  11708. }
  11709. return Ok(JsonView(true));
  11710. }
  11711. private bool IsValidDate(string dateString, string format)
  11712. {
  11713. DateTime dateValue;
  11714. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11715. return valid;
  11716. }
  11717. /// <summary>
  11718. /// 接团客户名单
  11719. /// 根据团组Id查询List
  11720. /// </summary>
  11721. /// <param name="dto"></param>
  11722. /// <returns></returns>
  11723. [HttpPost]
  11724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11725. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11726. {
  11727. #region 参数验证
  11728. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11729. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11730. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11731. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11732. #region 页面操作权限验证
  11733. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11734. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11735. #endregion
  11736. #endregion
  11737. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11738. if (viewData.Code != 0)
  11739. {
  11740. return Ok(JsonView(false, viewData.Msg));
  11741. }
  11742. return Ok(JsonView(viewData.Data));
  11743. }
  11744. /// <summary>
  11745. /// 接团客户名单
  11746. /// 基础数据 Init
  11747. /// </summary>
  11748. /// <param name="_dto"></param>
  11749. /// <returns></returns>
  11750. [HttpPost]
  11751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11752. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11753. {
  11754. #region 参数验证
  11755. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11756. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11757. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11758. #region 页面操作权限验证
  11759. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11760. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11761. #endregion
  11762. #endregion
  11763. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11764. }
  11765. /// <summary>
  11766. /// 接团客户名单
  11767. /// 根据 Id查询 Details
  11768. /// </summary>
  11769. /// <param name="_dto"></param>
  11770. /// <returns></returns>
  11771. [HttpPost]
  11772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11773. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11774. {
  11775. #region 参数验证
  11776. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11777. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11778. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11779. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11780. #region 页面操作权限验证
  11781. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11782. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11783. #endregion
  11784. #endregion
  11785. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11786. if (viewData.Code != 0)
  11787. {
  11788. return Ok(JsonView(false, viewData.Msg));
  11789. }
  11790. return Ok(JsonView(viewData.Data));
  11791. }
  11792. /// <summary>
  11793. /// 接团客户名单
  11794. /// Add Or Edit
  11795. /// </summary>
  11796. /// <param name="_dto"></param>
  11797. /// <returns></returns>
  11798. [HttpPost]
  11799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11800. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11801. {
  11802. #region 参数验证
  11803. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11804. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11805. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11806. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11807. #region 页面操作权限验证
  11808. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11809. if (_dto.Id == 0) //添加
  11810. {
  11811. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11812. }
  11813. else if (_dto.Id >= 0) //修改
  11814. {
  11815. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11816. }
  11817. #endregion
  11818. #endregion
  11819. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11820. if (viewData.Code != 0)
  11821. {
  11822. return Ok(JsonView(false, viewData.Msg));
  11823. }
  11824. return Ok(JsonView(true));
  11825. }
  11826. /// <summary>
  11827. /// 接团客户名单
  11828. /// AddMultiple(添加多个)
  11829. /// </summary>
  11830. /// <param name="_dto"></param>
  11831. /// <returns></returns>
  11832. [HttpPost]
  11833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11834. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11835. {
  11836. #region 参数验证
  11837. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11838. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11839. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11840. #region 页面操作权限验证
  11841. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11842. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11843. #endregion
  11844. #endregion
  11845. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11846. if (viewData.Code != 0)
  11847. {
  11848. return Ok(JsonView(false, viewData.Msg));
  11849. }
  11850. return Ok(JsonView(true));
  11851. }
  11852. /// <summary>
  11853. /// 接团客户名单
  11854. /// Del
  11855. /// </summary>
  11856. /// <param name="_dto"></param>
  11857. /// <returns></returns>
  11858. [HttpPost]
  11859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11860. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11861. {
  11862. #region 参数验证
  11863. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11864. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11865. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11866. #region 页面操作权限验证
  11867. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11868. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11869. #endregion
  11870. #endregion
  11871. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11872. if (viewData.Code != 0)
  11873. {
  11874. return Ok(JsonView(false, viewData.Msg));
  11875. }
  11876. return Ok(JsonView(true));
  11877. }
  11878. /// <summary>
  11879. /// 接团客户名单
  11880. /// 文件下载 客户名单
  11881. /// </summary>
  11882. /// <param name="_dto"></param>
  11883. /// <returns></returns>
  11884. [HttpPost]
  11885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11886. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11887. {
  11888. #region 参数验证
  11889. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11890. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11891. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11892. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11893. #region 页面操作权限验证
  11894. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11895. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11896. #endregion
  11897. #endregion
  11898. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11899. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11900. From Grp_TourClientList tcl
  11901. Left Join
  11902. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11903. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11904. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11905. From Crm_DeleClient dc
  11906. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11907. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11908. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11909. Where dc.IsDel = 0) temp
  11910. On temp.DcId =tcl.ClientId
  11911. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11912. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11913. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11914. //载入模板
  11915. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11916. if (_dto.Language == 1)
  11917. {
  11918. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11919. }
  11920. //载入模板
  11921. var doc = new Document(tempPath);
  11922. DocumentBuilder builder = new DocumentBuilder(doc);
  11923. //获取word里所有表格
  11924. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11925. //获取所填表格的序数
  11926. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11927. var rowStart = tableOne.Rows[0]; //获取第1行
  11928. if (_dto.Language == 0)
  11929. {
  11930. //循环赋值
  11931. for (int i = 0; i < DcList.Count; i++)
  11932. {
  11933. builder.MoveToCell(0, i + 1, 0, 0);
  11934. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11935. builder.MoveToCell(0, i + 1, 1, 0);
  11936. int sex = DcList[i].Sex;
  11937. string sexStr = string.Empty;
  11938. if (sex == 0) sexStr = "男";
  11939. else if (sex == 1) sexStr = "女";
  11940. else sexStr = "未设置";
  11941. builder.Write(sexStr);
  11942. builder.MoveToCell(0, i + 1, 2, 0);
  11943. string birthDay = DcList[i].BirthDay;
  11944. string birthDayStr = string.Empty;
  11945. if (!string.IsNullOrEmpty(birthDay))
  11946. {
  11947. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11948. }
  11949. builder.Write(birthDayStr);
  11950. builder.MoveToCell(0, i + 1, 3, 0);
  11951. string company = "";
  11952. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11953. {
  11954. company = DcList[i].CompanyFullName.ToString();
  11955. }
  11956. builder.Write(company);
  11957. builder.MoveToCell(0, i + 1, 4, 0);
  11958. builder.Write(DcList[i].Job);
  11959. }
  11960. }
  11961. else if (_dto.Language == 1)
  11962. {
  11963. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11964. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11965. List<string> transArrayStr = new List<string>();
  11966. string transStrRes1 = "";
  11967. for (int i = 0; i < DcList.Count; i++)
  11968. {
  11969. var dc = DcList[i];
  11970. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11971. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11972. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11973. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11974. else transStrRes1 += $"{str1}|";
  11975. }
  11976. //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";
  11977. string transStrRes = "";
  11978. if (transStrRes1.Length > 0)
  11979. {
  11980. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11981. }
  11982. //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
  11983. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11984. //List<string> transArray = new List<string> { };
  11985. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11986. if (transStrRes.Contains("|"))
  11987. {
  11988. string[] transArray1 = transStrRes.Split('|');
  11989. if (transArray1.Length > 0)
  11990. {
  11991. foreach (var item in transArray1)
  11992. {
  11993. if (item.Contains("&"))
  11994. {
  11995. string[] transArray2 = item.Split('&');
  11996. int index = 0;
  11997. string companyName = "", job = "";
  11998. if (transArray2.Length > 0)
  11999. {
  12000. bool success = int.TryParse(transArray2[0].Trim(), out index);
  12001. if (1 < transArray2.Length) companyName = transArray2[1];
  12002. if (2 < transArray2.Length) job = transArray2[2];
  12003. }
  12004. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  12005. }
  12006. }
  12007. }
  12008. }
  12009. //循环赋值
  12010. for (int i = 0; i < DcList.Count; i++)
  12011. {
  12012. string PYName = "";
  12013. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  12014. {
  12015. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  12016. string PY_First = DcList[i].Pinyin.Split('/')[1];
  12017. PYName = PY_First + " " + PY_Last;
  12018. }
  12019. else
  12020. {
  12021. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  12022. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  12023. PYName = PY_First + " " + PY_Last;
  12024. }
  12025. builder.MoveToCell(0, i + 1, 0, 0);
  12026. builder.Write(PYName);
  12027. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  12028. builder.MoveToCell(0, i + 1, 1, 0);
  12029. builder.Write(sex);
  12030. DateTime birthDt;
  12031. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  12032. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  12033. builder.MoveToCell(0, i + 1, 2, 0);
  12034. builder.Write(birthday);
  12035. string company = string.Empty, job = string.Empty;
  12036. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  12037. if (dcTransInfo != null)
  12038. {
  12039. company = dcTransInfo.CompanyName;
  12040. job = dcTransInfo.Job;
  12041. }
  12042. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12043. {
  12044. //查询对照表
  12045. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  12046. if (tempCec != null)
  12047. {
  12048. company = tempCec.enName;
  12049. }
  12050. //翻译
  12051. else
  12052. {
  12053. }
  12054. }
  12055. builder.MoveToCell(0, i + 1, 3, 0);
  12056. builder.Write(company);
  12057. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  12058. {
  12059. //查询对照表
  12060. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  12061. if (tempPec != null)
  12062. {
  12063. job = tempPec.enName;
  12064. }
  12065. //翻译
  12066. else
  12067. {
  12068. }
  12069. }
  12070. builder.MoveToCell(0, i + 1, 4, 0);
  12071. builder.Write(job);
  12072. }
  12073. }
  12074. //删除多余行
  12075. while (tableOne.Rows.Count > DcList.Count + 1)
  12076. {
  12077. tableOne.Rows.RemoveAt(DcList.Count + 1);
  12078. }
  12079. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  12080. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  12081. doc.Save(fileDir);
  12082. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  12083. return Ok(JsonView(true, "操作成功!", Url));
  12084. }
  12085. private class TranslateInfo
  12086. {
  12087. public int Index { get; set; }
  12088. public string CompanyName { get; set; }
  12089. public string Job { get; set; }
  12090. }
  12091. #endregion
  12092. #region 团组倒推表
  12093. /// <summary>
  12094. /// 倒推表基础数据
  12095. /// Init
  12096. /// </summary>
  12097. /// <param name="dto"></param>
  12098. /// <returns></returns>
  12099. [HttpPost]
  12100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12101. public async Task<IActionResult> PostInvertedListInit()
  12102. {
  12103. var viewData = await _invertedListRep._Init();
  12104. if (viewData.Code != 0)
  12105. {
  12106. return Ok(JsonView(false, viewData.Msg));
  12107. }
  12108. return Ok(JsonView(viewData.Data));
  12109. }
  12110. /// <summary>
  12111. /// 倒推表
  12112. /// Info
  12113. /// </summary>
  12114. /// <param name="dto"></param>
  12115. /// <returns></returns>
  12116. [HttpPost]
  12117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12118. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  12119. {
  12120. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  12121. if (viewData.Code != 0)
  12122. {
  12123. return Ok(JsonView(false, viewData.Msg));
  12124. }
  12125. return Ok(JsonView(viewData.Data));
  12126. }
  12127. /// <summary>
  12128. /// 倒推表
  12129. /// Create
  12130. /// </summary>
  12131. /// <param name="dto"></param>
  12132. /// <returns></returns>
  12133. [HttpPost]
  12134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12135. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  12136. {
  12137. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  12138. if (viewData.Code != 0)
  12139. {
  12140. return Ok(JsonView(false, viewData.Msg));
  12141. }
  12142. return Ok(JsonView(viewData.Data));
  12143. }
  12144. /// <summary>
  12145. /// 倒推表
  12146. /// Update
  12147. /// </summary>
  12148. /// <param name="dto"></param>
  12149. /// <returns></returns>
  12150. [HttpPost]
  12151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12152. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  12153. {
  12154. var viewData = await _invertedListRep._Update(dto);
  12155. if (viewData.Code != 0)
  12156. {
  12157. return Ok(JsonView(false, viewData.Msg));
  12158. }
  12159. return Ok(JsonView(viewData.Data));
  12160. }
  12161. /// <summary>
  12162. /// 倒推表
  12163. /// File Download
  12164. /// </summary>
  12165. /// <param name="dto"></param>
  12166. /// <returns></returns>
  12167. [HttpPost]
  12168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12169. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  12170. {
  12171. var info2 = await _invertedListRep._Info(1, dto.DiId);
  12172. if (info2.Code != 0)
  12173. {
  12174. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  12175. }
  12176. var info1 = info2.Data as InvertedListInfoView;
  12177. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  12178. string teamName = "";
  12179. if (info != null) teamName = info.TeamName;
  12180. //载入模板
  12181. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  12182. DocumentBuilder builder = new DocumentBuilder(doc);
  12183. //利用键值对存放数据
  12184. Dictionary<string, string> dic = new Dictionary<string, string>();
  12185. dic.Add("TeamName", teamName);
  12186. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  12187. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  12188. dic.Add("BPRemark", info1.ApprovalDataRemark);
  12189. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  12190. dic.Add("SQRemark", info1.ApprovalRemark);
  12191. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  12192. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  12193. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  12194. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  12195. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  12196. dic.Add("QZRemark", info1.VisaInformationRemark);
  12197. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  12198. dic.Add("SQQZRemark", info1.SendVisaRemark);
  12199. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  12200. dic.Add("CQRemark", info1.IssueVisaRemark);
  12201. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  12202. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  12203. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  12204. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  12205. #region 填充word模板书签内容
  12206. foreach (var key in dic.Keys)
  12207. {
  12208. builder.MoveToBookmark(key);
  12209. builder.Write(dic[key]);
  12210. }
  12211. #endregion
  12212. var fileDir = AppSettingsHelper.Get("WordBasePath");
  12213. string fileName = $"{teamName}团出行准备流程表.doc";
  12214. string filePath = fileDir + $@"InvertedList/{fileName}";
  12215. doc.Save(filePath);
  12216. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  12217. return Ok(JsonView(true, "操作成功!", Url));
  12218. }
  12219. #endregion
  12220. #region 三公签证费用(签证费、代办费)
  12221. /// <summary>
  12222. /// 三公签证费用(签证费、代办费)
  12223. /// List
  12224. /// </summary>
  12225. /// <returns></returns>
  12226. [HttpPost]
  12227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12228. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  12229. {
  12230. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  12231. if (_view.Code != 0)
  12232. {
  12233. return Ok(JsonView(false, _view.Msg));
  12234. }
  12235. return Ok(JsonView(true, "操作成功!", _view.Data));
  12236. }
  12237. /// <summary>
  12238. /// 三公签证费用(签证费、代办费)
  12239. /// Add Or Update
  12240. /// </summary>
  12241. /// <returns></returns>
  12242. [HttpPost]
  12243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12244. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  12245. {
  12246. var _view = await _visaFeeInfoRep._Update(_dto);
  12247. if (_view.Code != 0)
  12248. {
  12249. return Ok(JsonView(false, _view.Msg));
  12250. }
  12251. return Ok(JsonView(true, _view.Msg));
  12252. }
  12253. #endregion
  12254. #region 酒店询价
  12255. /// <summary>
  12256. /// 酒店询价
  12257. /// Init
  12258. /// </summary>
  12259. /// <param name="dto"></param>
  12260. /// <returns></returns>
  12261. [HttpPost]
  12262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12263. public async Task<IActionResult> PostHotelInquiryInit()
  12264. {
  12265. var res = await _hotelInquiryRep._Init();
  12266. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12267. return Ok(JsonView(true, res.Msg, res.Data));
  12268. }
  12269. /// <summary>
  12270. /// 酒店询价
  12271. /// page Item
  12272. /// </summary>
  12273. /// <param name="_dto"></param>
  12274. /// <returns></returns>
  12275. [HttpPost]
  12276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12277. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  12278. {
  12279. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  12280. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12281. var view = res.Data as PageDataViewBase;
  12282. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  12283. }
  12284. /// <summary>
  12285. /// 酒店询价
  12286. /// info
  12287. /// </summary>
  12288. /// <param name="_dto"></param>
  12289. /// <returns></returns>
  12290. [HttpPost]
  12291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12292. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12293. {
  12294. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12295. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12296. return Ok(JsonView(true, res.Msg, res.Data));
  12297. }
  12298. /// <summary>
  12299. /// 酒店询价
  12300. /// Add Or Edit
  12301. /// </summary>
  12302. /// <param name="_dto"></param>
  12303. /// <returns></returns>
  12304. [HttpPost]
  12305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12306. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12307. {
  12308. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12309. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12310. return Ok(JsonView(true, res.Msg, res.Data));
  12311. }
  12312. /// <summary>
  12313. /// 酒店询价
  12314. /// Del
  12315. /// </summary>
  12316. /// <param name="_dto"></param>
  12317. /// <returns></returns>
  12318. [HttpPost]
  12319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12320. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12321. {
  12322. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12323. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12324. return Ok(JsonView(true, res.Msg, res.Data));
  12325. }
  12326. #endregion
  12327. #region 下载匹配op行程单
  12328. /// <summary>
  12329. /// 匹配op行程单
  12330. /// Init
  12331. /// </summary>
  12332. /// <param name="dto">团组列表请求dto</param>
  12333. /// <returns></returns>
  12334. [HttpPost]
  12335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12336. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12337. {
  12338. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12339. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12340. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12341. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12342. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12343. .Where(it => it.IsDel == 0)
  12344. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12345. .OrderByDescending(it => it.CreateUserId)
  12346. .ToList();
  12347. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12348. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12349. var diids = groupInfos.Select(it => it.Id).ToList();
  12350. List<string> countrys = new List<string>();
  12351. foreach (var item in country)
  12352. {
  12353. var data = _groupRepository.FormartTeamName(item);
  12354. var dataArray = _groupRepository.GroupSplitCountry(data);
  12355. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12356. }
  12357. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12358. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12359. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12360. foreach (var item in areaItem)
  12361. {
  12362. string areaStr = item.Value;
  12363. if (!string.IsNullOrEmpty(areaStr))
  12364. {
  12365. string[] str1 = areaStr.Split("-");
  12366. if (str1.Length > 0)
  12367. {
  12368. areaArray.AddRange(str1);
  12369. }
  12370. }
  12371. }
  12372. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12373. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12374. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12375. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12376. .ToList();
  12377. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12378. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12379. .Where(it => countriesIds.Contains(it.Id))
  12380. .Select(it => new { it.Id, Name = it.Name_CN })
  12381. .ToList();
  12382. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12383. .Select(it => it.TeamName).ToList();
  12384. stopwatch.Stop();
  12385. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12386. }
  12387. ///// <summary>
  12388. ///// 匹配op行程单
  12389. ///// Init 查询区域数据
  12390. ///// </summary>
  12391. ///// <param name="dto">团组列表请求dto</param>
  12392. ///// <returns></returns>
  12393. //[HttpPost]
  12394. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12395. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12396. //{
  12397. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12398. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12399. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12400. // if (string.IsNullOrEmpty(countriesDataStr))
  12401. // {
  12402. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12403. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12404. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12405. // }
  12406. // else
  12407. // {
  12408. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12409. // }
  12410. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12411. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12412. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12413. // List<dynamic> childList = new List<dynamic>();
  12414. // int parentId = dto.CountriesId;
  12415. // if (provinceData.Count > 1)
  12416. // {
  12417. // foreach (var item1 in provinceData)
  12418. // {
  12419. // List<dynamic> childList1 = new List<dynamic>();
  12420. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12421. // foreach (var item2 in citiesData1)
  12422. // {
  12423. // List<dynamic> childList2 = new List<dynamic>();
  12424. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12425. // foreach (var item3 in countiesData1)
  12426. // {
  12427. // childList2.Add(new
  12428. // {
  12429. // id = item3.Id,
  12430. // parentId = item2.Id,
  12431. // level = "district",
  12432. // name = item3.Name_CN,
  12433. // });
  12434. // }
  12435. // childList1.Add(new
  12436. // {
  12437. // id = item2.Id,
  12438. // parentId = item1.Id,
  12439. // level = "city",
  12440. // name = item2.Name_CN,
  12441. // childList = childList2
  12442. // });
  12443. // }
  12444. // childList.Add(new
  12445. // {
  12446. // id = item1.Id,
  12447. // parentId = parentId,
  12448. // level = "province",
  12449. // name = item1.Name_CN,
  12450. // childList = childList1
  12451. // });
  12452. // }
  12453. // //城市
  12454. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12455. // foreach (var item2 in citiesData2)
  12456. // {
  12457. // List<dynamic> childList22 = new List<dynamic>();
  12458. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12459. // foreach (var item3 in countiesData1)
  12460. // {
  12461. // childList22.Add(new
  12462. // {
  12463. // id = item3.Id,
  12464. // parentId = item2.Id,
  12465. // level = "district",
  12466. // name = item3.Name_CN,
  12467. // });
  12468. // }
  12469. // childList.Add(new
  12470. // {
  12471. // id = item2.Id,
  12472. // parentId = parentId,
  12473. // level = "city",
  12474. // name = item2.Name_CN,
  12475. // childList = childList22
  12476. // });
  12477. // }
  12478. // }
  12479. // else
  12480. // {
  12481. // foreach (var item2 in citiesData)
  12482. // {
  12483. // string cname = item2.Name_CN;
  12484. // List<dynamic> childList1 = new List<dynamic>();
  12485. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12486. // foreach (var item3 in countiesData1)
  12487. // {
  12488. // childList1.Add(new
  12489. // {
  12490. // Id = item3.Id,
  12491. // parentId = item2.Id,
  12492. // level = "district",
  12493. // name = item3.Name_CN
  12494. // });
  12495. // }
  12496. // childList.Add(new
  12497. // {
  12498. // id = item2.Id,
  12499. // parentId = parentId,
  12500. // level = "city",
  12501. // name = item2.Name_CN,
  12502. // childList = childList1
  12503. // });
  12504. // }
  12505. // }
  12506. // stopwatch.Stop();
  12507. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12508. //}
  12509. /// <summary>
  12510. /// 匹配op行程单
  12511. /// 接团信息列表 Page
  12512. /// </summary>
  12513. /// <param name="dto">团组列表请求dto</param>
  12514. /// <returns></returns>
  12515. [HttpPost]
  12516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12517. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12518. {
  12519. var swatch = new Stopwatch();
  12520. swatch.Start();
  12521. #region 参数验证
  12522. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12523. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12524. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12525. #region 页面操作权限验证
  12526. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12527. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12528. #endregion
  12529. #endregion
  12530. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12531. {
  12532. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12533. string sqlWhere = "";
  12534. if (!string.IsNullOrEmpty(dto.Country))
  12535. {
  12536. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12537. }
  12538. if (!string.IsNullOrEmpty(dto.Area))
  12539. {
  12540. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12541. }
  12542. if (!string.IsNullOrEmpty(dto.TeamName))
  12543. {
  12544. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12545. }
  12546. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12547. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12548. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12549. swatch.Stop();
  12550. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12551. }
  12552. else
  12553. {
  12554. return Ok(JsonView(false, "查询失败"));
  12555. }
  12556. }
  12557. /// <summary>
  12558. /// 匹配op行程单
  12559. /// 行程单下载
  12560. /// </summary>
  12561. /// <param name="dto">团组列表请求dto</param>
  12562. /// <returns></returns>
  12563. [HttpPost]
  12564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12565. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12566. {
  12567. #region 参数验证
  12568. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12569. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12570. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12571. #region 页面操作权限验证
  12572. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12573. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12574. #endregion
  12575. #endregion
  12576. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12577. {
  12578. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12579. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12580. }
  12581. else
  12582. {
  12583. return Ok(JsonView(false, "下载失败!"));
  12584. }
  12585. }
  12586. #endregion
  12587. #region 国家信息 数据 注释
  12588. //[HttpPost]
  12589. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12590. //{
  12591. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12592. // foreach (var item in dto)
  12593. // {
  12594. // infos.Add(new Grp_GroupsTaskAssignment()
  12595. // {
  12596. // DIId = item,
  12597. // CTId = 82,
  12598. // UId = 248,
  12599. // IsEnable = 1,
  12600. // CreateUserId = 233,
  12601. // CreateTime = DateTime.Now,
  12602. // IsDel = 0
  12603. // });
  12604. // infos.Add(new Grp_GroupsTaskAssignment()
  12605. // {
  12606. // DIId = item,
  12607. // CTId = 82,
  12608. // UId = 286,
  12609. // IsEnable = 1,
  12610. // CreateUserId = 233,
  12611. // CreateTime = DateTime.Now,
  12612. // IsDel = 0
  12613. // });
  12614. // }
  12615. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12616. // return Ok("操作成功");
  12617. //}
  12618. //public class paramJsonDto
  12619. //{
  12620. // public List<CountriesInfo> str { get; set; }
  12621. //}
  12622. //[HttpPost]
  12623. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12624. //{
  12625. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12626. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12627. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12628. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12629. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12630. // _sqlSugar.BeginTran();
  12631. // int countitiesIndex = 0;
  12632. // foreach (var item in dto.str)
  12633. // {
  12634. // dynamic data = item.c;
  12635. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12636. // if (data != null)
  12637. // {
  12638. // countitiesIndex++;
  12639. // foreach (var item1 in data)
  12640. // {
  12641. // string cnname = item1.cn;
  12642. // string enname = item1.en;
  12643. // Sys_Cities provinceInfo = new Sys_Cities()
  12644. // {
  12645. // CountriesId = countriesId,
  12646. // Name_CN = cnname,
  12647. // Name_EN = enname,
  12648. // ParentId = 0,
  12649. // IsCapital = 1,
  12650. // CreateUserId = 208,
  12651. // CreateTime = DateTime.Now,
  12652. // IsDel = 0
  12653. // };
  12654. // if (item1.lv == "province") //省份
  12655. // {
  12656. // provinceInfo.Level = 1;
  12657. // int provinceId = 0;
  12658. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12659. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12660. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12661. // var data1 = item1.c;
  12662. // foreach (var item2 in data1)
  12663. // {
  12664. // if (item2.lv == "city")
  12665. // {
  12666. // string citycnname = item2.cn;
  12667. // string cityenname = item2.en;
  12668. // Sys_Cities cityInfo = new Sys_Cities()
  12669. // {
  12670. // CountriesId = countriesId,
  12671. // ParentId = provinceId,
  12672. // Level = 2,
  12673. // Name_CN = citycnname,
  12674. // Name_EN = cityenname,
  12675. // IsCapital = 1,
  12676. // CreateUserId = 208,
  12677. // CreateTime = DateTime.Now,
  12678. // IsDel = 0
  12679. // };
  12680. // if (item2.c != null)
  12681. // {
  12682. // int cityId = 0;
  12683. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12684. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12685. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12686. // foreach (var item3 in item2.c)
  12687. // {
  12688. // if (item3.lv == "district")
  12689. // {
  12690. // var districtInfo = new Sys_Cities()
  12691. // {
  12692. // CountriesId = countriesId,
  12693. // Name_CN = item3.cn,
  12694. // Name_EN = item3.en,
  12695. // Level = 3,
  12696. // ParentId = cityId,
  12697. // IsCapital = 1,
  12698. // CreateUserId = 208,
  12699. // CreateTime = DateTime.Now,
  12700. // IsDel = 0
  12701. // };
  12702. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12703. // //{
  12704. // districts.Add(districtInfo);
  12705. // //}
  12706. // }
  12707. // }
  12708. // }
  12709. // else
  12710. // {
  12711. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12712. // //{
  12713. // cities.Add(cityInfo);
  12714. // //}
  12715. // }
  12716. // }
  12717. // }
  12718. // }
  12719. // else if (item1.lv == "city")//城市
  12720. // {
  12721. // provinceInfo.Level = 2;
  12722. // if (item1.c != null)
  12723. // {
  12724. // int cityId = 0;
  12725. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12726. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12727. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12728. // foreach (var item3 in item1.c)
  12729. // {
  12730. // if (item3.lv == "district")
  12731. // {
  12732. // var districtInfo = new Sys_Cities()
  12733. // {
  12734. // CountriesId = countriesId,
  12735. // Name_CN = item3.cn,
  12736. // Name_EN = item3.en,
  12737. // Level = 3,
  12738. // ParentId = cityId,
  12739. // IsCapital = 1,
  12740. // CreateUserId = 208,
  12741. // CreateTime = DateTime.Now,
  12742. // IsDel = 0
  12743. // };
  12744. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12745. // //{
  12746. // districts.Add(districtInfo);
  12747. // //}
  12748. // }
  12749. // }
  12750. // }
  12751. // else
  12752. // {
  12753. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12754. // //{
  12755. // cities.Add(provinceInfo);
  12756. // //}
  12757. // }
  12758. // }
  12759. // }
  12760. // }
  12761. // }
  12762. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12763. // cities = cities.Distinct().ToList();
  12764. // districts = districts.Distinct().ToList();
  12765. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12766. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12767. // cities.AddRange(districts);
  12768. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12769. // //_sqlSugar.RollbackTran();
  12770. // _sqlSugar.CommitTran();
  12771. // return Ok(JsonView(false, "操作成功!"));
  12772. //}
  12773. //[HttpPost]
  12774. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12775. //{
  12776. // List<CountitiesInfo> infos = dto.MyProperty;
  12777. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12778. // _sqlSugar.BeginTran();
  12779. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12780. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12781. // foreach (var item in infos)
  12782. // {
  12783. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12784. // if (countryInfo != null)
  12785. // {
  12786. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12787. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12788. // if (cityInfo1 != null)
  12789. // {
  12790. // cityInfo1.IsCapital = 0;
  12791. // cityInfos.Add(cityInfo1);
  12792. // }
  12793. // }
  12794. // }
  12795. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12796. // .UpdateColumns(it => it.IsCapital)
  12797. // .WhereColumns(it => it.Id)
  12798. // .ExecuteCommand();
  12799. // //_sqlSugar.RollbackTran();
  12800. // _sqlSugar.CommitTran();
  12801. // return Ok(JsonView(false, "操作成功!"));
  12802. //}
  12803. //public class CounrtiesDto
  12804. //{
  12805. // public List<CountitiesInfo> MyProperty { get; set; }
  12806. //}
  12807. //public class CountitiesInfo
  12808. //{
  12809. // /// <summary>
  12810. // /// 圣约翰
  12811. // /// </summary>
  12812. // public string capital_name_chinese { get; set; }
  12813. // /// <summary>
  12814. // ///
  12815. // /// </summary>
  12816. // public string capital_name { get; set; }
  12817. // /// <summary>
  12818. // ///
  12819. // /// </summary>
  12820. // public string country_type { get; set; }
  12821. // /// <summary>
  12822. // /// 安提瓜和巴布达
  12823. // /// </summary>
  12824. // public string country_name_chinese { get; set; }
  12825. // /// <summary>
  12826. // /// 安提瓜和巴布达
  12827. // /// </summary>
  12828. // public string country_name_chinese_short { get; set; }
  12829. // /// <summary>
  12830. // /// 安提瓜和巴布达
  12831. // /// </summary>
  12832. // public string country_name_chinese_UN { get; set; }
  12833. // /// <summary>
  12834. // ///
  12835. // /// </summary>
  12836. // public string country_name_english_abbreviation { get; set; }
  12837. // /// <summary>
  12838. // ///
  12839. // /// </summary>
  12840. // public string country_name_english_formal { get; set; }
  12841. // /// <summary>
  12842. // ///
  12843. // /// </summary>
  12844. // public string country_name_english_UN { get; set; }
  12845. // /// <summary>
  12846. // ///
  12847. // /// </summary>
  12848. // public string continent_name { get; set; }
  12849. // /// <summary>
  12850. // ///
  12851. // /// </summary>
  12852. // public string subregion_name { get; set; }
  12853. // /// <summary>
  12854. // ///
  12855. // /// </summary>
  12856. // public string country_code2 { get; set; }
  12857. // /// <summary>
  12858. // ///
  12859. // /// </summary>
  12860. // public string country_code3 { get; set; }
  12861. // /// <summary>
  12862. // ///
  12863. // /// </summary>
  12864. // public string phone_code { get; set; }
  12865. //}
  12866. //public class CountriesInfo : BasicInfo
  12867. //{
  12868. // public List<CitiesInfo> c { get; set; }
  12869. //}
  12870. //public class CitiesInfo : BasicInfo
  12871. //{
  12872. // public List<AreaInfo> c { get; set; }
  12873. //}
  12874. //public class AreaInfo : BasicInfo
  12875. //{
  12876. // public List<AreaInfo> c { get; set; }
  12877. //}
  12878. //public class BasicInfo
  12879. //{
  12880. // public string code { get; set; }
  12881. // public string cn { get; set; }
  12882. // public string lv { get; set; }
  12883. // public string en { get; set; }
  12884. //}
  12885. #endregion
  12886. #region 查看邀请方
  12887. /// <summary>
  12888. /// 查看邀请方
  12889. /// 邀请方信息 Init
  12890. /// </summary>
  12891. /// <param name="dto"></param>
  12892. /// <returns></returns>
  12893. [HttpPost]
  12894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12895. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12896. {
  12897. string sqlWhere = string.Empty;
  12898. if (!string.IsNullOrEmpty(dto.Search))
  12899. {
  12900. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12901. }
  12902. string sql = string.Format($@"Select
  12903. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12904. Id,
  12905. UnitName
  12906. From Res_InvitationOfficialActivityData
  12907. Where IsDel = 0
  12908. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12909. RefAsync<int> total = 0;
  12910. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12911. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12912. }
  12913. /// <summary>
  12914. /// 查看邀请方
  12915. /// 国家信息 Init
  12916. /// </summary>
  12917. /// <param name="dto"></param>
  12918. /// <returns></returns>
  12919. [HttpPost]
  12920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12921. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12922. {
  12923. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12924. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12925. var diids = groupInfos.Select(it => it.Id).ToList();
  12926. List<string> countrys = new List<string>();
  12927. foreach (var item in country)
  12928. {
  12929. var data = _groupRepository.FormartTeamName(item);
  12930. var dataArray = _groupRepository.GroupSplitCountry(data);
  12931. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12932. }
  12933. countrys = countrys.Distinct().ToList();
  12934. for (int i = 0; i < countrys.Count; i++)
  12935. {
  12936. string item = countrys[i];
  12937. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12938. {
  12939. countrys.Remove(item);
  12940. i--;
  12941. }
  12942. }
  12943. RefAsync<int> total = 0;
  12944. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12945. .Where(it => countrys.Contains(it.Name_CN))
  12946. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12947. .Select(it => new { id = it.Id, name = it.Name_CN })
  12948. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12949. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12950. }
  12951. /// <summary>
  12952. /// 查看邀请方
  12953. /// 城市信息 Init
  12954. /// </summary>
  12955. /// <param name="dto"></param>
  12956. /// <returns></returns>
  12957. [HttpPost]
  12958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12959. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12960. {
  12961. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12962. RefAsync<int> total = 0;
  12963. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12964. .Where(it => it.CountriesId == dto.CountiesId)
  12965. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12966. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12967. .Select(it => new { id = it.Id, name = it.Name_CN })
  12968. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12969. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12970. }
  12971. /// <summary>
  12972. /// 查看邀请方
  12973. /// 团组名称 Init
  12974. /// </summary>
  12975. /// <param name="dto"></param>
  12976. /// <returns></returns>
  12977. [HttpPost]
  12978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12979. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12980. {
  12981. var watch = new Stopwatch();
  12982. watch.Start();
  12983. RefAsync<int> total = 0;
  12984. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12985. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12986. .Where((oa, di) => oa.IsDel == 0)
  12987. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12988. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12989. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12990. .Distinct()
  12991. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12992. watch.Stop();
  12993. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12994. }
  12995. /// <summary>
  12996. /// 查看邀请方
  12997. /// 团组 & 邀请方信息
  12998. /// </summary>
  12999. /// <param name="dto"></param>
  13000. /// <returns></returns>
  13001. [HttpPost]
  13002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13003. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  13004. {
  13005. var watch = new Stopwatch();
  13006. watch.Start();
  13007. RefAsync<int> total = 0;
  13008. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  13009. .AS("Grp_DelegationInfo")
  13010. .Includes(x => x.InvitingInfos)
  13011. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  13012. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  13013. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  13014. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  13015. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  13016. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  13017. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13018. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  13019. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  13020. infos.ForEach(x =>
  13021. {
  13022. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  13023. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  13024. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  13025. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  13026. });
  13027. watch.Stop();
  13028. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  13029. }
  13030. #endregion
  13031. #region 报批行程
  13032. /// <summary>
  13033. /// 报批行程初始化
  13034. /// </summary>
  13035. /// <param name="dto"></param>
  13036. /// <returns></returns>
  13037. [HttpPost]
  13038. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  13039. {
  13040. const int chiNumber = 5;
  13041. var jw = JsonView(false);
  13042. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  13043. var group = groupList.First();
  13044. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13045. group = groupList.First(x => x.Id == diid);
  13046. if (group == null)
  13047. {
  13048. jw.Msg = "暂无团组!";
  13049. return Ok(jw);
  13050. }
  13051. var data = new
  13052. {
  13053. groupList = groupList.Select(x => new
  13054. {
  13055. x.TeamName,
  13056. x.Id
  13057. }),
  13058. content = new ArrayList(),
  13059. groupInfo = new
  13060. {
  13061. group.VisitDays,
  13062. group.TourCode,
  13063. group.VisitPNumber,
  13064. group.TeamName,
  13065. group.Id,
  13066. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  13067. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  13068. },
  13069. };
  13070. var resultArr = new ArrayList();
  13071. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  13072. if (content.Count == 0)
  13073. {
  13074. var stay = "-";
  13075. var cityPath = "-";
  13076. //添加城市路径以及住宿地
  13077. //黑屏代码数据
  13078. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13079. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13080. {
  13081. jw = JsonView(true, "黑屏代码有误!", data);
  13082. return Ok(jw);
  13083. }
  13084. foreach (DataRow row in dtBlack.Rows)
  13085. {
  13086. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13087. {
  13088. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  13089. return Ok(jw);
  13090. }
  13091. }
  13092. //黑屏代码获取时间区间
  13093. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13094. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13095. _sqlSugar.BeginTran();
  13096. for (int i = 0; i < timeArr.Count; i++)
  13097. {
  13098. stay = "-";
  13099. cityPath = "-";
  13100. DateTime NewData = DateTime.Parse(timeArr[i]);
  13101. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13102. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13103. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13104. if (tbSelect.Length > 0)
  13105. {
  13106. List<string> threeCodeStr = new List<string>();
  13107. foreach (var item in tbSelect)
  13108. {
  13109. var threeCode = item["Three"].ToString() ?? "";
  13110. if (threeCode.Length == 6)
  13111. {
  13112. var start = threeCode.Substring(0, 3);
  13113. var end = threeCode.Substring(3, 3);
  13114. if (threeCodeStr.Count == 0)
  13115. {
  13116. threeCodeStr.Add(start);
  13117. threeCodeStr.Add(end);
  13118. }
  13119. else
  13120. {
  13121. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13122. {
  13123. threeCodeStr.Add(end);
  13124. }
  13125. else
  13126. {
  13127. threeCodeStr.Add(start);
  13128. threeCodeStr.Add(end);
  13129. }
  13130. }
  13131. }
  13132. }
  13133. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13134. var last = threeCodeStr.Last();
  13135. foreach (var item in threeCodeStr)
  13136. {
  13137. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13138. if (item.Equals(last))
  13139. {
  13140. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13141. }
  13142. }
  13143. cityPath = cityPath.Trim('-');
  13144. }
  13145. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13146. appro.Diid = diid ?? -1;
  13147. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13148. appro.Id = thisId;
  13149. appro.CreateUserId = dto.UserId;
  13150. appro.CreateTime = DateTime.Now;
  13151. content.Add(appro);
  13152. }
  13153. _sqlSugar.CommitTran();
  13154. }
  13155. foreach (var x in content)
  13156. {
  13157. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  13158. if (chiList.Count < chiNumber)
  13159. {
  13160. for (int i = chiList.Count; i < chiNumber; i++)
  13161. {
  13162. chiList.Add(new Grp_ApprovalTravelDetails());
  13163. }
  13164. }
  13165. resultArr.Add(new
  13166. {
  13167. x.Id,
  13168. x.Date,
  13169. x.Diid,
  13170. chiList = chiList.Select(x1 => new
  13171. {
  13172. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13173. x1.Details,
  13174. x1.ParentId,
  13175. x1.Id
  13176. })
  13177. });
  13178. }
  13179. data = data with
  13180. {
  13181. content = resultArr,
  13182. };
  13183. jw = JsonView(true, "获取成功!", data);
  13184. return Ok(jw);
  13185. }
  13186. /// <summary>
  13187. /// 报批行程删除
  13188. /// </summary>
  13189. /// <param name="dto"></param>
  13190. /// <returns></returns>
  13191. [HttpPost]
  13192. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  13193. {
  13194. var jw = JsonView(false);
  13195. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13196. if (group == null)
  13197. {
  13198. jw.Msg = "团组参数有误!";
  13199. return Ok(jw);
  13200. }
  13201. try
  13202. {
  13203. _sqlSugar.BeginTran();
  13204. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  13205. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  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.ParentId) && x.IsDel == 0).ExecuteCommand();
  13211. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  13212. {
  13213. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13214. DeleteUserId = dto.uesrId,
  13215. IsDel = 1
  13216. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  13217. _sqlSugar.CommitTran();
  13218. jw = JsonView(true, "删除成功");
  13219. }
  13220. catch (Exception ex)
  13221. {
  13222. jw = JsonView(false, ex.Message);
  13223. }
  13224. return Ok(jw);
  13225. }
  13226. /// <summary>
  13227. /// 报批行程保存
  13228. /// </summary>
  13229. /// <param name="dto"></param>
  13230. /// <returns></returns>
  13231. [HttpPost]
  13232. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  13233. {
  13234. var jw = JsonView(false);
  13235. var Find = dto.Arr.Find(x => x.id == 0);
  13236. if (Find != null)
  13237. {
  13238. jw.Msg = "生成的ID为0!";
  13239. return Ok(jw);
  13240. }
  13241. foreach (var item in dto.Arr)
  13242. {
  13243. foreach (var chi in item.chiList)
  13244. {
  13245. if (chi.parentId == 0)
  13246. {
  13247. chi.parentId = item.id;
  13248. }
  13249. }
  13250. }
  13251. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  13252. _sqlSugar.BeginTran();
  13253. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  13254. {
  13255. var parentIds = dto.Arr.Select(x => x.id).ToList();
  13256. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  13257. {
  13258. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13259. DeleteUserId = dto.UserId,
  13260. IsDel = 1
  13261. }).ExecuteCommand();
  13262. }
  13263. try
  13264. {
  13265. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  13266. {
  13267. CreateTime = DateTime.Now,
  13268. CreateUserId = dto.UserId,
  13269. Details = x.details,
  13270. ParentId = x.parentId,
  13271. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13272. Remark = "",
  13273. IsDel = 0
  13274. }).ToList()).ExecuteCommand();
  13275. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  13276. {
  13277. Id = x.id,
  13278. Details = x.details,
  13279. ParentId = x.parentId,
  13280. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13281. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  13282. {
  13283. Details = x.Details,
  13284. ParentId = x.ParentId,
  13285. Time = x.Time
  13286. }).ExecuteCommand();
  13287. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  13288. {
  13289. Id = x.id,
  13290. Date = x.date,
  13291. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13292. {
  13293. Date = x.Date
  13294. }).ExecuteCommand();
  13295. _sqlSugar.CommitTran();
  13296. jw = JsonView(true, "保存成功!");
  13297. }
  13298. catch (Exception ex)
  13299. {
  13300. _sqlSugar.RollbackTran();
  13301. jw = JsonView(false, "保存失败!" + ex.Message);
  13302. }
  13303. return Ok(jw);
  13304. }
  13305. /// <summary>
  13306. /// 报批行程生成
  13307. /// </summary>
  13308. /// <param name="dto"></param>
  13309. /// <returns></returns>
  13310. [HttpPost]
  13311. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13312. {
  13313. var jw = JsonView(false);
  13314. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13315. if (group == null)
  13316. {
  13317. jw.Msg = "暂无该团组!";
  13318. return Ok(jw);
  13319. }
  13320. //黑屏代码数据
  13321. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13322. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13323. {
  13324. jw.Msg = "黑屏代码有误!";
  13325. return Ok(jw);
  13326. }
  13327. foreach (DataRow row in dtBlack.Rows)
  13328. {
  13329. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13330. {
  13331. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13332. return Ok(jw);
  13333. }
  13334. }
  13335. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13336. var resultArr = new ArrayList();
  13337. if (officialActivitiesArr.Count == 0)
  13338. {
  13339. jw.Msg = "暂无公务出访信息!";
  13340. return Ok(jw);
  13341. }
  13342. try
  13343. {
  13344. _sqlSugar.BeginTran();
  13345. DeleteApprovalJourney(new
  13346. Domain.Dtos.Groups.DeleteApprovalJourney
  13347. {
  13348. Diid = dto.Diid,
  13349. uesrId = dto.Userid
  13350. });
  13351. var stay = "-";
  13352. var cityPath = "-";
  13353. //添加城市路径以及住宿地
  13354. //黑屏代码获取时间区间
  13355. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13356. var empty = "【未收入该三字码!请机票同事录入】";
  13357. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13358. for (int i = 0; i < timeArr.Count; i++)
  13359. {
  13360. stay = "-";
  13361. cityPath = "-";
  13362. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13363. DateTime NewData = DateTime.Parse(timeArr[i]);
  13364. 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();
  13365. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13366. if (tbSelect.Length > 0)
  13367. {
  13368. List<string> threeCodeStr = new List<string>();
  13369. bool isTrade = false;
  13370. string trip = string.Empty;
  13371. var rowLast = tbSelect.Last();
  13372. var rowFirst = tbSelect.First();
  13373. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13374. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13375. var takeOffTime = DateTime.Parse(timeArr[i]);
  13376. var fallToTime = DateTime.Parse(timeArr[i]);
  13377. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13378. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13379. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13380. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13381. foreach (var item in tbSelect)
  13382. {
  13383. var start = string.Empty;
  13384. var end = string.Empty;
  13385. var threeCode = item["Three"].ToString() ?? "";
  13386. if (threeCode.Length == 6)
  13387. {
  13388. start = threeCode.Substring(0, 3);
  13389. end = threeCode.Substring(3, 3);
  13390. if (threeCodeStr.Count == 0)
  13391. {
  13392. threeCodeStr.Add(start);
  13393. threeCodeStr.Add(end);
  13394. }
  13395. else
  13396. {
  13397. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13398. {
  13399. threeCodeStr.Add(end);
  13400. }
  13401. else
  13402. {
  13403. threeCodeStr.Add(start);
  13404. threeCodeStr.Add(end);
  13405. }
  13406. }
  13407. }
  13408. //处理机票信息
  13409. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13410. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13411. if (start_Object == null)
  13412. {
  13413. start_Object = new Res_ThreeCode()
  13414. {
  13415. AirPort = empty,
  13416. AirPort_En = empty,
  13417. City = empty,
  13418. Country = empty,
  13419. Four = empty,
  13420. Three = empty,
  13421. };
  13422. }
  13423. if (end_Object == null)
  13424. {
  13425. end_Object = new Res_ThreeCode()
  13426. {
  13427. AirPort = empty,
  13428. AirPort_En = empty,
  13429. City = empty,
  13430. Country = empty,
  13431. Four = empty,
  13432. Three = empty,
  13433. };
  13434. }
  13435. //机型判断
  13436. string airModel = item["AirModel"].ToString();
  13437. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13438. string flightTime = item["FlightTime"].ToString();
  13439. if (flightTime!.Contains(":"))
  13440. {
  13441. flightTime = flightTime.Replace(":", "小时");
  13442. flightTime += "分钟";
  13443. }
  13444. if (flightTime.Contains("H"))
  13445. {
  13446. flightTime = flightTime.Replace("H", "小时");
  13447. }
  13448. if (flightTime.Contains("M"))
  13449. {
  13450. flightTime = flightTime.Replace("M", "分钟");
  13451. }
  13452. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13453. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13454. {
  13455. flightTime = flightDataTime.Hour > 0
  13456. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13457. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13458. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13459. }
  13460. //航班号
  13461. string flightcode = item["Fliagtcode"].ToString();
  13462. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13463. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13464. if (aircompany == null)
  13465. {
  13466. aircompany = new Res_AirCompany
  13467. {
  13468. CnName = hsEmpty,
  13469. EnName = hsEmpty,
  13470. ShortCode = hsEmpty,
  13471. };
  13472. }
  13473. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13474. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13475. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13476. if (isTrade)
  13477. {
  13478. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13479. }
  13480. else
  13481. {
  13482. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13483. }
  13484. }
  13485. chiarr.Add(new Grp_ApprovalTravelDetails
  13486. {
  13487. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13488. CreateTime = DateTime.Now,
  13489. CreateUserId = dto.Userid,
  13490. ParentId = 0,
  13491. Details = trip
  13492. });
  13493. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13494. var last = threeCodeStr.Last();
  13495. foreach (var item in threeCodeStr)
  13496. {
  13497. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13498. if (item.Equals(last))
  13499. {
  13500. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13501. }
  13502. }
  13503. cityPath = cityPath.Trim('-');
  13504. }
  13505. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13506. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13507. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13508. appro.Diid = dto.Diid;
  13509. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13510. appro.Id = thisId;
  13511. appro.CreateUserId = dto.Userid;
  13512. appro.CreateTime = DateTime.Now;
  13513. foreach (var item in gwinfo)
  13514. {
  13515. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13516. chi.Details = "拜访" + item.Client;
  13517. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13518. {
  13519. chi.Details += "," + item.ReqSample;
  13520. }
  13521. chi.ParentId = thisId;
  13522. chi.Time = item.Time;
  13523. chiarr.Add(chi);
  13524. }
  13525. if (chiarr.Count < 5)
  13526. {
  13527. for (int j = chiarr.Count; j < 5; j++)
  13528. {
  13529. chiarr.Add(new
  13530. Grp_ApprovalTravelDetails());
  13531. }
  13532. }
  13533. resultArr.Add(new
  13534. {
  13535. appro.Id,
  13536. appro.Date,
  13537. appro.Diid,
  13538. chiList = chiarr.Select(x1 => new
  13539. {
  13540. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13541. x1.Details,
  13542. x1.ParentId,
  13543. x1.Id
  13544. })
  13545. });
  13546. }
  13547. _sqlSugar.CommitTran();
  13548. jw = JsonView(true, "生成成功!", resultArr);
  13549. }
  13550. catch (Exception ex)
  13551. {
  13552. jw.Code = 400;
  13553. jw.Msg = "生成失败!" + ex.Message;
  13554. }
  13555. return Ok(jw);
  13556. }
  13557. /// <summary>
  13558. /// 报批行程word导出
  13559. /// </summary>
  13560. /// <param name="dto"></param>
  13561. /// <returns></returns>
  13562. [HttpPost]
  13563. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13564. {
  13565. var jw = JsonView(false);
  13566. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13567. if (group == null)
  13568. {
  13569. jw.Msg = "暂无该团组!";
  13570. return Ok(jw);
  13571. }
  13572. //模板路径
  13573. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13574. //载入模板
  13575. Document doc = new Document(tempPath);
  13576. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13577. //获取所填表格的序数
  13578. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13579. Aspose.Words.Tables.Row titleRowClone = null;
  13580. Aspose.Words.Tables.Row CenterRowClone = null;
  13581. int index = 0;
  13582. int indexChi = 0;
  13583. int SetIndex = 0;
  13584. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13585. //获取数据,放到datatable
  13586. foreach (var item in ApprovalTravelArr)
  13587. {
  13588. if (index > 0)
  13589. {
  13590. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13591. tableOne.AppendChild(titleRowClone);
  13592. }
  13593. var textTime = item.Date;
  13594. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13595. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13596. SetIndex++;
  13597. if (ChiRep.Count > 0)
  13598. {
  13599. foreach (var itemChi in ChiRep)
  13600. {
  13601. var txtTime = itemChi.Time;
  13602. var txtDetail = itemChi.Details;
  13603. if (indexChi > 0)
  13604. {
  13605. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13606. tableOne.AppendChild(CenterRowClone);
  13607. }
  13608. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13609. {
  13610. SetCells(tableOne, doc, SetIndex, 0, "");
  13611. SetCells(tableOne, doc, SetIndex, 1, "");
  13612. indexChi++;
  13613. SetIndex++;
  13614. break;
  13615. }
  13616. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13617. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13618. indexChi++;
  13619. SetIndex++;
  13620. }
  13621. }
  13622. else
  13623. {
  13624. if (indexChi > 0)
  13625. {
  13626. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13627. tableOne.AppendChild(CenterRowClone);
  13628. }
  13629. SetCells(tableOne, doc, SetIndex, 0, "");
  13630. SetCells(tableOne, doc, SetIndex, 1, "");
  13631. indexChi++;
  13632. SetIndex++;
  13633. }
  13634. index++;
  13635. }
  13636. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13637. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13638. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13639. jw.Code = 200;
  13640. jw.Msg = "";
  13641. return Ok(jw);
  13642. }
  13643. private string intToString(int numberVal)
  13644. {
  13645. string numberval = numberVal.ToString();
  13646. Dictionary<char, string> Number = new Dictionary<char, string>();
  13647. Number.Add('1', "一");
  13648. Number.Add('2', "二");
  13649. Number.Add('3', "三");
  13650. Number.Add('4', "四");
  13651. Number.Add('5', "五");
  13652. Number.Add('6', "六");
  13653. Number.Add('7', "七");
  13654. Number.Add('8', "八");
  13655. Number.Add('9', "九");
  13656. string stringNumberVal = string.Empty;
  13657. for (int i = 0; i < numberval.Length; i++)
  13658. {
  13659. if (i == 0)
  13660. {
  13661. stringNumberVal += Number[numberval[i]];
  13662. }
  13663. else if (i >= 1)
  13664. {
  13665. if (numberval[i] == '0')
  13666. {
  13667. stringNumberVal = "十";
  13668. }
  13669. else
  13670. {
  13671. stringNumberVal += "十" + Number[numberval[i]];
  13672. }
  13673. }
  13674. }
  13675. return stringNumberVal;
  13676. }
  13677. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13678. {
  13679. //获取table中的某个单元格,从0开始
  13680. Cell lshCell = table.Rows[rows].Cells[cells];
  13681. //将单元格中段落移除
  13682. foreach (Node item in lshCell.Paragraphs)
  13683. {
  13684. lshCell.Paragraphs.Remove(item);
  13685. }
  13686. if (val.Contains("\r\n"))
  13687. {
  13688. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13689. foreach (var item in spArr)
  13690. {
  13691. //新建一个段落
  13692. Paragraph p = new Paragraph(doc);
  13693. var r = new Run(doc, item);
  13694. //把设置的值赋给之前新建的段落
  13695. p.AppendChild(r);
  13696. //将此段落加到单元格内
  13697. lshCell.AppendChild(p);
  13698. }
  13699. }
  13700. else
  13701. {
  13702. //新建一个段落
  13703. Paragraph p = new Paragraph(doc);
  13704. var r = new Run(doc, val);
  13705. //把设置的值赋给之前新建的段落
  13706. p.AppendChild(r);
  13707. //将此段落加到单元格内
  13708. lshCell.AppendChild(p);
  13709. }
  13710. }
  13711. [HttpPost]
  13712. public async Task<IActionResult> ServerHttp(string paramStr)
  13713. {
  13714. paramStr = paramStr.TrimEnd('\'');
  13715. paramStr = paramStr.TrimStart('\'');
  13716. JsonView jw = JsonView(false);
  13717. JObject param = JObject.Parse(paramStr);
  13718. if (!param.ContainsKey("url"))
  13719. {
  13720. jw.Msg = "url null";
  13721. return Ok(jw);
  13722. }
  13723. string url = param["url"]!.ToString();
  13724. var methon = "get";
  13725. Dictionary<string, string> headValues = null;
  13726. string bodyStr = string.Empty;
  13727. if (param.ContainsKey("methon"))
  13728. {
  13729. methon = param["methon"]!.ToString().ToLower();
  13730. }
  13731. if (param.ContainsKey("header"))
  13732. {
  13733. var header = param["header"]!.ToString();
  13734. JObject headerJobject = JObject.Parse(header);
  13735. headValues = new Dictionary<string, string>();
  13736. foreach (JProperty item in headerJobject.Properties())
  13737. {
  13738. var value = item.Value.ToString();
  13739. var head = item.Path;
  13740. headValues.Add(head, value);
  13741. }
  13742. }
  13743. HttpClient client = new HttpClient();
  13744. string responseString = string.Empty;
  13745. StringContent content = null;
  13746. if (headValues != null)
  13747. {
  13748. foreach (var item in headValues.Keys)
  13749. {
  13750. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13751. {
  13752. if (param.ContainsKey("body"))
  13753. {
  13754. bodyStr = param["body"]!.ToString();
  13755. }
  13756. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13757. }
  13758. else
  13759. {
  13760. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13761. }
  13762. }
  13763. }
  13764. try
  13765. {
  13766. if (methon == "get")
  13767. {
  13768. responseString = await client.GetStringAsync(url);
  13769. }
  13770. else if (methon == "post")
  13771. {
  13772. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13773. {
  13774. Content = content
  13775. };
  13776. var response = await client.SendAsync(request);
  13777. try
  13778. {
  13779. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13780. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13781. {
  13782. using (StreamReader reader = new StreamReader(gzipStream))
  13783. {
  13784. responseString = await reader.ReadToEndAsync();
  13785. }
  13786. }
  13787. }
  13788. catch (Exception)
  13789. {
  13790. responseString = await response.Content.ReadAsStringAsync();
  13791. }
  13792. }
  13793. else
  13794. {
  13795. responseString = "methon error";
  13796. }
  13797. jw = JsonView(true, "success", responseString);
  13798. }
  13799. catch (Exception ex)
  13800. {
  13801. jw.Msg = "error " + ex.Message;
  13802. jw.Data = ex.StackTrace;
  13803. }
  13804. finally
  13805. {
  13806. client.Dispose();
  13807. }
  13808. return Ok(jw);
  13809. }
  13810. #endregion
  13811. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13812. /// <summary>
  13813. /// 团组接待意见调查 - 信息管理
  13814. /// 基础数据(团组)
  13815. /// </summary>
  13816. /// <param name="dto"></param>
  13817. /// <returns></returns>
  13818. [HttpGet]
  13819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13820. public async Task<IActionResult> OpinionaireInit()
  13821. {
  13822. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13823. .Select(x => new
  13824. {
  13825. x.Id,
  13826. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13827. })
  13828. .OrderByDescending(x => x.Id)
  13829. .ToListAsync();
  13830. return Ok(JsonView(groupData, groupData.Count));
  13831. }
  13832. /// <summary>
  13833. /// 团组接待意见调查 - 信息管理
  13834. /// 列表
  13835. /// </summary>
  13836. /// <param name="groupId"></param>
  13837. /// <returns></returns>
  13838. [HttpGet("{groupId}")]
  13839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13840. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13841. {
  13842. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13843. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13844. .Select(x => new
  13845. {
  13846. x.Id,
  13847. x.TourGuideName,
  13848. x.CityName,
  13849. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13850. x.CreateTime
  13851. })
  13852. .OrderBy(x => x.Id)
  13853. .ToListAsync();
  13854. return Ok(JsonView(data));
  13855. }
  13856. /// <summary>
  13857. /// 团组接待意见调查 - 信息管理
  13858. /// 保存
  13859. /// </summary>
  13860. /// <param name="dto"></param>
  13861. /// <returns></returns>
  13862. [HttpPost]
  13863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13864. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  13865. {
  13866. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13867. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13868. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13869. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  13870. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  13871. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  13872. _opinionaireRep.BeginTran();
  13873. if (addData != null && addData.Count > 0)
  13874. {
  13875. foreach (var item in addData)
  13876. {
  13877. item.CreateUserId = currUserInfo.UserId;
  13878. item.DiId = dto.DiId;
  13879. }
  13880. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  13881. }
  13882. if (updData != null && updData.Count > 0)
  13883. {
  13884. var upd = await _opinionaireRep._sqlSugar
  13885. .Updateable(updData)
  13886. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  13887. .WhereColumns(x => new { x.Id })
  13888. .ExecuteCommandAsync();
  13889. }
  13890. _opinionaireRep.CommitTran();
  13891. return Ok(JsonView("操作成功!"));
  13892. }
  13893. /// <summary>
  13894. /// 团组接待意见调查 - 信息管理
  13895. /// 删除
  13896. /// </summary>
  13897. /// <param name="id"></param>
  13898. /// <returns></returns>
  13899. [HttpDelete("{id}")]
  13900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13901. public async Task<IActionResult> OpinionaireManageDel(int id)
  13902. {
  13903. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13904. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13905. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  13906. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  13907. if (!del) return Ok(JsonView("操作失败!"));
  13908. return Ok(JsonView("操作成功!"));
  13909. }
  13910. /// <summary>
  13911. /// 团组接待意见调查 - 用户
  13912. /// 列表
  13913. /// </summary>
  13914. /// <param name="id"></param>
  13915. /// <returns></returns>
  13916. [HttpGet("{diId}")]
  13917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13918. public async Task<IActionResult> OpinionaireUserList(int diId)
  13919. {
  13920. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13921. var sql = string.Format(@"
  13922. SELECT
  13923. o.Id,
  13924. o.DiId,
  13925. di.TeamName AS 'GroupName',
  13926. di.VisitPNumber AS 'PeopleNumber',
  13927. di.ClientName AS 'LeadGroup',
  13928. di.VisitCountry AS 'Travel',
  13929. di.VisitDays AS 'Days',
  13930. o.CityName,
  13931. o.TourGuideName,
  13932. o.Catering,
  13933. o.CateringReason,
  13934. o.Stay,
  13935. o.StayReason,
  13936. o.[Route],
  13937. o.RouteReason,
  13938. o.OfficialActivity,
  13939. o.OfficialActivityReason,
  13940. o.TourGuide,
  13941. o.TourGuideReason,
  13942. o.[Translate],
  13943. o.TranslateReason,
  13944. o.Trip,
  13945. o.TripReason,
  13946. o.ESFileName,
  13947. o.SignatureDate,
  13948. o.Remark
  13949. FROM
  13950. Grp_Opinionaire o
  13951. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  13952. WHERE
  13953. o.IsDel = 0
  13954. AND o.DiId = {0}
  13955. ORDER BY
  13956. o.Id ASC", diId);
  13957. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  13958. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  13959. return Ok(JsonView(data));
  13960. }
  13961. /// <summary>
  13962. /// 团组接待意见调查 - 用户
  13963. /// 保存
  13964. /// </summary>
  13965. /// <param name="id"></param>
  13966. /// <returns></returns>
  13967. [HttpPost]
  13968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13969. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  13970. {
  13971. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  13972. foreach (var item in dto)
  13973. {
  13974. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  13975. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  13976. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  13977. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  13978. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  13979. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  13980. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  13981. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  13982. }
  13983. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  13984. if (!Directory.Exists(filePathBase))
  13985. {
  13986. Directory.CreateDirectory(filePathBase);
  13987. }
  13988. #region 上传文件
  13989. var filePaths = new List<string>();
  13990. foreach (var item in dto)
  13991. {
  13992. var file = item.File;
  13993. // 将文件保存到指定位置
  13994. var filePath = Path.Combine(filePathBase, file.FileName);
  13995. using (var stream = new FileStream(filePath, FileMode.Create))
  13996. {
  13997. await file.CopyToAsync(stream);
  13998. }
  13999. //验证文件是否上传成功
  14000. if (!System.IO.File.Exists(filePath))
  14001. {
  14002. foreach (var filePathStr in filePaths)
  14003. {
  14004. System.IO.File.Delete(filePathStr);
  14005. }
  14006. return Ok(JsonView(false, "文件上传失败!"));
  14007. }
  14008. item.ESFileName = file.FileName;
  14009. }
  14010. #endregion
  14011. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  14012. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  14013. .UpdateColumns(x => new
  14014. {
  14015. x.Catering,
  14016. x.CateringReason,
  14017. x.Stay,
  14018. x.StayReason,
  14019. x.Route,
  14020. x.RouteReason,
  14021. x.OfficialActivity,
  14022. x.OfficialActivityReason,
  14023. x.TourGuide,
  14024. x.TourGuideReason,
  14025. x.Translate,
  14026. x.TranslateReason,
  14027. x.Trip,
  14028. x.TripReason,
  14029. x.ESFileName,
  14030. x.SignatureDate,
  14031. x.Remark
  14032. })
  14033. .WhereColumns(x => new { x.Id })
  14034. .ExecuteCommandAsync();
  14035. if (upd < 1)
  14036. {
  14037. foreach (var filePathStr in filePaths)
  14038. {
  14039. System.IO.File.Delete(filePathStr);
  14040. }
  14041. return Ok(JsonView(false));
  14042. }
  14043. return Ok(JsonView(true));
  14044. }
  14045. #endregion
  14046. // /// <summary>
  14047. // ///
  14048. // /// </summary>
  14049. // /// <param name="_dto"></param>
  14050. // /// <returns></returns>
  14051. // [HttpPost]
  14052. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14053. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14054. // {
  14055. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14056. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  14057. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  14058. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14059. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  14060. // dic_psg.Add("客人", 974);
  14061. // dic_psg.Add("司机", 975);
  14062. // dic_psg.Add("导游", 976);
  14063. // dic_psg.Add("公司内部人员", 977);
  14064. // dic_psg.Add("司机/导游/公司内部人员", 978);
  14065. // foreach (var item in list_visa)
  14066. // {
  14067. // Grp_VisaInfo temp = new Grp_VisaInfo();
  14068. // temp.Id = item.Id;
  14069. // temp.DIId = item.DIId;
  14070. // temp.VisaClient = item.VisaClient;
  14071. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  14072. // temp.VisaCurrency = item.VisaCurrency;
  14073. // temp.IsThird = item.IsThird;
  14074. // if (dic_psg.ContainsKey(item.PassengerType))
  14075. // {
  14076. // temp.PassengerType = dic_psg[item.PassengerType];
  14077. // }
  14078. // else {
  14079. // temp.PassengerType = -1;
  14080. // }
  14081. // temp.VisaNumber = item.VisaNumber;
  14082. // temp.VisaFreeNumber = item.VisaFreeNumber;
  14083. // temp.CreateUserId = item.Operators;
  14084. // DateTime dt_ct;
  14085. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  14086. // if (b_ct)
  14087. // {
  14088. // temp.CreateTime = dt_ct;
  14089. // }
  14090. // else
  14091. // {
  14092. // temp.CreateTime = DateTime.Now;
  14093. // }
  14094. // temp.DeleteTime = "";
  14095. // temp.DeleteUserId = 0;
  14096. // temp.Remark = item.Remark;
  14097. // if (string.IsNullOrEmpty(temp.Remark)) {
  14098. // temp.Remark = "";
  14099. // }
  14100. // temp.IsDel = item.IsDel;
  14101. // temp.VisaDescription = item.VisaAttachment;
  14102. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  14103. //([Id]
  14104. // ,[DIId]
  14105. // ,[VisaClient]
  14106. // ,[VisaPrice]
  14107. // ,[VisaCurrency]
  14108. // ,[IsThird]
  14109. // ,[PassengerType]
  14110. // ,[VisaNumber]
  14111. // ,[VisaFreeNumber]
  14112. // ,[CreateUserId]
  14113. // ,[CreateTime]
  14114. // ,[DeleteTime]
  14115. // ,[DeleteUserId]
  14116. // ,[Remark]
  14117. // ,[IsDel]
  14118. // ,[visaDescription])
  14119. // VALUES
  14120. // ({0},{1},'{2}',{3},{4}
  14121. //,{5},{6},{7},{8},{9}
  14122. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  14123. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  14124. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  14125. //);
  14126. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  14127. // }
  14128. // return Ok(JsonView(true, "操作成功!"));
  14129. // }
  14130. /// <summary>
  14131. /// 123132123
  14132. /// </summary>
  14133. /// <param name="_dto"></param>
  14134. /// <returns></returns>
  14135. [HttpPost]
  14136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14137. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14138. {
  14139. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14140. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  14141. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  14142. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14143. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  14144. dicDetail.Add(789, 1034);
  14145. dicDetail.Add(790, 1035);
  14146. dicDetail.Add(791, 1036);
  14147. dicDetail.Add(792, 1037);
  14148. dicDetail.Add(793, 1038);
  14149. dicDetail.Add(794, 1039);
  14150. dicDetail.Add(795, 1040);
  14151. dicDetail.Add(796, 1041);
  14152. dicDetail.Add(797, 1042);
  14153. dicDetail.Add(798, 1043);
  14154. dicDetail.Add(801, 1044);
  14155. dicDetail.Add(802, 1045);
  14156. dicDetail.Add(803, 1046);
  14157. Dictionary<int, int> dic = new Dictionary<int, int>();
  14158. dic.Add(806, 1027);
  14159. dic.Add(807, 1028);
  14160. dic.Add(808, 1029);
  14161. dic.Add(809, 1030);
  14162. dic.Add(810, 1031);
  14163. dic.Add(811, 1032);
  14164. dic.Add(812, 1033);
  14165. foreach (var item in list_visa)
  14166. {
  14167. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  14168. temp.Coefficient = item.coefficient;
  14169. DateTime dtCrt;
  14170. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  14171. if (b1)
  14172. {
  14173. temp.CreateTime = dtCrt;
  14174. }
  14175. else
  14176. {
  14177. temp.CreateTime = DateTime.Now;
  14178. }
  14179. temp.CreateUserId = item.Operators;
  14180. temp.DeleteTime = "";
  14181. temp.DeleteUserId = 0;
  14182. temp.DiId = int.Parse(item.DIID);
  14183. temp.FilePath = item.FilePath;
  14184. temp.IsDel = item.IsDel;
  14185. temp.Price = item.Price;
  14186. temp.PriceCount = 1;
  14187. temp.PriceCurrency = item.Currency;
  14188. int detailId = 0;
  14189. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  14190. {
  14191. detailId = dicDetail[item.PriceTypeDetail];
  14192. }
  14193. temp.PriceDetailType = detailId;
  14194. temp.PriceDt = DateTime.Now;
  14195. temp.PriceName = item.PriceName;
  14196. temp.PriceSum = item.Price;
  14197. int tid = 0;
  14198. if (dic.ContainsKey(item.PriceType))
  14199. {
  14200. tid = dic[item.PriceType];
  14201. }
  14202. temp.PriceType = tid;
  14203. temp.Remark = item.Remark;
  14204. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  14205. }
  14206. return Ok(JsonView(true, "操作成功!"));
  14207. }
  14208. }
  14209. }