GroupsController.cs 782 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820
  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.POIFS.Crypt.Dsig;
  12. using NPOI.SS.Format;
  13. using NPOI.SS.Formula.Functions;
  14. using NPOI.SS.UserModel;
  15. using NPOI.SS.Util;
  16. using NPOI.XSSF.UserModel;
  17. using OASystem.API.OAMethodLib;
  18. using OASystem.API.OAMethodLib.APNs;
  19. using OASystem.API.OAMethodLib.File;
  20. using OASystem.API.OAMethodLib.Hub.HubClients;
  21. using OASystem.API.OAMethodLib.Hub.Hubs;
  22. using OASystem.API.OAMethodLib.JuHeAPI;
  23. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  24. using OASystem.Domain.Dtos.CRM;
  25. using OASystem.Domain.Dtos.FileDto;
  26. using OASystem.Domain.Dtos.Financial;
  27. using OASystem.Domain.Dtos.Groups;
  28. using OASystem.Domain.Entities.Customer;
  29. using OASystem.Domain.Entities.Financial;
  30. using OASystem.Domain.Entities.Groups;
  31. using OASystem.Domain.ViewModels;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.Statistics;
  34. using OASystem.Infrastructure.Repositories.Financial;
  35. using OASystem.Infrastructure.Repositories.Groups;
  36. using OfficeOpenXml;
  37. using Org.BouncyCastle.Asn1.Ocsp;
  38. using Quartz.Util;
  39. using SqlSugar;
  40. using SqlSugar.Extensions;
  41. using System.Collections;
  42. using System.Data;
  43. using System.Data.OleDb;
  44. using System.Diagnostics;
  45. using System.Globalization;
  46. using System.IO;
  47. using System.IO.Compression;
  48. using System.Net.Http;
  49. using System.Reflection.PortableExecutable;
  50. using System.Security.Cryptography;
  51. using Ubiety.Dns.Core;
  52. using static NPOI.POIFS.Crypt.CryptoFunctions;
  53. using static OASystem.API.OAMethodLib.JWTHelper;
  54. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  55. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  56. using Bookmark = Aspose.Words.Bookmark;
  57. using Cell = Aspose.Words.Tables.Cell;
  58. using Table = Aspose.Words.Tables.Table;
  59. namespace OASystem.API.Controllers
  60. {
  61. /// <summary>
  62. /// 团组相关
  63. /// </summary>
  64. //[Authorize]
  65. [Route("api/[controller]/[action]")]
  66. public class GroupsController : ControllerBase
  67. {
  68. private readonly ILogger<GroupsController> _logger;
  69. private readonly GrpScheduleRepository _grpScheduleRep;
  70. private readonly IMapper _mapper;
  71. private readonly DelegationInfoRepository _groupRepository;
  72. private readonly TaskAssignmentRepository _taskAssignmentRep;
  73. private readonly AirTicketResRepository _airTicketResRep;
  74. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  75. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  76. private readonly DelegationEnDataRepository _delegationEnDataRep;
  77. private readonly DelegationVisaRepository _delegationVisaRep;
  78. private readonly VisaPriceRepository _visaPriceRep;
  79. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  80. private readonly HotelPriceRepository _hotelPriceRep;
  81. private readonly CustomersRepository _customersRep;
  82. private readonly MessageRepository _message;
  83. private readonly SqlSugarClient _sqlSugar;
  84. private readonly TourClientListRepository _tourClientListRep;
  85. private readonly TeamRateRepository _teamRateRep;
  86. #region 成本相关
  87. private readonly CheckBoxsRepository _checkBoxs;
  88. private readonly GroupCostRepository _GroupCostRepository;
  89. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  90. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  91. #endregion
  92. private readonly SetDataRepository _setDataRep;
  93. private string url;
  94. private string path;
  95. private readonly EnterExitCostRepository _enterExitCostRep;
  96. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  97. private readonly UsersRepository _usersRep;
  98. private readonly IJuHeApiService _juHeApi;
  99. private readonly InvertedListRepository _invertedListRep;
  100. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  101. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  102. private readonly ThreeCodeRepository _threeCodeRepository;
  103. private readonly HotelInquiryRepository _hotelInquiryRep;
  104. private readonly FeeAuditRepository _feeAuditRep;
  105. private readonly VisaCommissionRepository _visaCommissionRep;
  106. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  107. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  108. private readonly List<CurrencyInfo> _currencyInit;
  109. private readonly List<int> _portTypeData;
  110. public GroupsController(
  111. ILogger<GroupsController> logger,
  112. IMapper mapper,
  113. IHubContext<ChatHub, IChatClient> hubContext,
  114. SqlSugarClient sqlSugar,
  115. GrpScheduleRepository grpScheduleRep,
  116. DelegationInfoRepository groupRepository,
  117. TaskAssignmentRepository taskAssignmentRep,
  118. AirTicketResRepository airTicketResRep,
  119. DecreasePaymentsRepository decreasePaymentsRep,
  120. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  121. DelegationEnDataRepository delegationEnDataRep,
  122. EnterExitCostRepository enterExitCostRep,
  123. DelegationVisaRepository delegationVisaRep,
  124. MessageRepository message,
  125. VisaPriceRepository visaPriceRep,
  126. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  127. CheckBoxsRepository checkBoxs,
  128. GroupCostRepository GroupCostRepository,
  129. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  130. GroupCostParameterRepository GroupCostParameterRepository,
  131. HotelPriceRepository hotelPriceRep,
  132. CustomersRepository customersRep,
  133. SetDataRepository setDataRep,
  134. TourClientListRepository tourClientListRep,
  135. TeamRateRepository teamRateRep,
  136. UsersRepository usersRep, IJuHeApiService juHeApi,
  137. InvertedListRepository invertedListRep,
  138. VisaFeeInfoRepository visaFeeInfoRep,
  139. TicketBlackCodeRepository ticketBlackCodeRep,
  140. HotelInquiryRepository hotelInquiryRep,
  141. ThreeCodeRepository threeCodeRepository,
  142. FeeAuditRepository feeAuditRep,
  143. VisaCommissionRepository visaCommissionRep,
  144. ForeignReceivablesRepository ffrRep,
  145. OpinionaireRepository opinionaireRep
  146. )
  147. {
  148. _logger = logger;
  149. _mapper = mapper;
  150. _grpScheduleRep = grpScheduleRep;
  151. _groupRepository = groupRepository;
  152. _taskAssignmentRep = taskAssignmentRep;
  153. _airTicketResRep = airTicketResRep;
  154. _sqlSugar = sqlSugar;
  155. url = AppSettingsHelper.Get("ExcelBaseUrl");
  156. path = AppSettingsHelper.Get("ExcelBasePath");
  157. if (!System.IO.Directory.Exists(path))
  158. {
  159. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  160. }
  161. _decreasePaymentsRep = decreasePaymentsRep;
  162. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  163. _delegationEnDataRep = delegationEnDataRep;
  164. _enterExitCostRep = enterExitCostRep;
  165. _delegationVisaRep = delegationVisaRep;
  166. _message = message;
  167. _visaPriceRep = visaPriceRep;
  168. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  169. _checkBoxs = checkBoxs;
  170. _GroupCostRepository = GroupCostRepository;
  171. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  172. _GroupCostParameterRepository = GroupCostParameterRepository;
  173. _hotelPriceRep = hotelPriceRep;
  174. _customersRep = customersRep;
  175. _setDataRep = setDataRep;
  176. _tourClientListRep = tourClientListRep;
  177. _teamRateRep = teamRateRep;
  178. _hubContext = hubContext;
  179. _usersRep = usersRep;
  180. _juHeApi = juHeApi;
  181. _invertedListRep = invertedListRep;
  182. _visaFeeInfoRep = visaFeeInfoRep;
  183. _ticketBlackCodeRep = ticketBlackCodeRep;
  184. _hotelInquiryRep = hotelInquiryRep;
  185. _threeCodeRepository = threeCodeRepository;
  186. _feeAuditRep = feeAuditRep;
  187. _visaCommissionRep = visaCommissionRep;
  188. _ffrRep = ffrRep;
  189. _opinionaireRep = opinionaireRep;
  190. _currencyInit = new List<CurrencyInfo>()
  191. {
  192. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  193. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  194. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  195. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  196. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  197. };
  198. _portTypeData = new List<int>() { 2, 3 };
  199. }
  200. #region 流程管控
  201. /// <summary>
  202. /// 获取团组流程管控信息
  203. /// </summary>
  204. /// <param name="paras">参数Json字符串</param>
  205. /// <returns></returns>
  206. [HttpPost]
  207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  208. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  209. {
  210. if (string.IsNullOrEmpty(_jsonDto.Paras))
  211. {
  212. return Ok(JsonView(false, "参数为空"));
  213. }
  214. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  215. if (_ScheduleDto != null)
  216. {
  217. if (_ScheduleDto.SearchType == 2)//获取列表
  218. {
  219. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  220. return Ok(JsonView(_grpScheduleViewList));
  221. }
  222. else//获取对象
  223. {
  224. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  225. if (_grpScheduleView != null)
  226. {
  227. return Ok(JsonView(_grpScheduleView));
  228. }
  229. }
  230. }
  231. else
  232. {
  233. return Ok(JsonView(false, "参数反序列化失败"));
  234. }
  235. return Ok(JsonView(false, "暂无数据!"));
  236. }
  237. /// <summary>
  238. /// 修改团组流程管控详细表数据
  239. /// </summary>
  240. /// <param name="paras"></param>
  241. /// <returns></returns>
  242. [HttpPost]
  243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  244. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  245. {
  246. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  247. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  248. .SetColumns(it => it.Duty == _detail.Duty)
  249. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  250. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  251. .SetColumns(it => it.JobContent == _detail.JobContent)
  252. .SetColumns(it => it.Remark == _detail.Remark)
  253. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  254. .Where(s => s.Id == dto.Id)
  255. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  256. .ExecuteCommandAsync();
  257. if (result > 0)
  258. {
  259. return Ok(JsonView(true, "保存成功!"));
  260. }
  261. return Ok(JsonView(false, "保存失败!"));
  262. }
  263. /// <summary>
  264. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  265. /// </summary>
  266. /// <param name="dto"></param>
  267. /// <returns></returns>
  268. [HttpPost]
  269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  270. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  271. {
  272. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  273. _detail.IsDel = 1;
  274. _detail.DeleteUserId = dto.Duty;
  275. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  276. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  277. .SetColumns(it => it.IsDel == _detail.IsDel)
  278. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  279. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  280. .Where(it => it.Id == dto.Id)
  281. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  282. //.WhereColumns(s => s.Id == dto.Id)
  283. .ExecuteCommandAsync();
  284. if (result > 0)
  285. {
  286. return Ok(JsonView(true, "删除成功!"));
  287. }
  288. return Ok(JsonView(false, "删除失败!"));
  289. }
  290. /// <summary>
  291. /// 增加团组流程管控详细表数据
  292. /// </summary>
  293. /// <param name="dto"></param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  298. {
  299. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  300. if (DateTime.Now < _detail.ExpectBeginDt)
  301. {
  302. _detail.StepStatus = 0;
  303. }
  304. else
  305. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  306. _detail.StepStatus = 1;
  307. }
  308. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  309. if (result > 0)
  310. {
  311. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  312. return Ok(JsonView(true, "添加成功!", _result));
  313. }
  314. return Ok(JsonView(false, "添加失败!"));
  315. }
  316. #endregion
  317. #region 团组基本信息
  318. /// <summary>
  319. /// 接团信息列表
  320. /// </summary>
  321. /// <param name="dto">团组列表请求dto</param>
  322. /// <returns></returns>
  323. [HttpPost]
  324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  325. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  326. {
  327. var groupData = await _groupRepository.GetGroupList(dto);
  328. if (groupData.Code != 0)
  329. {
  330. return Ok(JsonView(false, groupData.Msg));
  331. }
  332. return Ok(JsonView(groupData.Data));
  333. }
  334. /// <summary>
  335. /// 分页查询团组列表
  336. /// </summary>
  337. /// <param name="dto"></param>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  342. {
  343. var watch = new Stopwatch();
  344. watch.Start();
  345. RefAsync<int> total = 0;
  346. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  347. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  348. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  349. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  350. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  351. .Distinct()
  352. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  353. watch.Stop();
  354. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  355. }
  356. /// <summary>
  357. /// 接团信息列表 Page
  358. /// </summary>
  359. /// <param name="dto">团组列表请求dto</param>
  360. /// <returns></returns>
  361. [HttpPost]
  362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  363. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  364. {
  365. #region 参数验证
  366. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  367. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  368. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  369. #region 页面操作权限验证
  370. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  371. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  372. #endregion
  373. #endregion
  374. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  375. {
  376. string sqlWhere = string.Empty;
  377. if (dto.IsSure == 0) //未完成
  378. {
  379. sqlWhere += string.Format(@" And IsSure = 0");
  380. }
  381. else if (dto.IsSure == 1) //已完成
  382. {
  383. sqlWhere += string.Format(@" And IsSure = 1");
  384. }
  385. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  386. {
  387. string tj = dto.SearchCriteria;
  388. 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}%')",
  389. tj, tj, tj, tj, tj);
  390. }
  391. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  392. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  393. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  394. JietuanOperator,IsSure,CreateTime,IsBid
  395. From (
  396. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  397. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  398. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  399. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  400. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  401. From Grp_DelegationInfo gdi
  402. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  403. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  404. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  405. Where gdi.IsDel = 0 {0}
  406. ) temp", sqlWhere);
  407. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  408. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  409. #region 处理所属部门
  410. /*
  411. * 1.sq 和 gyy 等显示 市场部
  412. * 2.王鸽和主管及张总还有管理员号统一国交部
  413. * 2-1. 4 管理员 ,21 张海麟
  414. */
  415. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  416. List<int> userIds1 = new List<int>() { 4, 21 };
  417. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  418. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  419. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  420. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  421. .ToList();
  422. foreach (var item in _DelegationList)
  423. {
  424. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  425. }
  426. #endregion
  427. var _view = new
  428. {
  429. PageFuncAuth = pageFunAuthView,
  430. Data = _DelegationList
  431. };
  432. return Ok(JsonView(true, "查询成功!", _view, total));
  433. }
  434. else
  435. {
  436. return Ok(JsonView(false, "查询失败"));
  437. }
  438. }
  439. /// <summary>
  440. /// 团组列表
  441. /// </summary>
  442. /// <returns></returns>
  443. [HttpPost]
  444. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  445. {
  446. #region 参数验证
  447. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  448. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  449. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  450. #region 页面操作权限验证
  451. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  452. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  453. #endregion
  454. #endregion
  455. if (dto.PortType != 1 && dto.PortType != 2)
  456. {
  457. return Ok(JsonView(false, "查询失败!"));
  458. }
  459. string orderbyStr = "order by gdi.CreateTime Desc";
  460. string sqlWhere = string.Empty;
  461. if (dto.IsSure == 0) //未完成
  462. {
  463. sqlWhere += string.Format(@" And IsSure = 0");
  464. }
  465. else if (dto.IsSure == 1) //已完成
  466. {
  467. sqlWhere += string.Format(@" And IsSure = 1");
  468. }
  469. //团组类型
  470. if (dto.TeamDid > 0)
  471. {
  472. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  473. }
  474. //团组名称
  475. if (!string.IsNullOrEmpty(dto.TeamName))
  476. {
  477. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  478. }
  479. //客户名称
  480. if (!string.IsNullOrEmpty(dto.ClientName))
  481. {
  482. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  483. }
  484. //客户单位
  485. if (!string.IsNullOrEmpty(dto.ClientUnit))
  486. {
  487. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  488. }
  489. //出访时间
  490. if (!string.IsNullOrEmpty(dto.visitDataTime))
  491. {
  492. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  493. orderbyStr = "order by gdi.VisitDate";
  494. }
  495. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  496. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  497. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  498. JietuanOperator,IsSure,CreateTime
  499. From (
  500. Select row_number() over({0}) as Row_Number,
  501. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  502. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  503. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  504. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  505. From Grp_DelegationInfo gdi
  506. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  507. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  508. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  509. Where gdi.IsDel = 0 {1}
  510. ) temp ", orderbyStr, sqlWhere);
  511. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  512. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  513. #region 处理所属部门
  514. /*
  515. * 1.sq 和 gyy 等显示 市场部
  516. * 2.王鸽和主管及张总还有管理员号统一国交部
  517. * 2-1. 4 管理员 ,21 张海麟
  518. */
  519. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  520. List<int> userIds1 = new List<int>() { 4, 21 };
  521. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  522. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  523. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  524. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  525. .ToList();
  526. foreach (var item in _DelegationList)
  527. {
  528. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  529. }
  530. #endregion
  531. var _view = new
  532. {
  533. PageFuncAuth = pageFunAuthView,
  534. Data = _DelegationList
  535. };
  536. return Ok(JsonView(true, "查询成功!", _view, total));
  537. }
  538. /// <summary>
  539. /// 接团信息详情
  540. /// </summary>
  541. /// <param name="dto">团组info请求dto</param>
  542. /// <returns></returns>
  543. [HttpPost]
  544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  545. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  546. {
  547. var groupData = await _groupRepository.GetGroupInfo(dto);
  548. if (groupData.Code != 0)
  549. {
  550. return Ok(JsonView(false, groupData.Msg));
  551. }
  552. return Ok(JsonView(groupData.Data));
  553. }
  554. /// <summary>
  555. /// 接团信息 编辑添加
  556. /// 基础信息数据源
  557. /// </summary>
  558. /// <param name="dto"></param>
  559. /// <returns></returns>
  560. [HttpPost]
  561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  562. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  563. {
  564. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  565. if (groupData.Code != 0)
  566. {
  567. return Ok(JsonView(false, groupData.Msg));
  568. }
  569. return Ok(JsonView(groupData.Data));
  570. }
  571. /// <summary>
  572. /// 接团信息 操作(增改)
  573. /// </summary>
  574. /// <param name="dto"></param>
  575. /// <returns></returns>
  576. [HttpPost]
  577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  578. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  579. {
  580. try
  581. {
  582. decimal ffrPrice = 0.00M;
  583. DateTime? visitDt = null;
  584. if (dto.Status == 2)
  585. {
  586. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  587. if (groupInfo != null)
  588. {
  589. ffrPrice = groupInfo.PaymentMoney;
  590. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  591. }
  592. }
  593. var groupData = await _groupRepository.GroupOperation(dto);
  594. if (groupData.Code != 0)
  595. {
  596. return Ok(JsonView(false, groupData.Msg));
  597. }
  598. int diId = 0;
  599. //添加时 默认加入团组汇率
  600. if (dto.Status == 1) //添加
  601. {
  602. diId = groupData.Data;
  603. //添加默认币种
  604. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  605. //默认分配权限
  606. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  607. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  608. var _managerIds = new List<int>() { 22, 32, 21 };
  609. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  610. if (userIds.Count > 0)
  611. {
  612. userIds.Add(208);
  613. //创建团组管控
  614. GroupStepForDelegation.CreateWorkStep(diId);
  615. //发送消息
  616. string groupName = dto.TeamName;
  617. string createGroupUser = string.Empty;
  618. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  619. if (userInfo != null) createGroupUser = userInfo.CnName;
  620. string title = $"系统通知";
  621. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  622. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  623. }
  624. //默认创建倒推表
  625. await _invertedListRep._Create(dto.UserId, diId);
  626. }
  627. else if (dto.Status == 2)
  628. {
  629. diId = dto.Id;
  630. }
  631. #region 签证人员团组时间通知
  632. #region 计算出访起止时间
  633. var startTime = new DateTime();
  634. var endTime = new DateTime();
  635. if (DateTime.TryParse(dto.VisitDate, out startTime))
  636. {
  637. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  638. }
  639. #endregion
  640. if (diId > 0)
  641. {
  642. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  643. }
  644. #endregion
  645. #region 团组操作默认添加/修改收款账单
  646. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  647. {
  648. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  649. .Where(x => x.IsDel == 0 &&
  650. x.Diid == diId &&
  651. x.Remark.Equals("预付款")
  652. )
  653. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  654. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  655. .FirstAsync();
  656. ffrInfo = new Fin_ForeignReceivables()
  657. {
  658. Diid = diId,
  659. PriceName = dto.ClientUnit,
  660. Price = dto.PaymentMoney,
  661. Count = 1,
  662. Unit = $"元",
  663. ItemSumPrice = dto.PaymentMoney,
  664. Rate = 1.0000M,
  665. Currency = 836,
  666. AddingWay = 0,
  667. CreateUserId = dto.UserId,
  668. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  669. Remark = $"预付款"
  670. };
  671. if (ffrInfo == null) //Add
  672. {
  673. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  674. }
  675. else //修改
  676. {
  677. await _sqlSugar.Updateable(ffrInfo)
  678. .UpdateColumns(x => new
  679. {
  680. x.PriceName,
  681. x.Price,
  682. x.ItemSumPrice,
  683. x.CreateTime,
  684. x.CreateUserId
  685. })
  686. .WhereColumns(x => x.Id)
  687. .ExecuteCommandAsync();
  688. }
  689. }
  690. #endregion
  691. return Ok(JsonView(true, "操作成功!", diId));
  692. }
  693. catch (Exception ex)
  694. {
  695. Logs("[response]" + JsonConvert.SerializeObject(dto));
  696. Logs(ex.Message);
  697. return Ok(JsonView(false, ex.Message));
  698. }
  699. }
  700. /// <summary>
  701. /// 接团流程操作(增改)
  702. /// 安卓端使用 建团时添加客户名单
  703. /// </summary>
  704. /// <param name="dto"></param>
  705. /// <returns></returns>
  706. [HttpPost]
  707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  708. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  709. {
  710. try
  711. {
  712. #region 参数验证
  713. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  714. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  715. #region 页面操作权限验证
  716. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  717. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  718. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  719. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  720. #endregion
  721. #endregion
  722. _sqlSugar.BeginTran();
  723. decimal ffrPrice = 0.00M;
  724. DateTime? visitDt = null;
  725. if (dto.Status == 2)
  726. {
  727. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  728. if (groupInfo != null)
  729. {
  730. ffrPrice = groupInfo.PaymentMoney;
  731. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  732. }
  733. }
  734. var _dto = new GroupOperationDto();
  735. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  736. var groupData = await _groupRepository.GroupOperation(_dto);
  737. if (groupData.Code != 0)
  738. {
  739. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  740. }
  741. int diId = 0;
  742. //添加时 默认加入团组汇率
  743. if (dto.Status == 1) //添加
  744. {
  745. diId = groupData.Data;
  746. //添加默认币种
  747. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  748. //默认分配权限
  749. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  750. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  751. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  752. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  753. if (userIds.Count > 0)
  754. {
  755. userIds.Add(208);
  756. //创建团组管控
  757. GroupStepForDelegation.CreateWorkStep(diId);
  758. //发送消息
  759. string groupName = dto.TeamName;
  760. string createGroupUser = string.Empty;
  761. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  762. if (userInfo != null) createGroupUser = userInfo.CnName;
  763. string title = $"系统通知";
  764. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  765. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  766. }
  767. #region 应用推送
  768. try
  769. {
  770. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  771. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  772. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  773. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  774. {
  775. List<string> userList = new List<string>() { users.QiyeChatUserId };
  776. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  777. }
  778. }
  779. catch (Exception ex)
  780. {
  781. }
  782. #endregion
  783. //默认创建倒推表
  784. await _invertedListRep._Create(dto.UserId, diId);
  785. }
  786. if (dto.Status == 2)
  787. {
  788. diId = dto.Id;
  789. if (diId == 0)
  790. {
  791. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  792. }
  793. }
  794. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  795. if (viewData.Code != 0)
  796. {
  797. _sqlSugar.RollbackTran();
  798. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  799. }
  800. #region 团组操作默认添加/修改收款账单
  801. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  802. {
  803. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  804. .Where(x => x.IsDel == 0 &&
  805. x.Diid == diId &&
  806. x.Remark.Equals("预付款")
  807. )
  808. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  809. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  810. .FirstAsync();
  811. ffrInfo = new Fin_ForeignReceivables()
  812. {
  813. Diid = diId,
  814. PriceName = dto.ClientUnit,
  815. Price = dto.PaymentMoney,
  816. Count = 1,
  817. Unit = $"元",
  818. ItemSumPrice = dto.PaymentMoney,
  819. Rate = 1.0000M,
  820. Currency = 836,
  821. AddingWay = 0,
  822. CreateUserId = dto.UserId,
  823. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  824. Remark = $"预付款"
  825. };
  826. if (ffrInfo == null) //Add
  827. {
  828. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  829. }
  830. else //修改
  831. {
  832. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  833. .UpdateColumns(x => new
  834. {
  835. x.PriceName,
  836. x.Price,
  837. x.ItemSumPrice,
  838. x.CreateTime,
  839. x.CreateUserId
  840. })
  841. .WhereColumns(x => x.Id)
  842. .ExecuteCommandAsync();
  843. }
  844. }
  845. #endregion
  846. #region 签证人员团组时间通知
  847. #region 计算出访起止时间
  848. var startTime = new DateTime();
  849. var endTime = new DateTime();
  850. if (DateTime.TryParse(dto.VisitDate, out startTime))
  851. {
  852. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  853. }
  854. #endregion
  855. if (diId > 0)
  856. {
  857. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  858. }
  859. #endregion
  860. _sqlSugar.CommitTran();
  861. return Ok(JsonView(true, "添加成功"));
  862. }
  863. catch (Exception ex)
  864. {
  865. _sqlSugar.RollbackTran();
  866. return Ok(JsonView(false, ex.Message));
  867. }
  868. }
  869. /// <summary>
  870. /// 接团信息 操作(删除)
  871. /// </summary>
  872. /// <param name="dto"></param>
  873. /// <returns></returns>
  874. [HttpPost]
  875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  876. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  877. {
  878. try
  879. {
  880. var groupData = await _groupRepository.GroupDel(dto);
  881. if (groupData.Code != 0)
  882. {
  883. return Ok(JsonView(false, groupData.Msg));
  884. }
  885. return Ok(JsonView(true));
  886. }
  887. catch (Exception ex)
  888. {
  889. Logs("[response]" + JsonConvert.SerializeObject(dto));
  890. Logs(ex.Message);
  891. return Ok(JsonView(false, ex.Message));
  892. }
  893. }
  894. /// <summary>
  895. /// 获取团组销售报价号
  896. /// 团组添加时 使用
  897. /// </summary>
  898. /// <returns></returns>
  899. [HttpPost]
  900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  901. public async Task<IActionResult> GetGroupSalesQuoteNo()
  902. {
  903. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  904. if (groupData.Code != 0)
  905. {
  906. return Ok(JsonView(false, groupData.Msg));
  907. }
  908. object salesQuoteNo = new
  909. {
  910. SalesQuoteNo = groupData.Data
  911. };
  912. return Ok(JsonView(salesQuoteNo));
  913. }
  914. /// <summary>
  915. /// 设置确认出团
  916. /// </summary>
  917. /// <param name="dto"></param>
  918. /// <returns></returns>
  919. [HttpPost]
  920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  921. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  922. {
  923. var groupData = await _groupRepository.ConfirmationGroup(dto);
  924. if (groupData.Code != 0)
  925. {
  926. return Ok(JsonView(false, groupData.Msg));
  927. }
  928. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  929. #region OA消息推送
  930. try
  931. {
  932. string groupName = groupInfo.TeamName;
  933. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  934. List<int> userIds = new List<int>();
  935. listUser.ForEach(s => userIds.Add(s.Id));
  936. string title = $"系统通知";
  937. string content = $"团组[{groupName}]已确认出团!";
  938. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  939. }
  940. catch (Exception ex)
  941. {
  942. }
  943. #endregion
  944. #region 应用推送
  945. try
  946. {
  947. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  948. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  949. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  950. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  951. {
  952. List<string> userList = new List<string>() { users.QiyeChatUserId };
  953. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  954. }
  955. }
  956. catch (Exception ex)
  957. {
  958. }
  959. #endregion
  960. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  961. return Ok(JsonView(true, "操作成功!", groupData.Data));
  962. }
  963. /// <summary>
  964. /// 获取团组名称data And 签证国别Data
  965. /// </summary>
  966. /// <param name="dto"></param>
  967. /// <returns></returns>
  968. [HttpPost]
  969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  970. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  971. {
  972. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  973. if (groupData.Code != 0)
  974. {
  975. return Ok(JsonView(false, groupData.Msg));
  976. }
  977. return Ok(JsonView(groupData.Data));
  978. }
  979. /// <summary>
  980. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  981. /// </summary>
  982. /// <returns></returns>
  983. [HttpPost]
  984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  985. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  986. {
  987. try
  988. {
  989. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  990. if (groupData.Code != 0)
  991. {
  992. return Ok(JsonView(false, groupData.Msg));
  993. }
  994. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  995. }
  996. catch (Exception ex)
  997. {
  998. return Ok(JsonView(false, "程序错误!"));
  999. throw;
  1000. }
  1001. }
  1002. /// <summary>
  1003. /// 团组清单 Excel
  1004. /// </summary>
  1005. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1006. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1007. /// <returns></returns>
  1008. [HttpGet]
  1009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1010. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1011. {
  1012. DateTime _beginDt, _endDt;
  1013. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1014. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1015. if (!beginBool && !endBool)
  1016. {
  1017. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1018. }
  1019. string sql = string.Format(@"
  1020. SELECT
  1021. ROW_NUMBER,
  1022. Id,
  1023. SalesQuoteNo,
  1024. TourCode,
  1025. TeamTypeId,
  1026. TeamType,
  1027. TeamLevId,
  1028. TeamLev,
  1029. TeamName,
  1030. ClientName,
  1031. ClientUnit,
  1032. VisitDate,
  1033. VisitDays,
  1034. VisitPNumber,
  1035. JietuanOperatorId,
  1036. JietuanOperator,
  1037. IsSure,
  1038. CreateTime,
  1039. IsBid
  1040. FROM
  1041. (
  1042. SELECT
  1043. ROW_NUMBER() OVER(
  1044. ORDER BY
  1045. gdi.CreateTime Desc
  1046. ) AS ROW_NUMBER,
  1047. gdi.Id,
  1048. SalesQuoteNo,
  1049. TourCode,
  1050. ssd.Id TeamTypeId,
  1051. ssd.Name TeamType,
  1052. ssd1.Id TeamLevId,
  1053. ssd1.Name TeamLev,
  1054. TeamName,
  1055. ClientName,
  1056. ClientUnit,
  1057. VisitDate,
  1058. VisitDays,
  1059. VisitPNumber,
  1060. JietuanOperator JietuanOperatorId,
  1061. su.CnName JietuanOperator,
  1062. IsSure,
  1063. gdi.CreateTime,
  1064. gdi.IsBid
  1065. FROM
  1066. Grp_DelegationInfo gdi
  1067. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1068. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1069. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1070. WHERE
  1071. gdi.IsDel = 0
  1072. AND gdi.IsBid = 0
  1073. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1074. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1075. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1076. #region 处理所属部门
  1077. /*
  1078. * 1.sq 和 gyy 等显示 市场部
  1079. * 2.王鸽和主管及张总还有管理员号统一国交部
  1080. * 2-1. 4 管理员 ,21 张海麟
  1081. */
  1082. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1083. List<int> userIds1 = new List<int>() { 4, 21 };
  1084. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1085. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1086. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1087. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1088. .ToListAsync();
  1089. foreach (var item in groupList)
  1090. {
  1091. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1092. }
  1093. #endregion
  1094. #region Excel
  1095. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1096. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1097. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1098. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1099. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1100. //载入模板
  1101. WorkbookDesigner designer = new WorkbookDesigner();
  1102. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1103. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1104. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1105. dt.TableName = "GroupList";
  1106. designer.SetDataSource(dt);
  1107. designer.Process();
  1108. if (!Directory.Exists(savePath))
  1109. {
  1110. Directory.CreateDirectory(savePath);
  1111. }
  1112. string serverPath = $"{savePath}{fileName}";
  1113. designer.Workbook.Save(serverPath);
  1114. string rst = $"{servicePath}{ftpPath}{fileName}";
  1115. #endregion
  1116. return Ok(JsonView(true, "操作成功!", rst));
  1117. }
  1118. #endregion
  1119. #region 团组&签证
  1120. /// <summary>
  1121. /// 根据团组Id获取签证客户信息List
  1122. /// </summary>
  1123. /// <param name="dto">请求dto</param>
  1124. /// <returns></returns>
  1125. [HttpPost]
  1126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1127. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1128. {
  1129. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1130. if (groupData.Code != 0)
  1131. {
  1132. return Ok(JsonView(false, groupData.Msg));
  1133. }
  1134. return Ok(JsonView(groupData.Data));
  1135. }
  1136. /// <summary>
  1137. /// IOS获取团组签证拍照上传进度01(团组列表)
  1138. /// </summary>
  1139. /// <param name="dto">请求dto</param>
  1140. /// <returns></returns>
  1141. [HttpPost]
  1142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1143. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1144. {
  1145. if (dto == null)
  1146. {
  1147. return Ok(JsonView(false, "参数为空"));
  1148. }
  1149. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1150. return Ok(JsonView(visaList));
  1151. }
  1152. /// <summary>
  1153. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1154. /// </summary>
  1155. /// <returns></returns>
  1156. [HttpPost]
  1157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1158. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1159. {
  1160. if (dto == null)
  1161. {
  1162. return Ok(JsonView(false, "请求错误:"));
  1163. }
  1164. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1165. return Ok(JsonView(list));
  1166. }
  1167. /// <summary>
  1168. /// IOS获取团组签证拍照上传进度03(相册)
  1169. /// </summary>
  1170. /// <returns></returns>
  1171. [HttpPost]
  1172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1173. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1174. {
  1175. if (dto == null)
  1176. {
  1177. return Ok(JsonView(false, "请求错误:"));
  1178. }
  1179. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1180. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1181. list.ForEach(s => s.url = url);
  1182. return Ok(JsonView(list));
  1183. }
  1184. /// <summary>
  1185. /// IOS获取团组签证拍照上传进度04(图片上传)
  1186. /// </summary>
  1187. /// <param name="dto"></param>
  1188. /// <returns></returns>
  1189. [HttpPost]
  1190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1191. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1192. {
  1193. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1194. //if (!string.IsNullOrEmpty(result))
  1195. //{
  1196. //}
  1197. //else {
  1198. // return Ok(JsonView(false, "上传失败"));
  1199. //}
  1200. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1201. int sucNum = 0;
  1202. try
  1203. {
  1204. foreach (var item in dto.base64DataList)
  1205. {
  1206. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1207. string result = decodeBase64ToImage(item, imageName);
  1208. if (!string.IsNullOrEmpty(result))
  1209. {
  1210. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1211. pic.CreateUserId = dto.CreateUserId;
  1212. pic.PicName = imageName;
  1213. pic.PicPath = result;
  1214. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1215. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1216. if (insertResult > 0)
  1217. {
  1218. sucNum++;
  1219. }
  1220. }
  1221. }
  1222. }
  1223. catch (Exception ex)
  1224. {
  1225. return Ok(JsonView(false, ex.Message));
  1226. }
  1227. string msg = string.Format(@"成功上传{0}张", sucNum);
  1228. return Ok(JsonView(true, msg));
  1229. }
  1230. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1231. {
  1232. string filename = "";//声明一个string类型的相对路径
  1233. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1234. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1235. try//会有异常抛出,try,catch一下
  1236. {
  1237. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1238. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1239. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1240. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1241. //文件名称
  1242. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1243. //上传的文件的路径
  1244. string filePath = "";
  1245. if (!Directory.Exists(fileDir))
  1246. {
  1247. Directory.CreateDirectory(fileDir);
  1248. }
  1249. //上传的文件的路径
  1250. filePath = fileDir + filename;
  1251. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1252. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1253. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1254. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1255. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1256. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1257. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1258. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1259. bitmap.Dispose();
  1260. }
  1261. catch (Exception e)
  1262. {
  1263. string massage = e.Message;
  1264. Logs("IOS图片上传Error:" + massage);
  1265. //filename = e.Message;
  1266. }
  1267. return filename;//返回相对路径
  1268. }
  1269. /// <summary>
  1270. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1271. /// </summary>
  1272. /// <param name="dto"></param>
  1273. /// <returns></returns>
  1274. [HttpPost]
  1275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1276. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1277. {
  1278. if (dto == null)
  1279. {
  1280. return Ok(JsonView(false, "请求错误:"));
  1281. }
  1282. string msg = "参数错误";
  1283. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1284. {
  1285. try
  1286. {
  1287. //_delegationVisaRep.BeginTran();
  1288. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1289. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1290. .Where(s => s.Id == dto.visaProgressCustomerId)
  1291. .ExecuteCommandAsync();
  1292. if (updCount > 0 && dto.publishCode == 1)
  1293. {
  1294. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1295. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1296. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1297. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1298. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1299. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1300. if (groupData == null)
  1301. {
  1302. _delegationVisaRep.RollbackTran();
  1303. }
  1304. string title = string.Format(@"[签证进度更新]");
  1305. string content = string.Format(@"测试文本");
  1306. bool rst = await _message.AddMsg(new MessageDto()
  1307. {
  1308. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1309. IssuerId = dto.publisher,
  1310. Title = title,
  1311. Content = content,
  1312. ReleaseTime = DateTime.Now,
  1313. UIdList = new List<int> {
  1314. 234
  1315. }
  1316. });
  1317. if (rst)
  1318. {
  1319. return Ok(JsonView(true, "发送通知成功"));
  1320. }
  1321. }
  1322. //_delegationVisaRep.CommitTran();
  1323. }
  1324. catch (Exception)
  1325. {
  1326. //_delegationVisaRep.RollbackTran();
  1327. }
  1328. }
  1329. return Ok(JsonView(true, msg));
  1330. }
  1331. #endregion
  1332. #region 团组任务分配
  1333. /// <summary>
  1334. /// 团组任务分配初始化
  1335. /// </summary>
  1336. /// <param name="dto"></param>
  1337. /// <returns></returns>
  1338. [HttpPost]
  1339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1340. public async Task<IActionResult> GetTaskAssignmen()
  1341. {
  1342. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1343. if (groupData.Code != 0)
  1344. {
  1345. return Ok(JsonView(false, groupData.Msg));
  1346. }
  1347. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1348. }
  1349. /// <summary>
  1350. /// 团组任务分配查询
  1351. /// </summary>
  1352. /// <param name="dto"></param>
  1353. /// <returns></returns>
  1354. [HttpPost]
  1355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1356. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1357. {
  1358. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1359. if (groupData.Code != 0)
  1360. {
  1361. return Ok(JsonView(false, groupData.Msg));
  1362. }
  1363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1364. }
  1365. /// <summary>
  1366. /// 团组任务分配操作
  1367. /// </summary>
  1368. /// <param name="dto"></param>
  1369. /// <returns></returns>
  1370. [HttpPost]
  1371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1372. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1373. {
  1374. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1375. if (groupData.Code != 0)
  1376. {
  1377. return Ok(JsonView(false, groupData.Msg));
  1378. }
  1379. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1380. }
  1381. /// <summary>
  1382. /// 团组任务分配
  1383. /// 批量分配
  1384. /// 查询团组
  1385. /// </summary>
  1386. /// <param name="dto"></param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1391. {
  1392. //参数验证
  1393. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1394. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1395. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1396. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1397. }
  1398. /// <summary>
  1399. /// 团组任务分配
  1400. /// 批量分配
  1401. /// </summary>
  1402. /// <param name="dto"></param>
  1403. /// <returns></returns>
  1404. [HttpPost]
  1405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1406. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1407. {
  1408. //参数验证
  1409. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1410. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1411. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1412. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1413. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1414. }
  1415. #endregion
  1416. #region 团组费用审核
  1417. /// <summary>
  1418. /// 费用审核
  1419. /// 团组列表 Page
  1420. /// </summary>
  1421. /// <param name="_dto">团组列表请求dto</param>
  1422. /// <returns></returns>
  1423. [HttpPost]
  1424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1425. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1426. {
  1427. #region 参数验证
  1428. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1429. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1430. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1431. #region 页面操作权限验证
  1432. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1433. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1434. #endregion
  1435. #endregion
  1436. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1437. {
  1438. string sqlWhere = string.Empty;
  1439. if (_dto.IsSure == 0) //未完成
  1440. {
  1441. sqlWhere += string.Format(@" And IsSure = 0");
  1442. }
  1443. else if (_dto.IsSure == 1) //已完成
  1444. {
  1445. sqlWhere += string.Format(@" And IsSure = 1");
  1446. }
  1447. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1448. {
  1449. string tj = _dto.SearchCriteria;
  1450. 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}%')",
  1451. tj, tj, tj, tj, tj);
  1452. }
  1453. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1454. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1455. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1456. From (
  1457. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1458. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1459. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1460. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1461. From Grp_DelegationInfo gdi
  1462. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1463. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1464. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1465. Where gdi.IsDel = 0 {0}
  1466. ) temp ", sqlWhere);
  1467. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1468. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1469. var _view = new
  1470. {
  1471. PageFuncAuth = pageFunAuthView,
  1472. Data = _DelegationList
  1473. };
  1474. return Ok(JsonView(true, "查询成功!", _view, total));
  1475. }
  1476. else
  1477. {
  1478. return Ok(JsonView(false, "查询失败"));
  1479. }
  1480. }
  1481. /// <summary>
  1482. /// 获取团组费用审核
  1483. /// </summary>
  1484. /// <param name="paras">参数Json字符串</param>
  1485. /// <returns></returns>
  1486. [HttpPost]
  1487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1488. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1489. {
  1490. try
  1491. {
  1492. #region 参数验证
  1493. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1494. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1495. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1496. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1497. #region 页面操作权限验证
  1498. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1499. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1500. #endregion
  1501. #endregion
  1502. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1503. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1504. #region 费用清单
  1505. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1506. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1507. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1508. List<Grp_CreditCardPayment> entityList = _groupRepository
  1509. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1510. .Where(exp.ToExpression())
  1511. .ToList();
  1512. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1513. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1514. /*
  1515. * 76://酒店预订
  1516. */
  1517. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1518. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1519. .ToListAsync();
  1520. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1521. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1522. .ToListAsync();
  1523. /*
  1524. * 79://车/导游地接
  1525. */
  1526. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1527. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1528. .ToListAsync();
  1529. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1530. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1531. .ToListAsync();
  1532. /*
  1533. * 80: //签证
  1534. */
  1535. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1536. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1537. .ToListAsync();
  1538. /*
  1539. *81: //邀请/公务活动
  1540. */
  1541. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1542. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1543. .ToListAsync();
  1544. /*
  1545. * 82: //团组客户保险
  1546. */
  1547. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1548. /*
  1549. * Lable = 85 机票预订
  1550. */
  1551. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1552. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1553. .ToListAsync();
  1554. /*
  1555. * 85 机票预定
  1556. */
  1557. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1558. /*
  1559. * 98 其他款项
  1560. */
  1561. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1562. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1563. .ToListAsync();
  1564. /*
  1565. * 285:收款退还
  1566. */
  1567. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1568. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1569. .ToListAsync();
  1570. /*
  1571. * 1015: //超支费用
  1572. */
  1573. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1574. /*
  1575. * 币种信息
  1576. */
  1577. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1578. /*
  1579. * 车/导游地接 费用类型
  1580. */
  1581. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1582. /*
  1583. * 车/导游地接 费用类型
  1584. */
  1585. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1586. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1587. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1588. /*
  1589. * 用户信息
  1590. */
  1591. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1592. /*
  1593. * 费用模块
  1594. */
  1595. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1596. string priceModule = string.Empty;
  1597. if (sdPriceName != null)
  1598. {
  1599. priceModule = sdPriceName.Name;
  1600. }
  1601. /*
  1602. * 成本信息
  1603. */
  1604. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1605. decimal _groupRate = 0.0000M;
  1606. string _groupCurrencyCode = "-";
  1607. if (groupCost != null)
  1608. {
  1609. _groupRate = groupCost.Rate;
  1610. if (int.TryParse(groupCost.Currency, out int _currency))
  1611. {
  1612. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1613. }
  1614. else _groupCurrencyCode = groupCost.Currency;
  1615. }
  1616. string costContentSql = $"Select * From Grp_GroupCost";
  1617. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1618. //处理日期为空的天数
  1619. for (int i = 0; i < groupCostDetails.Count; i++)
  1620. if (i != 0)
  1621. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1622. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1623. /*
  1624. * 处理详情数据
  1625. */
  1626. foreach (var entity in entityList)
  1627. {
  1628. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1629. _detail.Id = entity.Id;
  1630. _detail.PriceName = priceModule;
  1631. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1632. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1633. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1634. //处理金额
  1635. if (entity.CTable == 1015)
  1636. {
  1637. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1638. if (czInfo != null)
  1639. {
  1640. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1641. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1642. }
  1643. }
  1644. /*
  1645. * 应付款金额
  1646. */
  1647. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1648. string PaymentCurrency_WaitPay = "Unknown";
  1649. string hotelCurrncyCode = "Unknown";
  1650. string hotelCurrncyName = "Unknown";
  1651. if (sdPaymentCurrency_WaitPay != null)
  1652. {
  1653. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1654. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1655. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1656. if (hotelCurrncyCode.Equals("CNY"))
  1657. {
  1658. entity.DayRate = 1.0000M;
  1659. }
  1660. }
  1661. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1662. /*
  1663. * 此次付款金额
  1664. */
  1665. decimal CurrPayStr = 0.00M,
  1666. OriginalCurrPay = 0.00M;
  1667. if (entity.PayPercentage == 0)
  1668. {
  1669. if (entity.PayThenMoney != 0)
  1670. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1671. }
  1672. else
  1673. {
  1674. if (entity.PayMoney != 0)
  1675. {
  1676. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1677. }
  1678. }
  1679. if (_dto.Label == 79)
  1680. {
  1681. string original = string.Empty;
  1682. if (hotelCurrncyCode.Equals("CNY"))
  1683. {
  1684. OriginalCurrPay = CurrPayStr;
  1685. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1686. }
  1687. else
  1688. {
  1689. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1690. //760 EUR(7600.00 CNY)
  1691. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1692. }
  1693. }
  1694. else
  1695. {
  1696. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1697. }
  1698. /*
  1699. * 剩余尾款
  1700. */
  1701. decimal BalanceStr = 0;
  1702. if (CurrPayStr != 0)
  1703. {
  1704. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1705. BalanceStr = 0;
  1706. else
  1707. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1708. }
  1709. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1710. /*
  1711. * Bus名称
  1712. */
  1713. _detail.BusName = "待增加";
  1714. /*
  1715. *费用所属
  1716. */
  1717. switch (entity.CTable)
  1718. {
  1719. case 76://酒店预订
  1720. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1721. if (hotelReservations != null)
  1722. {
  1723. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1724. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1725. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1726. string roomFeeStr = "", roomFeestr1 = "";
  1727. //是否比较房型价格
  1728. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1729. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1730. roomFeeStr += $"<br/>";
  1731. if (hotelReservations.SingleRoomPrice > 0)
  1732. {
  1733. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1734. __isSingle = true;
  1735. }
  1736. if (hotelReservations.DoubleRoomPrice > 0)
  1737. {
  1738. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1739. __isDouble = true;
  1740. }
  1741. if (hotelReservations.SuiteRoomPrice > 0)
  1742. {
  1743. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1744. __isSuite = true;
  1745. }
  1746. if (hotelReservations.OtherRoomPrice > 0)
  1747. {
  1748. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1749. __isOther = true;
  1750. }
  1751. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1752. else roomFeeStr += " 0.00 * 0";
  1753. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1754. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1755. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1756. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1757. /*
  1758. * 费用类型
  1759. * 1:房费
  1760. * 2:早餐
  1761. * 3:地税
  1762. * 4:城市税
  1763. * </summary>
  1764. */
  1765. //地税
  1766. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1767. if (governmentRentData != null)
  1768. {
  1769. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1770. governmentRentFee = governmentRentData.Price;
  1771. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1772. if (governmentRentCurrData != null)
  1773. {
  1774. governmentRentCode = governmentRentCurrData.Name;
  1775. governmentRentName = $"({governmentRentCurrData.Remark})";
  1776. }
  1777. }
  1778. //城市税
  1779. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1780. if (cityTaxData != null)
  1781. {
  1782. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1783. cityTaxFee = cityTaxData.Price;
  1784. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1785. if (cityTaxCurrData != null)
  1786. {
  1787. cityTaxCode = cityTaxCurrData.Name;
  1788. cityTaxName = $"({cityTaxCurrData.Remark})";
  1789. }
  1790. }
  1791. //酒店早餐
  1792. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1793. if (breakfastData != null)
  1794. {
  1795. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1796. breakfastFee = breakfastData.Price;
  1797. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1798. if (breakfastCurrData != null)
  1799. {
  1800. breakfastCode = breakfastCurrData.Name;
  1801. breakfastName = $"({breakfastCurrData.Remark})";
  1802. }
  1803. }
  1804. //房间费用
  1805. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1806. if (roomData != null)
  1807. {
  1808. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1809. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1810. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1811. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1812. roomFee = roomData.Price;
  1813. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1814. if (roomCurrData != null)
  1815. {
  1816. roomCode = roomCurrData.Name;
  1817. roomName = $"({roomCurrData.Remark})";
  1818. }
  1819. }
  1820. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1821. string hotelCostStr = "";
  1822. decimal hotelCsotTotal = 0.00M;
  1823. if (groupCost != null)
  1824. {
  1825. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1826. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1827. }
  1828. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1829. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1830. string hotelCost_day = "";
  1831. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1832. foreach (var item in hotelCostDetails1)
  1833. {
  1834. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1835. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1836. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1837. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1838. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1839. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1840. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1841. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1842. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1843. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1844. hotelCost_day += @$"<br/>";
  1845. }
  1846. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1847. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1848. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1849. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1850. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1851. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1852. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1853. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1854. $"房间说明: {hotelReservations.Remark} <br/>" +
  1855. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1856. $"{hotelBreakfastStr}" +
  1857. $"{hotelGovernmentRentStr}" +
  1858. $"{hotelCityTaxStr}";
  1859. _detail.PriceNameContent = hotelReservations.HotelName;
  1860. }
  1861. break;
  1862. case 79://车/导游地接
  1863. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1864. if (touristGuideGroundReservations != null)
  1865. {
  1866. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1867. {
  1868. _detail.BusName = touristGuideGroundReservations.BusName;
  1869. }
  1870. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1871. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1872. //if (isInt)
  1873. //{
  1874. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1875. // if (cityInfo != null)
  1876. // {
  1877. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1878. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1879. // if (carFeeItem != null)
  1880. // {
  1881. // nameContent += $@"({carFeeItem.Name})";
  1882. // }
  1883. // _detail.PriceNameContent = nameContent;
  1884. // }
  1885. //}
  1886. //else
  1887. //{
  1888. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1889. //}
  1890. var touristGuideGroundReservationsContents =
  1891. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1892. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1893. foreach (var item in touristGuideGroundReservationsContents)
  1894. {
  1895. string typeName = "Unknown";
  1896. string carCurrencyCode = "Unknown";
  1897. string carCurrencyName = "Unknown";
  1898. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1899. if (carTypeData != null) typeName = carTypeData.Name;
  1900. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1901. if (currencyData != null)
  1902. {
  1903. carCurrencyCode = currencyData.Name;
  1904. carCurrencyName = currencyData.Remark;
  1905. }
  1906. //op、成本 币种是否一致
  1907. bool IsCurrencyAgreement = false;
  1908. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1909. string opCostStr = string.Empty;
  1910. decimal opCostTypePrice = 0.00M;
  1911. #region 处理成本各项费用
  1912. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1913. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1914. if (opCost.Count > 0)
  1915. {
  1916. switch (item.SId)
  1917. {
  1918. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1919. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1920. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1921. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1922. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1923. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1924. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1925. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1926. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1927. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1928. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1929. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1930. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1931. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1932. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1933. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1934. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1935. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1936. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1937. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1938. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1939. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1940. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1941. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1942. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1943. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1944. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1945. }
  1946. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1947. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1948. }
  1949. #endregion
  1950. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1951. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1952. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1953. $"{opTypeStr} {opCostStr}<br/>" +
  1954. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1955. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1956. }
  1957. _detail.PriceMsgContent = priceMsg;
  1958. }
  1959. break;
  1960. case 80: //签证
  1961. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1962. if (visaInfo != null)
  1963. {
  1964. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1965. _detail.PriceNameContent = visaInfo.VisaDescription;
  1966. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1967. }
  1968. break;
  1969. case 81: //邀请/公务活动
  1970. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1971. if (_ioa != null)
  1972. {
  1973. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1974. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1975. sendCurrName = "Unknown", //快递费用币种 Name
  1976. sendCurrCode = "Unknown", //快递费用币种 Code
  1977. eventsCurrName = "Unknown", //公务活动费币种 Name
  1978. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1979. translateCurrName = "Unknown", //公务翻译费 Name
  1980. translateCurrCode = "Unknown"; //公务翻译费 Code
  1981. #region 处理费用币种
  1982. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1983. if (inviteCurrData != null)
  1984. {
  1985. inviteCurrName = inviteCurrData.Remark;
  1986. inviteCurrCode = inviteCurrData.Name;
  1987. }
  1988. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1989. if (sendCurrData != null)
  1990. {
  1991. sendCurrName = sendCurrData.Remark;
  1992. sendCurrCode = sendCurrData.Name;
  1993. }
  1994. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1995. if (eventsCurrData != null)
  1996. {
  1997. eventsCurrName = eventsCurrData.Remark;
  1998. eventsCurrCode = eventsCurrData.Name;
  1999. }
  2000. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2001. if (translateCurrData != null)
  2002. {
  2003. translateCurrName = translateCurrData.Remark;
  2004. translateCurrCode = translateCurrData.Name;
  2005. }
  2006. #endregion
  2007. _detail.PriceNameContent = _ioa.InviterArea;
  2008. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2009. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2010. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2011. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2012. $@"备注:" + _ioa.Remark + "<br/>";
  2013. }
  2014. break;
  2015. case 82: //团组客户保险
  2016. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2017. if (customers != null)
  2018. {
  2019. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2020. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2021. }
  2022. break;
  2023. case 85: //机票预订
  2024. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2025. if (jpRes != null)
  2026. {
  2027. string FlightsDescription = jpRes.FlightsDescription;
  2028. string PriceDescription = jpRes.PriceDescription;
  2029. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2030. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2031. }
  2032. break;
  2033. case 98://其他款项
  2034. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2035. if (gdpRes != null)
  2036. {
  2037. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2038. _detail.PriceNameContent = gdpRes.PriceName;
  2039. }
  2040. break;
  2041. case 285://收款退还
  2042. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2043. if (refundAndOtherMoney != null)
  2044. {
  2045. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2046. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2047. }
  2048. break;
  2049. case 751://酒店早餐
  2050. break;
  2051. case 1015://超支费用
  2052. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2053. if (groupExtraCost != null)
  2054. {
  2055. _detail.PriceNameContent = groupExtraCost.PriceName;
  2056. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2057. }
  2058. break;
  2059. default:
  2060. break;
  2061. }
  2062. /*
  2063. * 申请人
  2064. */
  2065. string operatorName = " - ";
  2066. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2067. if (_opUser != null)
  2068. {
  2069. operatorName = _opUser.CnName;
  2070. }
  2071. _detail.OperatorName = operatorName;
  2072. /*
  2073. * 审核人
  2074. */
  2075. string auditOperatorName = "Unknown";
  2076. if (entity.AuditGMOperate == 0)
  2077. auditOperatorName = " - ";
  2078. else if (entity.AuditGMOperate == 4)
  2079. auditOperatorName = "自动审核";
  2080. else
  2081. {
  2082. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2083. if (_adUser != null)
  2084. {
  2085. auditOperatorName = _adUser.CnName;
  2086. }
  2087. }
  2088. _detail.AuditOperatorName = auditOperatorName;
  2089. /*
  2090. * 超预算比例
  2091. */
  2092. string overBudgetStr = "";
  2093. if (entity.ExceedBudget == -1)
  2094. overBudgetStr = sdPriceName.Name + "尚无预算";
  2095. else if (entity.ExceedBudget == 0)
  2096. {
  2097. if (entity.CTable == 76 || entity.CTable == 79)
  2098. {
  2099. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2100. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2101. }
  2102. else
  2103. {
  2104. overBudgetStr = "未超预算";
  2105. }
  2106. }
  2107. else
  2108. overBudgetStr = entity.ExceedBudget.ToString("P");
  2109. _detail.OverBudget = overBudgetStr;
  2110. /*
  2111. * 已审核金额
  2112. */
  2113. decimal auditFee = 0.00M;
  2114. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2115. /*
  2116. * 费用总计
  2117. */
  2118. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2119. {
  2120. CurrencyId = entity.PaymentCurrency,
  2121. CurrencyName = PaymentCurrency_WaitPay,
  2122. AmountPayable = entity.PayMoney,
  2123. ThisPayment = OriginalCurrPay,
  2124. BalancePayment = BalanceStr,
  2125. AuditedFunds = auditFee
  2126. });
  2127. _detail.IsAuditGM = entity.IsAuditGM;
  2128. detailList.Add(_detail);
  2129. }
  2130. #endregion
  2131. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2132. /*
  2133. * 下方描述处理
  2134. */
  2135. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2136. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2137. if (ccpCurrencyPrice != null)
  2138. {
  2139. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2140. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2141. }
  2142. else
  2143. {
  2144. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2145. }
  2146. string amountPayableStr = string.Format(@"应付款总金额: ");
  2147. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2148. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2149. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2150. foreach (var item in nonDuplicat)
  2151. {
  2152. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2153. if (strs.Count > 0)
  2154. {
  2155. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2156. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2157. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2158. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2159. //单独处理此次付款金额
  2160. if (item.CurrencyId == 836) //人民币
  2161. {
  2162. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2163. }
  2164. else
  2165. {
  2166. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2167. }
  2168. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2169. //单独处理已审核费用
  2170. if (item.CurrencyId == 836) //人民币
  2171. {
  2172. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2173. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2174. }
  2175. else
  2176. {
  2177. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2178. }
  2179. }
  2180. }
  2181. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2182. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2183. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2184. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2185. var _view1 = new
  2186. {
  2187. PageFuncAuth = pageFunAuthView,
  2188. Data = _view
  2189. };
  2190. return Ok(JsonView(_view1));
  2191. }
  2192. catch (Exception ex)
  2193. {
  2194. return Ok(JsonView(false, ex.Message));
  2195. }
  2196. }
  2197. /// <summary>
  2198. /// 费用审核
  2199. /// 修改团组费用审核状态
  2200. /// </summary>
  2201. /// <param name="_dto">参数Json字符串</param>
  2202. /// <returns></returns>
  2203. [HttpPost]
  2204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2205. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2206. {
  2207. #region 参数验证
  2208. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2209. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2210. #endregion
  2211. #region 页面操作权限验证
  2212. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2213. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2214. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2215. #endregion
  2216. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2217. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2218. DateTime dtNow = DateTime.Now;
  2219. _groupRepository.BeginTran();
  2220. int rst = 0;
  2221. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2222. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2223. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2224. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2225. List<dynamic> msgDatas = new List<dynamic>();
  2226. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2227. foreach (var item in idList)
  2228. {
  2229. int CreditId = int.Parse(item);
  2230. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2231. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2232. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2233. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2234. .Where(s => s.Id == CreditId)
  2235. .ExecuteCommandAsync();
  2236. if (result < 1)
  2237. {
  2238. rst = -1;
  2239. _groupRepository.RollbackTran();
  2240. return Ok(JsonView(false, "操作失败并回滚!"));
  2241. }
  2242. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2243. if (creditData != null)
  2244. {
  2245. #region 应用通知配置
  2246. try
  2247. {
  2248. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2249. }
  2250. catch (Exception ex)
  2251. {
  2252. }
  2253. #endregion
  2254. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2255. string groupNameStr = string.Empty;
  2256. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2257. if (groupData != null) groupNameStr = groupData.TeamName;
  2258. string creditTypeStr = string.Empty;
  2259. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2260. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2261. string creditCurrency = string.Empty;
  2262. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2263. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2264. if (creditCurrency.Equals("CNY"))
  2265. {
  2266. creditData.DayRate = 1.0000M;
  2267. }
  2268. if (creditData.PayPercentage == 0.00M)
  2269. {
  2270. creditData.PayPercentage = 100M;
  2271. }
  2272. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2273. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2274. string msgContent = "";
  2275. if (creditCurrency.Equals("CNY"))
  2276. {
  2277. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2278. }
  2279. else
  2280. {
  2281. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2282. }
  2283. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2284. }
  2285. }
  2286. if (rst == 0)
  2287. {
  2288. _groupRepository.CommitTran();
  2289. foreach (var item in msgDatas)
  2290. {
  2291. //发送消息
  2292. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2293. }
  2294. #region 应用推送
  2295. try
  2296. {
  2297. foreach (var ccpId in dic_ccp_user.Keys)
  2298. {
  2299. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2300. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2301. }
  2302. }
  2303. catch (Exception)
  2304. {
  2305. }
  2306. #endregion
  2307. return Ok(JsonView(true, "操作成功!"));
  2308. }
  2309. return Ok(JsonView(false, "操作失败!"));
  2310. }
  2311. #endregion
  2312. #region 机票费用录入
  2313. /// <summary>
  2314. /// 机票录入当前登录人可操作团组
  2315. /// </summary>
  2316. /// <param name="dto"></param>
  2317. /// <returns></returns>
  2318. [HttpPost]
  2319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2320. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2321. {
  2322. try
  2323. {
  2324. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2325. if (groupData.Code != 0)
  2326. {
  2327. return Ok(JsonView(false, groupData.Msg));
  2328. }
  2329. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2330. }
  2331. catch (Exception ex)
  2332. {
  2333. return Ok(JsonView(false, "程序错误!"));
  2334. throw;
  2335. }
  2336. }
  2337. /// <summary>
  2338. /// 机票费用录入列表
  2339. /// </summary>
  2340. /// <param name="dto"></param>
  2341. /// <returns></returns>
  2342. [HttpPost]
  2343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2344. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2345. {
  2346. try
  2347. {
  2348. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2349. if (groupData.Code != 0)
  2350. {
  2351. return Ok(JsonView(false, groupData.Msg));
  2352. }
  2353. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2354. }
  2355. catch (Exception ex)
  2356. {
  2357. return Ok(JsonView(false, ex.Message));
  2358. throw;
  2359. }
  2360. }
  2361. /// <summary>
  2362. /// 根据id查询费用录入信息
  2363. /// </summary>
  2364. /// <param name="dto"></param>
  2365. /// <returns></returns>
  2366. [HttpPost]
  2367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2368. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2369. {
  2370. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2371. if (groupData.Code != 0)
  2372. {
  2373. return Ok(JsonView(false, groupData.Msg));
  2374. }
  2375. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2376. }
  2377. /// <summary>
  2378. /// 机票费用录入操作(Status:1.新增,2.修改)
  2379. /// </summary>
  2380. /// <param name="dto"></param>
  2381. /// <returns></returns>
  2382. [HttpPost]
  2383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2384. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2385. {
  2386. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2387. if (groupData.Code != 0)
  2388. {
  2389. return Ok(JsonView(false, groupData.Msg));
  2390. }
  2391. #region 应用推送
  2392. try
  2393. {
  2394. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2395. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2396. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2397. //2024-10-21 新增LZ UID
  2398. var userIds = new List<int>() { 21 };
  2399. string title = $"系统通知";
  2400. string content = "";
  2401. var diId = dto.AirTicketResOpData.DiId;
  2402. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2403. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2404. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2405. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2406. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2407. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2408. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2409. }
  2410. catch (Exception ex)
  2411. {
  2412. }
  2413. #endregion
  2414. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2415. }
  2416. /// <summary>
  2417. /// 根据舱位类型查询接团客户名单信息
  2418. /// </summary>
  2419. /// <param name="dto"></param>
  2420. /// <returns></returns>
  2421. [HttpPost]
  2422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2423. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2424. {
  2425. try
  2426. {
  2427. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2428. if (crm_Groups.Count != 0)
  2429. {
  2430. List<dynamic> Customer = new List<dynamic>();
  2431. foreach (var item in crm_Groups)
  2432. {
  2433. var data = new
  2434. {
  2435. Id = item.Id,
  2436. Pinyin = item.Pinyin,
  2437. Name = item.LastName + item.FirstName
  2438. };
  2439. Customer.Add(data);
  2440. }
  2441. return Ok(JsonView(true, "查询成功!", Customer));
  2442. }
  2443. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2444. }
  2445. catch (Exception ex)
  2446. {
  2447. return Ok(JsonView(false, "程序错误!"));
  2448. throw;
  2449. }
  2450. }
  2451. /// <summary>
  2452. /// 根据团号获取客户信息
  2453. /// </summary>
  2454. /// <param name="dto"></param>
  2455. /// <returns></returns>
  2456. [HttpPost]
  2457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2458. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2459. {
  2460. var jw = JsonView(false);
  2461. if (dto.DIID < 1)
  2462. {
  2463. jw.Msg += "请输入正确的diid";
  2464. return Ok(jw);
  2465. }
  2466. var arr = getSimplClientList(dto.DIID);
  2467. jw = JsonView(true, "获取成功!", arr);
  2468. return Ok(jw);
  2469. }
  2470. private List<SimplClientInfo> getSimplClientList(int diId)
  2471. {
  2472. 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);
  2473. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2474. return arr;
  2475. }
  2476. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2477. {
  2478. string result = origin;
  2479. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2480. {
  2481. string[] temparr = origin.Split(',');
  2482. string fistrStr = temparr[0];
  2483. int count = temparr.Count();
  2484. int tempId;
  2485. bool success = int.TryParse(fistrStr, out tempId);
  2486. if (success)
  2487. {
  2488. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2489. if (tempInfo != null)
  2490. {
  2491. if (count > 1)
  2492. {
  2493. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2494. }
  2495. else
  2496. {
  2497. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2498. }
  2499. }
  2500. }
  2501. }
  2502. return result;
  2503. }
  2504. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2505. {
  2506. string result = origin;
  2507. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2508. {
  2509. string[] temparr = origin.Split(',');
  2510. result = "";
  2511. foreach (var item in temparr)
  2512. {
  2513. int tempId;
  2514. bool success = int.TryParse(item, out tempId);
  2515. if (success)
  2516. {
  2517. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2518. if (tempInfo != null)
  2519. {
  2520. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2521. }
  2522. }
  2523. }
  2524. }
  2525. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2526. return result;
  2527. }
  2528. /// <summary>
  2529. /// 机票费用录入,删除
  2530. /// </summary>
  2531. /// <param name="dto"></param>
  2532. /// <returns></returns>
  2533. [HttpPost]
  2534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2535. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2536. {
  2537. try
  2538. {
  2539. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2540. if (res)
  2541. {
  2542. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2543. {
  2544. IsDel = 1,
  2545. DeleteUserId = dto.DeleteUserId,
  2546. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2547. }).ExecuteCommandAsync();
  2548. return Ok(JsonView(true, "删除成功!"));
  2549. }
  2550. return Ok(JsonView(false, "删除失败!"));
  2551. }
  2552. catch (Exception ex)
  2553. {
  2554. return Ok(JsonView(false, "程序错误!"));
  2555. throw;
  2556. }
  2557. }
  2558. /// <summary>
  2559. /// 导出机票录入报表
  2560. /// </summary>
  2561. /// <param name="dto"></param>
  2562. /// <returns></returns>
  2563. [HttpPost]
  2564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2565. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2566. {
  2567. try
  2568. {
  2569. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2570. if (groupData.Code != 0)
  2571. {
  2572. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2573. }
  2574. else
  2575. {
  2576. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2577. if (AirTicketReservations.Count != 0)
  2578. {
  2579. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2580. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2581. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2582. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2583. WorkbookDesigner designer = new WorkbookDesigner();
  2584. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2585. decimal countCost = 0;
  2586. foreach (var item in AirTicketReservations)
  2587. {
  2588. #region 处理客人姓名
  2589. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2590. item.ClientName = clientNames;
  2591. #endregion
  2592. if (item.BankType == "其他")
  2593. {
  2594. item.BankNo = "--";
  2595. }
  2596. else
  2597. {
  2598. if (!string.IsNullOrEmpty(item.BankType))
  2599. {
  2600. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2601. }
  2602. }
  2603. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2604. item.Price = System.Decimal.Round(item.Price, 2);
  2605. countCost += Convert.ToDecimal(item.Price);
  2606. }
  2607. designer.SetDataSource("Export", AirTicketReservations);
  2608. designer.SetDataSource("ExportDiCode", diCode);
  2609. designer.SetDataSource("ExportDiName", diName);
  2610. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2611. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2612. designer.Process();
  2613. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2614. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2615. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2616. return Ok(JsonView(true, "成功", url = rst));
  2617. }
  2618. else
  2619. {
  2620. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2621. }
  2622. }
  2623. }
  2624. catch (Exception ex)
  2625. {
  2626. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2627. throw;
  2628. }
  2629. }
  2630. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2631. /// <summary>
  2632. /// 行程单导出
  2633. /// </summary>
  2634. /// <param name="dto"></param>
  2635. /// <returns></returns>
  2636. [HttpPost]
  2637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2638. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2639. {
  2640. try
  2641. {
  2642. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2643. if (groupData.Code != 0)
  2644. {
  2645. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2646. }
  2647. else
  2648. {
  2649. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2650. if (dto.Language == "CN")
  2651. {
  2652. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2653. DocumentBuilder builder = new DocumentBuilder(doc);
  2654. int tableIndex = 0;//表格索引
  2655. //得到文档中的第一个表格
  2656. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2657. foreach (var item in _AirTicketReservations)
  2658. {
  2659. #region 处理固定数据
  2660. string[] FlightsCode = item.FlightsCode.Split('/');
  2661. if (FlightsCode.Length != 0)
  2662. {
  2663. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2664. if (_AirCompany != null)
  2665. {
  2666. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2667. }
  2668. else
  2669. {
  2670. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2671. }
  2672. }
  2673. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2674. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2675. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2676. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2677. string name = "";
  2678. foreach (string clientName in nameArray)
  2679. {
  2680. if (!name.Contains(clientName))
  2681. {
  2682. name += clientName + ",";
  2683. }
  2684. }
  2685. if (!string.IsNullOrWhiteSpace(name))
  2686. {
  2687. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2688. }
  2689. else
  2690. {
  2691. table.Range.Bookmarks["ClientName"].Text = "--";
  2692. }
  2693. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2694. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2695. table.Range.Bookmarks["JointTicket"].Text = "--";
  2696. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2697. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2698. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2699. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2700. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2701. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2702. #endregion
  2703. #region 循环数据处理
  2704. List<AirInfo> airs = new List<AirInfo>();
  2705. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2706. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2707. for (int i = 0; i < FlightsCode.Length; i++)
  2708. {
  2709. AirInfo air = new AirInfo();
  2710. string[] tempstr = DayArray[i]
  2711. .Replace("\r\n", string.Empty)
  2712. .Replace("\\r\\n", string.Empty)
  2713. .TrimStart().TrimEnd()
  2714. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2715. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2716. string starCity = "";
  2717. if (star_Three != null)
  2718. {
  2719. starCity = star_Three.AirPort;
  2720. }
  2721. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2722. string EndCity = "";
  2723. if (End_Three != null)
  2724. {
  2725. EndCity = End_Three.AirPort;
  2726. }
  2727. air.Destination = starCity + "/" + EndCity;
  2728. air.Flight = FlightsCode[i];
  2729. air.SeatingClass = item.CTypeName;
  2730. string dateTime = tempstr[2];
  2731. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2732. air.FlightDate = DateTemp;
  2733. air.DepartureTime = tempstr[5];
  2734. air.LandingTime = tempstr[6];
  2735. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2736. air.TicketStatus = "--";
  2737. air.Luggage = "--";
  2738. air.DepartureTerminal = "--";
  2739. air.LandingTerminal = "--";
  2740. airs.Add(air);
  2741. }
  2742. int row = 13;
  2743. for (int i = 0; i < airs.Count; i++)
  2744. {
  2745. if (airs.Count > 2)
  2746. {
  2747. for (int j = 0; j < airs.Count - 2; j++)
  2748. {
  2749. var CopyRow = table.Rows[12].Clone(true);
  2750. table.Rows.Add(CopyRow);
  2751. }
  2752. }
  2753. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2754. int index = 0;
  2755. foreach (PropertyInfo property in properties)
  2756. {
  2757. string value = property.GetValue(airs[i]).ToString();
  2758. Cell ishcel0 = table.Rows[row].Cells[index];
  2759. Paragraph p = new Paragraph(doc);
  2760. string s = value;
  2761. p.AppendChild(new Run(doc, s));
  2762. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2763. ishcel0.AppendChild(p);
  2764. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2765. index++;
  2766. }
  2767. row++;
  2768. }
  2769. #endregion
  2770. Paragraph lastParagraph = new Paragraph(doc);
  2771. //第一个表格末尾加段落
  2772. table.ParentNode.InsertAfter(lastParagraph, table);
  2773. //复制第一个表格
  2774. Table cloneTable = (Table)table.Clone(true);
  2775. //在文档末尾段落后面加入复制的表格
  2776. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2777. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2778. {
  2779. int rownewsIndex = 13;
  2780. for (int i = 0; i < 2; i++)
  2781. {
  2782. var CopyRow = table.Rows[12].Clone(true);
  2783. table.Rows.RemoveAt(13);
  2784. table.Rows.Add(CopyRow);
  2785. rownewsIndex++;
  2786. }
  2787. }
  2788. else
  2789. {
  2790. table.Rows.RemoveAt(12);
  2791. }
  2792. cloneTable.Rows.RemoveAt(12);
  2793. }
  2794. if (_AirTicketReservations.Count != 0)
  2795. {
  2796. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2797. if (FlightsCode.Length != 0)
  2798. {
  2799. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2800. if (_AirCompany != null)
  2801. {
  2802. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2803. }
  2804. else
  2805. {
  2806. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2807. }
  2808. }
  2809. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2810. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2811. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2812. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2813. string name = "";
  2814. foreach (string clientName in nameArray)
  2815. {
  2816. if (!name.Contains(clientName))
  2817. {
  2818. name += clientName + ",";
  2819. }
  2820. }
  2821. if (!string.IsNullOrWhiteSpace(name))
  2822. {
  2823. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2824. }
  2825. else
  2826. {
  2827. table.Range.Bookmarks["ClientName"].Text = "--";
  2828. }
  2829. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2830. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2831. table.Range.Bookmarks["JointTicket"].Text = "--";
  2832. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2833. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2834. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2835. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2836. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2837. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2838. }
  2839. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2840. //保存合并后的文档
  2841. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2842. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2843. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2844. return Ok(JsonView(true, "成功!", rst));
  2845. }
  2846. else
  2847. {
  2848. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2849. DocumentBuilder builder = new DocumentBuilder(doc);
  2850. int tableIndex = 0;//表格索引
  2851. //得到文档中的第一个表格
  2852. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2853. List<string> texts = new List<string>();
  2854. foreach (var item in _AirTicketReservations)
  2855. {
  2856. string[] FlightsCode = item.FlightsCode.Split('/');
  2857. if (FlightsCode.Length != 0)
  2858. {
  2859. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2860. if (_AirCompany != null)
  2861. {
  2862. if (!transDic.ContainsKey(_AirCompany.CnName))
  2863. {
  2864. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2865. }
  2866. }
  2867. else
  2868. {
  2869. if (!transDic.ContainsKey("--"))
  2870. {
  2871. transDic.Add("--", "--");
  2872. }
  2873. }
  2874. }
  2875. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2876. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2877. string name = "";
  2878. foreach (string clientName in nameArray)
  2879. {
  2880. name += clientName + ",";
  2881. }
  2882. if (!texts.Contains(name))
  2883. {
  2884. texts.Add(name);
  2885. }
  2886. List<AirInfo> airs = new List<AirInfo>();
  2887. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2888. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2889. for (int i = 0; i < FlightsCode.Length; i++)
  2890. {
  2891. AirInfo air = new AirInfo();
  2892. string[] tempstr = DayArray[i]
  2893. .Replace("\r\n", string.Empty)
  2894. .Replace("\\r\\n", string.Empty)
  2895. .TrimStart().TrimEnd()
  2896. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2897. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2898. if (star_Three != null)
  2899. {
  2900. if (!transDic.ContainsKey(star_Three.AirPort))
  2901. {
  2902. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2903. }
  2904. }
  2905. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2906. if (End_Three != null)
  2907. {
  2908. if (!transDic.ContainsKey(End_Three.AirPort))
  2909. {
  2910. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2911. }
  2912. }
  2913. if (!texts.Contains(item.CTypeName))
  2914. {
  2915. texts.Add(item.CTypeName);
  2916. }
  2917. }
  2918. }
  2919. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2920. if (transData.Count > 0)
  2921. {
  2922. foreach (TranslateResult item in transData)
  2923. {
  2924. if (!transDic.ContainsKey(item.Query))
  2925. {
  2926. transDic.Add(item.Query, item.Translation);
  2927. }
  2928. }
  2929. }
  2930. foreach (var item in _AirTicketReservations)
  2931. {
  2932. #region 处理固定数据
  2933. string[] FlightsCode = item.FlightsCode.Split('/');
  2934. if (FlightsCode.Length != 0)
  2935. {
  2936. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2937. if (_AirCompany != null)
  2938. {
  2939. string str = "--";
  2940. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2941. if (!string.IsNullOrEmpty(translateResult))
  2942. {
  2943. str = translateResult;
  2944. str = _airTicketResRep.Processing(str);
  2945. }
  2946. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2947. }
  2948. else
  2949. {
  2950. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2951. }
  2952. }
  2953. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2954. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2955. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2956. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2957. string names = "";
  2958. foreach (string clientName in nameArray)
  2959. {
  2960. names += clientName + ",";
  2961. }
  2962. if (!string.IsNullOrWhiteSpace(names))
  2963. {
  2964. string str = "--";
  2965. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2966. if (!string.IsNullOrEmpty(translateResult))
  2967. {
  2968. str = translateResult;
  2969. str = _airTicketResRep.Processing(str);
  2970. }
  2971. table.Range.Bookmarks["ClientName"].Text = str;
  2972. }
  2973. else
  2974. {
  2975. table.Range.Bookmarks["ClientName"].Text = "--";
  2976. }
  2977. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2978. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2979. table.Range.Bookmarks["JointTicket"].Text = "--";
  2980. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2981. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2982. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2983. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2984. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2985. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2986. #endregion
  2987. #region 循环数据处理
  2988. List<AirInfo> airs = new List<AirInfo>();
  2989. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2990. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2991. for (int i = 0; i < FlightsCode.Length; i++)
  2992. {
  2993. AirInfo air = new AirInfo();
  2994. string[] tempstr = DayArray[i]
  2995. .Replace("\r\n", string.Empty)
  2996. .Replace("\\r\\n", string.Empty)
  2997. .TrimStart().TrimEnd()
  2998. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2999. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3000. string starCity = "";
  3001. if (star_Three != null)
  3002. {
  3003. string str2 = "--";
  3004. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3005. if (!string.IsNullOrEmpty(translateResult2))
  3006. {
  3007. str2 = translateResult2;
  3008. str2 = _airTicketResRep.Processing(str2);
  3009. }
  3010. starCity = str2;
  3011. }
  3012. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3013. string EndCity = "";
  3014. if (End_Three != null)
  3015. {
  3016. string str1 = "--";
  3017. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3018. if (!string.IsNullOrEmpty(translateResult1))
  3019. {
  3020. str1 = translateResult1;
  3021. str1 = _airTicketResRep.Processing(str1);
  3022. }
  3023. EndCity = str1;
  3024. }
  3025. air.Destination = starCity + "/" + EndCity;
  3026. air.Flight = FlightsCode[i];
  3027. string str = "--";
  3028. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3029. if (!string.IsNullOrEmpty(translateResult))
  3030. {
  3031. str = translateResult;
  3032. str = _airTicketResRep.Processing(str);
  3033. }
  3034. air.SeatingClass = str;
  3035. string dateTime = tempstr[2];
  3036. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3037. air.FlightDate = DateTemp;
  3038. air.DepartureTime = tempstr[5];
  3039. air.LandingTime = tempstr[6];
  3040. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3041. air.TicketStatus = "--";
  3042. air.Luggage = "--";
  3043. air.DepartureTerminal = "--";
  3044. air.LandingTerminal = "--";
  3045. airs.Add(air);
  3046. }
  3047. int row = 13;
  3048. for (int i = 0; i < airs.Count; i++)
  3049. {
  3050. if (airs.Count > 2)
  3051. {
  3052. for (int j = 0; j < airs.Count - 2; j++)
  3053. {
  3054. var CopyRow = table.Rows[12].Clone(true);
  3055. table.Rows.Add(CopyRow);
  3056. }
  3057. }
  3058. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3059. int index = 0;
  3060. foreach (PropertyInfo property in properties)
  3061. {
  3062. string value = property.GetValue(airs[i]).ToString();
  3063. Cell ishcel0 = table.Rows[row].Cells[index];
  3064. Paragraph p = new Paragraph(doc);
  3065. string s = value;
  3066. p.AppendChild(new Run(doc, s));
  3067. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3068. ishcel0.AppendChild(p);
  3069. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3070. //ishcel0.CellFormat.VerticalAlignment=
  3071. index++;
  3072. }
  3073. row++;
  3074. }
  3075. #endregion
  3076. Paragraph lastParagraph = new Paragraph(doc);
  3077. //第一个表格末尾加段落
  3078. table.ParentNode.InsertAfter(lastParagraph, table);
  3079. //复制第一个表格
  3080. Table cloneTable = (Table)table.Clone(true);
  3081. //在文档末尾段落后面加入复制的表格
  3082. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3083. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3084. {
  3085. int rownewsIndex = 13;
  3086. for (int i = 0; i < 2; i++)
  3087. {
  3088. var CopyRow = table.Rows[12].Clone(true);
  3089. table.Rows.RemoveAt(13);
  3090. table.Rows.Add(CopyRow);
  3091. rownewsIndex++;
  3092. }
  3093. }
  3094. else
  3095. {
  3096. table.Rows.RemoveAt(12);
  3097. }
  3098. cloneTable.Rows.RemoveAt(12);
  3099. }
  3100. if (_AirTicketReservations.Count != 0)
  3101. {
  3102. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3103. if (FlightsCode.Length != 0)
  3104. {
  3105. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3106. if (_AirCompany != null)
  3107. {
  3108. string str = "--";
  3109. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3110. if (!string.IsNullOrEmpty(translateResult))
  3111. {
  3112. str = translateResult;
  3113. str = _airTicketResRep.Processing(str);
  3114. }
  3115. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3116. }
  3117. else
  3118. {
  3119. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3120. }
  3121. }
  3122. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3123. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3124. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3125. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3126. string names = "";
  3127. foreach (string clientName in nameArray)
  3128. {
  3129. names += clientName + ",";
  3130. }
  3131. if (!string.IsNullOrWhiteSpace(names))
  3132. {
  3133. string str = "--";
  3134. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3135. if (!string.IsNullOrEmpty(translateResult))
  3136. {
  3137. str = translateResult;
  3138. str = _airTicketResRep.Processing(str);
  3139. }
  3140. table.Range.Bookmarks["ClientName"].Text = str;
  3141. }
  3142. else
  3143. {
  3144. table.Range.Bookmarks["ClientName"].Text = "--";
  3145. }
  3146. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3147. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3148. table.Range.Bookmarks["JointTicket"].Text = "--";
  3149. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3150. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3151. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3152. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3153. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3154. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3155. }
  3156. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3157. //保存合并后的文档
  3158. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3159. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3160. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3161. return Ok(JsonView(true, "成功!", rst));
  3162. }
  3163. }
  3164. }
  3165. catch (Exception ex)
  3166. {
  3167. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3168. throw;
  3169. }
  3170. }
  3171. #endregion
  3172. #region 团组增减款项 --> 其他款项
  3173. /// <summary>
  3174. /// 团组增减款项下拉框绑定
  3175. /// </summary>
  3176. /// <param name="dto"></param>
  3177. /// <returns></returns>
  3178. [HttpPost]
  3179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3180. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3181. {
  3182. #region 参数验证
  3183. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3184. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3185. #endregion
  3186. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3187. }
  3188. /// <summary>
  3189. /// 根据团组Id查询团组增减款项
  3190. /// </summary>
  3191. /// <param name="dto"></param>
  3192. /// <returns></returns>
  3193. [HttpPost]
  3194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3195. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3196. {
  3197. #region 参数验证
  3198. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3199. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3200. #endregion
  3201. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3202. }
  3203. /// <summary>
  3204. /// 团组增减款项操作(Status:1.新增,2.修改)
  3205. /// </summary>
  3206. /// <param name="dto"></param>
  3207. /// <returns></returns>
  3208. [HttpPost]
  3209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3210. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3211. {
  3212. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3213. if (groupData.Code != 200)
  3214. {
  3215. return Ok(JsonView(false, groupData.Msg));
  3216. }
  3217. #region 应用推送
  3218. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3219. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3220. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3221. //自动审核
  3222. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3223. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3224. //2024-10-21 新增LZ UID
  3225. var userIds = new List<int>() { 21 };
  3226. string title = $"系统通知";
  3227. string content = "";
  3228. var diId = dto.DiId;
  3229. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3230. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3231. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3232. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3233. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3234. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3235. #endregion
  3236. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3237. }
  3238. /// <summary>
  3239. /// 团组增减款项操作 删除
  3240. /// </summary>
  3241. /// <param name="dto"></param>
  3242. /// <returns></returns>
  3243. [HttpPost]
  3244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3245. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3246. {
  3247. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3248. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3249. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3250. if (res.Code == 0)
  3251. {
  3252. return Ok(JsonView(true, "删除成功!"));
  3253. }
  3254. return Ok(JsonView(false, "删除失败!"));
  3255. }
  3256. /// <summary>
  3257. /// 根据团组增减款项Id查询
  3258. /// </summary>
  3259. /// <param name="dto"></param>
  3260. /// <returns></returns>
  3261. [HttpPost]
  3262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3263. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3264. {
  3265. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3266. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3267. }
  3268. /// <summary>
  3269. /// 查询供应商名称
  3270. /// </summary>
  3271. /// <param name="dto"></param>
  3272. /// <returns></returns>
  3273. [HttpPost]
  3274. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3275. {
  3276. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3277. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3278. ?? new List<Grp_DecreasePayments>();
  3279. dbResult = dbResult.Distinct(new
  3280. ProductComparer()).ToList();
  3281. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3282. {
  3283. x.Id,
  3284. x.SupplierAddress,
  3285. x.SupplierArea,
  3286. x.SupplierContact,
  3287. x.SupplierContactNumber,
  3288. x.SupplierEmail,
  3289. x.SupplierName,
  3290. x.SupplierSocialAccount,
  3291. x.SupplierTypeId,
  3292. }).ToList());
  3293. return Ok(jw);
  3294. }
  3295. /// <summary>
  3296. /// 团组增减款项 OTA匹配
  3297. /// </summary>
  3298. /// <param name="file"></param>
  3299. /// <returns></returns>
  3300. [HttpPost]
  3301. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3302. {
  3303. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3304. string fileName = file.FileName;
  3305. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3306. {
  3307. return Ok(JsonView(false, "请上传Excel文件!"));
  3308. }
  3309. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3310. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3311. if (!Directory.Exists(path))
  3312. {
  3313. Directory.CreateDirectory(path);
  3314. }
  3315. var filePath = @$"{path}/{fileName}";
  3316. //保存文件
  3317. using (FileStream fs = System.IO.File.Create(filePath))
  3318. {
  3319. file.CopyTo(fs);
  3320. fs.Flush();
  3321. }
  3322. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3323. //读取ExcelFile
  3324. DataTable dt = ConvertExcelToDataTable(filePath);
  3325. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3326. dt.TableName = "TB";
  3327. //修改table列名
  3328. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3329. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3330. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3331. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3332. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3333. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3334. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3335. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3336. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3337. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3338. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3339. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3340. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3341. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3342. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3343. var otaOrderNos = new List<string>();
  3344. foreach (DataRow item in dt.Rows)
  3345. {
  3346. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3347. }
  3348. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3349. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3350. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3351. .Select((dp, di) => new
  3352. {
  3353. dp.PriceName,
  3354. dp.OTAOrderNo,
  3355. dp.FeeTotal,
  3356. di.TeamName,
  3357. })
  3358. .ToListAsync();
  3359. foreach (DataRow item in dt.Rows)
  3360. {
  3361. var otaOrderNo = item["OTAOrderNo"].ToString();
  3362. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3363. if (oaData == null) continue;
  3364. item["GroupName"] = oaData.TeamName;
  3365. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3366. }
  3367. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3368. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3369. List<DataTable> datas = new List<DataTable>();
  3370. datas.Add(dt);
  3371. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3372. return Ok(JsonView(true, "操作成功", new { url = url }));
  3373. }
  3374. #region
  3375. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3376. {
  3377. // 创建Workbook对象
  3378. Workbook workbook = new Workbook(excelFilePath);
  3379. // 获取第一个工作表
  3380. Worksheet worksheet = workbook.Worksheets[0];
  3381. // 将工作表转换为DataTable
  3382. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3383. return dataTable;
  3384. }
  3385. #endregion
  3386. #endregion
  3387. #region 文件上传、删除
  3388. /// <summary>
  3389. /// region 文件上传 可以带参数
  3390. /// </summary>
  3391. /// <param name="file"></param>
  3392. /// <returns></returns>
  3393. [HttpPost]
  3394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3395. public async Task<IActionResult> UploadProject(IFormFile file)
  3396. {
  3397. //var TypeName = Request.Headers["TypeName"].ToString();
  3398. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3399. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3400. ////文件名称
  3401. //string projectFileName = file.FileName;
  3402. ////上传的文件的路径
  3403. //string filePath = $"{fileDir}/{projectFileName}";
  3404. //if (TypeName == "A")//A代表团组增减款项
  3405. //{
  3406. // filePath = fileDir + $@"\团组增减款项相关文件";
  3407. // if (!Directory.Exists(filePath))
  3408. // {
  3409. // Directory.CreateDirectory(filePath);
  3410. // }
  3411. // //上传的文件的路径
  3412. // filePath += $@"\{projectFileName}";
  3413. //}
  3414. //else if (TypeName == "B")//B代表商邀相关文件
  3415. //{
  3416. // //上传的文件的路径
  3417. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3418. // if (!Directory.Exists(filePath))
  3419. // {
  3420. // Directory.CreateDirectory(filePath);
  3421. // }
  3422. // //上传的文件的路径
  3423. // filePath = $@"\{projectFileName}";
  3424. //}
  3425. //try
  3426. //{
  3427. // using (FileStream fs = System.IO.File.Create(filePath))
  3428. // {
  3429. // file.CopyTo(fs);
  3430. // fs.Flush();
  3431. // }
  3432. //}
  3433. //catch (Exception ex)
  3434. //{
  3435. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3436. //}
  3437. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3438. try
  3439. {
  3440. var TypeName = Request.Headers["TypeName"].ToString();
  3441. if (file != null)
  3442. {
  3443. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3444. //文件名称
  3445. string projectFileName = file.FileName;
  3446. //上传的文件的路径
  3447. string filePath = $"{fileDir}/{projectFileName}";
  3448. if (TypeName == "A")//A代表团组增减款项
  3449. {
  3450. if (!Directory.Exists(fileDir))
  3451. {
  3452. Directory.CreateDirectory(fileDir);
  3453. }
  3454. //上传的文件的路径
  3455. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3456. }
  3457. else if (TypeName == "B")//B代表商邀相关文件
  3458. {
  3459. if (!Directory.Exists(fileDir))
  3460. {
  3461. Directory.CreateDirectory(fileDir);
  3462. }
  3463. //上传的文件的路径
  3464. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3465. }
  3466. using (FileStream fs = System.IO.File.Create(filePath))
  3467. {
  3468. file.CopyTo(fs);
  3469. fs.Flush();
  3470. }
  3471. return Ok(JsonView(true, "上传成功!", projectFileName));
  3472. }
  3473. else
  3474. {
  3475. return Ok(JsonView(false, "上传失败!"));
  3476. }
  3477. }
  3478. catch (Exception ex)
  3479. {
  3480. return Ok(JsonView(false, "程序错误!"));
  3481. }
  3482. }
  3483. /// <summary>
  3484. /// 删除指定文件
  3485. /// </summary>
  3486. /// <param name="dto"></param>
  3487. /// <returns></returns>
  3488. [HttpPost]
  3489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3490. public async Task<IActionResult> DelFile(DelFileDto dto)
  3491. {
  3492. try
  3493. {
  3494. var TypeName = Request.Headers["TypeName"].ToString();
  3495. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3496. string filePath = "";
  3497. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3498. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3499. int id = 0;
  3500. if (TypeName == "A")
  3501. {
  3502. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3503. // 删除该文件
  3504. System.IO.File.Delete(filePath);
  3505. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3506. .Where(a => a.Id == dto.Id)
  3507. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3508. .ExecuteCommandAsync();
  3509. }
  3510. else if (TypeName == "B")
  3511. {
  3512. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3513. // 删除该文件
  3514. System.IO.File.Delete(filePath);
  3515. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3516. if (info != null)
  3517. {
  3518. string[] files = new string[] { };
  3519. if (!string.IsNullOrEmpty(info.Attachment))
  3520. {
  3521. try
  3522. {
  3523. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3524. }
  3525. catch (Exception)
  3526. {
  3527. files = new List<string>() { info.Attachment }.ToArray();
  3528. }
  3529. }
  3530. if (files.Length > 0)
  3531. {
  3532. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3533. string filePath2 = string.Empty;
  3534. if (files1.Length > 0)
  3535. {
  3536. filePath2 = JsonConvert.SerializeObject(files1);
  3537. }
  3538. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3539. .Where(a => a.Id == dto.Id)
  3540. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3541. .ExecuteCommandAsync();
  3542. }
  3543. }
  3544. }
  3545. if (id != 0)
  3546. {
  3547. return Ok(JsonView(true, "成功!"));
  3548. }
  3549. else
  3550. {
  3551. return Ok(JsonView(false, "失败!"));
  3552. }
  3553. }
  3554. catch (Exception ex)
  3555. {
  3556. return Ok(JsonView(false, "程序错误!"));
  3557. throw;
  3558. }
  3559. }
  3560. /// <summary>
  3561. /// 文件上传多个文件 可以带参数
  3562. /// </summary>
  3563. /// <param name="file"></param>
  3564. /// <returns></returns>
  3565. [HttpPost]
  3566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3567. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3568. {
  3569. try
  3570. {
  3571. var TypeName = Request.Headers["TypeName"].ToString();
  3572. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3573. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3574. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3575. var filePahts = new List<string>();
  3576. foreach (var file in files)
  3577. {
  3578. //文件名称
  3579. string projectFileName = file.FileName;
  3580. //上传的文件的路径
  3581. string filePath = $"{fileDir}/{projectFileName}";
  3582. if (TypeName == "A")//A代表团组增减款项
  3583. {
  3584. if (!Directory.Exists(fileDir))
  3585. {
  3586. Directory.CreateDirectory(fileDir);
  3587. }
  3588. //上传的文件的路径
  3589. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3590. }
  3591. else if (TypeName == "B")//B代表商邀相关文件
  3592. {
  3593. if (!Directory.Exists(fileDir))
  3594. {
  3595. Directory.CreateDirectory(fileDir);
  3596. }
  3597. //上传的文件的路径
  3598. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3599. }
  3600. using (FileStream fs = System.IO.File.Create(filePath))
  3601. {
  3602. file.CopyTo(fs);
  3603. fs.Flush();
  3604. }
  3605. filePahts.Add(projectFileName);
  3606. }
  3607. return Ok(JsonView(true, "上传成功!", filePahts));
  3608. }
  3609. catch (Exception ex)
  3610. {
  3611. return Ok(JsonView(false, "程序错误!"));
  3612. }
  3613. }
  3614. #endregion
  3615. #region 商邀费用录入
  3616. /// <summary>
  3617. /// 根据团组Id查询商邀费用列表
  3618. /// </summary>
  3619. /// <param name="dto"></param>
  3620. /// <returns></returns>
  3621. [HttpPost]
  3622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3623. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3624. {
  3625. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3626. if (groupData.Code != 0)
  3627. {
  3628. return Ok(JsonView(false, groupData.Msg));
  3629. }
  3630. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3631. }
  3632. /// <summary>
  3633. /// 商邀费用列表
  3634. /// 下载文件
  3635. /// </summary>
  3636. /// <param name="dto"></param>
  3637. /// <returns></returns>
  3638. [HttpGet("{id}")]
  3639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3640. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3641. {
  3642. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3643. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3644. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3645. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3646. var filePaths = new List<string>();
  3647. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3648. try
  3649. {
  3650. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3651. }
  3652. catch (Exception ex)
  3653. {
  3654. filePaths.Add(info.Attachment);
  3655. }
  3656. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3657. for (int i = 0; i < filePaths.Count; i++)
  3658. {
  3659. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3660. }
  3661. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3662. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3663. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3664. {
  3665. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3666. {
  3667. foreach (string filePath in filePaths)
  3668. {
  3669. if (System.IO.File.Exists(filePath))
  3670. {
  3671. // 获取文件名
  3672. string fileName = Path.GetFileName(filePath);
  3673. // 将文件添加到ZIP归档中
  3674. zipArchive.CreateEntryFromFile(filePath, fileName);
  3675. }
  3676. }
  3677. }
  3678. }
  3679. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3680. }
  3681. /// <summary>
  3682. /// 商邀费用 Info Page 基础数据源
  3683. /// </summary>
  3684. /// <param name="dto"></param>
  3685. /// <returns></returns>
  3686. [HttpPost]
  3687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3688. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3689. {
  3690. try
  3691. {
  3692. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3693. if (groupData.Code != 0)
  3694. {
  3695. return Ok(JsonView(false, groupData.Msg));
  3696. }
  3697. return Ok(JsonView(true, "操作成功", groupData.Data));
  3698. }
  3699. catch (Exception ex)
  3700. {
  3701. return Ok(JsonView(false, ex.Message));
  3702. throw;
  3703. }
  3704. }
  3705. /// <summary>
  3706. /// 根据商邀费用ID查询C表和商邀费用数据
  3707. /// </summary>
  3708. /// <param name="dto"></param>
  3709. /// <returns></returns>
  3710. [HttpPost]
  3711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3712. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3713. {
  3714. try
  3715. {
  3716. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3717. if (groupData.Code != 0)
  3718. {
  3719. return Ok(JsonView(false, groupData.Msg));
  3720. }
  3721. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3722. }
  3723. catch (Exception ex)
  3724. {
  3725. return Ok(JsonView(false, ex.Message));
  3726. throw;
  3727. }
  3728. }
  3729. /// <summary>
  3730. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3731. /// </summary>
  3732. /// <param name="dto"></param>
  3733. /// <returns></returns>
  3734. [HttpPost]
  3735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3736. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3737. {
  3738. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3739. if (groupData.Code != 0)
  3740. {
  3741. return Ok(JsonView(false, groupData.Msg));
  3742. }
  3743. #region 应用推送
  3744. try
  3745. {
  3746. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3747. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3748. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3749. //2024-10-21 新增LZ UID
  3750. var userIds = new List<int>() { 21 };
  3751. string title = $"系统通知";
  3752. string content = "";
  3753. var diId = dto.DiId;
  3754. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3755. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3756. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3757. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3758. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3759. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3760. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3761. }
  3762. catch (Exception ex)
  3763. {
  3764. }
  3765. #endregion
  3766. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3767. }
  3768. /// <summary>
  3769. /// 商邀删除
  3770. /// </summary>
  3771. /// <param name="dto"></param>
  3772. /// <returns></returns>
  3773. [HttpPost]
  3774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3775. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3776. {
  3777. try
  3778. {
  3779. _sqlSugar.BeginTran();
  3780. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3781. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3782. {
  3783. IsDel = 1,
  3784. DeleteUserId = dto.DeleteUserId,
  3785. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3786. })
  3787. .Where(it => it.Id == dto.Id)
  3788. .ExecuteCommand();
  3789. if (res1 > 0)
  3790. {
  3791. int _diId = 0;
  3792. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3793. if (_ioaInfo != null)
  3794. {
  3795. _diId = _ioaInfo.DiId;
  3796. }
  3797. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3798. .SetColumns(a => new Grp_CreditCardPayment()
  3799. {
  3800. IsDel = 1,
  3801. DeleteUserId = dto.DeleteUserId,
  3802. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3803. })
  3804. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3805. .ExecuteCommand();
  3806. if (res2 > 0)
  3807. {
  3808. _sqlSugar.CommitTran();
  3809. return Ok(JsonView(true, "删除成功!"));
  3810. }
  3811. }
  3812. _sqlSugar.RollbackTran();
  3813. return Ok(JsonView(false, "删除失败"));
  3814. }
  3815. catch (Exception ex)
  3816. {
  3817. _sqlSugar.RollbackTran();
  3818. return Ok(JsonView(false, ex.Message));
  3819. }
  3820. }
  3821. /// <summary>
  3822. /// 团组模块文件上传
  3823. /// </summary>
  3824. /// <param name="dto"></param>
  3825. /// <returns></returns>
  3826. [HttpPost]
  3827. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3828. {
  3829. var jw = JsonView(false);
  3830. long M = 1024 * 1024;
  3831. if (dto.Files == null || dto.Files.Count == 0)
  3832. {
  3833. jw.Msg = "无文件信息!";
  3834. return Ok(jw);
  3835. }
  3836. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3837. {
  3838. jw.Msg = "文件大小超过20M!";
  3839. return Ok(jw);
  3840. }
  3841. //var nameSp = dto.File.FileName.Split(".");
  3842. //if (nameSp.Length < 2)
  3843. //{
  3844. // jw.Msg = "拓展名称有误!";
  3845. // return Ok(jw);
  3846. //}
  3847. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3848. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3849. //{
  3850. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3851. // return Ok(jw);
  3852. //}
  3853. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3854. if (Ctable == null)
  3855. {
  3856. jw.Msg = "Ctable指向有误!";
  3857. return Ok(jw);
  3858. }
  3859. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3860. if (groupInfo == null)
  3861. {
  3862. jw.Msg = "团组信息不存在!";
  3863. return Ok(jw);
  3864. }
  3865. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3866. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3867. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3868. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3869. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3870. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3871. try
  3872. {
  3873. if (!Directory.Exists(fileBase))
  3874. {
  3875. Directory.CreateDirectory(fileBase);
  3876. }
  3877. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3878. foreach (var fileStream in dto.Files)
  3879. {
  3880. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3881. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3882. {
  3883. Cid = dto.Cid,
  3884. CreateTime = DateTime.Now,
  3885. CreateUserId = dto.Userid,
  3886. Ctable = dto.Ctable,
  3887. Diid = dto.Diid,
  3888. IsDel = 0,
  3889. FilePath = saveFilePath,
  3890. FileName = fileStream.FileName
  3891. };
  3892. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3893. {
  3894. fileStream.CopyTo(fs);
  3895. fs.Flush();
  3896. }
  3897. saveArr.Add(file);
  3898. }
  3899. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3900. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3901. jw = JsonView(true, "保存成功!", new
  3902. {
  3903. count = addResult,
  3904. filesName = saveArr.Select(x => x.FileName)
  3905. });
  3906. }
  3907. catch (Exception ex)
  3908. {
  3909. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3910. {
  3911. count = 0,
  3912. filesName = new string[0],
  3913. });
  3914. }
  3915. return Ok(jw);
  3916. }
  3917. /// <summary>
  3918. /// 查询各模块已保存文件
  3919. /// </summary>
  3920. /// <param name="dto"></param>
  3921. /// <returns></returns>
  3922. [HttpPost]
  3923. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3924. {
  3925. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3926. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3927. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3928. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3929. {
  3930. expression = Expressionable.Create<Grp_GroupModelFile>()
  3931. .And(x => visaIds.Contains(x.CreateUserId));
  3932. }
  3933. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3934. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3935. .Where(expression.ToExpression())
  3936. .ToList();
  3937. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3938. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3939. {
  3940. x.FileName,
  3941. x.Id,
  3942. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3943. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3944. })));
  3945. }
  3946. /// <summary>
  3947. /// 下载该团组下的所有文件
  3948. /// </summary>
  3949. /// <param name="dto"></param>
  3950. /// <returns></returns>
  3951. [HttpPost]
  3952. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3953. {
  3954. var jw = JsonView(false);
  3955. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3956. if (groupInfo == null)
  3957. {
  3958. jw.Msg = "团组信息不存在!";
  3959. return Ok(jw);
  3960. }
  3961. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3962. var isModule = Convert.ToBoolean(dto.isModule);
  3963. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3964. IOOperatorHelper io = new IOOperatorHelper();
  3965. if (isModule)
  3966. {
  3967. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3968. foreach (var moduleArr in moduleGroup)
  3969. {
  3970. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3971. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3972. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3973. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3974. foreach (var item in moduleArr)
  3975. {
  3976. if (System.IO.File.Exists(item.FilePath))
  3977. {
  3978. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3979. {
  3980. byte[] bytes = new byte[fileStream.Length];
  3981. fileStream.Read(bytes, 0, bytes.Length);
  3982. fileStream.Close();
  3983. Stream stream = new MemoryStream(bytes);
  3984. chiZips.Add(item.FileName, stream);
  3985. }
  3986. }
  3987. }
  3988. if (chiZips.Count > 0)
  3989. {
  3990. var byts = io.ConvertZipStream(chiZips);
  3991. Stream stream = new MemoryStream(byts);
  3992. Zips.Add(key.Name + "_.zip", stream);
  3993. }
  3994. }
  3995. }
  3996. else
  3997. {
  3998. foreach (var item in dbQuery)
  3999. {
  4000. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4001. {
  4002. byte[] bytes = new byte[fileStream.Length];
  4003. fileStream.Read(bytes, 0, bytes.Length);
  4004. fileStream.Close();
  4005. Stream stream = new MemoryStream(bytes);
  4006. while (Zips.Keys.Contains(item.FileName))
  4007. {
  4008. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4009. }
  4010. Zips.Add(item.FileName, stream);
  4011. }
  4012. }
  4013. }
  4014. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4015. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4016. if (Zips.Count > 0)
  4017. {
  4018. var byts = io.ConvertZipStream(Zips);
  4019. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4020. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4021. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4022. }
  4023. else
  4024. {
  4025. jw.Msg = "暂无生成文件!";
  4026. }
  4027. return Ok(jw);
  4028. }
  4029. /// <summary>
  4030. /// 下载该团组下此模块的所有文件
  4031. /// </summary>
  4032. /// <param name="dto"></param>
  4033. /// <returns></returns>
  4034. [HttpPost]
  4035. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4036. {
  4037. var jw = JsonView(false);
  4038. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4039. if (groupInfo == null)
  4040. {
  4041. jw.Msg = "团组信息不存在!";
  4042. return Ok(jw);
  4043. }
  4044. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4045. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4046. && x.IsDel == 0);
  4047. if (key == null)
  4048. {
  4049. jw.Msg = "Ctable指向错误!";
  4050. return Ok(jw);
  4051. }
  4052. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4053. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4054. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4055. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4056. IOOperatorHelper io = new IOOperatorHelper();
  4057. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4058. foreach (var item in dbQuery)
  4059. {
  4060. if (System.IO.File.Exists(item.FilePath))
  4061. {
  4062. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4063. {
  4064. byte[] bytes = new byte[fileStream.Length];
  4065. fileStream.Read(bytes, 0, bytes.Length);
  4066. fileStream.Close();
  4067. Stream stream = new MemoryStream(bytes);
  4068. while (Zips.Keys.Contains(item.FileName))
  4069. {
  4070. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4071. }
  4072. Zips.Add(item.FileName, stream);
  4073. }
  4074. }
  4075. }
  4076. if (Zips.Count > 0)
  4077. {
  4078. var byts = io.ConvertZipStream(Zips);
  4079. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4080. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4081. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4082. }
  4083. else
  4084. {
  4085. jw.Msg = "暂无生成文件!";
  4086. }
  4087. return Ok(jw);
  4088. }
  4089. /// <summary>
  4090. /// 删除该团组下的指定文件
  4091. /// </summary>
  4092. /// <param name="dto"></param>
  4093. /// <returns></returns>
  4094. [HttpPost]
  4095. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4096. {
  4097. var jw = JsonView(false);
  4098. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4099. if (sing == null)
  4100. {
  4101. jw.Msg = "暂无";
  4102. return Ok(jw);
  4103. }
  4104. if (System.IO.File.Exists(sing.FilePath))
  4105. {
  4106. try
  4107. {
  4108. System.IO.File.Delete(sing.FilePath);
  4109. }
  4110. catch (Exception ex)
  4111. {
  4112. jw.Msg = "删除失败!" + ex.Message;
  4113. return Ok(jw);
  4114. }
  4115. }
  4116. sing.IsDel = 1;
  4117. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4118. sing.DeleteUserId = dto.UserId;
  4119. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4120. jw = JsonView(true, "删除成功!");
  4121. return Ok(jw);
  4122. }
  4123. #endregion
  4124. #region 团组英文资料
  4125. /// <summary>
  4126. /// 查询团组英文所有资料
  4127. /// </summary>
  4128. /// <param name="dto"></param>
  4129. /// <returns></returns>
  4130. [HttpPost]
  4131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4132. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4133. {
  4134. try
  4135. {
  4136. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4137. if (groupData.Code != 0)
  4138. {
  4139. return Ok(JsonView(false, groupData.Msg));
  4140. }
  4141. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4142. }
  4143. catch (Exception ex)
  4144. {
  4145. return Ok(JsonView(false, "程序错误!"));
  4146. throw;
  4147. }
  4148. }
  4149. /// <summary>
  4150. /// 团组英文资料操作(Status:1.新增,2.修改)
  4151. /// </summary>
  4152. /// <param name="dto"></param>
  4153. /// <returns></returns>
  4154. [HttpPost]
  4155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4156. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4157. {
  4158. try
  4159. {
  4160. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4161. if (groupData.Code != 0)
  4162. {
  4163. return Ok(JsonView(false, groupData.Msg));
  4164. }
  4165. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4166. }
  4167. catch (Exception ex)
  4168. {
  4169. return Ok(JsonView(false, "程序错误!"));
  4170. throw;
  4171. }
  4172. }
  4173. /// <summary>
  4174. /// 团组英文资料Id查询数据
  4175. /// </summary>
  4176. /// <param name="dto"></param>
  4177. /// <returns></returns>
  4178. [HttpPost]
  4179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4180. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4181. {
  4182. try
  4183. {
  4184. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4185. if (_DelegationEnData != null)
  4186. {
  4187. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4188. }
  4189. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4190. }
  4191. catch (Exception ex)
  4192. {
  4193. return Ok(JsonView(false, "程序错误!"));
  4194. throw;
  4195. }
  4196. }
  4197. /// <summary>
  4198. /// 团组英文资料删除
  4199. /// </summary>
  4200. /// <param name="dto"></param>
  4201. /// <returns></returns>
  4202. [HttpPost]
  4203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4204. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4205. {
  4206. try
  4207. {
  4208. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4209. if (!res)
  4210. {
  4211. return Ok(JsonView(false, "删除失败"));
  4212. }
  4213. return Ok(JsonView(true, "删除成功!"));
  4214. }
  4215. catch (Exception ex)
  4216. {
  4217. return Ok(JsonView(false, "程序错误!"));
  4218. throw;
  4219. }
  4220. }
  4221. #endregion
  4222. #region 导出邀请函
  4223. /// <summary>
  4224. /// 导出邀请函页面初始化
  4225. /// </summary>
  4226. /// <param name="dto"></param>
  4227. /// <returns></returns>
  4228. [HttpPost]
  4229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4230. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4231. {
  4232. try
  4233. {
  4234. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4235. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4236. if (dto.DiId == 0)
  4237. {
  4238. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4239. }
  4240. else
  4241. {
  4242. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4243. }
  4244. return Ok(JsonView(true, "查询成功!", new
  4245. {
  4246. deleClient = crm_Deles,
  4247. delegations = grp_Delegations
  4248. }));
  4249. }
  4250. catch (Exception ex)
  4251. {
  4252. return Ok(JsonView(false, "程序错误!"));
  4253. throw;
  4254. }
  4255. }
  4256. /// <summary>
  4257. /// 导出邀请函
  4258. /// </summary>
  4259. /// <param name="dto"></param>
  4260. /// <returns></returns>
  4261. [HttpPost]
  4262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4263. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4264. {
  4265. #region 参数验证
  4266. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4267. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4268. #endregion
  4269. try
  4270. {
  4271. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4272. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4273. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4274. From Grp_TourClientList tcl
  4275. Left Join
  4276. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4277. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4278. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4279. From Crm_DeleClient dc
  4280. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4281. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4282. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4283. Where dc.IsDel = 0) temp
  4284. On temp.DcId =tcl.ClientId
  4285. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4286. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4287. List<string> texts = new List<string>();
  4288. if (datas.Count != 0)
  4289. {
  4290. foreach (TourClientListDetailsView item in datas)
  4291. {
  4292. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4293. {
  4294. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4295. }
  4296. else
  4297. {
  4298. string name = item.LastName + item.FirstName;
  4299. texts.Add(name);
  4300. }
  4301. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4302. {
  4303. if (!transDic.ContainsKey(item.Job))
  4304. {
  4305. texts.Add(item.Job);
  4306. }
  4307. }
  4308. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4309. {
  4310. texts.Add(item.CompanyFullName);
  4311. }
  4312. }
  4313. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4314. if (transData.Count > 0)
  4315. {
  4316. foreach (TranslateResult item in transData)
  4317. {
  4318. if (!transDic.ContainsKey(item.Query))
  4319. {
  4320. transDic.Add(item.Query, item.Translation);
  4321. }
  4322. }
  4323. }
  4324. List<GuestList> list = new List<GuestList>();
  4325. foreach (TourClientListDetailsView dele in datas)
  4326. {
  4327. GuestList guestList = new GuestList();
  4328. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4329. {
  4330. guestList.Name = dele.Pinyin;
  4331. }
  4332. else
  4333. {
  4334. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4335. guestList.Name = Name;
  4336. }
  4337. if (dele.Sex == 0)
  4338. {
  4339. guestList.Sex = "Male";
  4340. }
  4341. else if (dele.Sex == 1)
  4342. {
  4343. guestList.Sex = "Female";
  4344. }
  4345. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4346. if (!string.IsNullOrEmpty(dele.Job))
  4347. {
  4348. guestList.Job = dele.Job;
  4349. }
  4350. list.Add(guestList);
  4351. }
  4352. //载入模板
  4353. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4354. DocumentBuilder builder = new DocumentBuilder(doc);
  4355. //获取word里所有表格
  4356. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4357. //获取所填表格的序数
  4358. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4359. var rowStart = tableOne.Rows[0]; //获取第1行
  4360. //循环赋值
  4361. for (int i = 0; i < list.Count; i++)
  4362. {
  4363. builder.MoveToCell(0, i + 1, 0, 0);
  4364. builder.Write(list[i].Name.ToString());
  4365. builder.MoveToCell(0, i + 1, 1, 0);
  4366. builder.Write(list[i].Sex.ToString());
  4367. builder.MoveToCell(0, i + 1, 2, 0);
  4368. builder.Write(list[i].DOB.ToString());
  4369. builder.MoveToCell(0, i + 1, 3, 0);
  4370. builder.Write(list[i].Job.ToString());
  4371. }
  4372. //删除多余行
  4373. while (tableOne.Rows.Count > list.Count + 1)
  4374. {
  4375. tableOne.Rows.RemoveAt(list.Count + 1);
  4376. }
  4377. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4378. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4379. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4380. doc.Save(filePath);
  4381. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4382. return Ok(JsonView(true, "操作成功!", Url));
  4383. }
  4384. else
  4385. {
  4386. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4387. }
  4388. }
  4389. catch (Exception ex)
  4390. {
  4391. return Ok(JsonView(false, ex.Message));
  4392. throw;
  4393. }
  4394. }
  4395. #endregion
  4396. #region 团组经理模块 出入境费用
  4397. ///// <summary>
  4398. ///// 团组模块 - 出入境费用
  4399. ///// </summary>
  4400. ///// <returns></returns>
  4401. //[HttpPost]
  4402. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4403. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4404. //{
  4405. // try
  4406. // {
  4407. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4408. // if (data.Code != 0)
  4409. // {
  4410. // return Ok(JsonView(false, data.Msg));
  4411. // }
  4412. // return Ok(JsonView(true, "查询成功!"));
  4413. // }
  4414. // catch (Exception ex)
  4415. // {
  4416. // return Ok(JsonView(false, ex.Message));
  4417. // throw;
  4418. // }
  4419. //}
  4420. /// <summary>
  4421. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4422. /// </summary>
  4423. /// <returns></returns>
  4424. [HttpPost]
  4425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4426. public async Task<IActionResult> SetDayAndCostAreaChange()
  4427. {
  4428. try
  4429. {
  4430. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4431. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4432. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4433. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4434. foreach (var item in unite) //处理交集数据
  4435. {
  4436. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4437. }
  4438. foreach (var item in merge) //处理差集数据
  4439. {
  4440. int nationalTravelFeeId = 0;
  4441. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4442. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4443. else
  4444. {
  4445. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4446. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4447. }
  4448. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4449. }
  4450. //只更新dayAndCost 的 nationalTravelFeeId;
  4451. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4452. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4453. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4454. }
  4455. catch (Exception ex)
  4456. {
  4457. return Ok(JsonView(false, ex.Message));
  4458. throw;
  4459. }
  4460. }
  4461. /// <summary>
  4462. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4463. /// </summary>
  4464. /// <returns></returns>
  4465. [HttpPost]
  4466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4467. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4468. {
  4469. try
  4470. {
  4471. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4472. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4473. //SetDataInfoView
  4474. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4475. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4476. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4477. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4478. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4479. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4480. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4481. //默认币种显示
  4482. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4483. {
  4484. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4485. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4486. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4487. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4488. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4489. };
  4490. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4491. if (_currencyRate.Count > 0)
  4492. {
  4493. foreach (var item in _currencyInfos)
  4494. {
  4495. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4496. if (rateInfo != null)
  4497. {
  4498. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4499. rate1 *= 1.035M;
  4500. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4501. }
  4502. }
  4503. }
  4504. return Ok(JsonView(true, "查询成功!", new
  4505. {
  4506. GroupNameData = groupNameData.Data,
  4507. CurrencyData = _CurrencyData,
  4508. WordTypeData = _WordTypeData,
  4509. ExcelTypeData = _ExcelTypeData,
  4510. CurrencyInit = _currencyInfos
  4511. }));
  4512. }
  4513. catch (Exception ex)
  4514. {
  4515. return Ok(JsonView(false, ex.Message));
  4516. throw;
  4517. }
  4518. }
  4519. /// <summary>
  4520. /// 团组模块 - 出入境费用
  4521. /// 实时汇率 tips
  4522. /// 签证费用 tips
  4523. /// 机票费用 tips
  4524. /// </summary>
  4525. /// <returns></returns>
  4526. [HttpPost]
  4527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4528. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4529. {
  4530. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4531. //默认币种显示
  4532. var _currencyInfos = _currencyInit;
  4533. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4534. List<dynamic> reteInfos = new List<dynamic>();
  4535. if (_currencyRate.Count > 0)
  4536. {
  4537. foreach (var item in _currencyInfos)
  4538. {
  4539. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4540. if (rateInfo != null)
  4541. {
  4542. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4543. decimal rate1 = item.Rate;
  4544. rate1 *= 1.03M;
  4545. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4546. reteInfos.Add(new
  4547. {
  4548. currCode = item.CurrencyCode,
  4549. currName = item.CurrencyName,
  4550. rate = rate2,
  4551. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4552. });
  4553. }
  4554. }
  4555. }
  4556. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4557. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4558. return Ok(JsonView(true, "查询成功!", new
  4559. {
  4560. //GroupNameData = groupNameData.Data,
  4561. visaData = visaData.Data,
  4562. airData = airData.Data,
  4563. reteInfos = reteInfos
  4564. }));
  4565. }
  4566. /// <summary>
  4567. /// 团组模块 - 出入境费用 - Info
  4568. /// </summary>
  4569. /// <returns></returns>
  4570. [HttpPost]
  4571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4572. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4573. {
  4574. try
  4575. {
  4576. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4577. if (data.Code != 0)
  4578. {
  4579. return Ok(JsonView(false, data.Msg));
  4580. }
  4581. return Ok(JsonView(true, "查询成功!", data.Data));
  4582. }
  4583. catch (Exception ex)
  4584. {
  4585. return Ok(JsonView(false, ex.Message));
  4586. }
  4587. }
  4588. /// <summary>
  4589. /// 团组模块 - 出入境费用 - Add And Update
  4590. /// </summary>
  4591. /// <returns></returns>
  4592. [HttpPost]
  4593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4594. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4595. {
  4596. try
  4597. {
  4598. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4599. if (dto.DayOtherPriceData.Any())
  4600. {
  4601. var inserList = dto.DayOtherPriceData
  4602. .Where(x => x.Id == 0)
  4603. .Select(x => new Grp_DayOtherPrice
  4604. {
  4605. Cost = x.Cost,
  4606. Id = x.Id,
  4607. CreateTime = DateTime.Now,
  4608. CreateUserId = dto.UserId,
  4609. Currency = x.Currency,
  4610. Diid = x.DiId,
  4611. Index = x.Index,
  4612. IsDel = 0,
  4613. SetDataId = x.SetDataId,
  4614. SubTotal = x.SubTotal,
  4615. Remark = x.Remark
  4616. })
  4617. .ToList();
  4618. var updateList = dto.DayOtherPriceData
  4619. .Where(x => x.Id != 0)
  4620. .Select(x => new Grp_DayOtherPrice
  4621. {
  4622. Cost = x.Cost,
  4623. Id = x.Id,
  4624. CreateTime = DateTime.Now,
  4625. CreateUserId = dto.UserId,
  4626. Currency = x.Currency,
  4627. Diid = x.DiId,
  4628. Index = x.Index,
  4629. IsDel = 0,
  4630. SetDataId = x.SetDataId,
  4631. SubTotal = x.SubTotal,
  4632. Remark = x.Remark
  4633. })
  4634. .ToList();
  4635. //添加
  4636. _sqlSugar.BeginTran();
  4637. if (inserList.Any())
  4638. {
  4639. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4640. }
  4641. if (updateList.Any())
  4642. {
  4643. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4644. }
  4645. _sqlSugar.CommitTran();
  4646. }
  4647. if (data.Code != 0)
  4648. {
  4649. return Ok(JsonView(false, data.Msg));
  4650. }
  4651. //生成默认文件pdf并且通知人员
  4652. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4653. {
  4654. DiId = dto.DiId,
  4655. ExportType = 1,
  4656. SubTypeId = 1005
  4657. }, "pdf");
  4658. //发送通知
  4659. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4660. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4661. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4662. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4663. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4664. //汇率信息记录
  4665. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4666. return Ok(JsonView(true, data.Msg, data.Data));
  4667. }
  4668. catch (Exception ex)
  4669. {
  4670. return Ok(JsonView(false, ex.Message));
  4671. }
  4672. }
  4673. /// <summary>
  4674. /// 团组模块 - 出入境费用 - Confirm 费用
  4675. /// </summary>
  4676. /// <returns></returns>
  4677. [HttpPost]
  4678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4679. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4680. {
  4681. //TODO:测试完毕需把对应的用户ID更改
  4682. //1、数据表添加字段
  4683. //2、更改字段接口()
  4684. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4685. //3、确认成功 给财务发送消息
  4686. if (_view.Code == 200)
  4687. {
  4688. if (dto.Type == 1)
  4689. {
  4690. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4691. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4692. }
  4693. }
  4694. return Ok(_view);
  4695. }
  4696. /// <summary>
  4697. /// 团组模块 - 出入境费用 - File downlaod
  4698. /// </summary>
  4699. /// <param name="dto"></param>
  4700. /// <returns></returns>
  4701. [HttpPost]
  4702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4703. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4704. {
  4705. try
  4706. {
  4707. if (dto.DiId < 1)
  4708. {
  4709. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4710. }
  4711. if (dto.ExportType < 1)
  4712. {
  4713. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4714. }
  4715. if (dto.SubTypeId < 1)
  4716. {
  4717. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4718. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4719. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4720. 3 团组成员名单 1 团组成员名单", ""));
  4721. }
  4722. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4723. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4724. if (_EnterExitCosts == null)
  4725. {
  4726. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4727. }
  4728. //数据源
  4729. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4730. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4731. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4732. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4733. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4734. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4735. .LeftJoin<Sys_SetData>((x, a, b) => a.IsDel == 0 && a.Id == x.Currency)
  4736. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4737. .Select((x, a, b) => new
  4738. {
  4739. x.Index,
  4740. itemName = a.Name,
  4741. CurrencyStr = b.Name,
  4742. x.Cost,
  4743. x.SubTotal,
  4744. x.Remark
  4745. })
  4746. .OrderBy((x) => x.Index)
  4747. .ToList(); //其他款项费用
  4748. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4749. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4750. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4751. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4752. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4753. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4754. .Select((tcl, dc, cc) => new
  4755. {
  4756. Name = dc.LastName + dc.FirstName,
  4757. Sex = dc.Sex,
  4758. Birthday = dc.BirthDay,
  4759. Company = cc.CompanyFullName,
  4760. Job = dc.Job
  4761. })
  4762. .ToList();
  4763. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4764. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4765. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4766. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4767. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4768. if (dto.ExportType == 1) //明细表
  4769. {
  4770. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4771. {
  4772. //获取模板
  4773. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4774. //载入模板
  4775. Document doc = new Document(tempPath);
  4776. DocumentBuilder builder = new DocumentBuilder(doc);
  4777. //利用键值对存放数据
  4778. Dictionary<string, string> dic = new Dictionary<string, string>();
  4779. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4780. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4781. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4782. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4783. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4784. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4785. //境内费用(其他费用)
  4786. if (_EnterExitCosts.ChoiceOne == 1)
  4787. {
  4788. string row1_1 = "";
  4789. if (_EnterExitCosts.Visa > 0)
  4790. {
  4791. //insidePayTotal += _EnterExitCosts.Visa;
  4792. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4793. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4794. {
  4795. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4796. }
  4797. }
  4798. string row1_2 = "";
  4799. if (_EnterExitCosts.YiMiao > 0)
  4800. {
  4801. //insidePayTotal += _EnterExitCosts.YiMiao;
  4802. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4803. }
  4804. if (_EnterExitCosts.HeSuan > 0)
  4805. {
  4806. //insidePayTotal += _EnterExitCosts.HeSuan;
  4807. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4808. }
  4809. if (_EnterExitCosts.Service > 0)
  4810. {
  4811. //insidePayTotal += _EnterExitCosts.Service;
  4812. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4813. }
  4814. string row1_3 = "";
  4815. if (_EnterExitCosts.Safe > 0)
  4816. {
  4817. //insidePayTotal += _EnterExitCosts.Safe;
  4818. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4819. }
  4820. if (_EnterExitCosts.Ticket > 0)
  4821. {
  4822. //insidePayTotal += _EnterExitCosts.Ticket;
  4823. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4824. }
  4825. string row1 = "";
  4826. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4827. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4828. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4829. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4830. dic.Add("Row1Str", row1);
  4831. }
  4832. string airTotalStr = string.Empty,
  4833. airPriceStr = string.Empty;
  4834. //经济舱
  4835. if (_EnterExitCosts.SumJJC == 1)
  4836. {
  4837. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4838. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4839. }
  4840. //公务舱
  4841. if (_EnterExitCosts.SumGWC == 1)
  4842. {
  4843. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4844. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4845. }
  4846. //头等舱
  4847. if (_EnterExitCosts.SumTDC == 1)
  4848. {
  4849. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4850. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4851. }
  4852. dic.Add("AirTotalStr", airTotalStr);
  4853. dic.Add("AirPriceStr", airPriceStr);
  4854. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4855. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4856. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4857. int table1Row = 0,
  4858. table2Row = 0,
  4859. table3Row = 0,
  4860. table4Row = 0,
  4861. table5Row = 0;
  4862. //住宿费
  4863. if (_EnterExitCosts.ChoiceThree == 1)
  4864. {
  4865. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4866. table1Row = dac1.Count;
  4867. #region 填充word表格内容
  4868. for (int i = 0; i < dac1.Count; i++)
  4869. {
  4870. Grp_DayAndCost dac = dac1[i];
  4871. if (dac == null) continue;
  4872. builder.MoveToCell(0, i, 0, 0);
  4873. builder.Write("第" + dac.Days.ToString() + "晚:");
  4874. builder.MoveToCell(0, i, 1, 0);
  4875. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4876. //builder.Write(dac.Place == null ? "" : dac.Place);
  4877. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4878. builder.MoveToCell(0, i, 2, 0);
  4879. builder.Write("费用标准:");
  4880. string curr = "";
  4881. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4882. if (currData != null)
  4883. {
  4884. curr = currData.Name;
  4885. }
  4886. builder.MoveToCell(0, i, 3, 0);
  4887. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4888. builder.MoveToCell(0, i, 4, 0);
  4889. builder.Write("费用小计:");
  4890. builder.MoveToCell(0, i, 5, 0);
  4891. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4892. }
  4893. #endregion
  4894. }
  4895. else dic.Add("SubZS", "0.00");
  4896. //删除多余行
  4897. while (table1.Rows.Count > table1Row)
  4898. {
  4899. table1.Rows.RemoveAt(table1Row);
  4900. }
  4901. //伙食费
  4902. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4903. if (_EnterExitCosts.ChoiceFour == 1)
  4904. {
  4905. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4906. table2Row = dac2.Count;
  4907. #region 填充word表格内容
  4908. for (int i = 0; i < dac2.Count; i++)
  4909. {
  4910. Grp_DayAndCost dac = dac2[i];
  4911. if (dac == null) continue;
  4912. builder.MoveToCell(1, i, 0, 0);
  4913. builder.Write("第" + dac.Days.ToString() + "天:");
  4914. builder.MoveToCell(1, i, 1, 0);
  4915. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4916. builder.MoveToCell(1, i, 2, 0);
  4917. builder.Write("费用标准:");
  4918. string curr = "";
  4919. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4920. if (currData != null)
  4921. {
  4922. curr = currData.Name;
  4923. }
  4924. builder.MoveToCell(1, i, 3, 0);
  4925. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4926. builder.MoveToCell(1, i, 4, 0);
  4927. builder.Write("费用小计:");
  4928. builder.MoveToCell(1, i, 5, 0);
  4929. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4930. }
  4931. #endregion
  4932. }
  4933. else dic.Add("SubHS", "0.00");
  4934. //删除多余行
  4935. while (table2.Rows.Count > table2Row)
  4936. {
  4937. table2.Rows.RemoveAt(table2Row);
  4938. }
  4939. //公杂费
  4940. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4941. if (_EnterExitCosts.ChoiceFive == 1)
  4942. {
  4943. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4944. table3Row = dac3.Count;
  4945. #region 填充word表格内容
  4946. for (int i = 0; i < dac3.Count; i++)
  4947. {
  4948. Grp_DayAndCost dac = dac3[i];
  4949. if (dac == null) continue;
  4950. builder.MoveToCell(2, i, 0, 0);
  4951. builder.Write("第" + dac.Days.ToString() + "天:");
  4952. builder.MoveToCell(2, i, 1, 0);
  4953. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4954. builder.MoveToCell(2, i, 2, 0);
  4955. builder.Write("费用标准:");
  4956. string curr = "";
  4957. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4958. if (currData != null)
  4959. {
  4960. curr = currData.Name;
  4961. }
  4962. builder.MoveToCell(2, i, 3, 0);
  4963. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4964. builder.MoveToCell(2, i, 4, 0);
  4965. builder.Write("费用小计:");
  4966. builder.MoveToCell(2, i, 5, 0);
  4967. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4968. }
  4969. //删除多余行
  4970. while (table3.Rows.Count > table3Row)
  4971. {
  4972. table3.Rows.RemoveAt(table3Row);
  4973. }
  4974. #endregion
  4975. }
  4976. else dic.Add("SubGZF", "0.00");
  4977. //删除多余行
  4978. while (table3.Rows.Count > table3Row)
  4979. {
  4980. table3.Rows.RemoveAt(table3Row);
  4981. }
  4982. //培训费
  4983. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4984. if (_EnterExitCosts.ChoiceSix == 1)
  4985. {
  4986. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4987. dic.Add("SubPX", pxStr);
  4988. table4Row = dac4.Count;
  4989. #region 填充word表格内容
  4990. for (int i = 0; i < dac4.Count; i++)
  4991. {
  4992. Grp_DayAndCost dac = dac4[i];
  4993. if (dac == null) continue;
  4994. builder.MoveToCell(3, i, 0, 0);
  4995. builder.Write("第" + dac.Days.ToString() + "天:");
  4996. builder.MoveToCell(3, i, 1, 0);
  4997. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4998. builder.MoveToCell(3, i, 2, 0);
  4999. builder.Write("费用标准:");
  5000. string curr = "";
  5001. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5002. if (currData != null)
  5003. {
  5004. curr = currData.Name;
  5005. }
  5006. builder.MoveToCell(3, i, 3, 0);
  5007. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5008. builder.MoveToCell(3, i, 4, 0);
  5009. builder.Write("费用小计:");
  5010. builder.MoveToCell(3, i, 5, 0);
  5011. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5012. }
  5013. #endregion
  5014. }
  5015. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5016. //删除多余行
  5017. while (table4.Rows.Count > table4Row)
  5018. {
  5019. table4.Rows.RemoveAt(table4Row);
  5020. }
  5021. //其他费用
  5022. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5023. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5024. {
  5025. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5026. dic.Add("titleQi", qtStr);
  5027. table5Row = dac5.Count;
  5028. #region 填充word表格内容
  5029. for (int i = 0; i < dac5.Count; i++)
  5030. {
  5031. var dac = dac5[i];
  5032. if (dac == null) continue;
  5033. builder.MoveToCell(4, i, 0, 0);
  5034. builder.Write("第" + dac.Index.ToString() + "项:");
  5035. builder.MoveToCell(4, i, 1, 0);
  5036. builder.Write(dac.itemName);
  5037. builder.MoveToCell(4, i, 2, 0);
  5038. builder.Write("费用标准:");
  5039. builder.MoveToCell(4, i, 3, 0);
  5040. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5041. builder.MoveToCell(4, i, 4, 0);
  5042. builder.Write("费用小计:");
  5043. builder.MoveToCell(4, i, 5, 0);
  5044. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5045. builder.MoveToCell(4, i, 6, 0);
  5046. builder.Write("备注:");
  5047. builder.MoveToCell(4, i, 7, 0);
  5048. builder.Write(dac.Remark);
  5049. }
  5050. #endregion
  5051. }
  5052. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5053. //删除多余行
  5054. while (table5.Rows.Count > table5Row)
  5055. {
  5056. table5.Rows.RemoveAt(table5Row);
  5057. }
  5058. //加上其他费用
  5059. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5060. decimal subJJC = 0.00M,
  5061. subGWC = 0.00M,
  5062. subTDC = 0.00M;
  5063. //经济舱
  5064. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5065. //公务舱
  5066. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5067. //头等舱
  5068. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5069. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5070. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5071. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5072. #region 填充word模板书签内容
  5073. foreach (var key in dic.Keys)
  5074. {
  5075. Bookmark bookmark = doc.Range.Bookmarks[key];
  5076. if (bookmark != null)
  5077. {
  5078. builder.MoveToBookmark(key);
  5079. builder.Write(dic[key]);
  5080. }
  5081. }
  5082. #endregion
  5083. //文件名
  5084. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5085. AsposeHelper.removewatermark_v2180();
  5086. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5087. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5088. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5089. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5090. }
  5091. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5092. {
  5093. //获取模板
  5094. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5095. //载入模板
  5096. Document doc = new Document(tempPath);
  5097. DocumentBuilder builder = new DocumentBuilder(doc);
  5098. Dictionary<string, string> dic = new Dictionary<string, string>();
  5099. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5100. {
  5101. List<string> list = new List<string>();
  5102. try
  5103. {
  5104. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5105. foreach (var item in spilitArr)
  5106. {
  5107. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5108. var depCode = spDotandEmpty[2].Substring(0, 3);
  5109. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5110. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5111. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5112. list.Add(depName);
  5113. list.Add(arrName);
  5114. }
  5115. list = list.Distinct().ToList();
  5116. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5117. }
  5118. catch (Exception)
  5119. {
  5120. dic.Add("ReturnCode", "行程录入不正确!");
  5121. }
  5122. }
  5123. else
  5124. {
  5125. dic.Add("ReturnCode", "未录入行程!");
  5126. }
  5127. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5128. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5129. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5130. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5131. {
  5132. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5133. dic.Add("Day", sp.Days.ToString());
  5134. }
  5135. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5136. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5137. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5138. //dic.Add("Names", Names);
  5139. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5140. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5141. decimal dac1totalPrice = 0.00M;
  5142. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5143. foreach (var dac in dac1)
  5144. {
  5145. if (dac.SubTotal == 0.00M)
  5146. {
  5147. continue;
  5148. }
  5149. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5150. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5151. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5152. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5153. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5154. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5155. builder.Write(currency);//币种
  5156. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5157. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5158. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5159. builder.Write("");//人数
  5160. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5161. builder.Write("");//天数
  5162. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5163. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5164. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5165. decimal rate = 0.00M;
  5166. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5167. builder.Write(rate.ToString("#0.0000"));//汇率
  5168. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5169. decimal rbmPrice = dac.SubTotal;
  5170. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5171. accommodationStartIndex++;
  5172. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5173. }
  5174. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5175. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5176. {
  5177. table1.Rows.RemoveAt(i - 1);
  5178. foodandotherStartIndex--;
  5179. }
  5180. if (dac2.Count == dac3.Count)//国家 币种 金额
  5181. {
  5182. for (int i = 0; i < dac2.Count; i++)
  5183. {
  5184. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5185. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5186. }
  5187. }
  5188. decimal dac2totalPrice = 0.00M;
  5189. foreach (var dac in dac2)
  5190. {
  5191. if (dac.SubTotal == 0)
  5192. {
  5193. continue;
  5194. }
  5195. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5196. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5197. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5198. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5199. builder.Write(currency);//币种
  5200. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5201. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5202. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5203. builder.Write("");//人数
  5204. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5205. builder.Write("");//天数
  5206. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5207. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5208. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5209. decimal rate = 0.00M;
  5210. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5211. builder.Write(rate.ToString("#0.0000"));//汇率
  5212. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5213. decimal rbmPrice = dac.SubTotal;
  5214. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5215. foodandotherStartIndex++;
  5216. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5217. }
  5218. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5219. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5220. {
  5221. table1.Rows.RemoveAt(i - 1);
  5222. }
  5223. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5224. string otherFeeStr = "";
  5225. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5226. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5227. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5228. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5229. foreach (var otherInfo in dac5)
  5230. {
  5231. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5232. }
  5233. #endregion
  5234. if (otherFeeStr.Length > 0)
  5235. {
  5236. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5237. otherFeeStr = $"({otherFeeStr})";
  5238. dic.Add("OtherFeeStr", otherFeeStr);
  5239. }
  5240. //总计
  5241. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5242. //国际旅费
  5243. string outsideAir = string.Empty;
  5244. string allPriceAir = string.Empty;
  5245. if (_EnterExitCosts.SumJJC == 1)
  5246. {
  5247. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5248. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5249. }
  5250. if (_EnterExitCosts.SumGWC == 1)
  5251. {
  5252. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5253. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5254. }
  5255. if (_EnterExitCosts.SumTDC == 1)
  5256. {
  5257. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5258. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5259. }
  5260. dic.Add("InTravelPrice", $"({outsideAir})");
  5261. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5262. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5263. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5264. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5265. foreach (var key in dic.Keys)
  5266. {
  5267. builder.MoveToBookmark(key);
  5268. builder.Write(dic[key]);
  5269. }
  5270. //模板文件名
  5271. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5272. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5273. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5274. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5275. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5276. }
  5277. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5278. {
  5279. //获取模板
  5280. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5281. //载入模板
  5282. WorkbookDesigner designer = new WorkbookDesigner();
  5283. designer.Workbook = new Workbook(tempPath);
  5284. Dictionary<string, string> dic = new Dictionary<string, string>();
  5285. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5286. {
  5287. List<string> list = new List<string>();
  5288. try
  5289. {
  5290. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5291. foreach (var item in spilitArr)
  5292. {
  5293. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5294. var depCode = spDotandEmpty[2].Substring(0, 3);
  5295. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5296. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5297. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5298. list.Add(depName);
  5299. list.Add(arrName);
  5300. }
  5301. list = list.Distinct().ToList();
  5302. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5303. }
  5304. catch (Exception)
  5305. {
  5306. dic.Add("ReturnCode", "行程录入不正确!");
  5307. }
  5308. }
  5309. else
  5310. {
  5311. dic.Add("ReturnCode", "未录入行程!");
  5312. }
  5313. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5314. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5315. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5316. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5317. {
  5318. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5319. dic.Add("Day", sp.Days.ToString());
  5320. }
  5321. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5322. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5323. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5324. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5325. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5326. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5327. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5328. designer.SetDataSource("Name", Names);
  5329. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5330. designer.SetDataSource("Day", dic["Day"] + "天");
  5331. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5332. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5333. int startIndex = 10;
  5334. const int startIndexcopy = 10;
  5335. if (dac2.Count == dac3.Count)//国家 币种 金额
  5336. {
  5337. for (int i = 0; i < dac2.Count; i++)
  5338. {
  5339. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5340. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5341. }
  5342. }
  5343. DataTable dtdac1 = new DataTable();
  5344. List<string> place = new List<string>();
  5345. dtdac1.Columns.AddRange(new DataColumn[] {
  5346. new DataColumn(){ ColumnName = "city"},
  5347. new DataColumn(){ ColumnName = "curr"},
  5348. new DataColumn(){ ColumnName = "criterion"},
  5349. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5350. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5351. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5352. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5353. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5354. });
  5355. DataTable dtdac2 = new DataTable();
  5356. dtdac2.Columns.AddRange(new DataColumn[] {
  5357. new DataColumn(){ ColumnName = "city"},
  5358. new DataColumn(){ ColumnName = "curr"},
  5359. new DataColumn(){ ColumnName = "criterion"},
  5360. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5361. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5362. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5363. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5364. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5365. });
  5366. dtdac1.TableName = "tb1";
  5367. dtdac2.TableName = "tb2";
  5368. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5369. foreach (var item in dac1)
  5370. {
  5371. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5372. if (place.Contains(item.Place))
  5373. {
  5374. continue;
  5375. }
  5376. DataRow row = dtdac1.NewRow();
  5377. row["city"] = item.Place;
  5378. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5379. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5380. row["curr"] = currency;
  5381. row["rate"] = rate.ToString("#0.0000");
  5382. row["criterion"] = item.Cost.ToString("#0.00");
  5383. row["number"] = 1;
  5384. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5385. //row["costRMB"] = rbmPrice;
  5386. dtdac1.Rows.Add(row);
  5387. place.Add(item.Place);
  5388. }
  5389. place = new List<string>();
  5390. foreach (var item in dac2)
  5391. {
  5392. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5393. if (place.Contains(item.Place))
  5394. {
  5395. continue;
  5396. }
  5397. DataRow row = dtdac2.NewRow();
  5398. row["city"] = item.Place;
  5399. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5400. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5401. row["curr"] = currency;
  5402. row["rate"] = rate.ToString("#0.0000");
  5403. row["criterion"] = item.Cost.ToString("#0.00");
  5404. row["number"] = 1;
  5405. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5406. //row["cost"] = item.SubTotal;
  5407. //row["costRMB"] = rbmPrice;
  5408. dtdac2.Rows.Add(row);
  5409. place.Add(item.Place);
  5410. //dac2totalPrice += rbmPrice;
  5411. }
  5412. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5413. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5414. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5415. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5416. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5417. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5418. string cell4Str1 = string.Empty;
  5419. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5420. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5421. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5422. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5423. string cellStr = $" 5.其他费用(";
  5424. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5425. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5426. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5427. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5428. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5429. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5430. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5431. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5432. foreach (var otherInfo in dac5)
  5433. {
  5434. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5435. }
  5436. #endregion
  5437. if (cellStr.Length > 8)
  5438. {
  5439. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5440. }
  5441. cellStr += ")";
  5442. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5443. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5444. decimal pxFee = dac4.Sum(it => it.Cost);
  5445. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5446. string celllastStr1 = "";
  5447. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5448. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5449. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5450. celllastStr1 += $",国际旅费 元";
  5451. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5452. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5453. designer.SetDataSource("cell4Str", cell4Str);
  5454. designer.SetDataSource("cellStr", cellStr);
  5455. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5456. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5457. designer.SetDataSource("celllastStr", celllastStr);
  5458. Workbook wb = designer.Workbook;
  5459. var sheet = wb.Worksheets[0];
  5460. //绑定datatable数据集
  5461. designer.SetDataSource(dtdac1);
  5462. designer.SetDataSource(dtdac2);
  5463. designer.Process();
  5464. var rowStart = dtdac1.Rows.Count;
  5465. while (rowStart > 0)
  5466. {
  5467. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5468. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5469. startIndex++;
  5470. rowStart--;
  5471. }
  5472. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5473. startIndex += 1; //总计行
  5474. rowStart = dtdac2.Rows.Count;
  5475. while (rowStart > 0)
  5476. {
  5477. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5478. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5479. startIndex++;
  5480. rowStart--;
  5481. }
  5482. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5483. wb.CalculateFormula(true);
  5484. //模板文件名
  5485. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5486. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5487. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5488. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5489. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5490. }
  5491. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5492. {
  5493. //获取模板
  5494. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5495. //载入模板
  5496. Document doc = new Document(tempPath);
  5497. DocumentBuilder builder = new DocumentBuilder(doc);
  5498. Dictionary<string, string> dic = new Dictionary<string, string>();
  5499. dic.Add("GroupName", _DelegationInfo.TeamName);
  5500. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5501. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5502. string missionLeaderJob = "";//负责人job
  5503. int groupNumber = 0; //团人数
  5504. if (DeleClientList.Count > 0)
  5505. {
  5506. missionLeader = DeleClientList[0]?.Name ?? "";
  5507. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5508. }
  5509. dic.Add("MissionLeader", missionLeader); //团负责人
  5510. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5511. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5512. #region MyRegion
  5513. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5514. //{
  5515. // List<string> list = new List<string>();
  5516. // try
  5517. // {
  5518. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5519. // foreach (var item in spilitArr)
  5520. // {
  5521. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5522. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5523. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5524. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5525. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5526. // list.Add(depName);
  5527. // list.Add(arrName);
  5528. // }
  5529. // list = list.Distinct().ToList();
  5530. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5531. // }
  5532. // catch (Exception)
  5533. // {
  5534. // dic.Add("ReturnCode", "行程录入不正确!");
  5535. // }
  5536. //}
  5537. //else
  5538. //{
  5539. // dic.Add("ReturnCode", "未录入行程!");
  5540. //}
  5541. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5542. dic.Add("ReturnCode", string.Join("、", countrys));
  5543. #endregion
  5544. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5545. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5546. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5547. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5548. //{
  5549. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5550. // dic.Add("Day", sp.Days.ToString());
  5551. //}
  5552. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5553. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5554. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5555. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5556. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5557. //培训人员名单
  5558. int cultivateRowIndex = 7;
  5559. foreach (var item in DeleClientList)
  5560. {
  5561. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5562. builder.Write(item.Name);
  5563. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5564. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5565. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5566. string birthDay = "";
  5567. if (item.Birthday != null)
  5568. {
  5569. DateTime dt = Convert.ToDateTime(item.Birthday);
  5570. birthDay = $"{dt.Year}.{dt.Month}";
  5571. }
  5572. builder.Write(birthDay);
  5573. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5574. builder.Write(item.Company);
  5575. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5576. builder.Write(item.Job);
  5577. cultivateRowIndex++;
  5578. }
  5579. //删除多余行
  5580. //cultivateRowIndex -= 2;
  5581. int delRows = 10 + 7 - cultivateRowIndex;
  5582. if (delRows > 0)
  5583. {
  5584. for (int i = 0; i < delRows; i++)
  5585. {
  5586. table1.Rows.RemoveAt(cultivateRowIndex);
  5587. //cultivateRowIndex++;
  5588. }
  5589. }
  5590. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5591. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5592. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5593. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5594. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5595. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5596. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5597. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5598. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5599. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5600. //其他费用
  5601. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5602. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5603. //其他费用合计
  5604. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5605. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5606. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5607. //公务舱合计
  5608. //国际旅费
  5609. string outsideJJ = "";
  5610. string allPriceJJ = "";
  5611. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5612. {
  5613. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5614. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5615. }
  5616. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5617. {
  5618. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5619. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5620. }
  5621. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5622. {
  5623. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5624. dic.Add("AirFeeTotal", airFeeTotalStr);
  5625. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5626. dic.Add("FeeTotal", feeTotalStr);
  5627. }
  5628. foreach (var key in dic.Keys)
  5629. {
  5630. builder.MoveToBookmark(key);
  5631. builder.Write(dic[key]);
  5632. }
  5633. //模板文件名
  5634. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5635. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5636. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5637. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5638. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5639. }
  5640. }
  5641. else if (dto.ExportType == 2) //表格
  5642. {
  5643. //利用键值对存放数据
  5644. Dictionary<string, string> dic = new Dictionary<string, string>();
  5645. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5646. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5647. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5648. dic.Add("Day", sp.Days.ToString());
  5649. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5650. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5651. {
  5652. //获取模板
  5653. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5654. //载入模板
  5655. Document doc = new Document(tempPath);
  5656. DocumentBuilder builder = new DocumentBuilder(doc);
  5657. dic.Add("TeamName", _DelegationInfo.TeamName);
  5658. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5659. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5660. string missionLeaderName = "",
  5661. missionLeaderJob = "";
  5662. if (DeleClientList.Count > 0)
  5663. {
  5664. missionLeaderName = DeleClientList[0].Name;
  5665. missionLeaderJob = DeleClientList[0].Job;
  5666. }
  5667. dic.Add("MissionLeaderName", missionLeaderName);
  5668. dic.Add("MissionLeaderJob", missionLeaderJob);
  5669. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5670. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5671. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5672. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5673. int rowCount = 10;//总人数行
  5674. int startRowIndex = 7; //起始行
  5675. for (int i = 0; i < DeleClientList.Count; i++)
  5676. {
  5677. builder.MoveToCell(0, startRowIndex, 0, 0);
  5678. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5679. builder.MoveToCell(0, startRowIndex, 1, 0);
  5680. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5681. builder.Write(sex);//性别
  5682. builder.MoveToCell(0, startRowIndex, 2, 0);
  5683. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5684. builder.MoveToCell(0, startRowIndex, 3, 0);
  5685. builder.Write(DeleClientList[i].Company);//工作单位
  5686. builder.MoveToCell(0, startRowIndex, 4, 0);
  5687. builder.Write(DeleClientList[i].Job);//职务及级别
  5688. builder.MoveToCell(0, startRowIndex, 5, 0);
  5689. builder.Write("");//人员属性
  5690. builder.MoveToCell(0, startRowIndex, 6, 0);
  5691. builder.Write("");//上次出国时间
  5692. startRowIndex++;
  5693. }
  5694. int nullRow = rowCount - DeleClientList.Count;//空行
  5695. for (int i = 0; i < nullRow; i++)
  5696. {
  5697. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5698. }
  5699. foreach (var key in dic.Keys)
  5700. {
  5701. builder.MoveToBookmark(key);
  5702. builder.Write(dic[key]);
  5703. }
  5704. //模板文件名
  5705. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5706. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5707. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5708. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5709. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5710. }
  5711. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5712. {
  5713. //获取模板
  5714. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5715. //载入模板
  5716. Document doc = new Document(tempPath);
  5717. DocumentBuilder builder = new DocumentBuilder(doc);
  5718. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5719. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5720. dic.Add("Names", Names);
  5721. int accommodationRows = 12, foodandotherRows = 12;
  5722. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5723. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5724. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5725. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5726. int accommodationStartIndex = 6;
  5727. decimal dac1totalPrice = 0.00M;
  5728. foreach (var dac in dac1)
  5729. {
  5730. if (dac.SubTotal == 0)
  5731. {
  5732. continue;
  5733. }
  5734. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5735. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5736. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5737. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5738. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5739. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5740. builder.Write(currency);//币种
  5741. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5742. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5743. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5744. builder.Write("");//人数
  5745. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5746. builder.Write("");//天数
  5747. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5748. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5749. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5750. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5751. builder.Write(rate.ToString("#0.0000"));//汇率
  5752. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5753. decimal rbmPrice = rate * dac.SubTotal;
  5754. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5755. accommodationStartIndex++;
  5756. dac1totalPrice += rbmPrice;
  5757. }
  5758. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5759. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5760. builder.Write("小计");
  5761. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5762. builder.Write(dac1totalPrice.ToString("#0.00"));
  5763. accommodationStartIndex++;
  5764. int nullRow = accommodationRows - dac1.Count;
  5765. //删除空行
  5766. //if (nullRow > 0)
  5767. //{
  5768. // int rowIndex = accommodationStartIndex;
  5769. // for (int i = 0; i < nullRow; i++)
  5770. // {
  5771. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5772. // row.Remove();
  5773. // rowIndex++;
  5774. // }
  5775. //}
  5776. if (dac2.Count == dac3.Count)//国家 币种 金额
  5777. {
  5778. for (int i = 0; i < dac2.Count; i++)
  5779. {
  5780. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5781. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5782. }
  5783. }
  5784. int foodandotherStartIndex = 19;//
  5785. decimal dac2totalPrice = 0.00M;
  5786. foreach (var dac in dac2)
  5787. {
  5788. if (dac.SubTotal == 0)
  5789. {
  5790. continue;
  5791. }
  5792. //foodandotherStartIndex = 12;
  5793. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5794. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5795. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5796. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5797. builder.Write(currency);//币种
  5798. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5799. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5800. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5801. builder.Write("");//人数
  5802. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5803. builder.Write("");//天数
  5804. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5805. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5806. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5807. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5808. builder.Write(rate.ToString("#0.0000"));//汇率
  5809. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5810. decimal rbmPrice = rate * dac.SubTotal;
  5811. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5812. foodandotherStartIndex++;
  5813. dac2totalPrice += rbmPrice;
  5814. }
  5815. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5816. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5817. //删除空行
  5818. //if (dac2.Count < foodandotherRows)
  5819. //{
  5820. // while (table2.Rows.Count > dac2.Count)
  5821. // {
  5822. // table2.Rows.RemoveAt(dac2.Count);
  5823. // }
  5824. //}
  5825. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5826. string otherFeeStr = "";
  5827. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5828. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5829. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5830. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5831. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5832. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5833. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5834. foreach (var otherInfo in dac5)
  5835. {
  5836. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5837. }
  5838. #endregion
  5839. if (otherFeeStr.Length > 0)
  5840. {
  5841. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5842. otherFeeStr = $"({otherFeeStr})";
  5843. dic.Add("OtherFeeStr", otherFeeStr);
  5844. }
  5845. foreach (var key in dic.Keys)
  5846. {
  5847. builder.MoveToBookmark(key);
  5848. builder.Write(dic[key]);
  5849. }
  5850. //模板文件名
  5851. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5852. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5853. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5854. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5855. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5856. }
  5857. }
  5858. else if (dto.ExportType == 3)
  5859. {
  5860. if (dto.SubTypeId == 1) //团组成员名单
  5861. {
  5862. if (DeleClientList.Count < 1)
  5863. {
  5864. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5865. }
  5866. //获取模板
  5867. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5868. //载入模板
  5869. Document doc = new Document(tempPath);
  5870. DocumentBuilder builder = new DocumentBuilder(doc);
  5871. //获取word里所有表格
  5872. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5873. //获取所填表格的序数
  5874. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5875. var rowStart = tableOne.Rows[0]; //获取第1行
  5876. //循环赋值
  5877. for (int i = 0; i < DeleClientList.Count; i++)
  5878. {
  5879. builder.MoveToCell(0, i + 1, 0, 0);
  5880. builder.Write(DeleClientList[i].Name);
  5881. builder.MoveToCell(0, i + 1, 1, 0);
  5882. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5883. builder.Write(sex);
  5884. builder.MoveToCell(0, i + 1, 2, 0);
  5885. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5886. builder.MoveToCell(0, i + 1, 3, 0);
  5887. builder.Write(DeleClientList[i].Company);
  5888. builder.MoveToCell(0, i + 1, 4, 0);
  5889. builder.Write(DeleClientList[i].Job);
  5890. }
  5891. //删除多余行
  5892. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5893. {
  5894. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5895. }
  5896. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5897. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5898. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5899. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5900. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5901. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5902. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5903. }
  5904. }
  5905. return Ok(JsonView(400, "操作失败!", ""));
  5906. }
  5907. catch (Exception ex)
  5908. {
  5909. return Ok(JsonView(400, ex.Message, ""));
  5910. }
  5911. }
  5912. /// <summary>
  5913. /// 获取三公费用标准city
  5914. /// </summary>
  5915. /// <param name="placeData"></param>
  5916. /// <param name="nationalTravelFeeId"></param>
  5917. /// <returns></returns>
  5918. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5919. {
  5920. string _city = string.Empty;
  5921. if (placeData.Count < 1) return _city;
  5922. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5923. if (data == null) return _city;
  5924. string country = data.Country;
  5925. string city = data.City;
  5926. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5927. else _city = city;
  5928. return _city;
  5929. }
  5930. /// <summary>
  5931. /// 团组模块 - 出入境费用 - 明细表导出
  5932. /// </summary>
  5933. /// <returns></returns>
  5934. [HttpPost]
  5935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5936. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5937. {
  5938. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5939. if (data.Code != 0)
  5940. {
  5941. return Ok(JsonView(false, data.Msg));
  5942. }
  5943. return Ok(JsonView(true, data.Msg, data.Data));
  5944. }
  5945. /// <summary>
  5946. /// 团组模块 - 出入境费用 - 一键清空
  5947. /// </summary>
  5948. /// <returns></returns>
  5949. [HttpPost]
  5950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5951. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5952. {
  5953. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5954. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5955. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5956. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5957. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5958. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5959. .SetColumns(x => new Grp_DayOtherPrice
  5960. {
  5961. IsDel = 1,
  5962. DeleteUserId = dto.UserId,
  5963. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5964. })
  5965. .ExecuteCommandAsync();
  5966. if (_view.Code == 0)
  5967. {
  5968. return Ok(JsonView(true, "操作成功"));
  5969. }
  5970. return Ok(JsonView(false, "操作失败"));
  5971. }
  5972. /// <summary>
  5973. /// 团组模块 - 出入境费用 - 子项删除
  5974. /// </summary>
  5975. /// <returns></returns>
  5976. [HttpPost]
  5977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5978. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5979. {
  5980. try
  5981. {
  5982. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5983. if (data.Code != 0)
  5984. {
  5985. return Ok(JsonView(false, data.Msg));
  5986. }
  5987. return Ok(JsonView(true, "操作成功!", data.Data));
  5988. }
  5989. catch (Exception ex)
  5990. {
  5991. return Ok(JsonView(false, ex.Message));
  5992. }
  5993. }
  5994. /// <summary>
  5995. /// 删除三公其他费用
  5996. /// </summary>
  5997. /// <param name="dto"></param>
  5998. /// <returns></returns>
  5999. [HttpPost]
  6000. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6001. {
  6002. var jw = JsonView(false,"删除失败!");
  6003. var data = new Grp_DayOtherPrice()
  6004. {
  6005. Id = dto.Id,
  6006. IsDel = 1,
  6007. DeleteUserId = dto.DeleteUserId,
  6008. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6009. };
  6010. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6011. if (del > 0)
  6012. {
  6013. jw.Code = 200;
  6014. jw.Msg = "删除成功!";
  6015. }
  6016. return Ok(jw);
  6017. }
  6018. /// <summary>
  6019. /// 团组模块 - 出入境国家费用标准 List
  6020. /// </summary>
  6021. /// <returns></returns>
  6022. [HttpPost]
  6023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6024. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6025. {
  6026. try
  6027. {
  6028. Stopwatch sw = new Stopwatch();
  6029. sw.Start();
  6030. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6031. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6032. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6033. Where gntf.Isdel = 0");
  6034. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6035. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6036. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6037. //foreach (var item in nationalTravel)
  6038. //{
  6039. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6040. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6041. // if (otherData != null)
  6042. // {
  6043. // cityData.Remove(otherData);
  6044. // cityData.Add(otherData);
  6045. // }
  6046. // nationalTravelFeeData1.Add(new
  6047. // {
  6048. // Country = item.Country,
  6049. // CityData = cityData
  6050. // });
  6051. //}
  6052. sw.Stop();
  6053. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6054. }
  6055. catch (Exception ex)
  6056. {
  6057. return Ok(JsonView(false, ex.Message));
  6058. throw;
  6059. }
  6060. }
  6061. /// <summary>
  6062. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6063. /// </summary>
  6064. /// <returns></returns>
  6065. [HttpPost]
  6066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6067. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6068. {
  6069. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6070. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6071. List<string> countryData = new List<string>();
  6072. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6073. countryData = countryData.Distinct().ToList();
  6074. List<dynamic> dataSource = new List<dynamic>();
  6075. foreach (var item in countryData)
  6076. {
  6077. List<string> cityData1 = new List<string>();
  6078. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6079. var countryData2 = new
  6080. {
  6081. CountryName = item,
  6082. CityData = cityData1
  6083. };
  6084. dataSource.Add(countryData2);
  6085. }
  6086. return Ok(JsonView(true, "查询成功!", dataSource));
  6087. }
  6088. /// <summary>
  6089. /// 团组模块 - 出入境国家费用标准 Page List
  6090. /// </summary>
  6091. /// <returns></returns>
  6092. [HttpPost]
  6093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6094. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6095. {
  6096. int portId = dto.PortType;
  6097. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6098. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6099. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6100. string whereSql = string.Empty;
  6101. if (!string.IsNullOrEmpty(dto.Country))
  6102. {
  6103. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6104. }
  6105. if (!string.IsNullOrEmpty(dto.City))
  6106. {
  6107. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6108. }
  6109. string pageSql = string.Format(@"Select * From (
  6110. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6111. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6112. From Grp_NationalTravelFee gntf
  6113. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6114. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6115. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6116. RefAsync<int> total = 0;
  6117. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6118. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6119. }
  6120. /// <summary>
  6121. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6122. /// </summary>
  6123. /// <returns></returns>
  6124. [HttpPost]
  6125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6126. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6127. {
  6128. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6129. int portId = dto.PortType;
  6130. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6131. string whereSql = string.Empty;
  6132. if (!string.IsNullOrEmpty(dto.Country))
  6133. {
  6134. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6135. }
  6136. if (!string.IsNullOrEmpty(dto.City))
  6137. {
  6138. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6139. }
  6140. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6141. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6142. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6143. From Grp_NationalTravelFee gntf
  6144. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6145. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6146. Where gntf.Isdel = 0 {0} ", whereSql);
  6147. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6148. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6149. }
  6150. /// <summary>
  6151. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6152. /// </summary>
  6153. /// <returns></returns>
  6154. [HttpPost]
  6155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6156. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6157. {
  6158. try
  6159. {
  6160. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6161. if (data.Code != 0)
  6162. {
  6163. return Ok(JsonView(false, data.Msg));
  6164. }
  6165. return Ok(JsonView(true, "操作成功!", data.Data));
  6166. }
  6167. catch (Exception ex)
  6168. {
  6169. return Ok(JsonView(false, ex.Message));
  6170. }
  6171. }
  6172. /// <summary>
  6173. /// 团组模块 - 出入境国家费用标准 - Del
  6174. /// </summary>
  6175. /// <returns></returns>
  6176. [HttpPost]
  6177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6178. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6179. {
  6180. try
  6181. {
  6182. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6183. {
  6184. Id = dto.Id,
  6185. DeleteUserId = dto.DeleteUserId,
  6186. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6187. IsDel = 1
  6188. };
  6189. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6190. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6191. .WhereColumns(it => new { it.Id })
  6192. .ExecuteCommandAsync();
  6193. if (delStatus <= 0)
  6194. {
  6195. return Ok(JsonView(false, "删除失败!"));
  6196. }
  6197. return Ok(JsonView(true, "操作成功!"));
  6198. }
  6199. catch (Exception ex)
  6200. {
  6201. return Ok(JsonView(false, ex.Message));
  6202. }
  6203. }
  6204. /// <summary>
  6205. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6206. /// 注:Get 请求Headers 加 Token
  6207. /// </summary>
  6208. /// <param name="groupId"></param>
  6209. /// <returns></returns>
  6210. [HttpGet("{groupId}")]
  6211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6212. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6213. {
  6214. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6215. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6216. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6217. data.ForEach(x =>
  6218. {
  6219. x.CreateUserId = _currUserInfo.UserId;
  6220. });
  6221. if (data.Count > 0)
  6222. {
  6223. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6224. if (add > 0)
  6225. {
  6226. return Ok(JsonView(true, "操作成功!"));
  6227. }
  6228. }
  6229. return Ok(JsonView(false, "未操作!"));
  6230. }
  6231. #endregion
  6232. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6233. /// <summary>
  6234. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6235. /// </summary>
  6236. /// <returns></returns>
  6237. [HttpPost]
  6238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6239. public async Task<IActionResult> PostEnterExitCostMobileDataSource(PortDtoBase dto)
  6240. {
  6241. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6242. //SetDataInfoView
  6243. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6244. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6245. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6246. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6247. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6248. //默认币种显示
  6249. var _currencyInfos = _currencyInit;
  6250. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6251. if (_currencyRate.Count > 0)
  6252. {
  6253. foreach (var item in _currencyInfos)
  6254. {
  6255. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6256. if (rateInfo != null)
  6257. {
  6258. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6259. rate1 *= 1.035M;
  6260. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6261. }
  6262. }
  6263. }
  6264. return Ok(JsonView(true, "查询成功!", new
  6265. {
  6266. WordTypeData = _WordTypeData,
  6267. ExcelTypeData = _ExcelTypeData,
  6268. CurrencyInit = _currencyInfos
  6269. }));
  6270. }
  6271. /// <summary>
  6272. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6273. /// </summary>
  6274. /// <returns></returns>
  6275. [HttpPost]
  6276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6277. public async Task<IActionResult> PostEnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6278. {
  6279. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6280. RefAsync<int> total = 0;
  6281. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6282. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6283. .WhereIF(!string.IsNullOrEmpty(dto.GroupName), x => x.TeamName.Contains(dto.GroupName))
  6284. .Select(x => new
  6285. {
  6286. Id = x.Id,
  6287. GroupName = x.TeamName
  6288. })
  6289. .OrderByDescending(x => x.Id)
  6290. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6291. return Ok(JsonView(true, "查询成功!", data, total));
  6292. }
  6293. /// <summary>
  6294. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6295. /// </summary>
  6296. /// <returns></returns>
  6297. [HttpPost]
  6298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6299. public async Task<IActionResult> PostEnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6300. {
  6301. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6302. RefAsync<int> total = 0;
  6303. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6304. .Where(x => x.IsDel == 0 && x.STid == 66)
  6305. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6306. .Select(x => new
  6307. {
  6308. id = x.Id,
  6309. name = x.Name,
  6310. remark = x.Remark,
  6311. })
  6312. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6313. return Ok(JsonView(true, "查询成功!", data, total));
  6314. }
  6315. /// <summary>
  6316. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6317. /// </summary>
  6318. /// <returns></returns>
  6319. [HttpPost]
  6320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6321. public async Task<IActionResult> PostEnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6322. {
  6323. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6324. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6325. var tipsData = new List<int>() {1,2,3 };
  6326. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6327. if (dto.TipsType == 1)
  6328. {
  6329. //默认币种显示
  6330. var _currencyInfos = _currencyInit;
  6331. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6332. List<dynamic> reteInfos = new List<dynamic>();
  6333. if (_currencyRate.Count > 0)
  6334. {
  6335. foreach (var item in _currencyInfos)
  6336. {
  6337. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6338. if (rateInfo != null)
  6339. {
  6340. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6341. decimal rate1 = item.Rate;
  6342. rate1 *= 1.03M;
  6343. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6344. reteInfos.Add(new
  6345. {
  6346. currCode = item.CurrencyCode,
  6347. currName = item.CurrencyName,
  6348. rate = rate2,
  6349. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6350. });
  6351. }
  6352. }
  6353. }
  6354. return Ok(JsonView(true, "查询成功!", reteInfos));
  6355. }
  6356. else if (dto.TipsType == 2)
  6357. {
  6358. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6359. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6360. }
  6361. else if (dto.TipsType == 3)
  6362. {
  6363. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6364. return Ok(JsonView(true, "查询成功!", airData.Data));
  6365. }
  6366. return Ok(JsonView(false));
  6367. }
  6368. /// <summary>
  6369. /// 团组模块 - 出入境国家费用标准 List
  6370. /// </summary>
  6371. /// <returns></returns>
  6372. [HttpPost]
  6373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6374. public async Task<IActionResult> PostNationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6375. {
  6376. Stopwatch sw = new Stopwatch();
  6377. sw.Start();
  6378. RefAsync<int> total = 0;
  6379. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6380. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6381. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6382. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6383. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6384. .Select((ntf, sd, u) => new
  6385. {
  6386. Id = ntf.Id,
  6387. Area = $"{ntf.Country}-{ntf.City}",
  6388. Currency = ntf.Currency,
  6389. CurrencyCode = sd.Name,
  6390. CurrencyName = sd.Remark,
  6391. RoomCost = ntf.RoomCost,
  6392. FoodCost = ntf.FoodCost,
  6393. PublicCost = ntf.PublicCost,
  6394. LastUpdateUserId = ntf.LastUpdateUserId,
  6395. LastUpdateUserName = u.CnName,
  6396. LastUpdateTime = ntf.LastUpdateTime,
  6397. })
  6398. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6399. sw.Stop();
  6400. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6401. }
  6402. #endregion
  6403. #region 签证费用录入
  6404. /// <summary>
  6405. /// 根据diid查询签证费用列表
  6406. /// </summary>
  6407. /// <param name="dto"></param>
  6408. /// <returns></returns>
  6409. [HttpPost]
  6410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6411. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6412. {
  6413. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6414. if (groupData.Code != 0)
  6415. {
  6416. return Ok(JsonView(false, groupData.Msg));
  6417. }
  6418. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6419. }
  6420. /// <summary>
  6421. /// 根据签证费用Id查询单条数据及c表数据
  6422. /// </summary>
  6423. /// <param name="dto"></param>
  6424. /// <returns></returns>
  6425. [HttpPost]
  6426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6427. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6428. {
  6429. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6430. if (groupData.Code != 0)
  6431. {
  6432. return Ok(JsonView(false, groupData.Msg));
  6433. }
  6434. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6435. }
  6436. /// <summary>
  6437. /// 签证费用删除
  6438. /// </summary>
  6439. /// <param name="dto"></param>
  6440. /// <returns></returns>
  6441. [HttpPost]
  6442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6443. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6444. {
  6445. _sqlSugar.BeginTran();
  6446. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6447. if (!res)
  6448. {
  6449. _sqlSugar.RollbackTran();
  6450. return Ok(JsonView(false, "删除失败"));
  6451. }
  6452. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6453. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6454. .SetColumns(a => new Grp_CreditCardPayment()
  6455. {
  6456. IsDel = 1,
  6457. DeleteUserId = dto.DeleteUserId,
  6458. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6459. })
  6460. .ExecuteCommand();
  6461. if (resSub < 1)
  6462. {
  6463. _sqlSugar.RollbackTran();
  6464. return Ok(JsonView(false, "删除失败"));
  6465. }
  6466. _sqlSugar.CommitTran();
  6467. return Ok(JsonView(true, "删除成功!"));
  6468. }
  6469. /// <summary>
  6470. /// 签证费用录入下拉框初始化
  6471. /// </summary>
  6472. /// <returns></returns>
  6473. [HttpPost]
  6474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6475. public async Task<IActionResult> VisaPriceAddSelect()
  6476. {
  6477. //支付方式
  6478. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6479. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6480. //币种
  6481. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6482. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6483. //乘客类型
  6484. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6485. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6486. //卡类型
  6487. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6488. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6489. //代办费类型
  6490. var agencyFeeTypeData = new List<dynamic>() {
  6491. new { id = 0 , Text = "未选择" },
  6492. new { id = 1 , Text = "小公务" },
  6493. new { id = 2 , Text = "大公务" },
  6494. };
  6495. //签证费用标准国家Data
  6496. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  6497. var data = new
  6498. {
  6499. Payment = _Payment,
  6500. CurrencyList = _CurrencyList,
  6501. PassengerType = _PassengerType,
  6502. BankCard = _BankCard,
  6503. AgencyFeeType = agencyFeeTypeData,
  6504. CountryFeeData = visaCountryFeeData
  6505. };
  6506. return Ok(JsonView(true, "查询成功!", data));
  6507. }
  6508. /// <summary>
  6509. /// 签证费用录入操作(Status:1.新增,2.修改)
  6510. /// </summary>
  6511. /// <param name="dto"></param>
  6512. /// <returns></returns>
  6513. [HttpPost]
  6514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6515. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6516. {
  6517. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6518. if (groupData.Code != 0)
  6519. {
  6520. return Ok(JsonView(false, groupData.Msg));
  6521. }
  6522. #region 应用推送
  6523. try
  6524. {
  6525. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6526. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6527. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6528. //2024-10-21 新增LZ UID
  6529. var userIds = new List<int>() { 21 };
  6530. string title = $"系统通知";
  6531. string content = "";
  6532. var diId = dto.DiId;
  6533. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6534. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6535. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6536. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6537. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6538. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  6539. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6540. }
  6541. catch (Exception ex)
  6542. {
  6543. }
  6544. #endregion
  6545. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6546. }
  6547. #endregion
  6548. #region 签证提成录入
  6549. /// <summary>
  6550. /// 签证提成录入
  6551. /// 基础数据
  6552. /// </summary>
  6553. /// <param name="_dto"></param>
  6554. /// <returns></returns>
  6555. [HttpGet]
  6556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6557. public async Task<IActionResult> VisaCommissionInit()
  6558. {
  6559. return Ok(await _visaCommissionRep.Init());
  6560. }
  6561. /// <summary>
  6562. /// 签证提成录入
  6563. /// Item
  6564. /// </summary>
  6565. /// <param name="_dto"></param>
  6566. /// <returns></returns>
  6567. [HttpPost]
  6568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6569. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6570. {
  6571. var validator = new VisaCommissionItemDtoValidator();
  6572. var validatorRes = await validator.ValidateAsync(_dto);
  6573. if (!validatorRes.IsValid)
  6574. {
  6575. StringBuilder sb = new StringBuilder();
  6576. foreach (var item in validatorRes.Errors)
  6577. {
  6578. sb.AppendLine(item.ErrorMessage);
  6579. }
  6580. return Ok(JsonView(false, sb.ToString()));
  6581. }
  6582. return Ok(await _visaCommissionRep.Item(_dto));
  6583. }
  6584. /// <summary>
  6585. /// 签证提成录入
  6586. /// Save
  6587. /// </summary>
  6588. /// <param name="_dto"></param>
  6589. /// <returns></returns>
  6590. [HttpPost]
  6591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6592. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6593. {
  6594. //参数验证
  6595. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6596. foreach (var item in _dto.Items)
  6597. {
  6598. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6599. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6600. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6601. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6602. }
  6603. return Ok(await _visaCommissionRep.Save(_dto));
  6604. }
  6605. /// <summary>
  6606. /// 签证提成录入
  6607. /// Create
  6608. /// </summary>
  6609. /// <param name="_dto"></param>
  6610. /// <returns></returns>
  6611. [HttpPost]
  6612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6613. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6614. {
  6615. var validator = new VisaCommissionCreateDtoValidator();
  6616. var validatorRes = await validator.ValidateAsync(_dto);
  6617. if (!validatorRes.IsValid)
  6618. {
  6619. StringBuilder sb = new StringBuilder();
  6620. foreach (var item in validatorRes.Errors)
  6621. {
  6622. sb.AppendLine(item.ErrorMessage);
  6623. }
  6624. return Ok(JsonView(false, sb.ToString()));
  6625. }
  6626. return Ok(await _visaCommissionRep.Create(_dto));
  6627. }
  6628. /// <summary>
  6629. /// 签证提成录入
  6630. /// Put(编辑)
  6631. /// </summary>
  6632. /// <param name="id"></param>
  6633. /// <param name="_dto"></param>
  6634. /// <returns></returns>
  6635. [HttpPut]
  6636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6637. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6638. {
  6639. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6640. var validator = new VisaCommissionCreateDtoValidator();
  6641. var validatorRes = await validator.ValidateAsync(_dto);
  6642. if (!validatorRes.IsValid)
  6643. {
  6644. StringBuilder sb = new StringBuilder();
  6645. foreach (var item in validatorRes.Errors)
  6646. {
  6647. sb.AppendLine(item.ErrorMessage);
  6648. }
  6649. return Ok(JsonView(false, sb.ToString()));
  6650. }
  6651. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6652. }
  6653. /// <summary>
  6654. /// 签证提成录入
  6655. /// Del
  6656. /// </summary>
  6657. /// <param name="id"></param>
  6658. /// <param name="currUserId"></param>
  6659. /// <returns></returns>
  6660. [HttpPost]
  6661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6662. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6663. {
  6664. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6665. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6666. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6667. }
  6668. #endregion
  6669. #region op费用录入
  6670. /// <summary>
  6671. /// 根据diid查询op费用列表
  6672. /// </summary>
  6673. /// <param name="dto"></param>
  6674. /// <returns></returns>
  6675. [HttpPost]
  6676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6677. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6678. {
  6679. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6680. if (groupData.Code != 0)
  6681. {
  6682. return Ok(JsonView(false, groupData.Msg));
  6683. }
  6684. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6685. }
  6686. /// <summary>
  6687. /// 根据op费用Id查询单条数据及c表数据
  6688. /// </summary>
  6689. /// <param name="dto"></param>
  6690. /// <returns></returns>
  6691. [HttpPost]
  6692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6693. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6694. {
  6695. try
  6696. {
  6697. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6698. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6699. var data = new
  6700. {
  6701. CarTouristGuideGround = _groupData,
  6702. CreditCardPayment = _creditCardPayment
  6703. };
  6704. return Ok(JsonView(true, "查询成功!", data));
  6705. }
  6706. catch (Exception ex)
  6707. {
  6708. return Ok(JsonView(false, "程序错误!"));
  6709. }
  6710. }
  6711. /// <summary>
  6712. /// op费用删除
  6713. /// </summary>
  6714. /// <param name="dto"></param>
  6715. /// <returns></returns>
  6716. [HttpPost]
  6717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6718. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6719. {
  6720. try
  6721. {
  6722. _sqlSugar.BeginTran();
  6723. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6724. if (!res)
  6725. {
  6726. return Ok(JsonView(false, "删除失败"));
  6727. }
  6728. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6729. {
  6730. IsDel = 1,
  6731. DeleteUserId = dto.DeleteUserId,
  6732. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6733. }).ExecuteCommandAsync();
  6734. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6735. {
  6736. IsDel = 1,
  6737. DeleteUserId = dto.DeleteUserId,
  6738. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6739. }).ExecuteCommandAsync();
  6740. #region 删除超支相关数据
  6741. //删除导入的超支数据
  6742. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6743. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6744. {
  6745. IsDel = 1,
  6746. DeleteUserId = dto.DeleteUserId,
  6747. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6748. }).ExecuteCommand();
  6749. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6750. {
  6751. IsDel = 1,
  6752. DeleteUserId = dto.DeleteUserId,
  6753. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6754. }).ExecuteCommand();
  6755. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6756. {
  6757. IsDel = 1,
  6758. DeleteUserId = dto.DeleteUserId,
  6759. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6760. }).ExecuteCommand();
  6761. #endregion
  6762. _sqlSugar.CommitTran();
  6763. return Ok(JsonView(true, "删除成功!"));
  6764. }
  6765. catch (Exception ex)
  6766. {
  6767. _sqlSugar.RollbackTran();
  6768. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6769. }
  6770. }
  6771. /// <summary>
  6772. /// op费用录入操作(Status:1.新增,2.修改)
  6773. /// </summary>
  6774. /// <param name="dto"></param>
  6775. /// <returns></returns>
  6776. [HttpPost]
  6777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6778. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6779. {
  6780. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6781. if (groupData.Code != 0)
  6782. {
  6783. return Ok(JsonView(false, groupData.Msg));
  6784. }
  6785. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6786. }
  6787. /// <summary>
  6788. /// 填写费用详细页面初始化绑定
  6789. /// </summary>
  6790. /// <param name="dto"></param>
  6791. /// <returns></returns>
  6792. [HttpPost]
  6793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6794. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6795. {
  6796. try
  6797. {
  6798. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6799. if (groupData.Code != 0)
  6800. {
  6801. return Ok(JsonView(false, groupData.Msg));
  6802. }
  6803. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6804. }
  6805. catch (Exception ex)
  6806. {
  6807. return Ok(JsonView(false, ex.Message));
  6808. }
  6809. }
  6810. /// <summary>
  6811. /// 根据op费用Id查询详细数据
  6812. /// </summary>
  6813. /// <param name="dto"></param>
  6814. /// <returns></returns>
  6815. [HttpPost]
  6816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6817. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6818. {
  6819. try
  6820. {
  6821. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6822. if (groupData.Code != 0)
  6823. {
  6824. return Ok(JsonView(false, groupData.Msg));
  6825. }
  6826. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6827. }
  6828. catch (Exception ex)
  6829. {
  6830. return Ok(JsonView(false, ex.Message));
  6831. }
  6832. }
  6833. /// <summary>
  6834. /// OP费用录入填写详情
  6835. /// </summary>
  6836. /// <param name="dto"></param>
  6837. /// <returns></returns>
  6838. [HttpPost]
  6839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6840. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6841. {
  6842. try
  6843. {
  6844. #region 参数校验
  6845. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6846. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6847. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6848. #endregion
  6849. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6850. if (groupData.Code != 0)
  6851. {
  6852. return Ok(JsonView(false, groupData.Msg));
  6853. }
  6854. //自动审核
  6855. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6856. #region 应用推送
  6857. try
  6858. {
  6859. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6860. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6861. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6862. //2024-10-21 新增LZ UID
  6863. var userIds = new List<int>() { 21 };
  6864. string title = $"系统通知";
  6865. var diId = dto.DiId;
  6866. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6867. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6868. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6869. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6870. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  6871. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6872. }
  6873. catch (Exception ex)
  6874. {
  6875. }
  6876. #endregion
  6877. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6878. }
  6879. catch (Exception ex)
  6880. {
  6881. return Ok(JsonView(false, ex.Message));
  6882. }
  6883. }
  6884. /// <summary>
  6885. /// 获取三公详细所有城市
  6886. /// </summary>
  6887. /// <returns></returns>
  6888. [HttpGet]
  6889. public IActionResult OpCarCityResult()
  6890. {
  6891. var jw = JsonView(false);
  6892. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6893. {
  6894. x.Id,
  6895. x.Country,
  6896. x.City,
  6897. }).ToList();
  6898. if (data.Count > 0)
  6899. {
  6900. jw = JsonView(true, "获取成功!", data);
  6901. }
  6902. else
  6903. {
  6904. jw.Msg = "城市数据为空!";
  6905. jw.Data = new string[0];
  6906. }
  6907. return Ok(jw);
  6908. }
  6909. /// <summary>
  6910. /// 导出地接费用明细
  6911. /// </summary>
  6912. /// <param name="dto"></param>
  6913. /// <returns></returns>
  6914. [HttpPost]
  6915. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6916. {
  6917. var jw = JsonView(false);
  6918. if (dto.Diid < 1)
  6919. {
  6920. jw.Msg = "请输入正确的diid!";
  6921. return Ok(jw);
  6922. }
  6923. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6924. if (group == null)
  6925. {
  6926. jw.Msg = "未找到团组信息!";
  6927. return Ok(jw);
  6928. }
  6929. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6930. if (localGuideArr.Count == 0)
  6931. {
  6932. jw.Msg = "该团组暂无地接信息!";
  6933. return Ok(jw);
  6934. }
  6935. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6936. var overspendSoure = new Dictionary<int, int>
  6937. {
  6938. { 91, 982 }, //车
  6939. { 92 , 1059} ,//导游
  6940. { 994 , 1073}, //翻译
  6941. { 988 , 1074 }, //早餐
  6942. { 93 , 1075 }, //午餐
  6943. { 989 , 1076 }, //晚餐
  6944. };
  6945. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6946. foreach (var groupArr in localGroup)
  6947. {
  6948. var keyValue = groupArr.Key;
  6949. if (int.TryParse(keyValue, out int cityid))
  6950. {
  6951. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6952. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6953. }
  6954. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6955. foreach (var item in groupArr)
  6956. {
  6957. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6958. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6959. new Grp_CarTouristGuideGroundReservationsContentExtend
  6960. {
  6961. Count = a.Count,
  6962. CreateTime = a.CreateTime,
  6963. CreateUserId = a.CreateUserId,
  6964. CTGGRId = a.CTGGRId,
  6965. Currency = a.Currency,
  6966. DatePrice = a.DatePrice,
  6967. DeleteTime = a.DeleteTime,
  6968. DeleteUserId = a.DeleteUserId,
  6969. DiId = a.DiId,
  6970. Id = a.Id,
  6971. IsDel = a.IsDel,
  6972. Price = a.Price,
  6973. PriceContent = a.PriceContent,
  6974. Remark = a.Remark,
  6975. SId = a.SId,
  6976. SidName = b.Name,
  6977. Units = a.Units,
  6978. }
  6979. ).ToList();
  6980. if (content.Count > 0)
  6981. {
  6982. contentArr.Add(content);
  6983. }
  6984. }
  6985. //open excel
  6986. //set excel
  6987. //save excel
  6988. try
  6989. {
  6990. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6991. IWorkbook workbook;
  6992. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6993. {
  6994. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6995. }
  6996. else
  6997. {
  6998. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6999. }
  7000. ISheet sheet = workbook.GetSheetAt(0);
  7001. var rowStartIndex = 2;
  7002. var clounmCount = 10;
  7003. var initStyleRow = sheet.GetRow(2);
  7004. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7005. //var overspendArrDetail =
  7006. var existsId = new List<CarCompare>();
  7007. var lastElem = arr.Last();
  7008. var thisSid = -1;
  7009. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7010. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7011. {
  7012. Name = "未知币种!",
  7013. Remark = "未知币种!",
  7014. };
  7015. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7016. Action cloneRowFn = () =>
  7017. {
  7018. rowStartIndex++;
  7019. var cloneRow = sheet.CreateRow(rowStartIndex);
  7020. // 复制样式
  7021. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7022. {
  7023. ICell sourceCell = initStyleRow.GetCell(i);
  7024. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7025. // 确保单元格存在样式
  7026. if (sourceCell.CellStyle != null)
  7027. {
  7028. targetCell.CellStyle = sourceCell.CellStyle;
  7029. }
  7030. }
  7031. };
  7032. var mergeRow = () =>
  7033. {
  7034. for (int i = 2; i < sheet.LastRowNum; i++)
  7035. {
  7036. var row = sheet.GetRow(i);
  7037. var cellFirst = row.GetCell(0);
  7038. var thisIndex = i + 1;
  7039. while (thisIndex < sheet.LastRowNum)
  7040. {
  7041. var nextRow = sheet.GetRow(thisIndex);
  7042. var nextCellFirst = nextRow.GetCell(0);
  7043. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7044. {
  7045. thisIndex++;
  7046. }
  7047. else
  7048. {
  7049. break;
  7050. }
  7051. }
  7052. thisIndex--;
  7053. if (thisIndex != i)
  7054. {
  7055. //合并row
  7056. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7057. i, // 起始行索引(0-based)
  7058. thisIndex, // 结束行索引(0-based)
  7059. 0, // 起始列索引(0-based)
  7060. 0 // 结束列索引(0-based)
  7061. );
  7062. sheet.AddMergedRegion(cellRangeAddress);
  7063. i = thisIndex;
  7064. }
  7065. }
  7066. };
  7067. var chaoshiNumber = 0;
  7068. var totalNumber = 0.00M;
  7069. string lastStr = "";
  7070. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7071. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7072. {
  7073. b.IsAuditGM,
  7074. x.Id,
  7075. x.Area,
  7076. b.PayPercentage,
  7077. b.PayMoney,
  7078. }).ToList();
  7079. string yesPayment = "", noPayment = "";
  7080. foreach (var item in queryCarArrByCityAndDiid)
  7081. {
  7082. if (item.IsAuditGM == 1)
  7083. {
  7084. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7085. }
  7086. else
  7087. {
  7088. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7089. }
  7090. }
  7091. lastStr = yesPayment + noPayment;
  7092. foreach (var item in arr)
  7093. {
  7094. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  7095. {
  7096. if (thisSid != item.SId)
  7097. {
  7098. if (thisSid == -1)
  7099. {
  7100. thisSid = item.SId;
  7101. }
  7102. else
  7103. {
  7104. //合并小计行
  7105. //创建合并区域的实例
  7106. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7107. rowStartIndex, // 起始行索引(0-based)
  7108. rowStartIndex, // 结束行索引(0-based)
  7109. 0, // 起始列索引(0-based)
  7110. 3 // 结束列索引(0-based)
  7111. );
  7112. sheet.AddMergedRegion(cellRangeAddress);
  7113. var CellStyle = workbook.CreateCellStyle();
  7114. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7115. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7116. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7117. for (int i = 0; i <= clounmCount; i++)
  7118. {
  7119. if (i > 6)
  7120. {
  7121. var CellStyle1 = workbook.CreateCellStyle();
  7122. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7123. IFont Font = workbook.CreateFont(); // 创建字体
  7124. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7125. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7126. CellStyle1.SetFont(Font);
  7127. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7128. }
  7129. else
  7130. {
  7131. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7132. }
  7133. }
  7134. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7135. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7136. //超时合计
  7137. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7138. //超时数
  7139. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7140. //超时合计费用
  7141. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7142. thisSid = item.SId;
  7143. cloneRowFn();
  7144. chaoshiNumber = 0;
  7145. totalNumber = 0;
  7146. }
  7147. }
  7148. IRow row = sheet.GetRow(rowStartIndex);
  7149. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7150. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  7151. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  7152. if (isOpenOverspendSoure)
  7153. {
  7154. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7155. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  7156. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  7157. }
  7158. for (int i = 0; i <= clounmCount; i++)
  7159. {
  7160. var cell = row.GetCell(i);
  7161. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  7162. if (cell == null)
  7163. {
  7164. cell = row.CreateCell(i);
  7165. }
  7166. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  7167. fontRed.CloneStyleFrom(cell.CellStyle);
  7168. IFont Font = workbook.CreateFont(); // 创建字体
  7169. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  7170. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7171. fontRed.SetFont(Font);
  7172. byte[] rgb = new byte[3] { 255, 242, 204 };
  7173. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  7174. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  7175. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  7176. if (workbook is XSSFWorkbook)
  7177. {
  7178. BackgroundColor255_242_204.FillForegroundColor = 0;
  7179. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  7180. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  7181. }
  7182. else
  7183. {
  7184. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  7185. }
  7186. if (i == 1 || i > 6)
  7187. {
  7188. if (i > 6)
  7189. {
  7190. fontRed.FillForegroundColor = 0;
  7191. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  7192. fontRed.FillPattern = FillPattern.SolidForeground;
  7193. }
  7194. cell.CellStyle = fontRed;
  7195. }
  7196. if (i > 2 && i < 7)
  7197. {
  7198. cell.CellStyle = BackgroundColor255_242_204;
  7199. }
  7200. cell.SetCellValue(setCellValue); //写入单元格
  7201. }
  7202. if (overspendSoure.ContainsKey(thisSid))
  7203. {
  7204. var overspendId = overspendSoure[thisSid];
  7205. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7206. }
  7207. cloneRowFn();
  7208. existsId.Add(new CarCompare
  7209. {
  7210. DataPrice = item.DatePrice.ObjToDate(),
  7211. Sid = item.SId
  7212. });
  7213. }
  7214. if (item.Equals(lastElem))
  7215. {
  7216. //合并小计行
  7217. //创建合并区域的实例
  7218. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7219. rowStartIndex, // 起始行索引(0-based)
  7220. rowStartIndex, // 结束行索引(0-based)
  7221. 0, // 起始列索引(0-based)
  7222. 3 // 结束列索引(0-based)
  7223. );
  7224. sheet.AddMergedRegion(cellRangeAddress);
  7225. var CellStyle = workbook.CreateCellStyle();
  7226. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7227. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7228. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7229. for (int i = 0; i <= clounmCount; i++)
  7230. {
  7231. if (i > 6)
  7232. {
  7233. var CellStyle1 = workbook.CreateCellStyle();
  7234. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7235. IFont Font = workbook.CreateFont(); // 创建字体
  7236. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7237. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7238. CellStyle1.SetFont(Font);
  7239. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7240. }
  7241. else
  7242. {
  7243. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7244. }
  7245. }
  7246. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7247. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7248. //超时合计
  7249. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7250. //超时数
  7251. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7252. //超时合计费用
  7253. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7254. cloneRowFn();
  7255. // 创建合并区域的实例
  7256. cellRangeAddress = new CellRangeAddress(
  7257. rowStartIndex, // 起始行索引(0-based)
  7258. rowStartIndex, // 结束行索引(0-based)
  7259. 0, // 起始列索引(0-based)
  7260. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  7261. );
  7262. // 添加合并区域
  7263. sheet.AddMergedRegion(cellRangeAddress);
  7264. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  7265. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  7266. }
  7267. }
  7268. mergeRow();
  7269. // 保存修改后的Excel文件到新文件
  7270. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  7271. // new FileStream(newFilePath, FileMode.CreateNew)
  7272. using (var stream = new MemoryStream())
  7273. {
  7274. workbook.Write(stream, true);
  7275. stream.Flush();
  7276. stream.Seek(0, SeekOrigin.Begin);
  7277. MemoryStream memoryStream = new MemoryStream();
  7278. stream.CopyTo(memoryStream);
  7279. memoryStream.Seek(0, SeekOrigin.Begin);
  7280. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  7281. }
  7282. workbook.Close();
  7283. workbook.Dispose();
  7284. }
  7285. catch (Exception ex)
  7286. {
  7287. jw.Msg = "出现异常!" + ex.Message;
  7288. return Ok(jw);
  7289. }
  7290. }
  7291. if (Zips.Count > 0)
  7292. {
  7293. IOOperatorHelper io = new IOOperatorHelper();
  7294. var byts = io.ConvertZipStream(Zips);
  7295. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  7296. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  7297. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  7298. }
  7299. else
  7300. {
  7301. jw.Msg = "暂无生成文件!";
  7302. }
  7303. return Ok(jw);
  7304. }
  7305. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  7306. {
  7307. string outStr = string.Empty;
  7308. switch (i)
  7309. {
  7310. case 0:
  7311. outStr = arr[0].SidName;
  7312. break;
  7313. case 1:
  7314. outStr = arr[0].DataPriceStr;
  7315. break;
  7316. case 2:
  7317. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  7318. break;
  7319. case 4:
  7320. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  7321. break;
  7322. case 7:
  7323. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7324. {
  7325. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  7326. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  7327. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  7328. }
  7329. break;
  7330. case 8:
  7331. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7332. {
  7333. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  7334. }
  7335. break;
  7336. case 9:
  7337. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7338. {
  7339. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  7340. }
  7341. break;
  7342. case 10:
  7343. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  7344. {
  7345. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  7346. }
  7347. break;
  7348. }
  7349. return outStr;
  7350. }
  7351. #region OP行程单
  7352. /// <summary>
  7353. /// OP行程单初始化
  7354. /// </summary>
  7355. /// <param name="dto"></param>
  7356. /// <returns></returns>
  7357. [HttpPost]
  7358. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7359. {
  7360. var jw = JsonView(false);
  7361. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7362. var group = groupList.First();
  7363. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7364. if (group == null)
  7365. {
  7366. jw.Msg = "暂无团组!";
  7367. return Ok(jw);
  7368. }
  7369. group = groupList.Find(x => x.Id == diid);
  7370. if (group == null)
  7371. {
  7372. jw.Msg = "请输入正确的团组ID!";
  7373. return Ok(jw);
  7374. }
  7375. string city = string.Empty;
  7376. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7377. if (blackCode.Count > 0)
  7378. {
  7379. var black = blackCode.First();
  7380. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7381. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7382. if (blackSp.Length > 0)
  7383. {
  7384. try
  7385. {
  7386. var cityArrCode = new List<string>(20);
  7387. foreach (var item in blackSp)
  7388. {
  7389. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7390. var IndexSelect = itemSp[2];
  7391. var cityArrCodeLength = cityArrCode.Count - 1;
  7392. var startCity = IndexSelect.Substring(0, 3);
  7393. if (cityArrCodeLength > 0)
  7394. {
  7395. var arrEndCity = cityArrCode[cityArrCodeLength];
  7396. if (arrEndCity != startCity)
  7397. {
  7398. cityArrCode.Add(startCity.ToUpper());
  7399. }
  7400. }
  7401. else
  7402. {
  7403. cityArrCode.Add(startCity.ToUpper());
  7404. }
  7405. var endCity = IndexSelect.Substring(3, 3);
  7406. cityArrCode.Add(endCity.ToUpper());
  7407. }
  7408. var cityThree = string.Empty;
  7409. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7410. cityThree = cityThree.TrimEnd(',');
  7411. if (string.IsNullOrWhiteSpace(cityThree))
  7412. {
  7413. throw new
  7414. Exception("error");
  7415. }
  7416. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7417. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7418. foreach (var item in cityArrCode)
  7419. {
  7420. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7421. if (find != null)
  7422. {
  7423. city += find.City + "/";
  7424. }
  7425. else
  7426. {
  7427. city += item + "三字码未收入/";
  7428. }
  7429. }
  7430. city = city.TrimEnd('/');
  7431. }
  7432. catch (Exception e)
  7433. {
  7434. city = "黑屏代码格式不正确!";
  7435. }
  7436. }
  7437. }
  7438. else
  7439. {
  7440. city = "未录入黑屏代码";
  7441. }
  7442. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7443. {
  7444. Date = x.Date,
  7445. Days = x.Days,
  7446. Diffgroup = x.Diffgroup,
  7447. Diid = x.Diid,
  7448. Traffic_First = x.Traffic_First,
  7449. Traffic_Second = x.Traffic_Second,
  7450. Trip = x.Trip,
  7451. WeekDay = x.WeekDay,
  7452. Id = x.Id
  7453. }).ToList();
  7454. jw.Data = new
  7455. {
  7456. groupList = groupList.Select(x => new
  7457. {
  7458. x.Id,
  7459. x.TeamName,
  7460. x.TourCode
  7461. }).ToList(),
  7462. groupInfo = new
  7463. {
  7464. group.VisitDays,
  7465. group.TourCode,
  7466. group.VisitPNumber,
  7467. group.TeamName,
  7468. city
  7469. },
  7470. OpTravelList
  7471. };
  7472. jw.Code = 200;
  7473. jw.Msg = "操作成功!";
  7474. return Ok(jw);
  7475. }
  7476. /// <summary>
  7477. /// 删除团组行程单
  7478. /// </summary>
  7479. /// <returns></returns>
  7480. [HttpPost]
  7481. public IActionResult DelTravel(DelOpTravelDto dto)
  7482. {
  7483. var jw = JsonView(false);
  7484. if (dto.UserId <= 0 || dto.Diid <= 0)
  7485. {
  7486. jw.Msg = "请输入正确的参数!";
  7487. return Ok(jw);
  7488. }
  7489. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7490. .SetColumns(x => new Grp_TravelList
  7491. {
  7492. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7493. DeleteUserId = dto.UserId,
  7494. IsDel = 1,
  7495. }).ExecuteCommand();
  7496. jw = JsonView(true);
  7497. return Ok(jw);
  7498. }
  7499. /// <summary>
  7500. /// 行程单保存
  7501. /// </summary>
  7502. /// <returns></returns>
  7503. [HttpPost]
  7504. public IActionResult TravelSave(TravelSaveDto dto)
  7505. {
  7506. var jw = JsonView(false);
  7507. if (dto.Arr.Count > 0)
  7508. {
  7509. try
  7510. {
  7511. _sqlSugar.BeginTran();
  7512. foreach (var item in dto.Arr)
  7513. {
  7514. if (item.Id == 0)
  7515. {
  7516. throw new Exception("请传入正确的Id");
  7517. }
  7518. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7519. .SetColumns(x => new Grp_TravelList
  7520. {
  7521. Trip = item.Trip
  7522. }).ExecuteCommand();
  7523. }
  7524. _sqlSugar.CommitTran();
  7525. jw = JsonView(true);
  7526. }
  7527. catch (Exception ex)
  7528. {
  7529. _sqlSugar.RollbackTran();
  7530. jw.Msg = "程序异常!" + ex.Message;
  7531. }
  7532. }
  7533. else
  7534. {
  7535. jw.Msg = "请传入正确的参数!";
  7536. }
  7537. return Ok(jw);
  7538. }
  7539. /// <summary>
  7540. /// 导出行程单
  7541. /// </summary>
  7542. /// <param name="dto"></param>
  7543. /// <returns></returns>
  7544. [HttpPost]
  7545. public IActionResult ExportTravel(ExportTravelDto dto)
  7546. {
  7547. var jw = JsonView(false);
  7548. jw.Data = "";
  7549. int diid = 0;
  7550. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7551. if (Find == null)
  7552. {
  7553. jw.Msg = "请选择正确的团组!";
  7554. return Ok(jw);
  7555. }
  7556. else
  7557. {
  7558. diid = Find.Id;
  7559. }
  7560. //数据源
  7561. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7562. DataTable dtBlack = null;
  7563. try
  7564. {
  7565. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7566. }
  7567. catch (Exception)
  7568. {
  7569. jw.Msg = "机票黑屏代码有误!";
  7570. return Ok(jw);
  7571. }
  7572. string CityStr = string.Empty;
  7573. if (dtBlack.Rows.Count == 0)
  7574. {
  7575. jw.Msg = "机票黑屏代码有误!";
  7576. return Ok(jw);
  7577. }
  7578. else
  7579. {
  7580. foreach (DataRow row in dtBlack.Rows)
  7581. {
  7582. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7583. {
  7584. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7585. return Ok(jw);
  7586. }
  7587. }
  7588. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7589. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7590. }
  7591. //创建数据源Table
  7592. DataTable dtSource = new DataTable();
  7593. dtSource.Columns.Add("Days", typeof(string));
  7594. dtSource.Columns.Add("Date", typeof(string));
  7595. dtSource.Columns.Add("Week", typeof(string));
  7596. dtSource.Columns.Add("Traffic", typeof(string));
  7597. dtSource.Columns.Add("Trip", typeof(string));
  7598. //获取数据,放到datatable
  7599. foreach (var item in _travelList)
  7600. {
  7601. DataRow dr = dtSource.NewRow();
  7602. dr["Days"] = item.Days;
  7603. dr["Date"] = item.Date;
  7604. dr["Week"] = item.WeekDay;
  7605. dr["Traffic"] = item.Traffic_First
  7606. + "\r\n"
  7607. + item.Traffic_Second;
  7608. dr["Trip"] = item.Trip;
  7609. dtSource.Rows.Add(dr);
  7610. }
  7611. Dictionary<string, string> dic = new Dictionary<string, string>();
  7612. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7613. dic.Add("City", CityStr);
  7614. dic.Add("Days", Find.VisitDays.ToString());
  7615. dic.Add("DeleCode", Find.TourCode);
  7616. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7617. //模板路径
  7618. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7619. //载入模板
  7620. Document doc = null;
  7621. DocumentBuilder builder = null;
  7622. try
  7623. {
  7624. //载入模板
  7625. doc = new Document(tempPath);
  7626. builder = new DocumentBuilder(doc);
  7627. }
  7628. catch (Exception)
  7629. {
  7630. jw.Msg = "模板位置不存在!";
  7631. return Ok(jw);
  7632. }
  7633. foreach (var key in dic.Keys)
  7634. {
  7635. Bookmark bookmark = doc.Range.Bookmarks[key];
  7636. if (bookmark != null)
  7637. {
  7638. builder.MoveToBookmark(key);
  7639. builder.Write(dic[key]);
  7640. }
  7641. }
  7642. //获取word里所有表格
  7643. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7644. //获取所填表格的序数
  7645. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7646. try
  7647. {
  7648. //循环赋值
  7649. for (int i = 0; i < dtSource.Rows.Count; i++)
  7650. {
  7651. builder.MoveToCell(0, i + 1, 0, 0);
  7652. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7653. builder.MoveToCell(0, i + 1, 1, 0);
  7654. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7655. builder.MoveToCell(0, i + 1, 2, 0);
  7656. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7657. var trip = dtSource.Rows[i]["Trip"].ToString();
  7658. builder.MoveToCell(0, i + 1, 3, 0);
  7659. builder.Write(trip);
  7660. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7661. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7662. // 获取特定索引的段落
  7663. Paragraph paragraph = (Paragraph)paragraphs[0];
  7664. Run run = paragraph.Runs[0];
  7665. Aspose.Words.Font font = run.Font;
  7666. font.Name = "黑体";
  7667. //设置双休红色
  7668. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7669. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7670. paragraph = (Paragraph)paragraphs[1];
  7671. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7672. {
  7673. run = paragraph.Runs[0];
  7674. font = run.Font;
  7675. font.Color = Color.Red;
  7676. }
  7677. }
  7678. }
  7679. catch (Exception ex)
  7680. {
  7681. }
  7682. //删除多余行
  7683. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7684. {
  7685. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7686. }
  7687. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7688. if (!Directory.Exists(savePath))
  7689. {
  7690. try
  7691. {
  7692. Directory.CreateDirectory(savePath);
  7693. }
  7694. catch
  7695. {
  7696. }
  7697. }
  7698. string path = savePath + Find.TeamName + "出访日程";
  7699. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7700. try
  7701. {
  7702. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7703. string postfix = ".docx";
  7704. if (dto.IsPDF == 1)
  7705. {
  7706. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7707. postfix = ".pdf";
  7708. }
  7709. doc.Save(path + postfix, saveFormat);
  7710. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7711. }
  7712. catch (Exception)
  7713. {
  7714. jw = JsonView(false);
  7715. }
  7716. return Ok(jw);
  7717. }
  7718. /// <summary>
  7719. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7720. /// </summary>
  7721. /// <param name="num"></param>
  7722. /// <returns></returns>
  7723. string GetNum(string num)
  7724. {
  7725. string str = "";
  7726. switch (num)
  7727. {
  7728. case "1":
  7729. str = "一";
  7730. break;
  7731. case "2":
  7732. str = "二";
  7733. break;
  7734. case "3":
  7735. str = "三";
  7736. break;
  7737. case "4":
  7738. str = "四";
  7739. break;
  7740. case "5":
  7741. str = "五";
  7742. break;
  7743. case "6":
  7744. str = "六";
  7745. break;
  7746. case "7":
  7747. str = "七";
  7748. break;
  7749. case "8":
  7750. str = "八";
  7751. break;
  7752. case "9":
  7753. str = "九";
  7754. break;
  7755. case "10":
  7756. str = "十";
  7757. break;
  7758. case "11":
  7759. str = "十一";
  7760. break;
  7761. case "12":
  7762. str = "十二";
  7763. break;
  7764. case "一":
  7765. str = "1";
  7766. break;
  7767. case "二":
  7768. str = "2";
  7769. break;
  7770. case "三":
  7771. str = "3";
  7772. break;
  7773. case "四":
  7774. str = "4";
  7775. break;
  7776. case "五":
  7777. str = "5";
  7778. break;
  7779. case "六":
  7780. str = "6";
  7781. break;
  7782. case "七":
  7783. str = "7";
  7784. break;
  7785. case "八":
  7786. str = "8";
  7787. break;
  7788. case "九":
  7789. str = "9";
  7790. break;
  7791. case "十":
  7792. str = "10";
  7793. break;
  7794. case "十一":
  7795. str = "11";
  7796. break;
  7797. case "十二":
  7798. str = "12";
  7799. break;
  7800. }
  7801. return str;
  7802. }
  7803. #endregion
  7804. #endregion
  7805. #region 团组成本
  7806. /// <summary>
  7807. /// 团组成本数据初始化
  7808. /// </summary>
  7809. /// <param name="dto"></param>
  7810. /// <returns></returns>
  7811. [HttpPost]
  7812. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7813. {
  7814. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7815. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7816. WHEN COUNT(*) >= 0 THEN 'True'
  7817. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7818. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7819. ").ToList(); //团组列表
  7820. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7821. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7822. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7823. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7824. if (groupinfoValue != null)
  7825. {
  7826. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7827. var spArr = new string[1] { countryArr };
  7828. if (countryArr.Contains("|"))
  7829. {
  7830. spArr = countryArr.Split("|");
  7831. }
  7832. else if (countryArr.Contains("、"))
  7833. {
  7834. spArr = countryArr.Split("、");
  7835. }
  7836. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7837. {
  7838. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7839. if (dbQueryCountry != null)
  7840. {
  7841. visaCountryInfoArr.Add(dbQueryCountry);
  7842. }
  7843. }
  7844. }
  7845. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7846. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7847. var create = _GroupCostRepository.
  7848. CreateGroupCostByBlackCode(dto.Diid);
  7849. if (groupCost.Count == 0 && create.Code == 0)
  7850. {
  7851. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7852. }
  7853. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7854. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7855. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7856. groupCostMap = groupCostMap.Select(x =>
  7857. {
  7858. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7859. {
  7860. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7861. }
  7862. return x;
  7863. }).ToList();
  7864. //GroupCostParameter.Add(new
  7865. // Grp_GroupCostParameter());
  7866. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7867. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7868. return Ok(JsonView(new
  7869. {
  7870. groupList,
  7871. groupInfo,
  7872. groupChecks,
  7873. groupCost = groupCostMap,
  7874. hotelNumber,
  7875. GroupCostParameter = GroupCostParameterMap,
  7876. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7877. {
  7878. x.VisaCountry,
  7879. x.VisaPrice,
  7880. x.Id,
  7881. }).ToList(),
  7882. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7883. blackCodeIsTrue = create.Code == 0 ? true : false,
  7884. hotelIsTrue = hotelIsTrue,
  7885. }));
  7886. }
  7887. /// <summary>
  7888. /// 团组成本信息保存
  7889. /// </summary>
  7890. /// <param name="dto"></param>
  7891. /// <returns></returns>
  7892. [HttpPost]
  7893. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7894. {
  7895. if (dto.Diid <= 0 || dto.Userid <= 0)
  7896. {
  7897. return Ok(JsonView(false));
  7898. }
  7899. JsonView jw = null;
  7900. bool isTrue = false;
  7901. #region 复制团组成本
  7902. //if (dto.Diid == 2581)
  7903. //{
  7904. // dto.Diid = 2599;
  7905. // dto.CheckBoxs.ForEach(x =>
  7906. // {
  7907. // x.Diid = 2599;
  7908. // });
  7909. // dto.GroupCosts.ForEach(x =>
  7910. // {
  7911. // x.Diid = 2599;
  7912. // });
  7913. // dto.CostTypeHotelNumbers.ForEach(x =>
  7914. // {
  7915. // x.Diid = 2599;
  7916. // });
  7917. // dto.GroupCostParameters.ForEach(x =>
  7918. // {
  7919. // x.DiId = 2599;
  7920. // });
  7921. //}
  7922. #endregion
  7923. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7924. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7925. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7926. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7927. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7928. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7929. try
  7930. {
  7931. _sqlSugar.BeginTran();
  7932. isTrue = await _GroupCostRepository.
  7933. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7934. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7935. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7936. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7937. _sqlSugar.CommitTran();
  7938. jw = JsonView(true, "保存成功!", isTrue);
  7939. }
  7940. catch (Exception)
  7941. {
  7942. _sqlSugar.RollbackTran();
  7943. jw = JsonView(false);
  7944. }
  7945. return Ok(jw);
  7946. }
  7947. /// <summary>
  7948. /// 司兼导数据
  7949. /// </summary>
  7950. /// <param name="dto"></param>
  7951. /// <returns></returns>
  7952. [HttpPost]
  7953. public IActionResult GetCarGuides(CarGuidesDto dto)
  7954. {
  7955. JsonView jw = null;
  7956. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7957. jw = JsonView(true, "获取成功!", Data);
  7958. return Ok(jw);
  7959. }
  7960. /// <summary>
  7961. /// 导游数据
  7962. /// </summary>
  7963. /// <param name="dto"></param>
  7964. /// <returns></returns>
  7965. [HttpPost]
  7966. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7967. {
  7968. JsonView jw = null;
  7969. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7970. // 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
  7971. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7972. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7973. jw = JsonView(true, "获取成功!", Data);
  7974. return Ok(jw);
  7975. }
  7976. /// <summary>
  7977. /// 成本车数据
  7978. /// </summary>
  7979. /// <param name="dto"></param>
  7980. /// <returns></returns>
  7981. [HttpPost]
  7982. public IActionResult GetCarInfo(CarGuidesDto dto)
  7983. {
  7984. JsonView jw = null;
  7985. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7986. jw = JsonView(true, "获取成功!", Data);
  7987. return Ok(jw);
  7988. }
  7989. /// <summary>
  7990. /// 景点数据
  7991. /// </summary>
  7992. /// <param name="dto"></param>
  7993. /// <returns></returns>
  7994. [HttpPost]
  7995. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7996. {
  7997. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7998. return Ok(JsonView(true, "获取成功!", Data));
  7999. }
  8000. /// <summary>
  8001. /// 成本通知
  8002. /// </summary>
  8003. /// <param name="dto"></param>
  8004. /// <returns></returns>
  8005. [HttpPost]
  8006. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8007. {
  8008. if (dto.Diid < 0)
  8009. {
  8010. return Ok(JsonView(false));
  8011. }
  8012. JsonView jw = null;
  8013. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8014. if (GroupCostParameter != null)
  8015. {
  8016. int IsShare = 0;
  8017. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8018. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8019. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8020. string msg = string.Empty;
  8021. if (isTrue)
  8022. {
  8023. if (IsShare == 0)
  8024. {
  8025. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8026. }
  8027. else
  8028. {
  8029. #region 企微通知对应岗位用户
  8030. try
  8031. {
  8032. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8033. }
  8034. catch (Exception ex)
  8035. {
  8036. }
  8037. #endregion
  8038. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8039. }
  8040. jw = JsonView(isTrue, msg, new { IsShare });
  8041. }
  8042. else
  8043. {
  8044. msg = "修改失败!";
  8045. jw = JsonView(isTrue, msg);
  8046. }
  8047. }
  8048. else
  8049. {
  8050. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8051. }
  8052. return Ok(jw);
  8053. }
  8054. /// <summary>
  8055. /// 导出报价单
  8056. /// </summary>
  8057. /// <param name="dto"></param>
  8058. /// <returns></returns>
  8059. [HttpPost]
  8060. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8061. {
  8062. if (dto.Diid == 0)
  8063. {
  8064. return Ok(JsonView(false, "请传递团组id"));
  8065. }
  8066. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8067. if (deleInfo.Code != 0)
  8068. {
  8069. return Ok(JsonView(false, "团组信息查询失败!"));
  8070. }
  8071. var di = deleInfo.Data as DelegationInfoWebView;
  8072. if (di != null)
  8073. {
  8074. di.TeamName = di.TeamName.Replace("|", "、");
  8075. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8076. //文件名
  8077. string strFileName = di.TeamName + "-收款账单.doc";
  8078. //获取模板
  8079. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8080. //载入模板
  8081. Document doc = new Document(tmppath);
  8082. decimal TotalPrice = 0.00M;
  8083. string itemStr = string.Empty;
  8084. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  8085. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8086. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8087. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  8088. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  8089. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  8090. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  8091. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  8092. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  8093. foreach (var cost in groupCostType)
  8094. {
  8095. var List = cost.ToList();
  8096. if (cost.Key == "A")
  8097. {
  8098. foreach (var ListItem in List)
  8099. {
  8100. if (ListItem.number > 0)
  8101. {
  8102. if (ListItem.code.Contains("TBR"))
  8103. {
  8104. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8105. }
  8106. else
  8107. {
  8108. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8109. }
  8110. TotalPrice += (ListItem.number * ListItem.price);
  8111. }
  8112. }
  8113. }
  8114. else
  8115. {
  8116. itemStr = itemStr.Insert(0, "A段\r\n");
  8117. itemStr += "B段\r\n";
  8118. foreach (var ListItem in List)
  8119. {
  8120. if (ListItem.number > 0)
  8121. {
  8122. if (ListItem.code.Contains("TBR"))
  8123. {
  8124. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8125. }
  8126. else
  8127. {
  8128. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8129. }
  8130. TotalPrice += (ListItem.number * ListItem.price);
  8131. }
  8132. }
  8133. }
  8134. }
  8135. #region 替换Word模板书签内容
  8136. Dictionary<string, string> marks = new Dictionary<string, string>();
  8137. marks.Add("To", di.ClientUnit);//付款方
  8138. marks.Add("ToTel", di.TellPhone);//付款方电话
  8139. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  8140. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  8141. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  8142. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  8143. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  8144. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  8145. marks.Add("PayItemContent", itemStr);//详细信息
  8146. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  8147. #endregion
  8148. ////注
  8149. //if (doc.Range.Bookmarks["Attention"] != null)
  8150. //{
  8151. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  8152. // mark.Text = frList[0].Attention;
  8153. //}
  8154. foreach (var item in marks.Keys)
  8155. {
  8156. if (doc.Range.Bookmarks[item] != null)
  8157. {
  8158. Bookmark mark = doc.Range.Bookmarks[item];
  8159. mark.Text = marks[item];
  8160. }
  8161. }
  8162. byte[] bytes = null;
  8163. using (MemoryStream stream = new MemoryStream())
  8164. {
  8165. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8166. bytes = stream.ToArray();
  8167. }
  8168. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  8169. return Ok(JsonView(true, "", new
  8170. {
  8171. Data = bytes,
  8172. strFileName,
  8173. }));
  8174. }
  8175. else
  8176. {
  8177. return Ok(JsonView(false, "团组信息不存在!"));
  8178. }
  8179. }
  8180. /// <summary>
  8181. /// 导出团组成本
  8182. /// </summary>
  8183. /// <param name="dto"></param>
  8184. /// <returns></returns>
  8185. [HttpPost]
  8186. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  8187. {
  8188. var jw = JsonView(false);
  8189. if (dto.Diid == 0)
  8190. {
  8191. return Ok(JsonView(false, "请传递团组id"));
  8192. }
  8193. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8194. if (deleInfo.Code != 0)
  8195. {
  8196. return Ok(JsonView(false, "团组信息查询失败!"));
  8197. }
  8198. var di = deleInfo.Data as DelegationInfoWebView;
  8199. if (di == null)
  8200. {
  8201. return Ok(JsonView(false, "团组信息查询失败!"));
  8202. }
  8203. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  8204. WorkbookDesigner designer = new WorkbookDesigner();
  8205. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  8206. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  8207. for (int i = 0; i < List_GC.Count; i++)
  8208. {
  8209. GroupCost_Excel gc = new GroupCost_Excel();
  8210. gc.Id = List_GC[i].Id;
  8211. gc.Diid = List_GC[i].Diid.ToString();
  8212. gc.DAY = List_GC[i].DAY;
  8213. string week = "";
  8214. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  8215. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  8216. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  8217. gc.ITIN = List_GC[i].ITIN;
  8218. gc.CarType = List_GC[i].CarType;
  8219. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  8220. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  8221. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  8222. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  8223. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  8224. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  8225. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  8226. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  8227. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  8228. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  8229. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  8230. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  8231. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8232. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  8233. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  8234. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  8235. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  8236. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  8237. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  8238. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  8239. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  8240. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  8241. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  8242. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  8243. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  8244. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  8245. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  8246. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  8247. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  8248. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  8249. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  8250. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  8251. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  8252. List_GC1.Add(gc);
  8253. }
  8254. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  8255. dt.TableName = "TB";
  8256. //报表标题等不用dt的值
  8257. designer.SetDataSource("TeamName", dto.title.TeamName);
  8258. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  8259. designer.SetDataSource("Tax", dto.title.Tax);
  8260. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  8261. designer.SetDataSource("Currency", dto.title.Currency);
  8262. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  8263. designer.SetDataSource("Rate", dto.title.Rate);
  8264. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  8265. var Aparams = hotels.Find(x => x.Type == "Default");
  8266. if (Aparams == null)
  8267. {
  8268. return Ok(jw);
  8269. }
  8270. //酒店数量
  8271. var txtSGRNumber = Aparams.SGR.ToString();
  8272. var txtTBRNumber = Aparams.TBR.ToString();
  8273. var txtJSESNumber = Aparams.JSES.ToString();
  8274. var txtSUITENumbe = Aparams.SUITE.ToString();
  8275. if (dto.costType == "B")
  8276. {
  8277. Aparams = hotels.Find(x => x.Type == "A");
  8278. var Bparams = hotels.Find(x => x.Type == "B");
  8279. if (Aparams == null || Bparams == null)
  8280. {
  8281. return Ok(jw);
  8282. }
  8283. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  8284. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  8285. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  8286. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  8287. }
  8288. designer.SetDataSource("SGRNumber", txtSGRNumber);
  8289. designer.SetDataSource("TBRNumber", txtTBRNumber);
  8290. designer.SetDataSource("JSESNumber", txtJSESNumber);
  8291. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  8292. var ws = designer.Workbook.Worksheets[0];
  8293. int Row = List_GC.Count;
  8294. int startIndex = 11;
  8295. int HideRows = 0;
  8296. List<int> hideRowsList = new List<int>();
  8297. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  8298. #region A段left数据
  8299. var left = dto.leftInfo.Find(x => x.Type == "A");
  8300. if (left == null)
  8301. {
  8302. return Ok(jw);
  8303. }
  8304. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  8305. if (leftBindData != null)
  8306. {
  8307. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  8308. designer.SetDataSource("VisaRS", leftBindData.rs);
  8309. designer.SetDataSource("VisaXS", leftBindData.xs);
  8310. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8311. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8312. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8313. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8314. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8315. }
  8316. else
  8317. {
  8318. hideRowsList.Add(Row + startIndex + HideRows);
  8319. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8320. }
  8321. HideRows += 2;
  8322. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  8323. if (leftBindData != null)
  8324. {
  8325. designer.SetDataSource("BXDRCB", leftBindData.cb);
  8326. designer.SetDataSource("BXRS", leftBindData.rs);
  8327. designer.SetDataSource("BXXS", leftBindData.xs);
  8328. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8329. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8330. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8331. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8332. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8333. }
  8334. else
  8335. {
  8336. hideRowsList.Add(Row + startIndex + HideRows);
  8337. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8338. }
  8339. HideRows += 2;
  8340. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8341. if (leftBindData != null)
  8342. {
  8343. designer.SetDataSource("HSDRCB", leftBindData.cb);
  8344. designer.SetDataSource("HSRS", leftBindData.rs);
  8345. designer.SetDataSource("HSXS", leftBindData.xs);
  8346. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8347. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8348. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8349. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8350. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8351. }
  8352. else
  8353. {
  8354. hideRowsList.Add(Row + startIndex + HideRows);
  8355. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8356. }
  8357. HideRows += 2;
  8358. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8359. if (leftBindData != null)
  8360. {
  8361. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8362. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8363. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8364. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8365. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8366. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8367. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8368. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8369. }
  8370. else
  8371. {
  8372. hideRowsList.Add(Row + startIndex + HideRows);
  8373. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8374. }
  8375. HideRows += 2;
  8376. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8377. if (leftBindData != null)
  8378. {
  8379. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8380. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8381. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8382. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8383. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8384. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8385. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8386. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8387. }
  8388. else
  8389. {
  8390. hideRowsList.Add(Row + startIndex + HideRows);
  8391. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8392. }
  8393. HideRows += 2;
  8394. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8395. if (leftBindData != null)
  8396. {
  8397. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8398. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8399. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8400. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8401. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8402. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8403. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8404. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8405. }
  8406. else
  8407. {
  8408. hideRowsList.Add(Row + startIndex + HideRows);
  8409. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8410. }
  8411. HideRows += 2;
  8412. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8413. if (leftBindData != null)
  8414. {
  8415. ////TBR
  8416. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8417. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8418. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8419. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8420. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8421. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8422. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8423. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8424. }
  8425. else
  8426. {
  8427. hideRowsList.Add(Row + startIndex + HideRows);
  8428. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8429. }
  8430. HideRows += 2;
  8431. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8432. if (leftBindData != null)
  8433. {
  8434. ////SGR
  8435. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8436. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8437. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8438. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8439. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8440. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8441. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8442. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8443. }
  8444. else
  8445. {
  8446. hideRowsList.Add(Row + startIndex + HideRows);
  8447. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8448. }
  8449. HideRows += 2;
  8450. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8451. if (leftBindData != null)
  8452. {
  8453. ////JS/ES
  8454. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8455. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8456. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8457. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8458. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8459. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8460. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8461. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8462. }
  8463. else
  8464. {
  8465. hideRowsList.Add(Row + startIndex + HideRows);
  8466. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8467. }
  8468. HideRows += 2;
  8469. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8470. if (leftBindData != null)
  8471. {
  8472. ////SUITE
  8473. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8474. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8475. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8476. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8477. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8478. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8479. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8480. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8481. }
  8482. else
  8483. {
  8484. hideRowsList.Add(Row + startIndex + HideRows);
  8485. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8486. }
  8487. HideRows += 2;
  8488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8489. if (leftBindData != null)
  8490. {
  8491. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8492. designer.SetDataSource("DJRS", leftBindData.rs);
  8493. designer.SetDataSource("DJXS", leftBindData.xs);
  8494. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8495. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8496. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8497. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8498. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8499. }
  8500. else
  8501. {
  8502. hideRowsList.Add(Row + startIndex + HideRows);
  8503. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8504. }
  8505. HideRows += 2;
  8506. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8507. if (leftBindData != null)
  8508. {
  8509. designer.SetDataSource("HCPCB", leftBindData.cb);
  8510. designer.SetDataSource("HCPRS", leftBindData.rs);
  8511. designer.SetDataSource("HCPXS", leftBindData.xs);
  8512. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8513. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8514. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8515. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8516. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8517. }
  8518. else
  8519. {
  8520. hideRowsList.Add(Row + startIndex + HideRows);
  8521. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8522. }
  8523. HideRows += 2;
  8524. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8525. if (leftBindData != null)
  8526. {
  8527. designer.SetDataSource("CPCB", leftBindData.cb);
  8528. designer.SetDataSource("CPRS", leftBindData.rs);
  8529. designer.SetDataSource("CPXS", leftBindData.xs);
  8530. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8531. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8532. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8533. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8534. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8535. }
  8536. else
  8537. {
  8538. hideRowsList.Add(Row + startIndex + HideRows);
  8539. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8540. }
  8541. HideRows += 2;
  8542. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8543. if (leftBindData != null)
  8544. {
  8545. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8546. designer.SetDataSource("GWRS", leftBindData.rs);
  8547. designer.SetDataSource("GWXS", leftBindData.xs);
  8548. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8549. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8550. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8551. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8552. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8553. }
  8554. else
  8555. {
  8556. hideRowsList.Add(Row + startIndex + HideRows);
  8557. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8558. }
  8559. HideRows += 2;
  8560. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8561. if (leftBindData != null)
  8562. {
  8563. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8564. designer.SetDataSource("LYJRS", leftBindData.rs);
  8565. designer.SetDataSource("LYJXS", leftBindData.xs);
  8566. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8567. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8568. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8569. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8570. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8571. }
  8572. else
  8573. {
  8574. hideRowsList.Add(Row + startIndex + HideRows);
  8575. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8576. }
  8577. #endregion
  8578. #region A段Right信息
  8579. var right = dto.rightInfo.Find(x => x.Type == "A");
  8580. if (right == null)
  8581. {
  8582. return Ok(jw);
  8583. }
  8584. HideRows += 4;
  8585. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8586. if (rightBindData != null)
  8587. {
  8588. //经济舱 + 双人间 TBR
  8589. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8590. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8591. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8592. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8593. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8594. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8595. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8596. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8597. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8598. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8599. }
  8600. else
  8601. {
  8602. hideRowsList.Add(Row + startIndex + HideRows);
  8603. }
  8604. HideRows += 2;
  8605. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8606. if (rightBindData != null)
  8607. {
  8608. //经济舱 + 单人间 SGR
  8609. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8610. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8611. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8612. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8613. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8614. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8615. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8616. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8617. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8618. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8619. }
  8620. else
  8621. {
  8622. hideRowsList.Add(Row + startIndex + HideRows);
  8623. }
  8624. HideRows += 2;
  8625. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8626. if (rightBindData != null)
  8627. {
  8628. //公务舱 + 单人间 SGR
  8629. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8630. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8631. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8632. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8633. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8634. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8635. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8636. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8637. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8638. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8639. }
  8640. else
  8641. {
  8642. hideRowsList.Add(Row + startIndex + HideRows);
  8643. }
  8644. HideRows += 2;
  8645. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8646. if (rightBindData != null)
  8647. {
  8648. //公务舱 + 小套房 JSES
  8649. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8650. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8651. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8652. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8653. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8654. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8655. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8656. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8657. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8658. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8659. }
  8660. else
  8661. {
  8662. hideRowsList.Add(Row + startIndex + HideRows);
  8663. }
  8664. HideRows += 2;
  8665. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8666. if (rightBindData != null)
  8667. {
  8668. //公务舱 + 小套房 JSES
  8669. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8670. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8671. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8672. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8673. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8674. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8675. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8676. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8677. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8678. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8679. }
  8680. else
  8681. {
  8682. hideRowsList.Add(Row + startIndex + HideRows);
  8683. }
  8684. HideRows += 2;
  8685. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8686. if (rightBindData != null)
  8687. {
  8688. //经济舱 + 大套房
  8689. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8690. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8691. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8692. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8693. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8694. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8695. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8696. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8697. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8698. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8699. }
  8700. else
  8701. {
  8702. hideRowsList.Add(Row + startIndex + HideRows);
  8703. }
  8704. HideRows += 2;
  8705. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8706. if (rightBindData != null)
  8707. {
  8708. //头等舱 + 小套房 JSES
  8709. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8710. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8711. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8712. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8713. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8714. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8715. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8716. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8717. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8718. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8719. }
  8720. else
  8721. {
  8722. hideRowsList.Add(Row + startIndex + HideRows);
  8723. }
  8724. HideRows += 2;
  8725. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8726. if (rightBindData != null)
  8727. {
  8728. //头等舱 + 大套房
  8729. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8730. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8731. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8732. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8733. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8734. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8735. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8736. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8737. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8738. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8739. }
  8740. else
  8741. {
  8742. hideRowsList.Add(Row + startIndex + HideRows);
  8743. }
  8744. #endregion
  8745. #region B段标题清空
  8746. designer.SetDataSource("CostBDRCB", "");
  8747. designer.SetDataSource("CostBRS", "");
  8748. designer.SetDataSource("CostBXS", "");
  8749. designer.SetDataSource("CostBZCB", "");
  8750. designer.SetDataSource("CostBDRBJ", "");
  8751. designer.SetDataSource("CostBZBJ", "");
  8752. designer.SetDataSource("CostBDRLR", "");
  8753. designer.SetDataSource("CostBZLR", "");
  8754. designer.SetDataSource("CostBDRCBOM", "");
  8755. designer.SetDataSource("CostBRSOM", "");
  8756. designer.SetDataSource("CostBZCBOM", "");
  8757. designer.SetDataSource("CostBDRBJOM", "");
  8758. designer.SetDataSource("CostBZBJOM", "");
  8759. designer.SetDataSource("CostBDRLROM", "");
  8760. designer.SetDataSource("CostBZLROM", "");
  8761. #endregion
  8762. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8763. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8764. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8765. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8766. designer.SetDataSource("DJName", "地接(CNY)");
  8767. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8768. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8769. designer.SetDataSource("GWName", "公务(CNY)");
  8770. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8771. designer.SetDataSource("LYJName", "零用金(CNY)");
  8772. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8773. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8774. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8775. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8776. designer.SetDataSource("BXName", "保险(CNY)");
  8777. designer.SetDataSource("VisaName", "签证(CNY)");
  8778. #region B段基本数据
  8779. if (dto.costType == "B")
  8780. {
  8781. left = dto.leftInfo.Find(x => x.Type == "B");
  8782. if (left == null)
  8783. {
  8784. return Ok(jw);
  8785. }
  8786. #region B段left数据
  8787. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8788. if (leftBindData != null)
  8789. {
  8790. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8791. designer.SetDataSource("BHSRS", leftBindData.rs);
  8792. designer.SetDataSource("BHSXS", leftBindData.xs);
  8793. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8794. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8795. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8796. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8797. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8798. }
  8799. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8800. if (leftBindData != null)
  8801. {
  8802. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8803. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8804. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8805. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8806. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8807. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8808. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8809. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8810. }
  8811. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8812. if (leftBindData != null)
  8813. {
  8814. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8815. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8816. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8817. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8818. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8819. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8820. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8821. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8822. }
  8823. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8824. if (leftBindData != null)
  8825. {
  8826. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8827. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8828. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8829. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8830. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8831. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8832. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8833. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8834. }
  8835. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8836. if (leftBindData != null)
  8837. {
  8838. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8839. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8840. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8841. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8842. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8843. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8844. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8845. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8846. }
  8847. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8848. if (leftBindData != null)
  8849. {
  8850. designer.SetDataSource("BCPCB", leftBindData.cb);
  8851. designer.SetDataSource("BCPRS", leftBindData.rs);
  8852. designer.SetDataSource("BCPXS", leftBindData.xs);
  8853. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8854. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8855. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8856. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8857. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8858. }
  8859. //TBR
  8860. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8861. if (leftBindData != null)
  8862. {
  8863. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8864. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8865. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8866. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8867. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8868. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8869. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8870. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8871. }
  8872. //SGR
  8873. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8874. if (leftBindData != null)
  8875. {
  8876. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8877. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8878. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8879. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8880. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8881. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8882. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8883. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8884. }
  8885. //JS/ES
  8886. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8887. if (leftBindData != null)
  8888. {
  8889. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8890. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8891. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8892. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8893. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8894. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8895. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8896. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8897. }
  8898. //SUITE
  8899. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8900. if (leftBindData != null)
  8901. {
  8902. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8903. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8904. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8905. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8906. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8907. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8908. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8909. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8910. }
  8911. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8912. if (leftBindData != null)
  8913. {
  8914. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8915. designer.SetDataSource("BDJRS", leftBindData.rs);
  8916. designer.SetDataSource("BDJXS", leftBindData.xs);
  8917. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8918. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8919. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8920. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8921. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8922. }
  8923. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8924. if (leftBindData != null)
  8925. {
  8926. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8927. designer.SetDataSource("BGWRS", leftBindData.rs);
  8928. designer.SetDataSource("BGWXS", leftBindData.xs);
  8929. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8930. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8931. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8932. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8933. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8934. }
  8935. #region 优化方案
  8936. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8937. //excelBind.Add("零用金", new {
  8938. //cb="",
  8939. //rs="",
  8940. //xs ="",
  8941. //zcb = "",
  8942. //});
  8943. #endregion
  8944. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8945. if (leftBindData != null)
  8946. {
  8947. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8948. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8949. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8950. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8951. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8952. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8953. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8954. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8955. }
  8956. #endregion
  8957. #region B段Right信息
  8958. right = dto.rightInfo.Find(x => x.Type == "B");
  8959. if (right == null)
  8960. {
  8961. return Ok(jw);
  8962. }
  8963. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8964. if (rightBindData != null)
  8965. {
  8966. //经济舱 + 双人间 TBR
  8967. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8968. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8969. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8970. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8971. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8972. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8973. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8974. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8975. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8976. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8977. }
  8978. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8979. if (rightBindData != null)
  8980. {
  8981. //经济舱 + 单人间 SGR
  8982. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8983. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8984. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8985. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8986. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8987. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8988. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8989. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8990. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8991. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8992. }
  8993. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8994. if (rightBindData != null)
  8995. {
  8996. //公务舱 + 单人间 SGR
  8997. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8998. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8999. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9000. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9001. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9002. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9003. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9004. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9005. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9006. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9007. }
  9008. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9009. if (rightBindData != null)
  9010. {
  9011. //公务舱 + 小套房 JSES
  9012. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9013. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9014. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9015. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9016. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9017. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9018. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9019. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9020. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9021. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9022. }
  9023. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9024. if (rightBindData != null)
  9025. {
  9026. //公务舱 + 小套房 JSES
  9027. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9028. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9029. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9030. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9031. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9032. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9033. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9034. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9035. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9036. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9037. }
  9038. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9039. if (rightBindData != null)
  9040. {
  9041. //经济舱 + 大套房
  9042. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9043. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9044. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9045. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9046. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9047. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9048. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9049. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9050. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9051. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9052. }
  9053. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9054. if (rightBindData != null)
  9055. {
  9056. //头等舱 + 小套房 JSES
  9057. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9058. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9059. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9060. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9061. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9062. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9063. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9064. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9065. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9066. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9067. }
  9068. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9069. if (rightBindData != null)
  9070. {
  9071. //头等舱 + 大套房
  9072. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9073. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9074. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9075. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9076. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9077. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9078. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9079. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9080. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9081. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9082. }
  9083. #endregion
  9084. #region 标题
  9085. designer.SetDataSource("CostBDRCB", "单人成本");
  9086. designer.SetDataSource("CostBRS", "人数");
  9087. designer.SetDataSource("CostBXS", "系数");
  9088. designer.SetDataSource("CostBZCB", "总成本");
  9089. designer.SetDataSource("CostBDRBJ", "单人报价");
  9090. designer.SetDataSource("CostBZBJ", "总报价");
  9091. designer.SetDataSource("CostBDRLR", "单人利润");
  9092. designer.SetDataSource("CostBZLR", "总利润");
  9093. designer.SetDataSource("CostBDRCBOM", "单人成本");
  9094. designer.SetDataSource("CostBRSOM", "人数");
  9095. designer.SetDataSource("CostBZCBOM", "总成本");
  9096. designer.SetDataSource("CostBDRBJOM", "单人报价");
  9097. designer.SetDataSource("CostBZBJOM", "总报价");
  9098. designer.SetDataSource("CostBDRLROM", "单人利润");
  9099. designer.SetDataSource("CostBZLROM", "总利润");
  9100. #endregion
  9101. }
  9102. #endregion
  9103. designer.SetDataSource("TzZCB2", TzZCB2);
  9104. designer.SetDataSource("TzZBJ2", TzZBJ2);
  9105. designer.SetDataSource("TzZLR2", TzZLR2);
  9106. string[] dataSourceKeys = new string[]
  9107. {
  9108. "VF",
  9109. "TGS",
  9110. "TGOF",
  9111. "TGM",
  9112. "TGA",
  9113. "TGTF",
  9114. "TGEF",
  9115. "CFM",
  9116. "CFOF",
  9117. "B",
  9118. "L",
  9119. "D",
  9120. "TBR",
  9121. "SGR",
  9122. "JSES",
  9123. "Suite",
  9124. "TV",
  9125. "1L",
  9126. "IF",
  9127. "EF",
  9128. "BRF",
  9129. "TE",
  9130. "TGT",
  9131. "DRVT",
  9132. "PC",
  9133. "TLF",
  9134. "ECT"
  9135. };
  9136. foreach (var item in dataSourceKeys)
  9137. {
  9138. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  9139. if (find != null)
  9140. {
  9141. designer.SetDataSource(item, find.text);
  9142. }
  9143. else
  9144. {
  9145. designer.SetDataSource(item, 0);
  9146. }
  9147. }
  9148. designer.SetDataSource(dt);
  9149. //根据数据源处理生成报表内容
  9150. designer.Process();
  9151. designer.Workbook.Worksheets[0].Name = "清单";
  9152. Worksheet sheet = designer.Workbook.Worksheets[0];
  9153. foreach (var Rowindex in hideRowsList)
  9154. {
  9155. ws.Cells.HideRows(Rowindex, 2);
  9156. }
  9157. byte[] bytes = null;
  9158. string strFileName = di.TeamName + "-团组-成本.xls";
  9159. using (MemoryStream stream = new MemoryStream())
  9160. {
  9161. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  9162. bytes = stream.ToArray();
  9163. }
  9164. return Ok(JsonView(true, "", new
  9165. {
  9166. Data = bytes,
  9167. strFileName,
  9168. }));
  9169. }
  9170. /// <summary>
  9171. /// 导出客户报表
  9172. /// </summary>
  9173. /// <returns></returns>
  9174. [HttpPost]
  9175. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  9176. {
  9177. var jw = JsonView(false);
  9178. if (dto.Diid == 0)
  9179. {
  9180. return Ok(JsonView(false, "请传递团组id"));
  9181. }
  9182. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9183. if (deleInfo.Code != 0)
  9184. {
  9185. return Ok(JsonView(false, "团组信息查询失败!"));
  9186. }
  9187. var di = deleInfo.Data as DelegationInfoWebView;
  9188. if (di == null)
  9189. {
  9190. return Ok(JsonView(false, "团组信息查询失败!"));
  9191. }
  9192. //文件名
  9193. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  9194. //获取模板
  9195. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  9196. //载入模板
  9197. Document doc = new Document(tmppath);
  9198. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  9199. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  9200. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  9201. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  9202. var AParameter = ParameterList.Find(x => x.CostType == "A");
  9203. var BParameter = ParameterList.Find(x => x.CostType == "B");
  9204. if (AParameter == null)
  9205. {
  9206. return Ok(JsonView(false, "系数不存在!"));
  9207. }
  9208. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  9209. , TzAirDesc, TzZCost;
  9210. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  9211. = TzAirDesc = TzZCost = string.Empty;
  9212. TzNumber = AParameter.CostTypenumber.ToString();
  9213. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  9214. CarGuides1 = dto.CarGuides1;
  9215. Meal = dto.Meal;
  9216. SubsidizedMeals = dto.SubsidizedMeals;
  9217. NightRepair = dto.NightRepair;
  9218. AttractionsTickets = dto.AttractionsTickets;
  9219. MiscellaneousFees = dto.MiscellaneousFees;
  9220. ATip = dto.ATip;
  9221. TzHotelDesc = "";
  9222. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  9223. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  9224. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  9225. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  9226. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  9227. TzAirDesc = "";
  9228. TzZCost = dto.TzZCost;
  9229. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  9230. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  9231. var index = 1;
  9232. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  9233. foreach (var item in TzHotelDescArr)
  9234. {
  9235. if (AinfoArr != null)
  9236. {
  9237. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9238. if (Ainfo != null)
  9239. {
  9240. if (int.Parse(Ainfo.rs) <= 0)
  9241. {
  9242. continue;
  9243. }
  9244. var hotelText = string.Empty;
  9245. switch (item)
  9246. {
  9247. case "SGR":
  9248. hotelText = "单人间";
  9249. break;
  9250. case "JSES":
  9251. hotelText = "小套房";
  9252. break;
  9253. case "SUITE":
  9254. hotelText = "套房";
  9255. break;
  9256. case "TBR":
  9257. hotelText = "双人间";
  9258. break;
  9259. }
  9260. if (item != "TBR")
  9261. {
  9262. 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";
  9263. }
  9264. else
  9265. {
  9266. 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";
  9267. }
  9268. index++;
  9269. }
  9270. }
  9271. }
  9272. index = 1;
  9273. foreach (var item in TzAirDescArr)
  9274. {
  9275. if (AinfoArr != null)
  9276. {
  9277. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9278. if (Ainfo != null)
  9279. {
  9280. if (int.Parse(Ainfo.rs) <= 0)
  9281. {
  9282. continue;
  9283. }
  9284. 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";
  9285. index++;
  9286. }
  9287. }
  9288. }
  9289. if (dto.costType == "B")
  9290. {
  9291. if (BParameter == null)
  9292. {
  9293. return Ok(JsonView(false, "B段系数不存在!"));
  9294. }
  9295. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  9296. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  9297. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  9298. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  9299. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  9300. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  9301. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  9302. foreach (var item in TzHotelDescArr)
  9303. {
  9304. if (AinfoArr != null)
  9305. {
  9306. TzHotelDesc += "B段信息 \r\n";
  9307. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9308. if (Ainfo != null)
  9309. {
  9310. if (int.Parse(Ainfo.rs) <= 0)
  9311. {
  9312. continue;
  9313. }
  9314. var hotelText = string.Empty;
  9315. switch (item)
  9316. {
  9317. case "SGR":
  9318. hotelText = "单人间";
  9319. break;
  9320. case "JSES":
  9321. hotelText = "小套房";
  9322. break;
  9323. case "SUITE":
  9324. hotelText = "套房";
  9325. break;
  9326. case "TBR":
  9327. hotelText = "双人间";
  9328. break;
  9329. }
  9330. if (item != "TBR")
  9331. {
  9332. 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";
  9333. }
  9334. else
  9335. {
  9336. 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";
  9337. }
  9338. index++;
  9339. }
  9340. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  9341. }
  9342. }
  9343. index = 1;
  9344. foreach (var item in TzAirDescArr)
  9345. {
  9346. if (AinfoArr != null)
  9347. {
  9348. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9349. if (Ainfo != null)
  9350. {
  9351. if (int.Parse(Ainfo.rs) <= 0)
  9352. {
  9353. continue;
  9354. }
  9355. 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";
  9356. index++;
  9357. }
  9358. }
  9359. }
  9360. }
  9361. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9362. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9363. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9364. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9365. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9366. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9367. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9368. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9369. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9370. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9371. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9372. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9373. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9374. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9375. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9376. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9377. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9378. DickeyValue.Add("TzZCost", TzZCost);
  9379. foreach (var key in DickeyValue.Keys)
  9380. {
  9381. if (doc.Range.Bookmarks[key] != null)
  9382. {
  9383. Bookmark mark = doc.Range.Bookmarks[key];
  9384. mark.Text = DickeyValue[key];
  9385. }
  9386. }
  9387. byte[] bytes = null;
  9388. string strFileName = di.TeamName + "-客户报价.doc";
  9389. using (MemoryStream stream = new MemoryStream())
  9390. {
  9391. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9392. bytes = stream.ToArray();
  9393. }
  9394. return Ok(JsonView(true, "", new
  9395. {
  9396. Data = bytes,
  9397. strFileName,
  9398. }));
  9399. }
  9400. /// <summary>
  9401. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9402. /// </summary>
  9403. /// <param name="dto"></param>
  9404. /// <returns></returns>
  9405. [HttpPost]
  9406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9407. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9408. {
  9409. try
  9410. {
  9411. #region 参数验证
  9412. if (dto.DiId < 0)
  9413. {
  9414. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9415. }
  9416. List<int> cTableIds = new List<int>() {
  9417. 76 ,//酒店预订
  9418. 77 ,//行程
  9419. 79 ,//车/导游地接
  9420. 80 ,//签证
  9421. 81 ,//邀请/公务活
  9422. 82 ,//团组客户保险
  9423. 85 ,//机票预订
  9424. 98 ,//其他款项
  9425. 285 ,//收款退还
  9426. 751 ,//酒店早餐
  9427. 1015 // 超支费用
  9428. };
  9429. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9430. {
  9431. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9432. }
  9433. #endregion
  9434. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9435. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9436. if (_GroupCostParameters.Count <= 0)
  9437. {
  9438. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9439. }
  9440. if (_GroupCostParameters[0].IsShare == 0)
  9441. {
  9442. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9443. }
  9444. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9445. //处理date为空问题
  9446. if (_GroupCosts.Count > 0)
  9447. {
  9448. for (int i = 0; i < _GroupCosts.Count; i++)
  9449. {
  9450. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9451. {
  9452. if (i > 0)
  9453. {
  9454. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9455. }
  9456. }
  9457. }
  9458. }
  9459. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9460. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9461. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9462. string currCode = "";
  9463. #region currCode 验证
  9464. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9465. if (isInt)
  9466. {
  9467. var currData = currDatas.Find(it => it.Id == intCurrency);
  9468. if (currData != null)
  9469. {
  9470. currCode = currData.Name;
  9471. }
  9472. }
  9473. else
  9474. {
  9475. currCode = _GroupCostParameters[0].Currency.Trim();
  9476. }
  9477. #endregion
  9478. //op,酒店单段模式存储
  9479. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9480. {
  9481. CurrencyCode = currCode,
  9482. Rate = _GroupCostParameters[0].Rate,
  9483. CostType = _GroupCostParameters[0].CostType,
  9484. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9485. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9486. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9487. };
  9488. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9489. if (_GroupCostParameters.Count == 2)
  9490. {
  9491. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9492. }
  9493. foreach (var item in _GroupCostParameters)
  9494. {
  9495. decimal _rate = 1;
  9496. decimal _rate1 = item.Rate;
  9497. decimal _scale = 1;
  9498. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9499. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9500. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9501. //if (userInfo != null)
  9502. //{
  9503. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9504. // {
  9505. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9506. // {
  9507. // _scale = 1.00M;
  9508. // }
  9509. // }
  9510. //}
  9511. #endregion
  9512. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9513. {
  9514. CurrencyCode = currCode,
  9515. Rate = _rate1,
  9516. CostType = item.CostType,
  9517. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9518. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9519. CostTypeNumber = item.CostTypenumber
  9520. };
  9521. if (_GroupCostParameters.Count > 1)
  9522. {
  9523. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9524. }
  9525. else
  9526. {
  9527. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9528. }
  9529. if (dto.CTable == 79)//
  9530. {
  9531. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9532. modulePromptInfo.TotalCost = item.DJCB;
  9533. }
  9534. List<string> costTypes = new List<string>() { "A", "B" };
  9535. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9536. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9537. if (_GroupCostsDuplicates.Count() == 1)
  9538. {
  9539. _GroupCostsTypeData = _GroupCosts;
  9540. }
  9541. else
  9542. {
  9543. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9544. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9545. }
  9546. /*
  9547. * 76 酒店预订
  9548. * 77 行程
  9549. * 79 车/导游地接
  9550. * 80 签证
  9551. * 81 邀请/公务活动
  9552. * 82 团组客户保险
  9553. * 85 机票预订
  9554. * 98 其他款项
  9555. * 285 收款退还
  9556. * 751 酒店早餐
  9557. * 1015 超支费用
  9558. */
  9559. switch (dto.CTable)
  9560. {
  9561. case 76: // 酒店预订
  9562. _ModuleSubPromptInfo.AddRange(
  9563. _GroupCostsTypeData.Select(it => new
  9564. {
  9565. it.DAY,
  9566. it.Date,
  9567. it.ACCON,
  9568. it.ITIN,
  9569. it.SGR,
  9570. it.TBR,
  9571. it.JS_ES,
  9572. it.Suite
  9573. })
  9574. );
  9575. break;
  9576. case 79: // 车/导游地接
  9577. _ModuleSubPromptInfo.AddRange(
  9578. _GroupCostsTypeData.Select(it => new
  9579. {
  9580. Date = it.Date, //日期
  9581. CarFee = it.CarCost * _rate * _scale, //车费用
  9582. CarType = it.CarType, //车型
  9583. DriverFee = it.CFS * _rate * _scale, //司机工资
  9584. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9585. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9586. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9587. GuideFee = it.TGS * _rate * _scale, //导游费用
  9588. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9589. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9590. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9591. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9592. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9593. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9594. Breakfast = it.B * _rate * _scale, //早餐费
  9595. Lunch = it.L * _rate * _scale, //午餐费
  9596. Dinner = it.D * _rate * _scale, //晚餐费
  9597. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9598. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9599. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9600. TicketFee = it.EF * _rate * _scale, //门票费
  9601. TicketRemark = it.EFR, //门票费描述
  9602. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9603. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9604. SpentCash = it.PC * _rate * _scale, //零用金
  9605. LeadersFee = it.TLF * _rate * _scale, //领队费
  9606. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9607. })
  9608. );
  9609. break;
  9610. case 85: // 机票
  9611. List<dynamic> datas = new List<dynamic>();
  9612. datas.Add(
  9613. new
  9614. {
  9615. AirType = "经济舱",
  9616. AirNum = item.JJCRS,
  9617. AirDRCB = item.JJCCB,
  9618. AirZCB = (item.JJCRS * item.JJCCB)
  9619. }
  9620. );
  9621. datas.Add(
  9622. new
  9623. {
  9624. AirType = "公务舱",
  9625. AirNum = item.GWCRS,
  9626. AirDRCB = item.GWCCB,
  9627. AirZCB = (item.GWCRS * item.GWCCB)
  9628. }
  9629. );
  9630. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9631. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9632. modulePromptInfo.Data = new
  9633. {
  9634. airFeeData = datas,
  9635. airInitData = initDatas
  9636. };
  9637. _ModulePromptInfos.Add(modulePromptInfo);
  9638. break;
  9639. default:
  9640. break;
  9641. }
  9642. }
  9643. if (dto.CTable != 85)
  9644. {
  9645. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9646. _ModulePromptInfos.Add(_ModulePromptInfo);
  9647. }
  9648. _view.ModulePromptInfos = _ModulePromptInfos;
  9649. return Ok(JsonView(true, "操作成功!", _view));
  9650. }
  9651. catch (Exception ex)
  9652. {
  9653. return Ok(JsonView(false, ex.Message));
  9654. }
  9655. }
  9656. /// <summary>
  9657. /// 根据黑屏代码重新生成行程
  9658. /// </summary>
  9659. /// <param name="dto"></param>
  9660. /// <returns></returns>
  9661. [HttpPost]
  9662. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9663. {
  9664. var jw = JsonView(false);
  9665. var Create = _GroupCostRepository.
  9666. CreateGroupCostByBlackCode(dto.Diid);
  9667. jw.Msg = Create.Msg;
  9668. if (Create.Code == 0)
  9669. {
  9670. jw.Code = 200;
  9671. jw.Data = new
  9672. {
  9673. groupCost = Create.Data,
  9674. blackCodeIsTrue = true
  9675. };
  9676. }
  9677. else
  9678. {
  9679. jw.Code = 400;
  9680. jw.Data = new
  9681. {
  9682. groupCost = Create.Data,
  9683. blackCodeIsTrue = false,
  9684. };
  9685. }
  9686. return Ok(jw);
  9687. }
  9688. /// <summary>
  9689. /// 成本获取OP历史车费用
  9690. /// </summary>
  9691. /// <param name="dto"></param>
  9692. /// <returns></returns>
  9693. [HttpPost]
  9694. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9695. {
  9696. var jw = JsonView(false);
  9697. try
  9698. {
  9699. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9700. //获取现有所有车的数据
  9701. if (!dto.Param.IsNullOrWhiteSpace())
  9702. {
  9703. string sql = $@"
  9704. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9705. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9706. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9707. 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
  9708. AND gctggr.ServiceEndTime is not NULL
  9709. ORDER by gctggrc.id DESC
  9710. ";
  9711. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9712. var numeberResult = await Task.Run(() =>
  9713. {
  9714. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9715. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9716. return numberArr;
  9717. });
  9718. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9719. foreach (var item in numeberResult)
  9720. {
  9721. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9722. {
  9723. Country = "数据异常!",
  9724. City = string.Empty,
  9725. };
  9726. item.Area = find.Country + " " + find.City;
  9727. }
  9728. dbResult.AddRange(numeberResult);
  9729. if (dto.Param.Contains("、"))
  9730. {
  9731. var sp = dto.Param.Split("、");
  9732. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9733. .Where(x =>
  9734. {
  9735. return System.Array.Exists(sp, e =>
  9736. {
  9737. bool where = false;
  9738. if (x.Area != null)
  9739. {
  9740. where = x.Area.Contains(e);
  9741. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9742. {
  9743. return false;
  9744. }
  9745. }
  9746. if (x.PriceName != null && !where)
  9747. {
  9748. where = x.PriceName.Contains(e);
  9749. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9750. {
  9751. return false;
  9752. }
  9753. }
  9754. return where;
  9755. });
  9756. }).ToList();
  9757. }
  9758. else
  9759. {
  9760. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9761. .Where(x =>
  9762. {
  9763. bool where = false;
  9764. if (x.Area != null)
  9765. {
  9766. where = x.Area.Contains(dto.Param);
  9767. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9768. {
  9769. return false;
  9770. }
  9771. }
  9772. if (x.PriceName != null && !where)
  9773. {
  9774. where = x.PriceName.Contains(dto.Param);
  9775. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9776. {
  9777. return false;
  9778. }
  9779. }
  9780. return where;
  9781. }
  9782. )
  9783. .ToList();
  9784. }
  9785. }
  9786. var view = dbResult.Select(x =>
  9787. {
  9788. decimal dp = 0.00M;
  9789. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9790. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9791. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9792. {
  9793. if (startB && endB)
  9794. {
  9795. var timesp = endD.Subtract(startD);
  9796. if ((timesp.Days + 1) != 0)
  9797. {
  9798. dp = x.Price / (timesp.Days + 1);
  9799. }
  9800. }
  9801. }
  9802. else
  9803. {
  9804. dp = x.Price;
  9805. }
  9806. return new
  9807. {
  9808. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9809. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9810. x.Area,
  9811. x.id,
  9812. price = x.Price.ToString("F2"),
  9813. x.PriceName,
  9814. x.PriceContent,
  9815. x.TeamName,
  9816. x.DatePrice,
  9817. dayPrice = dp.ToString("F2"),
  9818. };
  9819. }).OrderByDescending(x => x.id).ToList();
  9820. jw = JsonView(true, "获取成功!", view);
  9821. }
  9822. catch (Exception e)
  9823. {
  9824. jw = JsonView(false, e.Message);
  9825. }
  9826. return Ok(jw);
  9827. }
  9828. #endregion
  9829. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9830. /// <summary>
  9831. /// 酒店预订
  9832. /// 酒店费用列表 根据团组Id查询
  9833. /// </summary>
  9834. /// <param name="_dto"></param>
  9835. /// <returns></returns>
  9836. [HttpPost]
  9837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9838. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9839. {
  9840. #region 参数验证
  9841. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9842. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9843. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9844. #region 团组操作权限验证 76 酒店预定模块
  9845. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9846. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9847. #endregion
  9848. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9849. #region 页面操作权限验证
  9850. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9851. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9852. #endregion
  9853. #endregion
  9854. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9855. }
  9856. /// <summary>
  9857. /// 酒店预订
  9858. /// 基础数据
  9859. /// </summary>
  9860. /// <param name="_dto"></param>
  9861. /// <returns></returns>
  9862. [HttpPost]
  9863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9864. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9865. {
  9866. #region 参数验证
  9867. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9868. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9869. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9870. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9871. #region 页面操作权限验证
  9872. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9873. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9874. #endregion
  9875. #region 团组操作权限验证 76 酒店预定模块
  9876. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9877. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9878. #endregion
  9879. #endregion
  9880. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9881. }
  9882. /// <summary>
  9883. /// 酒店预订
  9884. /// 创建 入住卷号码
  9885. /// </summary>
  9886. /// <param name="_dto"></param>
  9887. /// <returns></returns>
  9888. [HttpPost]
  9889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9890. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9891. {
  9892. #region 参数验证
  9893. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9894. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9895. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9896. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9897. #region 页面操作权限验证
  9898. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9899. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9900. #endregion
  9901. #region 团组操作权限验证 76 酒店预定模块
  9902. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9903. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9904. #endregion
  9905. #endregion
  9906. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9907. if (data.Code != 0)
  9908. {
  9909. return Ok(JsonView(false, data.Msg));
  9910. }
  9911. return Ok(JsonView(true, data.Msg, data.Data));
  9912. }
  9913. /// <summary>
  9914. /// 酒店预订
  9915. /// 详情
  9916. /// </summary>
  9917. /// <param name="_dto"></param>
  9918. /// <returns></returns>
  9919. [HttpPost]
  9920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9921. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9922. {
  9923. #region 参数验证
  9924. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9925. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9926. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9927. #region 团组操作权限验证 76 酒店预定模块
  9928. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9929. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9930. #endregion
  9931. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9932. #region 页面操作权限验证
  9933. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9934. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9935. #endregion
  9936. #endregion
  9937. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9938. }
  9939. /// <summary>
  9940. /// 酒店预订
  9941. /// Add Or Edit
  9942. /// </summary>
  9943. /// <param name="_dto"></param>
  9944. /// <returns></returns>
  9945. [HttpPost]
  9946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9947. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9948. {
  9949. #region 参数验证
  9950. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9951. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9952. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9953. #region 团组操作权限验证 76 酒店预定模块
  9954. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9955. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9956. #endregion
  9957. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9958. #region 页面操作权限验证
  9959. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9960. if (_dto.Id == 0) // Add
  9961. {
  9962. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9963. }
  9964. else if (_dto.Id > 1) // Edit
  9965. {
  9966. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9967. }
  9968. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9969. #endregion
  9970. #endregion
  9971. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9972. if (_view.Code != 200)
  9973. {
  9974. return Ok(_view);
  9975. }
  9976. #region 应用推送
  9977. try
  9978. {
  9979. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9980. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9981. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9982. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  9983. //2024-10-21 新增LZ UID
  9984. var userIds = new List<int>() { 21 };
  9985. string title = $"费用审核";
  9986. var diId = _dto.DiId;
  9987. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9988. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9989. string content = "";
  9990. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9991. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9992. try
  9993. {
  9994. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  9995. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  9996. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  9997. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  9998. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  9999. }
  10000. catch (Exception ex )
  10001. {
  10002. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  10003. }
  10004. }
  10005. catch (Exception ex)
  10006. {
  10007. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  10008. }
  10009. try
  10010. {
  10011. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10012. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10013. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10014. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10015. //自动审核
  10016. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  10017. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  10018. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  10019. //2024-10-21 新增LZ UID
  10020. var userIds = new List<int>() { 21 };
  10021. string title = $"系统通知";
  10022. var diId = _dto.DiId;
  10023. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10024. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10025. string content = "";
  10026. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10027. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10028. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10029. }
  10030. catch (Exception ex)
  10031. {
  10032. }
  10033. #endregion
  10034. return Ok(_view);
  10035. }
  10036. /// <summary>
  10037. /// 酒店自动审核测试
  10038. /// Add Or Edit
  10039. /// </summary>
  10040. /// <param name="_dto"></param>
  10041. /// <returns></returns>
  10042. [HttpPost]
  10043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10044. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  10045. {
  10046. #region 应用推送
  10047. try
  10048. {
  10049. //自动审核
  10050. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  10051. }
  10052. catch (Exception ex)
  10053. {
  10054. return Ok(JsonView(false, "操作失败"));
  10055. }
  10056. #endregion
  10057. return Ok(JsonView(false, "操作成功"));
  10058. }
  10059. /// <summary>
  10060. /// 酒店预订
  10061. /// Del
  10062. /// </summary>
  10063. /// <param name="_dto"></param>
  10064. /// <returns></returns>
  10065. [HttpPost]
  10066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10067. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  10068. {
  10069. #region 参数验证
  10070. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10071. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10072. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10073. #region 团组操作权限验证 76 酒店预定模块
  10074. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10075. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10076. #endregion
  10077. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10078. #region 页面操作权限验证
  10079. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10080. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10081. #endregion
  10082. #endregion
  10083. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  10084. }
  10085. /// <summary>
  10086. /// 酒店预订
  10087. /// 生成VOUCHER
  10088. /// 2024.05.06 之前版本
  10089. /// </summary>
  10090. /// <param name="_dto"></param>
  10091. /// <returns></returns>
  10092. [HttpPost]
  10093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10094. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  10095. {
  10096. try
  10097. {
  10098. #region 参数验证
  10099. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10100. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10101. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10102. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  10103. #region 团组操作权限验证 76 酒店预定模块
  10104. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10105. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10106. #endregion
  10107. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10108. #region 页面操作权限验证
  10109. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10110. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10111. #endregion
  10112. #endregion
  10113. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  10114. //判断数据是否完整
  10115. if (hr != null)
  10116. {
  10117. if (!string.IsNullOrEmpty(hr.DetermineNo))
  10118. {
  10119. string strFileName = "HotelStatement/";
  10120. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10121. if (dele != null)
  10122. strFileName += dele.TourCode;
  10123. //载入模板
  10124. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  10125. Document doc = new Document(sss);
  10126. DocumentBuilder builder = new DocumentBuilder(doc);
  10127. #region 替换Word模板书签内容
  10128. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  10129. //入住卷预定号码
  10130. if (doc.Range.Bookmarks["VNO"] != null)
  10131. {
  10132. Bookmark mark = doc.Range.Bookmarks["VNO"];
  10133. mark.Text = hr.CheckNumber;
  10134. }
  10135. //酒店时间
  10136. if (doc.Range.Bookmarks["Date"] != null)
  10137. {
  10138. Bookmark mark = doc.Range.Bookmarks["Date"];
  10139. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  10140. }
  10141. //团号
  10142. if (doc.Range.Bookmarks["TNo"] != null)
  10143. {
  10144. Bookmark mark = doc.Range.Bookmarks["TNo"];
  10145. mark.Text = dele.TourCode;
  10146. }
  10147. //预定号码
  10148. if (doc.Range.Bookmarks["BookingId"] != null)
  10149. {
  10150. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  10151. mark.Text = hr.ReservationsNo;
  10152. }
  10153. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  10154. {
  10155. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  10156. mark.Text = hr.DetermineNo;
  10157. }
  10158. //酒店城市
  10159. if (doc.Range.Bookmarks["City"] != null)
  10160. {
  10161. Bookmark mark = doc.Range.Bookmarks["City"];
  10162. mark.Text = hr.City;
  10163. }
  10164. //酒店名称
  10165. if (doc.Range.Bookmarks["HName"] != null)
  10166. {
  10167. Bookmark mark = doc.Range.Bookmarks["HName"];
  10168. mark.Text = hr.HotelName;
  10169. }
  10170. //酒店地址
  10171. if (doc.Range.Bookmarks["Address"] != null)
  10172. {
  10173. Bookmark mark = doc.Range.Bookmarks["Address"];
  10174. mark.Text = hr.HotelAddress;
  10175. }
  10176. //酒店电话
  10177. if (doc.Range.Bookmarks["Tel"] != null)
  10178. {
  10179. Bookmark mark = doc.Range.Bookmarks["Tel"];
  10180. mark.Text = hr.HotelTel;
  10181. }
  10182. //酒店传真
  10183. if (doc.Range.Bookmarks["Fax"] != null)
  10184. {
  10185. Bookmark mark = doc.Range.Bookmarks["Fax"];
  10186. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  10187. {
  10188. mark.Text = hr.HotelFax;
  10189. }
  10190. }
  10191. //入住时间
  10192. if (doc.Range.Bookmarks["CIn"] != null)
  10193. {
  10194. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  10195. Bookmark mark = doc.Range.Bookmarks["CIn"];
  10196. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  10197. }
  10198. //退房时间
  10199. if (doc.Range.Bookmarks["COut"] != null)
  10200. {
  10201. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  10202. Bookmark mark = doc.Range.Bookmarks["COut"];
  10203. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  10204. }
  10205. //客户名称
  10206. if (doc.Range.Bookmarks["GName"] != null)
  10207. {
  10208. string guestName = "";
  10209. string[] clients = new string[] { };
  10210. if (hr.GuestName.Contains(","))
  10211. {
  10212. clients = hr.GuestName.Split(",");
  10213. }
  10214. else
  10215. {
  10216. clients = new string[] { hr.GuestName };
  10217. }
  10218. List<int> clientIds_int = new List<int>();
  10219. if (clients.Length > 0)
  10220. {
  10221. foreach (var item in clients)
  10222. {
  10223. if (item.IsNumeric())
  10224. {
  10225. clientIds_int.Add(int.Parse(item));
  10226. }
  10227. }
  10228. }
  10229. if (clientIds_int.Count > 0)
  10230. {
  10231. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  10232. foreach (var client in _clientDatas)
  10233. {
  10234. //男
  10235. if (client.Sex == 0) guestName += $"Mr.";
  10236. //女
  10237. else if (client.Sex == 1) guestName += $"Ms.";
  10238. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  10239. {
  10240. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  10241. }
  10242. //guestName += $"{client.Pinyin},";
  10243. }
  10244. if (guestName.Length > 0)
  10245. {
  10246. guestName = guestName.Substring(0, guestName.Length - 1);
  10247. }
  10248. }
  10249. else
  10250. {
  10251. guestName = hr.GuestName;
  10252. }
  10253. Bookmark mark = doc.Range.Bookmarks["GName"];
  10254. mark.Text = guestName;
  10255. }
  10256. //房间介绍
  10257. if (doc.Range.Bookmarks["ROOM"] != null)
  10258. {
  10259. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  10260. mark.Text = hr.RoomExplanation;
  10261. }
  10262. //报价描述
  10263. if (doc.Range.Bookmarks["NOTE"] != null)
  10264. {
  10265. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  10266. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  10267. if (ss != null)
  10268. mark.Text = ss.Name;
  10269. }
  10270. //入住时间
  10271. if (doc.Range.Bookmarks["CheckIn"] != null)
  10272. {
  10273. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  10274. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  10275. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10276. }
  10277. //退房时间
  10278. if (doc.Range.Bookmarks["CheckOut"] != null)
  10279. {
  10280. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  10281. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  10282. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  10283. }
  10284. //日期
  10285. if (doc.Range.Bookmarks["DT"] != null)
  10286. {
  10287. Bookmark mark = doc.Range.Bookmarks["DT"];
  10288. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  10289. }
  10290. //名称
  10291. if (doc.Range.Bookmarks["VName"] != null)
  10292. {
  10293. Bookmark mark = doc.Range.Bookmarks["VName"];
  10294. mark.Text = hr.HotelName;
  10295. }
  10296. //号码
  10297. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  10298. {
  10299. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  10300. mark.Text = hr.CheckNumber;
  10301. }
  10302. #endregion
  10303. strFileName += "VOUCHER.doc";
  10304. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10305. doc.Save(fileDir);
  10306. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10307. return Ok(JsonView(true, "操作成功!", Url));
  10308. }
  10309. else
  10310. {
  10311. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  10312. }
  10313. }
  10314. else
  10315. {
  10316. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  10317. }
  10318. }
  10319. catch (Exception ex)
  10320. {
  10321. return Ok(JsonView(false, ex.Message));
  10322. }
  10323. }
  10324. /// <summary>
  10325. /// 酒店预订
  10326. /// 生成VOUCHER
  10327. /// 2024.05.06 之后版本
  10328. /// </summary>
  10329. /// <param name="_dto"></param>
  10330. /// <returns></returns>
  10331. [HttpPost]
  10332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10333. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  10334. {
  10335. #region 参数验证
  10336. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10337. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10338. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10339. #region 团组操作权限验证 76 酒店预定模块
  10340. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10341. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10342. #endregion
  10343. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10344. #region 页面操作权限验证
  10345. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10346. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10347. #endregion
  10348. #endregion
  10349. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10350. //判断数据是否完整
  10351. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10352. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10353. string strFileName = "HotelStatement/";
  10354. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10355. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  10356. #region 数据处理
  10357. List<int> guestIds = new List<int>();
  10358. int index = 0;
  10359. foreach (var item in hrDtas)
  10360. {
  10361. if (item.GuestName.Contains(","))
  10362. {
  10363. string[] guestIdArr = item.GuestName.Split(',');
  10364. foreach (var guestIdStr in guestIdArr)
  10365. {
  10366. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  10367. if (guestBool)
  10368. {
  10369. guestIds.Add(guestId);
  10370. }
  10371. }
  10372. }
  10373. else guestNames += item.GuestName;
  10374. var voucherInfo = new HotelVoucherInfoView()
  10375. {
  10376. HotelName = item.HotelName,
  10377. CheckInDate = item.CheckInDate,
  10378. CheckOutDate = item.CheckOutDate,
  10379. ConfirmationNumber = item.DetermineNo.Trim(),
  10380. RoomType = item.RoomExplanation
  10381. };
  10382. vouchers.Add(voucherInfo);
  10383. }
  10384. if (guestIds.Count > 0)
  10385. {
  10386. guestIds = guestIds.Distinct().ToList();
  10387. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  10388. if (guestDatas.Count > 0)
  10389. {
  10390. guestNames = "";
  10391. foreach (var guest in guestDatas)
  10392. {
  10393. string guestName = "";
  10394. if (guest.Sex == 0) guestName += @"MR.";
  10395. else if (guest.Sex == 1) guestName += @"MS.";
  10396. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10397. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10398. guestNames += @$"{guestName.Trim()}、";
  10399. }
  10400. if (guestNames.Length > 0)
  10401. {
  10402. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10403. }
  10404. }
  10405. }
  10406. #endregion
  10407. //载入模板
  10408. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10409. Document doc = new Document(sss);
  10410. DocumentBuilder builder = new DocumentBuilder(doc);
  10411. if (doc.Range.Bookmarks["GuestName"] != null)
  10412. {
  10413. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10414. mark.Text = guestNames;
  10415. }
  10416. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10417. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10418. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10419. for (int i = 1; i <= vouchers.Count; i++)
  10420. {
  10421. HotelVoucherInfoView hviv = vouchers[i - 1];
  10422. builder.MoveToCell(0, i, 0, 0);
  10423. builder.Write(hviv.HotelName);
  10424. builder.MoveToCell(0, i, 1, 0);
  10425. builder.Write(hviv.CheckInDate);
  10426. builder.MoveToCell(0, i, 2, 0);
  10427. builder.Write(hviv.CheckOutDate);
  10428. builder.MoveToCell(0, i, 3, 0);
  10429. builder.Write(hviv.RoomType);
  10430. builder.MoveToCell(0, i, 4, 0);
  10431. builder.Write(hviv.ConfirmationNumber);
  10432. }
  10433. //删除多余行
  10434. int currRowIndex = vouchers.Count + 1;
  10435. int delRows = 21 - currRowIndex;
  10436. if (delRows > 0)
  10437. {
  10438. for (int i = 0; i < delRows; i++)
  10439. {
  10440. table.Rows.RemoveAt(currRowIndex);
  10441. //cultivateRowIndex++;
  10442. }
  10443. }
  10444. strFileName += "VOUCHER.docx";
  10445. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10446. doc.Save(fileDir);
  10447. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10448. return Ok(JsonView(true, "操作成功!", Url));
  10449. }
  10450. /// <summary>
  10451. /// 酒店预订
  10452. /// 生成VOUCHER 批量生成
  10453. /// New
  10454. /// </summary>
  10455. /// <param name="_dto"></param>
  10456. /// <returns></returns>
  10457. [HttpPost]
  10458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10459. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10460. {
  10461. #region 参数验证
  10462. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10463. if (_dto.PageId < 1) _dto.PageId = 28;
  10464. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10465. #region 团组操作权限验证 76 酒店预定模块
  10466. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10467. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10468. #endregion
  10469. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10470. #region 页面操作权限验证
  10471. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10472. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10473. #endregion
  10474. #endregion
  10475. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10476. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10477. .OrderBy(x => x.CheckInDate)
  10478. .ToListAsync();
  10479. //判断数据是否完整
  10480. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10481. string strFileName = "HotelStatement/";
  10482. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10483. if (dele != null)
  10484. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10485. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10486. for (int i = 0; i < hrDtas.Count; i++)
  10487. {
  10488. string guestNames = string.Empty;
  10489. List<int> guestIds = new List<int>();
  10490. var item = hrDtas[i];
  10491. //处理客户姓名
  10492. if (item.GuestName.Contains(","))
  10493. {
  10494. string[] guestIdArr = item.GuestName.Split(',');
  10495. foreach (var guestIdStr in guestIdArr)
  10496. if (int.TryParse(guestIdStr, out int guestId))
  10497. guestIds.Add(guestId);
  10498. }
  10499. else
  10500. {
  10501. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10502. if (guestIdBool)
  10503. {
  10504. guestIds.Add(guestId);
  10505. }
  10506. //NaN
  10507. if (item.GuestName.Contains("NaN"))
  10508. {
  10509. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10510. }
  10511. }
  10512. if (guestIds.Count > 0)
  10513. {
  10514. guestIds = guestIds.Distinct().ToList();
  10515. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10516. if (guestDatas1.Count > 0)
  10517. {
  10518. guestNames = "";
  10519. foreach (var guest in guestDatas1)
  10520. {
  10521. string guestName = "";
  10522. if (guest.Sex == 0) guestName += @"MR.";
  10523. else if (guest.Sex == 1) guestName += @"MS.";
  10524. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10525. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10526. guestNames += @$"{guestName.Trim()}、";
  10527. }
  10528. if (guestNames.Length > 0)
  10529. {
  10530. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10531. }
  10532. }
  10533. }
  10534. //if (!string.IsNullOrEmpty(guestNames))
  10535. //{
  10536. hrDtas[i].GuestName = guestNames;
  10537. //}
  10538. }
  10539. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10540. Document doc = new Document();
  10541. DocumentBuilder builder = new DocumentBuilder(doc);
  10542. try
  10543. {
  10544. builder.MoveToDocumentStart();
  10545. foreach (var item in hrDtas)
  10546. {
  10547. //标题
  10548. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10549. builder.ParagraphFormat.LineSpacing = 1;
  10550. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10551. builder.ParagraphFormat.Style.Font.Size = 9;
  10552. builder.ParagraphFormat.Style.Font.Bold = true;
  10553. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10554. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10555. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10557. builder.ParagraphFormat.LineSpacing = 1;
  10558. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10559. builder.ParagraphFormat.Style.Font.Size = 9;
  10560. builder.ParagraphFormat.Style.Font.Bold = true;
  10561. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10562. builder.StartTable();
  10563. // 设置边框颜色
  10564. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10565. //设置边框样式
  10566. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10567. //表格
  10568. #region 第一行
  10569. builder.InsertCell();
  10570. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10571. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10572. //builder.CellFormat.AllowAutoFit = false;
  10573. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10574. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10575. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10576. builder.CellFormat.WrapText = true; //自动换行
  10577. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10578. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10579. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10580. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10581. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10582. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10583. builder.Write("TOUR NO:");
  10584. builder.InsertCell();
  10585. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10586. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10587. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10588. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10589. builder.ParagraphFormat.Style.Font.Bold = false;
  10590. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10591. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10592. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10593. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10594. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10595. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10596. builder.Write($"{dele?.TourCode ?? "-"}");
  10597. builder.InsertCell();
  10598. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10599. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10600. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10601. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10602. builder.ParagraphFormat.Style.Font.Bold = false;
  10603. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10604. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10605. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10606. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10607. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10608. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10609. builder.Write($"CITY:");
  10610. builder.InsertCell();
  10611. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10612. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10613. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10614. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10615. builder.ParagraphFormat.Style.Font.Bold = false;
  10616. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10617. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10618. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10619. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10620. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10621. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10622. builder.Write($"{item.City}");
  10623. builder.EndRow();
  10624. #endregion
  10625. #region 第二行
  10626. builder.InsertCell();
  10627. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10628. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10629. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10630. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10631. builder.ParagraphFormat.Style.Font.Bold = false;
  10632. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10633. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10634. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10635. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10636. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10637. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10638. builder.Write("CONFIRMATION NO:");
  10639. builder.InsertCell();
  10640. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10641. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10642. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10643. builder.ParagraphFormat.Style.Font.Bold = false;
  10644. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10645. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10646. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10647. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10648. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10649. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10650. builder.CellFormat.VerticalMerge = CellMerge.None;
  10651. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10652. builder.Write($"{item.DetermineNo}");
  10653. builder.InsertCell();
  10654. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10655. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10656. builder.InsertCell();
  10657. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10658. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10659. builder.EndRow();
  10660. #endregion
  10661. #region 第三行
  10662. builder.InsertCell();
  10663. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10664. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10665. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10666. builder.ParagraphFormat.Style.Font.Bold = false;
  10667. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10668. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10669. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10670. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10671. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10672. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10673. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10674. builder.Write($"HOTEL NAME:");
  10675. builder.InsertCell();
  10676. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10677. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10678. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10679. builder.ParagraphFormat.Style.Font.Bold = false;
  10680. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10681. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10682. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10683. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10684. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10685. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10686. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10687. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10688. builder.Write($"{item.HotelName}");
  10689. builder.InsertCell();
  10690. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10691. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10692. builder.InsertCell();
  10693. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10694. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10695. builder.EndRow();
  10696. #endregion
  10697. #region 第四行
  10698. builder.InsertCell();
  10699. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10700. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10701. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10702. builder.ParagraphFormat.Style.Font.Bold = false;
  10703. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10704. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10705. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10706. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10707. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10708. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10709. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10710. builder.Write($"HOTEL ADDRESS:");
  10711. builder.InsertCell();
  10712. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10713. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10714. builder.ParagraphFormat.Style.Font.Size = 8;
  10715. builder.ParagraphFormat.Style.Font.Bold = false;
  10716. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10717. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10718. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10719. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10720. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10721. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10722. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10723. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10724. builder.Write($"{item.HotelAddress}");
  10725. builder.InsertCell();
  10726. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10727. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10728. builder.InsertCell();
  10729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10730. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10731. builder.EndRow();
  10732. #endregion
  10733. #region 第五行
  10734. builder.InsertCell();
  10735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10736. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10737. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10738. builder.ParagraphFormat.Style.Font.Bold = false;
  10739. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10742. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10743. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10744. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10745. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10746. builder.Write("TEL:");
  10747. builder.InsertCell();
  10748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10749. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10750. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10751. builder.ParagraphFormat.Style.Font.Bold = false;
  10752. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10753. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10754. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10755. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10756. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10757. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10758. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10759. builder.Write($"{item.HotelTel}");
  10760. builder.InsertCell();
  10761. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10762. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10763. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10764. builder.ParagraphFormat.Style.Font.Bold = false;
  10765. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10766. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10767. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10768. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10769. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10770. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10771. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10772. builder.Write($"FAX:");
  10773. builder.InsertCell();
  10774. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10775. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10776. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10777. builder.ParagraphFormat.Style.Font.Bold = false;
  10778. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10779. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10780. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10781. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10782. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10783. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10784. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10785. builder.Write($"{item.HotelFax}");
  10786. builder.EndRow();
  10787. #endregion
  10788. #region 第六行
  10789. builder.InsertCell();
  10790. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10791. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10792. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10793. builder.ParagraphFormat.Style.Font.Bold = false;
  10794. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10795. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10796. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10797. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10798. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10799. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10800. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10801. builder.Write("CHECK IN:");
  10802. builder.InsertCell();
  10803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10804. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10805. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10806. builder.ParagraphFormat.Style.Font.Bold = false;
  10807. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10808. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10809. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10810. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10811. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10812. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10813. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10814. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10815. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10816. builder.Write($"{checkInStr}");
  10817. builder.InsertCell();
  10818. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10819. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10820. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10821. builder.ParagraphFormat.Style.Font.Bold = false;
  10822. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10823. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10824. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10825. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10826. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10827. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10828. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10829. builder.Write($"CHECK OUT:");
  10830. builder.InsertCell();
  10831. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10832. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10833. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10834. builder.ParagraphFormat.Style.Font.Bold = false;
  10835. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10836. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10837. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10838. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10839. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10840. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10841. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10842. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10843. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10844. builder.Write($"{checkOutStr}");
  10845. builder.EndRow();
  10846. #endregion
  10847. #region 第七行
  10848. builder.InsertCell();
  10849. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10850. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10851. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10852. builder.ParagraphFormat.Style.Font.Bold = false;
  10853. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10854. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10855. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10856. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10857. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10858. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10859. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10860. builder.Write($"GUEST NAME:");
  10861. builder.InsertCell();
  10862. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10863. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10864. builder.ParagraphFormat.Style.Font.Size = 8;
  10865. builder.ParagraphFormat.Style.Font.Bold = false;
  10866. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10867. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10868. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10869. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10870. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10871. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10872. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10873. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10874. builder.Write($"{item.GuestName}");
  10875. builder.InsertCell();
  10876. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10877. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10878. builder.InsertCell();
  10879. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10880. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10881. builder.EndRow();
  10882. #endregion
  10883. #region 第八行
  10884. builder.InsertCell();
  10885. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10886. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10887. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10888. builder.ParagraphFormat.Style.Font.Bold = false;
  10889. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10890. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10891. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10892. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10893. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10894. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10895. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10896. builder.Write($"ROOM TYPE:");
  10897. builder.InsertCell();
  10898. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10899. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10900. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10901. builder.ParagraphFormat.Style.Font.Bold = false;
  10902. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10903. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10904. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10905. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10906. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10907. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10908. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10909. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10910. builder.Write($"{item.RoomExplanation}");
  10911. builder.InsertCell();
  10912. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10913. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10914. builder.InsertCell();
  10915. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10916. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10917. builder.EndRow();
  10918. #endregion
  10919. #region 第九行
  10920. builder.InsertCell();
  10921. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10922. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10923. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10924. builder.ParagraphFormat.Style.Font.Bold = false;
  10925. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10926. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10927. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10928. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10929. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10930. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10931. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10932. builder.Write($"NOTE:");
  10933. builder.InsertCell();
  10934. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10935. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10936. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10937. builder.ParagraphFormat.Style.Font.Bold = false;
  10938. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10939. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10940. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10941. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10942. 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.");
  10943. builder.InsertCell();
  10944. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10945. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10946. builder.InsertCell();
  10947. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10948. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10949. builder.EndRow();
  10950. #endregion
  10951. builder.EndTable();
  10952. //换行
  10953. builder.Writeln("");
  10954. builder.Writeln("");
  10955. }
  10956. #region 获取文档中的所有表格 设置文字自适应
  10957. // 获取文档中的所有表格。
  10958. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10959. {
  10960. // 遍历表格中的所有行。
  10961. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10962. {
  10963. foreach (Cell cell in row.Cells)
  10964. {
  10965. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10966. cellFormat.Width = 0;
  10967. }
  10968. }
  10969. }
  10970. #endregion
  10971. #region 设置页眉
  10972. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10973. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10974. if (System.IO.File.Exists(voucherHeaderPath))
  10975. {
  10976. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10977. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10978. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10979. Shape shape = builder.InsertImage(imageBytes);
  10980. // 调整图片位置
  10981. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10982. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10983. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10984. shape.Left = 0; // 将图片距离页面左边缘的距离
  10985. shape.Width = 81; // 设置图片宽度
  10986. shape.Height = 36; // 设置图片高度
  10987. }
  10988. //靠右
  10989. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10990. //// 设置页脚上下边距
  10991. //builder.PageSetup.HeaderDistance = 42;
  10992. // 添加页眉线
  10993. Aspose.Words.Border borderHeader = null;
  10994. try
  10995. {
  10996. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10997. }
  10998. catch (Exception e)
  10999. {
  11000. // TODO Auto-generated catch block
  11001. //e.printStackTrace();
  11002. }
  11003. borderHeader.Shadow = true;
  11004. borderHeader.DistanceFromText = 2;
  11005. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  11006. #endregion
  11007. }
  11008. catch (Exception ex)
  11009. {
  11010. }
  11011. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11012. doc.Save(fileDir);
  11013. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11014. return Ok(JsonView(true, "操作成功!", Url));
  11015. }
  11016. /// <summary>
  11017. /// 酒店预订
  11018. /// 生成 预定成本 Excel
  11019. /// </summary>
  11020. /// <param name="_dto"></param>
  11021. /// <returns></returns>
  11022. [HttpPost]
  11023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11024. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  11025. {
  11026. #region 参数验证
  11027. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  11028. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  11029. if (!vadalitorRes.IsValid)
  11030. {
  11031. var errors = new StringBuilder();
  11032. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  11033. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  11034. }
  11035. #region 团组操作权限验证 76 酒店预定模块
  11036. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11037. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11038. #endregion
  11039. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11040. #region 页面操作权限验证
  11041. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11042. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11043. #endregion
  11044. #endregion
  11045. decimal _rate = 1.00M;
  11046. string _currency = string.Empty;
  11047. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  11048. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11049. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  11050. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11051. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  11052. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  11053. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  11054. if (_GroupCostParameter == null)
  11055. {
  11056. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  11057. bool isIntType = int.TryParse(_currency, out int currId);
  11058. if (isIntType)
  11059. {
  11060. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11061. }
  11062. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11063. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11064. if (currInfo == null)
  11065. {
  11066. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11067. }
  11068. else _rate = currInfo.Rate;
  11069. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  11070. {
  11071. _rate = _GroupCostParameter.Rate;
  11072. }
  11073. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11074. string strFileName = "HotelStatement/";
  11075. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11076. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  11077. var rateDatas = new List<dynamic>();
  11078. #region 数据处理
  11079. foreach (var item in hrDtas)
  11080. {
  11081. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  11082. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  11083. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  11084. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  11085. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  11086. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  11087. {
  11088. continue;
  11089. }
  11090. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  11091. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  11092. string singleRoomFeeStr = string.Empty,
  11093. doubleRoomFeeStr = string.Empty,
  11094. suiteRoomFeeStr = string.Empty,
  11095. otherRoomFeeStr = string.Empty,
  11096. payMoneyStr = string.Empty,
  11097. cardPriceStr = string.Empty;
  11098. if (roomCurr.Equals("CNY"))
  11099. {
  11100. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  11101. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11102. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11103. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11104. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11105. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  11106. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  11107. }
  11108. else
  11109. {
  11110. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11111. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11112. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11113. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11114. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  11115. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11116. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11117. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11118. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11119. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  11120. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  11121. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  11122. if (ccpPaymentCurrency.Equals("CNY"))
  11123. {
  11124. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  11125. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  11126. }
  11127. else
  11128. {
  11129. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  11130. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  11131. }
  11132. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  11133. if (hotelcardPriceCurrency.Equals("CNY"))
  11134. {
  11135. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  11136. }
  11137. else
  11138. {
  11139. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  11140. }
  11141. }
  11142. string breakfastPriceStr = string.Empty,
  11143. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11144. governmentRentStr = string.Empty,
  11145. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11146. cityTaxStr = string.Empty,
  11147. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11148. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  11149. if (!string.IsNullOrEmpty(breakfastCurrency1))
  11150. {
  11151. if (breakfastCurrency1.Equals("CNY"))
  11152. {
  11153. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  11154. }
  11155. else
  11156. {
  11157. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  11158. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  11159. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  11160. }
  11161. }
  11162. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  11163. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  11164. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  11165. {
  11166. if (governmentRentCurrency.Equals("CNY"))
  11167. {
  11168. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  11169. }
  11170. else
  11171. {
  11172. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  11173. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  11174. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  11175. }
  11176. }
  11177. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  11178. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  11179. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  11180. {
  11181. if (cityTaxStrCurrency1.Equals("CNY"))
  11182. {
  11183. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  11184. }
  11185. else
  11186. {
  11187. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  11188. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  11189. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  11190. }
  11191. }
  11192. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  11193. int payDId = roomInfo?.PayDId ?? 0;
  11194. pcfds.Add(new HotelReservations_PCFD_View()
  11195. {
  11196. City = item.City,
  11197. HotelName = item.HotelName,
  11198. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11199. // SingleRoomCount = item.SingleRoomCount,
  11200. SingleRoomPrice = singleRoomFeeStr,
  11201. // DoubleRoomCount = item.DoubleRoomCount,
  11202. DoubleRoomPrice = doubleRoomFeeStr,
  11203. //SuiteRoomCount = item.SuiteRoomCount,
  11204. SuiteRoomPrice = suiteRoomFeeStr,
  11205. OtherRoomPrice = otherRoomFeeStr,
  11206. //OtherRoomCount = item.OtherRoomCount,
  11207. BreakfastPrice = breakfastPriceStr,
  11208. GovernmentRent = governmentRentStr,
  11209. CityTax = cityTaxStr,
  11210. RoomExplanation = item.RoomExplanation,
  11211. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11212. PayTime = roomInfo?.ConsumptionDate,
  11213. BankNo = roomInfo?.BankNo,
  11214. PayMoney = payMoneyStr,
  11215. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11216. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11217. CardPrice = cardPriceStr,
  11218. Remark = ccpInfo.Remark
  11219. });
  11220. }
  11221. #endregion
  11222. //载入模板
  11223. WorkbookDesigner designer = new WorkbookDesigner();
  11224. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11225. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11226. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11227. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11228. var rateDatas1 = rateDatas.Distinct();
  11229. var rateStr = string.Empty;
  11230. foreach (var item in rateDatas1)
  11231. {
  11232. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  11233. }
  11234. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  11235. designer.SetDataSource("Opertor", userInfo.CnName);
  11236. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11237. dt.TableName = "ViewMyHotelReservations";
  11238. designer.SetDataSource(dt);
  11239. designer.Process();
  11240. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11241. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11242. designer.Workbook.Save(serverPath);
  11243. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11244. #region 删除指定行
  11245. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11246. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11247. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11248. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11249. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11250. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11251. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11252. cssIndex = dt.Columns["CityTax"].Ordinal,
  11253. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11254. remarkIndex = dt.Columns["Remark"].Ordinal;
  11255. //删除指定列
  11256. foreach (DataRow item in dt.Rows)
  11257. {
  11258. string singleStr = item["SingleRoomPrice"].ToString();
  11259. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11260. if (containsDigitButNotZero1) singleDel = false;
  11261. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11262. string doubleStr = item["DoubleRoomPrice"].ToString();
  11263. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11264. if (containsDigitButNotZero2) doubleDel = false;
  11265. string suiteStr = item["SuiteRoomPrice"].ToString();
  11266. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11267. if (containsDigitButNotZero3) suiteDel = false;
  11268. string otherStr = item["OtherRoomPrice"].ToString();
  11269. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11270. if (containsDigitButNotZero4) otherDel = false;
  11271. string zcStr = item["BreakfastPrice"].ToString();
  11272. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11273. if (containsDigitButNotZero5) zcDel = false;
  11274. string dsStr = item["GovernmentRent"].ToString();
  11275. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11276. if (containsDigitButNotZero6) dsDel = false;
  11277. string cssStr = item["CityTax"].ToString();
  11278. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11279. if (containsDigitButNotZero7) cssDel = false;
  11280. string cpStr = item["ConsumptionPatterns"].ToString();
  11281. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11282. string remarkStr = item["Remark"].ToString();
  11283. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11284. }
  11285. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11286. DeleteColumn(serverPath, cpIndex, cpDel);
  11287. DeleteColumn(serverPath, dsIndex, dsDel);
  11288. DeleteColumn(serverPath, cssIndex, cssDel);
  11289. DeleteColumn(serverPath, zcIndex, zcDel);
  11290. DeleteColumn(serverPath, otherIndex, otherDel);
  11291. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11292. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11293. DeleteColumn(serverPath, singleIndex, singleDel);
  11294. #endregion
  11295. //只保留第一个表格
  11296. DeleteSheet(serverPath);
  11297. return Ok(JsonView(true, "操作成功", url = rst));
  11298. }
  11299. else
  11300. {
  11301. _currency = _GroupCostParameter.Currency;
  11302. bool isIntType = int.TryParse(_currency, out int currId);
  11303. if (isIntType)
  11304. {
  11305. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11306. }
  11307. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11308. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11309. if (currInfo == null)
  11310. {
  11311. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11312. }
  11313. if (!_currency.ToUpper().Equals("CNY"))
  11314. {
  11315. _rate = _GroupCostParameter.Rate;
  11316. }
  11317. _rate = currInfo.Rate;
  11318. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11319. string strFileName = "HotelStatement/";
  11320. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11321. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  11322. #region 数据处理
  11323. foreach (var item in hrDtas)
  11324. {
  11325. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  11326. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  11327. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  11328. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  11329. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  11330. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  11331. string singleRoomFeeStr = string.Empty,
  11332. doubleRoomFeeStr = string.Empty,
  11333. suiteRoomFeeStr = string.Empty,
  11334. otherRoomFeeStr = string.Empty,
  11335. payMoneyStr = string.Empty,
  11336. cardPriceStr = string.Empty;
  11337. if (roomCurr.Equals(_currency))
  11338. {
  11339. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  11340. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  11341. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  11342. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  11343. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  11344. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  11345. }
  11346. else
  11347. {
  11348. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  11349. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  11350. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  11351. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  11352. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  11353. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  11354. }
  11355. string breakfastPriceStr = string.Empty,
  11356. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  11357. governmentRentStr = string.Empty,
  11358. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  11359. cityTaxStrStr = string.Empty,
  11360. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  11361. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  11362. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  11363. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  11364. int payDId = roomInfo?.PayDId ?? 0;
  11365. pcfds.Add(new HotelReservations_PCFD_View()
  11366. {
  11367. City = item.City,
  11368. HotelName = item.HotelName,
  11369. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  11370. // SingleRoomCount = item.SingleRoomCount,
  11371. SingleRoomPrice = singleRoomFeeStr,
  11372. // DoubleRoomCount = item.DoubleRoomCount,
  11373. DoubleRoomPrice = doubleRoomFeeStr,
  11374. //SuiteRoomCount = item.SuiteRoomCount,
  11375. SuiteRoomPrice = suiteRoomFeeStr,
  11376. OtherRoomPrice = otherRoomFeeStr,
  11377. //OtherRoomCount = item.OtherRoomCount,
  11378. BreakfastPrice = breakfastPriceStr,
  11379. GovernmentRent = governmentRentStr,
  11380. CityTax = cityTaxStrStr,
  11381. RoomExplanation = item.RoomExplanation,
  11382. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11383. PayTime = roomInfo?.ConsumptionDate,
  11384. BankNo = roomInfo?.BankNo,
  11385. PayMoney = payMoneyStr,
  11386. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11387. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11388. CardPrice = cardPriceStr,
  11389. Remark = ccpInfo.Remark
  11390. });
  11391. }
  11392. #endregion
  11393. //载入模板
  11394. WorkbookDesigner designer = new WorkbookDesigner();
  11395. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11396. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11397. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11398. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11399. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  11400. designer.SetDataSource("Opertor", userInfo.CnName);
  11401. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11402. dt.TableName = "ViewMyHotelReservations";
  11403. designer.SetDataSource(dt);
  11404. designer.Process();
  11405. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11406. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11407. designer.Workbook.Save(serverPath);
  11408. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11409. #region 删除指定行
  11410. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11411. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11412. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11413. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11414. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11415. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11416. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11417. cssIndex = dt.Columns["CityTax"].Ordinal,
  11418. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11419. remarkIndex = dt.Columns["Remark"].Ordinal;
  11420. //删除指定列
  11421. foreach (DataRow item in dt.Rows)
  11422. {
  11423. string singleStr = item["SingleRoomPrice"].ToString();
  11424. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11425. if (containsDigitButNotZero1) singleDel = false;
  11426. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11427. string doubleStr = item["DoubleRoomPrice"].ToString();
  11428. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11429. if (containsDigitButNotZero2) doubleDel = false;
  11430. string suiteStr = item["SuiteRoomPrice"].ToString();
  11431. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11432. if (containsDigitButNotZero3) suiteDel = false;
  11433. string otherStr = item["OtherRoomPrice"].ToString();
  11434. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11435. if (containsDigitButNotZero4) otherDel = false;
  11436. string zcStr = item["BreakfastPrice"].ToString();
  11437. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11438. if (containsDigitButNotZero5) zcDel = false;
  11439. string dsStr = item["GovernmentRent"].ToString();
  11440. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11441. if (containsDigitButNotZero6) dsDel = false;
  11442. string cssStr = item["CityTax"].ToString();
  11443. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11444. if (containsDigitButNotZero7) cssDel = false;
  11445. string cpStr = item["ConsumptionPatterns"].ToString();
  11446. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11447. string remarkStr = item["Remark"].ToString();
  11448. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11449. }
  11450. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11451. DeleteColumn(serverPath, cpIndex, cpDel);
  11452. DeleteColumn(serverPath, dsIndex, dsDel);
  11453. DeleteColumn(serverPath, cssIndex, cssDel);
  11454. DeleteColumn(serverPath, zcIndex, zcDel);
  11455. DeleteColumn(serverPath, otherIndex, otherDel);
  11456. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11457. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11458. DeleteColumn(serverPath, singleIndex, singleDel);
  11459. #endregion
  11460. //只保留第一个表格
  11461. DeleteSheet(serverPath);
  11462. return Ok(JsonView(true, "操作成功", url = rst));
  11463. }
  11464. return Ok(JsonView(false));
  11465. }
  11466. /// <summary>
  11467. /// 删除指定列
  11468. /// </summary>
  11469. /// <param name="file"></param>
  11470. /// <param name="columnIndex"></param>
  11471. /// <param name="isDel"></param>
  11472. private void DeleteColumn(string file, int columnIndex, bool isDel)
  11473. {
  11474. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11475. //wb.Save(file);
  11476. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  11477. if (sheet1 != null)
  11478. {
  11479. if (isDel)
  11480. {
  11481. Cells cells = sheet1.Cells;
  11482. cells.DeleteColumn(columnIndex);
  11483. }
  11484. }
  11485. wb.Save(file);
  11486. }
  11487. /// <summary>
  11488. /// 删除sheet
  11489. /// </summary>
  11490. /// <param name="file"></param>
  11491. /// <param name="sheetName"></param>
  11492. private void DeleteSheet(string file, string sheetName = "")
  11493. {
  11494. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11495. //wb.Save(file);
  11496. List<string> sheets = new List<string>();
  11497. foreach (var item in wb.Worksheets)
  11498. {
  11499. sheets.Add(item.Name);
  11500. }
  11501. if (sheets.Count > 0)
  11502. {
  11503. sheets.RemoveAt(0);//不删除第一个sheet
  11504. foreach (var item in sheets)
  11505. {
  11506. wb.Worksheets.RemoveAt(item);
  11507. }
  11508. }
  11509. wb.Save(file);
  11510. }
  11511. /// <summary>
  11512. /// 酒店预订
  11513. /// 确认单
  11514. /// </summary>
  11515. /// <param name="_dto"></param>
  11516. /// <returns></returns>
  11517. [HttpPost]
  11518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11519. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  11520. {
  11521. try
  11522. {
  11523. #region 参数验证
  11524. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11525. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11526. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11527. #region 团组操作权限验证 76 酒店预定模块
  11528. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11529. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11530. #endregion
  11531. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11532. #region 页面操作权限验证
  11533. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11534. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11535. #endregion
  11536. #endregion
  11537. //团组信息
  11538. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  11539. //酒店数据
  11540. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  11541. if (listhoteldata.Count < 0)
  11542. {
  11543. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  11544. }
  11545. //利datatable存储
  11546. DataTable dt = new DataTable();
  11547. dt.Columns.Add("CheckInDate", typeof(string));
  11548. dt.Columns.Add("City", typeof(string));
  11549. dt.Columns.Add("Hotel", typeof(string));
  11550. dt.Columns.Add("Room", typeof(string));
  11551. for (int i = 0; i < listhoteldata.Count; i++)
  11552. {
  11553. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  11554. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  11555. while (dayStart < dayEnd)
  11556. {
  11557. string temp = "";
  11558. DataRow row = dt.NewRow();
  11559. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  11560. row["City"] = listhoteldata[i].City;
  11561. row["Hotel"] = listhoteldata[i].HotelName;
  11562. if (listhoteldata[i].SingleRoomCount > 0)
  11563. {
  11564. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  11565. }
  11566. if (listhoteldata[i].DoubleRoomCount > 0)
  11567. {
  11568. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  11569. }
  11570. if (listhoteldata[i].SuiteRoomCount > 0)
  11571. {
  11572. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  11573. }
  11574. if (listhoteldata[i].OtherRoomCount > 0)
  11575. {
  11576. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  11577. }
  11578. row["Room"] = temp;
  11579. dt.Rows.Add(row);
  11580. dayStart = dayStart.AddDays(1);
  11581. }
  11582. }
  11583. Dictionary<string, string> dic = new Dictionary<string, string>();
  11584. dic.Add("Dele", di.TeamName);
  11585. dic.Add("City", di.VisitCountry);
  11586. //模板路径
  11587. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  11588. //载入模板
  11589. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  11590. DocumentBuilder builder = new DocumentBuilder(doc);
  11591. foreach (var key in dic.Keys)
  11592. {
  11593. builder.MoveToBookmark(key);
  11594. builder.Write(dic[key]);
  11595. }
  11596. //获取word里所有表格
  11597. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11598. //获取所填表格的序数
  11599. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11600. var rowStart = tableOne.Rows[0]; //获取第1行
  11601. //循环赋值
  11602. for (int i = 0; i < dt.Rows.Count; i++)
  11603. {
  11604. builder.MoveToCell(0, i + 1, 0, 0);
  11605. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  11606. builder.MoveToCell(0, i + 1, 1, 0);
  11607. builder.Write(dt.Rows[i]["City"].ToString());
  11608. builder.MoveToCell(0, i + 1, 2, 0);
  11609. builder.Write(dt.Rows[i]["Hotel"].ToString());
  11610. builder.MoveToCell(0, i + 1, 3, 0);
  11611. builder.Write(dt.Rows[i]["Room"].ToString());
  11612. }
  11613. //删除多余行
  11614. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  11615. {
  11616. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  11617. }
  11618. string strFileName = di.TeamName + "酒店确认单.doc";
  11619. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  11620. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  11621. return Ok(JsonView(true, "成功", url));
  11622. }
  11623. catch (Exception ex)
  11624. {
  11625. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  11626. }
  11627. }
  11628. #endregion
  11629. #region 团组状态
  11630. /// <summary>
  11631. /// 团组状态列表 Page
  11632. /// </summary>
  11633. /// <param name="dto">团组列表请求dto</param>
  11634. /// <returns></returns>
  11635. [HttpPost]
  11636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11637. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11638. {
  11639. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11640. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11641. {
  11642. string sqlWhere = string.Empty;
  11643. if (dto.IsSure == 0) //未完成
  11644. {
  11645. sqlWhere += string.Format(@" And IsSure = 0");
  11646. }
  11647. else if (dto.IsSure == 1) //已完成
  11648. {
  11649. sqlWhere += string.Format(@" And IsSure = 1");
  11650. }
  11651. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11652. {
  11653. string tj = dto.SearchCriteria;
  11654. 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}%')",
  11655. tj, tj, tj, tj, tj);
  11656. }
  11657. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11658. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11659. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11660. From (
  11661. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11662. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11663. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11664. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11665. From Grp_DelegationInfo gdi
  11666. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11667. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11668. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11669. Where gdi.IsDel = 0 {0}
  11670. ) temp ", sqlWhere);
  11671. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11672. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11673. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11674. }
  11675. else
  11676. {
  11677. return Ok(JsonView(false, "查询失败"));
  11678. }
  11679. }
  11680. /// <summary>
  11681. /// 团组状态
  11682. /// 设置操作完成
  11683. /// </summary>
  11684. /// <param name="dto">团组列表请求dto</param>
  11685. /// <returns></returns>
  11686. [HttpPost]
  11687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11688. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11689. {
  11690. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11691. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11692. {
  11693. Id = dto.Id,
  11694. IsSure = 1
  11695. };
  11696. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11697. .UpdateColumns(it => new { it.IsSure })
  11698. .WhereColumns(it => new { it.Id })
  11699. .ExecuteCommandAsync();
  11700. if (result > 0)
  11701. {
  11702. return Ok(JsonView(true, "操作完成!"));
  11703. }
  11704. return Ok(JsonView(false, "操作失败!"));
  11705. }
  11706. #endregion
  11707. #region 保险费用录入
  11708. /// <summary>
  11709. /// 根据团组Id查询保险费用列表
  11710. /// </summary>
  11711. /// <param name="dto"></param>
  11712. /// <returns></returns>
  11713. [HttpPost]
  11714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11715. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11716. {
  11717. Result groupData = await _customersRep.CustomersByDiId(dto);
  11718. if (groupData.Code != 0)
  11719. {
  11720. return Ok(JsonView(false, groupData.Msg));
  11721. }
  11722. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11723. }
  11724. /// <summary>
  11725. /// 根据保险费用Id查询保险费用详细
  11726. /// </summary>
  11727. /// <param name="dto"></param>
  11728. /// <returns></returns>
  11729. [HttpPost]
  11730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11731. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11732. {
  11733. try
  11734. {
  11735. Result groupData = await _customersRep.CustomersById(dto);
  11736. if (groupData.Code != 0)
  11737. {
  11738. return Ok(JsonView(false, groupData.Msg));
  11739. }
  11740. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11741. }
  11742. catch (Exception ex)
  11743. {
  11744. return Ok(JsonView(false, ex.Message));
  11745. }
  11746. }
  11747. /// <summary>
  11748. /// 保险费用录入页面初始化绑定
  11749. /// </summary>
  11750. /// <param name="dto"></param>
  11751. /// <returns></returns>
  11752. [HttpPost]
  11753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11754. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11755. {
  11756. try
  11757. {
  11758. Result groupData = await _customersRep.CustomersInitialize(dto);
  11759. if (groupData.Code != 0)
  11760. {
  11761. return Ok(JsonView(false, groupData.Msg));
  11762. }
  11763. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11764. }
  11765. catch (Exception ex)
  11766. {
  11767. return Ok(JsonView(false, ex.Message));
  11768. }
  11769. }
  11770. /// <summary>
  11771. /// 保险费用操作(Status:1.新增,2.修改)
  11772. /// </summary>
  11773. /// <param name="dto"></param>
  11774. /// <returns></returns>
  11775. [HttpPost]
  11776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11777. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11778. {
  11779. Result groupData = await _customersRep.OpCustomers(dto);
  11780. if (groupData.Code != 0)
  11781. {
  11782. return Ok(JsonView(false, groupData.Msg));
  11783. }
  11784. #region 应用推送
  11785. try
  11786. {
  11787. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11788. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11789. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11790. //2024-10-21 新增LZ UID
  11791. var userIds = new List<int>() { 21 };
  11792. string title = $"系统通知";
  11793. var diId = dto.DiId;
  11794. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11795. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11796. string content = "";
  11797. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11798. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11799. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11800. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11801. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11802. }
  11803. catch (Exception ex)
  11804. {
  11805. }
  11806. #endregion
  11807. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11808. }
  11809. /// <summary>
  11810. /// 保险文件上传
  11811. /// </summary>
  11812. /// <param name="file"></param>
  11813. /// <returns></returns>
  11814. [HttpPost]
  11815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11816. public async Task<IActionResult> UploadCus(IFormFile file)
  11817. {
  11818. try
  11819. {
  11820. if (file != null)
  11821. {
  11822. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11823. //文件名称
  11824. string projectFileName = file.FileName;
  11825. //上传的文件的路径
  11826. string filePath = "";
  11827. if (!Directory.Exists(fileDir))
  11828. {
  11829. Directory.CreateDirectory(fileDir);
  11830. }
  11831. //上传的文件的路径
  11832. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11833. using (FileStream fs = System.IO.File.Create(filePath))
  11834. {
  11835. file.CopyTo(fs);
  11836. fs.Flush();
  11837. }
  11838. return Ok(JsonView(true, "上传成功!", projectFileName));
  11839. }
  11840. else
  11841. {
  11842. return Ok(JsonView(false, "上传失败!"));
  11843. }
  11844. }
  11845. catch (Exception ex)
  11846. {
  11847. return Ok(JsonView(false, "程序错误!"));
  11848. throw;
  11849. }
  11850. }
  11851. /// <summary>
  11852. /// 保险删除指定文件
  11853. /// </summary>
  11854. /// <param name="dto"></param>
  11855. /// <returns></returns>
  11856. [HttpPost]
  11857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11858. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11859. {
  11860. try
  11861. {
  11862. string filePath = "";
  11863. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11864. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11865. //int id = 0;
  11866. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11867. // 删除该文件
  11868. try
  11869. {
  11870. System.IO.File.Delete(filePath);
  11871. 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()
  11872. {
  11873. Attachment = "",
  11874. }).ExecuteCommandAsync();
  11875. if (result != 0)
  11876. {
  11877. return Ok(JsonView(true, "成功!"));
  11878. }
  11879. else
  11880. {
  11881. return Ok(JsonView(false, "失败!"));
  11882. }
  11883. }
  11884. catch (Exception)
  11885. {
  11886. 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()
  11887. {
  11888. Attachment = "",
  11889. }).ExecuteCommandAsync();
  11890. if (result != 0)
  11891. {
  11892. return Ok(JsonView(true, "成功!"));
  11893. }
  11894. else
  11895. {
  11896. return Ok(JsonView(false, "失败!"));
  11897. }
  11898. }
  11899. }
  11900. catch (Exception ex)
  11901. {
  11902. return Ok(JsonView(false, "程序错误!"));
  11903. throw;
  11904. }
  11905. }
  11906. /// <summary>
  11907. /// 保险费用操作(删除)
  11908. /// </summary>
  11909. /// <param name="dto"></param>
  11910. /// <returns></returns>
  11911. [HttpPost]
  11912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11913. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11914. {
  11915. try
  11916. {
  11917. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11918. if (!res)
  11919. {
  11920. return Ok(JsonView(false, "删除失败"));
  11921. }
  11922. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11923. {
  11924. IsDel = 1,
  11925. DeleteUserId = dto.DeleteUserId,
  11926. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11927. }).ExecuteCommandAsync();
  11928. return Ok(JsonView(true, "删除成功!"));
  11929. }
  11930. catch (Exception ex)
  11931. {
  11932. return Ok(JsonView(false, "程序错误!"));
  11933. throw;
  11934. }
  11935. }
  11936. #endregion
  11937. #region 接团客户名单 PageId 104
  11938. /// <summary>
  11939. /// 接团客户名单
  11940. /// 迁移数据(慎用!)
  11941. /// </summary>
  11942. /// <param name="dto"></param>
  11943. /// <returns></returns>
  11944. [HttpPost]
  11945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11946. public async Task<IActionResult> PostTourClientListChange()
  11947. {
  11948. try
  11949. {
  11950. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11951. //var groupClinetData1
  11952. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11953. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11954. int updateCount = 0;
  11955. if (oldOAClientList.Count > 0)
  11956. {
  11957. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11958. _sqlSugar.BeginTran();
  11959. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11960. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11961. foreach (var item in oldOAClientList)
  11962. {
  11963. int comId = 0;
  11964. string format = "yyyy-MM-dd HH:mm:ss";
  11965. string data11 = "1990-01-01 00:00";
  11966. var data1 = IsValidDate(item.OPdate, format);
  11967. if (data1) data11 = item.OPdate;
  11968. //客户公司验证
  11969. if (!string.IsNullOrEmpty(item.Company))
  11970. {
  11971. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11972. if (clientComInfo == null) // add
  11973. {
  11974. var addInfo = new Crm_CustomerCompany()
  11975. {
  11976. CompanyAbbreviation = "",
  11977. CompanyFullName = item.Company,
  11978. Address = "",
  11979. PostCodes = "",
  11980. LastedOpUserId = item.OPer,
  11981. LastedOpDt = Convert.ToDateTime(data11),
  11982. CreateUserId = item.OPer,
  11983. CreateTime = Convert.ToDateTime(data11),
  11984. IsDel = 0
  11985. };
  11986. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11987. if (comId1 > 0) comId = comId1;
  11988. }
  11989. else comId = clientComInfo.Id;
  11990. }
  11991. //客户人员验证
  11992. int clientId = 0;
  11993. string name = item.LastName + item.Name;
  11994. if (!string.IsNullOrEmpty(name))
  11995. {
  11996. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11997. if (clientInfo == null)
  11998. {
  11999. DateTime? dateTime = null;
  12000. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  12001. if (isDt) dateTime = birthDayDt;
  12002. var addInfo1 = new Crm_DeleClient()
  12003. {
  12004. CrmCompanyId = comId,
  12005. DiId = -1,
  12006. LastName = item.LastName,
  12007. FirstName = item.Name,
  12008. OldName = "",
  12009. Pinyin = item.Pinyin,
  12010. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  12011. Marriage = 0,
  12012. Phone = item.Phone,
  12013. Job = item.Job,
  12014. BirthDay = dateTime
  12015. };
  12016. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  12017. if (clientId1 > 0) clientId = clientId1;
  12018. }
  12019. else clientId = clientInfo.Id;
  12020. }
  12021. if (clientId < 1)
  12022. {
  12023. continue;
  12024. }
  12025. int airType = 0;
  12026. if (item.AirType == "超经舱") airType = 459;
  12027. else if (item.AirType == "公务舱") airType = 458;
  12028. else if (item.AirType == "经济舱") airType = 460;
  12029. else if (item.AirType == "其他") airType = 565;
  12030. else if (item.AirType == "头等舱") airType = 457;
  12031. var _TourClientListEntity = new Grp_TourClientList()
  12032. {
  12033. DiId = item.Diid,
  12034. ClientId = clientId,
  12035. CreateUserId = item.OPer,
  12036. CreateTime = Convert.ToDateTime(data11),
  12037. Remark = item.Remark,
  12038. IsDel = item.Isdel,
  12039. ShippingSpaceTypeId = airType,
  12040. ShippingSpaceSpecialNeeds = item.AirRemark,
  12041. HotelSpecialNeeds = item.RoomType
  12042. };
  12043. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  12044. if (_TourClientList > 0)
  12045. {
  12046. updateCount++;
  12047. }
  12048. }
  12049. _sqlSugar.CommitTran();
  12050. }
  12051. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  12052. }
  12053. catch (Exception ex)
  12054. {
  12055. _sqlSugar.RollbackTran();
  12056. return Ok(JsonView(false, ex.Message));
  12057. }
  12058. return Ok(JsonView(true));
  12059. }
  12060. private bool IsValidDate(string dateString, string format)
  12061. {
  12062. DateTime dateValue;
  12063. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  12064. return valid;
  12065. }
  12066. /// <summary>
  12067. /// 接团客户名单
  12068. /// 根据团组Id查询List
  12069. /// </summary>
  12070. /// <param name="dto"></param>
  12071. /// <returns></returns>
  12072. [HttpPost]
  12073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12074. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  12075. {
  12076. #region 参数验证
  12077. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  12078. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  12079. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  12080. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12081. #region 页面操作权限验证
  12082. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12083. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12084. #endregion
  12085. #endregion
  12086. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  12087. if (viewData.Code != 0)
  12088. {
  12089. return Ok(JsonView(false, viewData.Msg));
  12090. }
  12091. return Ok(JsonView(viewData.Data));
  12092. }
  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> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  12102. {
  12103. #region 参数验证
  12104. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12105. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12106. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12107. #region 页面操作权限验证
  12108. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12109. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12110. #endregion
  12111. #endregion
  12112. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  12113. }
  12114. /// <summary>
  12115. /// 接团客户名单
  12116. /// 根据 Id查询 Details
  12117. /// </summary>
  12118. /// <param name="_dto"></param>
  12119. /// <returns></returns>
  12120. [HttpPost]
  12121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12122. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  12123. {
  12124. #region 参数验证
  12125. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12126. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12127. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  12128. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12129. #region 页面操作权限验证
  12130. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12131. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12132. #endregion
  12133. #endregion
  12134. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  12135. if (viewData.Code != 0)
  12136. {
  12137. return Ok(JsonView(false, viewData.Msg));
  12138. }
  12139. return Ok(JsonView(viewData.Data));
  12140. }
  12141. /// <summary>
  12142. /// 接团客户名单
  12143. /// Add Or Edit
  12144. /// </summary>
  12145. /// <param name="_dto"></param>
  12146. /// <returns></returns>
  12147. [HttpPost]
  12148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12149. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  12150. {
  12151. #region 参数验证
  12152. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12153. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12154. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  12155. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12156. #region 页面操作权限验证
  12157. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12158. if (_dto.Id == 0) //添加
  12159. {
  12160. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12161. }
  12162. else if (_dto.Id >= 0) //修改
  12163. {
  12164. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  12165. }
  12166. #endregion
  12167. #endregion
  12168. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  12169. if (viewData.Code != 0)
  12170. {
  12171. return Ok(JsonView(false, viewData.Msg));
  12172. }
  12173. return Ok(JsonView(true));
  12174. }
  12175. /// <summary>
  12176. /// 接团客户名单
  12177. /// AddMultiple(添加多个)
  12178. /// </summary>
  12179. /// <param name="_dto"></param>
  12180. /// <returns></returns>
  12181. [HttpPost]
  12182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12183. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  12184. {
  12185. #region 参数验证
  12186. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12187. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12188. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12189. #region 页面操作权限验证
  12190. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12191. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12192. #endregion
  12193. #endregion
  12194. var viewData = await _tourClientListRep._AddMultiple(_dto);
  12195. if (viewData.Code != 0)
  12196. {
  12197. return Ok(JsonView(false, viewData.Msg));
  12198. }
  12199. return Ok(JsonView(true));
  12200. }
  12201. /// <summary>
  12202. /// 接团客户名单
  12203. /// Del
  12204. /// </summary>
  12205. /// <param name="_dto"></param>
  12206. /// <returns></returns>
  12207. [HttpPost]
  12208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12209. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  12210. {
  12211. #region 参数验证
  12212. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12213. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12214. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12215. #region 页面操作权限验证
  12216. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12217. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12218. #endregion
  12219. #endregion
  12220. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  12221. if (viewData.Code != 0)
  12222. {
  12223. return Ok(JsonView(false, viewData.Msg));
  12224. }
  12225. return Ok(JsonView(true));
  12226. }
  12227. /// <summary>
  12228. /// 接团客户名单
  12229. /// 文件下载 客户名单
  12230. /// </summary>
  12231. /// <param name="_dto"></param>
  12232. /// <returns></returns>
  12233. [HttpPost]
  12234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12235. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  12236. {
  12237. #region 参数验证
  12238. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  12239. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  12240. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  12241. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12242. #region 页面操作权限验证
  12243. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12244. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12245. #endregion
  12246. #endregion
  12247. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  12248. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  12249. From Grp_TourClientList tcl
  12250. Left Join
  12251. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  12252. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  12253. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  12254. From Crm_DeleClient dc
  12255. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  12256. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  12257. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  12258. Where dc.IsDel = 0) temp
  12259. On temp.DcId =tcl.ClientId
  12260. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  12261. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  12262. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  12263. //载入模板
  12264. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  12265. if (_dto.Language == 1)
  12266. {
  12267. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  12268. }
  12269. //载入模板
  12270. var doc = new Document(tempPath);
  12271. DocumentBuilder builder = new DocumentBuilder(doc);
  12272. //获取word里所有表格
  12273. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12274. //获取所填表格的序数
  12275. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12276. var rowStart = tableOne.Rows[0]; //获取第1行
  12277. if (_dto.Language == 0)
  12278. {
  12279. //循环赋值
  12280. for (int i = 0; i < DcList.Count; i++)
  12281. {
  12282. builder.MoveToCell(0, i + 1, 0, 0);
  12283. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  12284. builder.MoveToCell(0, i + 1, 1, 0);
  12285. int sex = DcList[i].Sex;
  12286. string sexStr = string.Empty;
  12287. if (sex == 0) sexStr = "男";
  12288. else if (sex == 1) sexStr = "女";
  12289. else sexStr = "未设置";
  12290. builder.Write(sexStr);
  12291. builder.MoveToCell(0, i + 1, 2, 0);
  12292. string birthDay = DcList[i].BirthDay;
  12293. string birthDayStr = string.Empty;
  12294. if (!string.IsNullOrEmpty(birthDay))
  12295. {
  12296. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  12297. }
  12298. builder.Write(birthDayStr);
  12299. builder.MoveToCell(0, i + 1, 3, 0);
  12300. string company = "";
  12301. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12302. {
  12303. company = DcList[i].CompanyFullName.ToString();
  12304. }
  12305. builder.Write(company);
  12306. builder.MoveToCell(0, i + 1, 4, 0);
  12307. builder.Write(DcList[i].Job);
  12308. }
  12309. }
  12310. else if (_dto.Language == 1)
  12311. {
  12312. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  12313. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  12314. List<string> transArrayStr = new List<string>();
  12315. string transStrRes1 = "";
  12316. for (int i = 0; i < DcList.Count; i++)
  12317. {
  12318. var dc = DcList[i];
  12319. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  12320. if (dc.Job.Equals("暂无")) dc.Job = "-";
  12321. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  12322. if (DcList.Count - 1 == i) transStrRes1 += str1;
  12323. else transStrRes1 += $"{str1}|";
  12324. }
  12325. //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";
  12326. string transStrRes = "";
  12327. if (transStrRes1.Length > 0)
  12328. {
  12329. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  12330. }
  12331. //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
  12332. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  12333. //List<string> transArray = new List<string> { };
  12334. List<TranslateInfo> transArray = new List<TranslateInfo>();
  12335. if (transStrRes.Contains("|"))
  12336. {
  12337. string[] transArray1 = transStrRes.Split('|');
  12338. if (transArray1.Length > 0)
  12339. {
  12340. foreach (var item in transArray1)
  12341. {
  12342. if (item.Contains("&"))
  12343. {
  12344. string[] transArray2 = item.Split('&');
  12345. int index = 0;
  12346. string companyName = "", job = "";
  12347. if (transArray2.Length > 0)
  12348. {
  12349. bool success = int.TryParse(transArray2[0].Trim(), out index);
  12350. if (1 < transArray2.Length) companyName = transArray2[1];
  12351. if (2 < transArray2.Length) job = transArray2[2];
  12352. }
  12353. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  12354. }
  12355. }
  12356. }
  12357. }
  12358. //循环赋值
  12359. for (int i = 0; i < DcList.Count; i++)
  12360. {
  12361. string PYName = "";
  12362. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  12363. {
  12364. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  12365. string PY_First = DcList[i].Pinyin.Split('/')[1];
  12366. PYName = PY_First + " " + PY_Last;
  12367. }
  12368. else
  12369. {
  12370. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  12371. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  12372. PYName = PY_First + " " + PY_Last;
  12373. }
  12374. builder.MoveToCell(0, i + 1, 0, 0);
  12375. builder.Write(PYName);
  12376. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  12377. builder.MoveToCell(0, i + 1, 1, 0);
  12378. builder.Write(sex);
  12379. DateTime birthDt;
  12380. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  12381. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  12382. builder.MoveToCell(0, i + 1, 2, 0);
  12383. builder.Write(birthday);
  12384. string company = string.Empty, job = string.Empty;
  12385. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  12386. if (dcTransInfo != null)
  12387. {
  12388. company = dcTransInfo.CompanyName;
  12389. job = dcTransInfo.Job;
  12390. }
  12391. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12392. {
  12393. //查询对照表
  12394. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  12395. if (tempCec != null)
  12396. {
  12397. company = tempCec.enName;
  12398. }
  12399. //翻译
  12400. else
  12401. {
  12402. }
  12403. }
  12404. builder.MoveToCell(0, i + 1, 3, 0);
  12405. builder.Write(company);
  12406. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  12407. {
  12408. //查询对照表
  12409. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  12410. if (tempPec != null)
  12411. {
  12412. job = tempPec.enName;
  12413. }
  12414. //翻译
  12415. else
  12416. {
  12417. }
  12418. }
  12419. builder.MoveToCell(0, i + 1, 4, 0);
  12420. builder.Write(job);
  12421. }
  12422. }
  12423. //删除多余行
  12424. while (tableOne.Rows.Count > DcList.Count + 1)
  12425. {
  12426. tableOne.Rows.RemoveAt(DcList.Count + 1);
  12427. }
  12428. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  12429. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  12430. doc.Save(fileDir);
  12431. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  12432. return Ok(JsonView(true, "操作成功!", Url));
  12433. }
  12434. private class TranslateInfo
  12435. {
  12436. public int Index { get; set; }
  12437. public string CompanyName { get; set; }
  12438. public string Job { get; set; }
  12439. }
  12440. #endregion
  12441. #region 团组倒推表
  12442. /// <summary>
  12443. /// 倒推表基础数据
  12444. /// Init
  12445. /// </summary>
  12446. /// <param name="dto"></param>
  12447. /// <returns></returns>
  12448. [HttpPost]
  12449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12450. public async Task<IActionResult> PostInvertedListInit()
  12451. {
  12452. var viewData = await _invertedListRep._Init();
  12453. if (viewData.Code != 0)
  12454. {
  12455. return Ok(JsonView(false, viewData.Msg));
  12456. }
  12457. return Ok(JsonView(viewData.Data));
  12458. }
  12459. /// <summary>
  12460. /// 倒推表
  12461. /// Info
  12462. /// </summary>
  12463. /// <param name="dto"></param>
  12464. /// <returns></returns>
  12465. [HttpPost]
  12466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12467. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  12468. {
  12469. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  12470. if (viewData.Code != 0)
  12471. {
  12472. return Ok(JsonView(false, viewData.Msg));
  12473. }
  12474. return Ok(JsonView(viewData.Data));
  12475. }
  12476. /// <summary>
  12477. /// 倒推表
  12478. /// Create
  12479. /// </summary>
  12480. /// <param name="dto"></param>
  12481. /// <returns></returns>
  12482. [HttpPost]
  12483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12484. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  12485. {
  12486. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  12487. if (viewData.Code != 0)
  12488. {
  12489. return Ok(JsonView(false, viewData.Msg));
  12490. }
  12491. return Ok(JsonView(viewData.Data));
  12492. }
  12493. /// <summary>
  12494. /// 倒推表
  12495. /// Update
  12496. /// </summary>
  12497. /// <param name="dto"></param>
  12498. /// <returns></returns>
  12499. [HttpPost]
  12500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12501. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  12502. {
  12503. var viewData = await _invertedListRep._Update(dto);
  12504. if (viewData.Code != 0)
  12505. {
  12506. return Ok(JsonView(false, viewData.Msg));
  12507. }
  12508. return Ok(JsonView(viewData.Data));
  12509. }
  12510. /// <summary>
  12511. /// 倒推表
  12512. /// File Download
  12513. /// </summary>
  12514. /// <param name="dto"></param>
  12515. /// <returns></returns>
  12516. [HttpPost]
  12517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12518. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  12519. {
  12520. var info2 = await _invertedListRep._Info(1, dto.DiId);
  12521. if (info2.Code != 0)
  12522. {
  12523. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  12524. }
  12525. var info1 = info2.Data as InvertedListInfoView;
  12526. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  12527. string teamName = "";
  12528. if (info != null) teamName = info.TeamName;
  12529. //载入模板
  12530. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  12531. DocumentBuilder builder = new DocumentBuilder(doc);
  12532. //利用键值对存放数据
  12533. Dictionary<string, string> dic = new Dictionary<string, string>();
  12534. dic.Add("TeamName", teamName);
  12535. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  12536. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  12537. dic.Add("BPRemark", info1.ApprovalDataRemark);
  12538. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  12539. dic.Add("SQRemark", info1.ApprovalRemark);
  12540. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  12541. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  12542. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  12543. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  12544. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  12545. dic.Add("QZRemark", info1.VisaInformationRemark);
  12546. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  12547. dic.Add("SQQZRemark", info1.SendVisaRemark);
  12548. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  12549. dic.Add("CQRemark", info1.IssueVisaRemark);
  12550. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  12551. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  12552. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  12553. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  12554. #region 填充word模板书签内容
  12555. foreach (var key in dic.Keys)
  12556. {
  12557. builder.MoveToBookmark(key);
  12558. builder.Write(dic[key]);
  12559. }
  12560. #endregion
  12561. var fileDir = AppSettingsHelper.Get("WordBasePath");
  12562. string fileName = $"{teamName}团出行准备流程表.doc";
  12563. string filePath = fileDir + $@"InvertedList/{fileName}";
  12564. doc.Save(filePath);
  12565. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  12566. return Ok(JsonView(true, "操作成功!", Url));
  12567. }
  12568. #endregion
  12569. #region 三公签证费用(签证费、代办费)
  12570. /// <summary>
  12571. /// 三公签证费用(签证费、代办费)
  12572. /// List
  12573. /// </summary>
  12574. /// <returns></returns>
  12575. [HttpPost]
  12576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12577. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  12578. {
  12579. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  12580. if (_view.Code != 0)
  12581. {
  12582. return Ok(JsonView(false, _view.Msg));
  12583. }
  12584. return Ok(JsonView(true, "操作成功!", _view.Data));
  12585. }
  12586. /// <summary>
  12587. /// 三公签证费用(签证费、代办费)
  12588. /// Add Or Update
  12589. /// </summary>
  12590. /// <returns></returns>
  12591. [HttpPost]
  12592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12593. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  12594. {
  12595. var _view = await _visaFeeInfoRep._Update(_dto);
  12596. if (_view.Code != 0)
  12597. {
  12598. return Ok(JsonView(false, _view.Msg));
  12599. }
  12600. return Ok(JsonView(true, _view.Msg));
  12601. }
  12602. #endregion
  12603. #region 酒店询价
  12604. /// <summary>
  12605. /// 酒店询价
  12606. /// Init
  12607. /// </summary>
  12608. /// <param name="dto"></param>
  12609. /// <returns></returns>
  12610. [HttpPost]
  12611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12612. public async Task<IActionResult> PostHotelInquiryInit()
  12613. {
  12614. var res = await _hotelInquiryRep._Init();
  12615. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12616. return Ok(JsonView(true, res.Msg, res.Data));
  12617. }
  12618. /// <summary>
  12619. /// 酒店询价
  12620. /// page Item
  12621. /// </summary>
  12622. /// <param name="_dto"></param>
  12623. /// <returns></returns>
  12624. [HttpPost]
  12625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12626. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  12627. {
  12628. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  12629. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12630. var view = res.Data as PageDataViewBase;
  12631. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  12632. }
  12633. /// <summary>
  12634. /// 酒店询价
  12635. /// info
  12636. /// </summary>
  12637. /// <param name="_dto"></param>
  12638. /// <returns></returns>
  12639. [HttpPost]
  12640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12641. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12642. {
  12643. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12644. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12645. return Ok(JsonView(true, res.Msg, res.Data));
  12646. }
  12647. /// <summary>
  12648. /// 酒店询价
  12649. /// Add Or Edit
  12650. /// </summary>
  12651. /// <param name="_dto"></param>
  12652. /// <returns></returns>
  12653. [HttpPost]
  12654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12655. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12656. {
  12657. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12658. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12659. return Ok(JsonView(true, res.Msg, res.Data));
  12660. }
  12661. /// <summary>
  12662. /// 酒店询价
  12663. /// Del
  12664. /// </summary>
  12665. /// <param name="_dto"></param>
  12666. /// <returns></returns>
  12667. [HttpPost]
  12668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12669. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12670. {
  12671. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12672. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12673. return Ok(JsonView(true, res.Msg, res.Data));
  12674. }
  12675. #endregion
  12676. #region 下载匹配op行程单
  12677. /// <summary>
  12678. /// 匹配op行程单
  12679. /// Init
  12680. /// </summary>
  12681. /// <param name="dto">团组列表请求dto</param>
  12682. /// <returns></returns>
  12683. [HttpPost]
  12684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12685. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12686. {
  12687. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12688. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12689. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12690. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12691. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12692. .Where(it => it.IsDel == 0)
  12693. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12694. .OrderByDescending(it => it.CreateUserId)
  12695. .ToList();
  12696. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12697. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12698. var diids = groupInfos.Select(it => it.Id).ToList();
  12699. List<string> countrys = new List<string>();
  12700. foreach (var item in country)
  12701. {
  12702. var data = _groupRepository.FormartTeamName(item);
  12703. var dataArray = _groupRepository.GroupSplitCountry(data);
  12704. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12705. }
  12706. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12707. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12708. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12709. foreach (var item in areaItem)
  12710. {
  12711. string areaStr = item.Value;
  12712. if (!string.IsNullOrEmpty(areaStr))
  12713. {
  12714. string[] str1 = areaStr.Split("-");
  12715. if (str1.Length > 0)
  12716. {
  12717. areaArray.AddRange(str1);
  12718. }
  12719. }
  12720. }
  12721. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12722. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12723. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12724. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12725. .ToList();
  12726. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12727. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12728. .Where(it => countriesIds.Contains(it.Id))
  12729. .Select(it => new { it.Id, Name = it.Name_CN })
  12730. .ToList();
  12731. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12732. .Select(it => it.TeamName).ToList();
  12733. stopwatch.Stop();
  12734. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12735. }
  12736. ///// <summary>
  12737. ///// 匹配op行程单
  12738. ///// Init 查询区域数据
  12739. ///// </summary>
  12740. ///// <param name="dto">团组列表请求dto</param>
  12741. ///// <returns></returns>
  12742. //[HttpPost]
  12743. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12744. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12745. //{
  12746. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12747. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12748. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12749. // if (string.IsNullOrEmpty(countriesDataStr))
  12750. // {
  12751. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12752. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12753. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12754. // }
  12755. // else
  12756. // {
  12757. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12758. // }
  12759. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12760. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12761. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12762. // List<dynamic> childList = new List<dynamic>();
  12763. // int parentId = dto.CountriesId;
  12764. // if (provinceData.Count > 1)
  12765. // {
  12766. // foreach (var item1 in provinceData)
  12767. // {
  12768. // List<dynamic> childList1 = new List<dynamic>();
  12769. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12770. // foreach (var item2 in citiesData1)
  12771. // {
  12772. // List<dynamic> childList2 = new List<dynamic>();
  12773. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12774. // foreach (var item3 in countiesData1)
  12775. // {
  12776. // childList2.Add(new
  12777. // {
  12778. // id = item3.Id,
  12779. // parentId = item2.Id,
  12780. // level = "district",
  12781. // name = item3.Name_CN,
  12782. // });
  12783. // }
  12784. // childList1.Add(new
  12785. // {
  12786. // id = item2.Id,
  12787. // parentId = item1.Id,
  12788. // level = "city",
  12789. // name = item2.Name_CN,
  12790. // childList = childList2
  12791. // });
  12792. // }
  12793. // childList.Add(new
  12794. // {
  12795. // id = item1.Id,
  12796. // parentId = parentId,
  12797. // level = "province",
  12798. // name = item1.Name_CN,
  12799. // childList = childList1
  12800. // });
  12801. // }
  12802. // //城市
  12803. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12804. // foreach (var item2 in citiesData2)
  12805. // {
  12806. // List<dynamic> childList22 = new List<dynamic>();
  12807. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12808. // foreach (var item3 in countiesData1)
  12809. // {
  12810. // childList22.Add(new
  12811. // {
  12812. // id = item3.Id,
  12813. // parentId = item2.Id,
  12814. // level = "district",
  12815. // name = item3.Name_CN,
  12816. // });
  12817. // }
  12818. // childList.Add(new
  12819. // {
  12820. // id = item2.Id,
  12821. // parentId = parentId,
  12822. // level = "city",
  12823. // name = item2.Name_CN,
  12824. // childList = childList22
  12825. // });
  12826. // }
  12827. // }
  12828. // else
  12829. // {
  12830. // foreach (var item2 in citiesData)
  12831. // {
  12832. // string cname = item2.Name_CN;
  12833. // List<dynamic> childList1 = new List<dynamic>();
  12834. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12835. // foreach (var item3 in countiesData1)
  12836. // {
  12837. // childList1.Add(new
  12838. // {
  12839. // Id = item3.Id,
  12840. // parentId = item2.Id,
  12841. // level = "district",
  12842. // name = item3.Name_CN
  12843. // });
  12844. // }
  12845. // childList.Add(new
  12846. // {
  12847. // id = item2.Id,
  12848. // parentId = parentId,
  12849. // level = "city",
  12850. // name = item2.Name_CN,
  12851. // childList = childList1
  12852. // });
  12853. // }
  12854. // }
  12855. // stopwatch.Stop();
  12856. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12857. //}
  12858. /// <summary>
  12859. /// 匹配op行程单
  12860. /// 接团信息列表 Page
  12861. /// </summary>
  12862. /// <param name="dto">团组列表请求dto</param>
  12863. /// <returns></returns>
  12864. [HttpPost]
  12865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12866. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12867. {
  12868. var swatch = new Stopwatch();
  12869. swatch.Start();
  12870. #region 参数验证
  12871. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12872. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12873. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12874. #region 页面操作权限验证
  12875. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12876. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12877. #endregion
  12878. #endregion
  12879. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12880. {
  12881. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12882. string sqlWhere = "";
  12883. if (!string.IsNullOrEmpty(dto.Country))
  12884. {
  12885. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12886. }
  12887. if (!string.IsNullOrEmpty(dto.Area))
  12888. {
  12889. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12890. }
  12891. if (!string.IsNullOrEmpty(dto.TeamName))
  12892. {
  12893. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12894. }
  12895. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12896. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12897. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12898. swatch.Stop();
  12899. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12900. }
  12901. else
  12902. {
  12903. return Ok(JsonView(false, "查询失败"));
  12904. }
  12905. }
  12906. /// <summary>
  12907. /// 匹配op行程单
  12908. /// 行程单下载
  12909. /// </summary>
  12910. /// <param name="dto">团组列表请求dto</param>
  12911. /// <returns></returns>
  12912. [HttpPost]
  12913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12914. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12915. {
  12916. #region 参数验证
  12917. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12918. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12919. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12920. #region 页面操作权限验证
  12921. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12922. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12923. #endregion
  12924. #endregion
  12925. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12926. {
  12927. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12928. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12929. }
  12930. else
  12931. {
  12932. return Ok(JsonView(false, "下载失败!"));
  12933. }
  12934. }
  12935. #endregion
  12936. #region 国家信息 数据 注释
  12937. //[HttpPost]
  12938. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12939. //{
  12940. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12941. // foreach (var item in dto)
  12942. // {
  12943. // infos.Add(new Grp_GroupsTaskAssignment()
  12944. // {
  12945. // DIId = item,
  12946. // CTId = 82,
  12947. // UId = 248,
  12948. // IsEnable = 1,
  12949. // CreateUserId = 233,
  12950. // CreateTime = DateTime.Now,
  12951. // IsDel = 0
  12952. // });
  12953. // infos.Add(new Grp_GroupsTaskAssignment()
  12954. // {
  12955. // DIId = item,
  12956. // CTId = 82,
  12957. // UId = 286,
  12958. // IsEnable = 1,
  12959. // CreateUserId = 233,
  12960. // CreateTime = DateTime.Now,
  12961. // IsDel = 0
  12962. // });
  12963. // }
  12964. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12965. // return Ok("操作成功");
  12966. //}
  12967. //public class paramJsonDto
  12968. //{
  12969. // public List<CountriesInfo> str { get; set; }
  12970. //}
  12971. //[HttpPost]
  12972. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12973. //{
  12974. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12975. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12976. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12977. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12978. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12979. // _sqlSugar.BeginTran();
  12980. // int countitiesIndex = 0;
  12981. // foreach (var item in dto.str)
  12982. // {
  12983. // dynamic data = item.c;
  12984. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12985. // if (data != null)
  12986. // {
  12987. // countitiesIndex++;
  12988. // foreach (var item1 in data)
  12989. // {
  12990. // string cnname = item1.cn;
  12991. // string enname = item1.en;
  12992. // Sys_Cities provinceInfo = new Sys_Cities()
  12993. // {
  12994. // CountriesId = countriesId,
  12995. // Name_CN = cnname,
  12996. // Name_EN = enname,
  12997. // ParentId = 0,
  12998. // IsCapital = 1,
  12999. // CreateUserId = 208,
  13000. // CreateTime = DateTime.Now,
  13001. // IsDel = 0
  13002. // };
  13003. // if (item1.lv == "province") //省份
  13004. // {
  13005. // provinceInfo.Level = 1;
  13006. // int provinceId = 0;
  13007. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  13008. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  13009. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13010. // var data1 = item1.c;
  13011. // foreach (var item2 in data1)
  13012. // {
  13013. // if (item2.lv == "city")
  13014. // {
  13015. // string citycnname = item2.cn;
  13016. // string cityenname = item2.en;
  13017. // Sys_Cities cityInfo = new Sys_Cities()
  13018. // {
  13019. // CountriesId = countriesId,
  13020. // ParentId = provinceId,
  13021. // Level = 2,
  13022. // Name_CN = citycnname,
  13023. // Name_EN = cityenname,
  13024. // IsCapital = 1,
  13025. // CreateUserId = 208,
  13026. // CreateTime = DateTime.Now,
  13027. // IsDel = 0
  13028. // };
  13029. // if (item2.c != null)
  13030. // {
  13031. // int cityId = 0;
  13032. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  13033. // if (citiesInfo != null) cityId = citiesInfo.Id;
  13034. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  13035. // foreach (var item3 in item2.c)
  13036. // {
  13037. // if (item3.lv == "district")
  13038. // {
  13039. // var districtInfo = new Sys_Cities()
  13040. // {
  13041. // CountriesId = countriesId,
  13042. // Name_CN = item3.cn,
  13043. // Name_EN = item3.en,
  13044. // Level = 3,
  13045. // ParentId = cityId,
  13046. // IsCapital = 1,
  13047. // CreateUserId = 208,
  13048. // CreateTime = DateTime.Now,
  13049. // IsDel = 0
  13050. // };
  13051. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  13052. // //{
  13053. // districts.Add(districtInfo);
  13054. // //}
  13055. // }
  13056. // }
  13057. // }
  13058. // else
  13059. // {
  13060. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  13061. // //{
  13062. // cities.Add(cityInfo);
  13063. // //}
  13064. // }
  13065. // }
  13066. // }
  13067. // }
  13068. // else if (item1.lv == "city")//城市
  13069. // {
  13070. // provinceInfo.Level = 2;
  13071. // if (item1.c != null)
  13072. // {
  13073. // int cityId = 0;
  13074. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  13075. // if (citiesInfo != null) cityId = citiesInfo.Id;
  13076. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13077. // foreach (var item3 in item1.c)
  13078. // {
  13079. // if (item3.lv == "district")
  13080. // {
  13081. // var districtInfo = new Sys_Cities()
  13082. // {
  13083. // CountriesId = countriesId,
  13084. // Name_CN = item3.cn,
  13085. // Name_EN = item3.en,
  13086. // Level = 3,
  13087. // ParentId = cityId,
  13088. // IsCapital = 1,
  13089. // CreateUserId = 208,
  13090. // CreateTime = DateTime.Now,
  13091. // IsDel = 0
  13092. // };
  13093. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  13094. // //{
  13095. // districts.Add(districtInfo);
  13096. // //}
  13097. // }
  13098. // }
  13099. // }
  13100. // else
  13101. // {
  13102. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  13103. // //{
  13104. // cities.Add(provinceInfo);
  13105. // //}
  13106. // }
  13107. // }
  13108. // }
  13109. // }
  13110. // }
  13111. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  13112. // cities = cities.Distinct().ToList();
  13113. // districts = districts.Distinct().ToList();
  13114. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  13115. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  13116. // cities.AddRange(districts);
  13117. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  13118. // //_sqlSugar.RollbackTran();
  13119. // _sqlSugar.CommitTran();
  13120. // return Ok(JsonView(false, "操作成功!"));
  13121. //}
  13122. //[HttpPost]
  13123. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  13124. //{
  13125. // List<CountitiesInfo> infos = dto.MyProperty;
  13126. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  13127. // _sqlSugar.BeginTran();
  13128. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13129. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  13130. // foreach (var item in infos)
  13131. // {
  13132. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  13133. // if (countryInfo != null)
  13134. // {
  13135. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  13136. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  13137. // if (cityInfo1 != null)
  13138. // {
  13139. // cityInfo1.IsCapital = 0;
  13140. // cityInfos.Add(cityInfo1);
  13141. // }
  13142. // }
  13143. // }
  13144. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  13145. // .UpdateColumns(it => it.IsCapital)
  13146. // .WhereColumns(it => it.Id)
  13147. // .ExecuteCommand();
  13148. // //_sqlSugar.RollbackTran();
  13149. // _sqlSugar.CommitTran();
  13150. // return Ok(JsonView(false, "操作成功!"));
  13151. //}
  13152. //public class CounrtiesDto
  13153. //{
  13154. // public List<CountitiesInfo> MyProperty { get; set; }
  13155. //}
  13156. //public class CountitiesInfo
  13157. //{
  13158. // /// <summary>
  13159. // /// 圣约翰
  13160. // /// </summary>
  13161. // public string capital_name_chinese { get; set; }
  13162. // /// <summary>
  13163. // ///
  13164. // /// </summary>
  13165. // public string capital_name { get; set; }
  13166. // /// <summary>
  13167. // ///
  13168. // /// </summary>
  13169. // public string country_type { get; set; }
  13170. // /// <summary>
  13171. // /// 安提瓜和巴布达
  13172. // /// </summary>
  13173. // public string country_name_chinese { get; set; }
  13174. // /// <summary>
  13175. // /// 安提瓜和巴布达
  13176. // /// </summary>
  13177. // public string country_name_chinese_short { get; set; }
  13178. // /// <summary>
  13179. // /// 安提瓜和巴布达
  13180. // /// </summary>
  13181. // public string country_name_chinese_UN { get; set; }
  13182. // /// <summary>
  13183. // ///
  13184. // /// </summary>
  13185. // public string country_name_english_abbreviation { get; set; }
  13186. // /// <summary>
  13187. // ///
  13188. // /// </summary>
  13189. // public string country_name_english_formal { get; set; }
  13190. // /// <summary>
  13191. // ///
  13192. // /// </summary>
  13193. // public string country_name_english_UN { get; set; }
  13194. // /// <summary>
  13195. // ///
  13196. // /// </summary>
  13197. // public string continent_name { get; set; }
  13198. // /// <summary>
  13199. // ///
  13200. // /// </summary>
  13201. // public string subregion_name { get; set; }
  13202. // /// <summary>
  13203. // ///
  13204. // /// </summary>
  13205. // public string country_code2 { get; set; }
  13206. // /// <summary>
  13207. // ///
  13208. // /// </summary>
  13209. // public string country_code3 { get; set; }
  13210. // /// <summary>
  13211. // ///
  13212. // /// </summary>
  13213. // public string phone_code { get; set; }
  13214. //}
  13215. //public class CountriesInfo : BasicInfo
  13216. //{
  13217. // public List<CitiesInfo> c { get; set; }
  13218. //}
  13219. //public class CitiesInfo : BasicInfo
  13220. //{
  13221. // public List<AreaInfo> c { get; set; }
  13222. //}
  13223. //public class AreaInfo : BasicInfo
  13224. //{
  13225. // public List<AreaInfo> c { get; set; }
  13226. //}
  13227. //public class BasicInfo
  13228. //{
  13229. // public string code { get; set; }
  13230. // public string cn { get; set; }
  13231. // public string lv { get; set; }
  13232. // public string en { get; set; }
  13233. //}
  13234. #endregion
  13235. #region 查看邀请方
  13236. /// <summary>
  13237. /// 查看邀请方
  13238. /// 邀请方信息 Init
  13239. /// </summary>
  13240. /// <param name="dto"></param>
  13241. /// <returns></returns>
  13242. [HttpPost]
  13243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13244. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  13245. {
  13246. string sqlWhere = string.Empty;
  13247. if (!string.IsNullOrEmpty(dto.Search))
  13248. {
  13249. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  13250. }
  13251. string sql = string.Format($@"Select
  13252. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  13253. Id,
  13254. UnitName
  13255. From Res_InvitationOfficialActivityData
  13256. Where IsDel = 0
  13257. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  13258. RefAsync<int> total = 0;
  13259. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13260. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  13261. }
  13262. /// <summary>
  13263. /// 查看邀请方
  13264. /// 国家信息 Init
  13265. /// </summary>
  13266. /// <param name="dto"></param>
  13267. /// <returns></returns>
  13268. [HttpPost]
  13269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13270. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  13271. {
  13272. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  13273. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13274. var diids = groupInfos.Select(it => it.Id).ToList();
  13275. List<string> countrys = new List<string>();
  13276. foreach (var item in country)
  13277. {
  13278. var data = _groupRepository.FormartTeamName(item);
  13279. var dataArray = _groupRepository.GroupSplitCountry(data);
  13280. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13281. }
  13282. countrys = countrys.Distinct().ToList();
  13283. for (int i = 0; i < countrys.Count; i++)
  13284. {
  13285. string item = countrys[i];
  13286. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  13287. {
  13288. countrys.Remove(item);
  13289. i--;
  13290. }
  13291. }
  13292. RefAsync<int> total = 0;
  13293. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  13294. .Where(it => countrys.Contains(it.Name_CN))
  13295. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13296. .Select(it => new { id = it.Id, name = it.Name_CN })
  13297. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13298. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13299. }
  13300. /// <summary>
  13301. /// 查看邀请方
  13302. /// 城市信息 Init
  13303. /// </summary>
  13304. /// <param name="dto"></param>
  13305. /// <returns></returns>
  13306. [HttpPost]
  13307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13308. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  13309. {
  13310. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  13311. RefAsync<int> total = 0;
  13312. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  13313. .Where(it => it.CountriesId == dto.CountiesId)
  13314. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  13315. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  13316. .Select(it => new { id = it.Id, name = it.Name_CN })
  13317. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13318. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  13319. }
  13320. /// <summary>
  13321. /// 查看邀请方
  13322. /// 团组名称 Init
  13323. /// </summary>
  13324. /// <param name="dto"></param>
  13325. /// <returns></returns>
  13326. [HttpPost]
  13327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13328. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  13329. {
  13330. var watch = new Stopwatch();
  13331. watch.Start();
  13332. RefAsync<int> total = 0;
  13333. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  13334. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  13335. .Where((oa, di) => oa.IsDel == 0)
  13336. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  13337. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  13338. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  13339. .Distinct()
  13340. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13341. watch.Stop();
  13342. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  13343. }
  13344. /// <summary>
  13345. /// 查看邀请方
  13346. /// 团组 & 邀请方信息
  13347. /// </summary>
  13348. /// <param name="dto"></param>
  13349. /// <returns></returns>
  13350. [HttpPost]
  13351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13352. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  13353. {
  13354. var watch = new Stopwatch();
  13355. watch.Start();
  13356. RefAsync<int> total = 0;
  13357. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  13358. .AS("Grp_DelegationInfo")
  13359. .Includes(x => x.InvitingInfos)
  13360. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  13361. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  13362. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  13363. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  13364. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  13365. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  13366. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13367. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  13368. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  13369. infos.ForEach(x =>
  13370. {
  13371. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  13372. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  13373. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  13374. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  13375. });
  13376. watch.Stop();
  13377. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  13378. }
  13379. #endregion
  13380. #region 报批行程
  13381. /// <summary>
  13382. /// 报批行程初始化
  13383. /// </summary>
  13384. /// <param name="dto"></param>
  13385. /// <returns></returns>
  13386. [HttpPost]
  13387. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  13388. {
  13389. const int chiNumber = 5;
  13390. var jw = JsonView(false);
  13391. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  13392. var group = groupList.First();
  13393. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13394. group = groupList.First(x => x.Id == diid);
  13395. if (group == null)
  13396. {
  13397. jw.Msg = "暂无团组!";
  13398. return Ok(jw);
  13399. }
  13400. var data = new
  13401. {
  13402. groupList = groupList.Select(x => new
  13403. {
  13404. x.TeamName,
  13405. x.Id
  13406. }),
  13407. content = new ArrayList(),
  13408. groupInfo = new
  13409. {
  13410. group.VisitDays,
  13411. group.TourCode,
  13412. group.VisitPNumber,
  13413. group.TeamName,
  13414. group.Id,
  13415. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  13416. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  13417. },
  13418. };
  13419. var resultArr = new ArrayList();
  13420. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  13421. if (content.Count == 0)
  13422. {
  13423. var stay = "-";
  13424. var cityPath = "-";
  13425. //添加城市路径以及住宿地
  13426. //黑屏代码数据
  13427. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13428. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13429. {
  13430. jw = JsonView(true, "黑屏代码有误!", data);
  13431. return Ok(jw);
  13432. }
  13433. foreach (DataRow row in dtBlack.Rows)
  13434. {
  13435. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13436. {
  13437. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  13438. return Ok(jw);
  13439. }
  13440. }
  13441. //黑屏代码获取时间区间
  13442. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13443. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13444. _sqlSugar.BeginTran();
  13445. for (int i = 0; i < timeArr.Count; i++)
  13446. {
  13447. stay = "-";
  13448. cityPath = "-";
  13449. DateTime NewData = DateTime.Parse(timeArr[i]);
  13450. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13451. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13452. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13453. if (tbSelect.Length > 0)
  13454. {
  13455. List<string> threeCodeStr = new List<string>();
  13456. foreach (var item in tbSelect)
  13457. {
  13458. var threeCode = item["Three"].ToString() ?? "";
  13459. if (threeCode.Length == 6)
  13460. {
  13461. var start = threeCode.Substring(0, 3);
  13462. var end = threeCode.Substring(3, 3);
  13463. if (threeCodeStr.Count == 0)
  13464. {
  13465. threeCodeStr.Add(start);
  13466. threeCodeStr.Add(end);
  13467. }
  13468. else
  13469. {
  13470. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13471. {
  13472. threeCodeStr.Add(end);
  13473. }
  13474. else
  13475. {
  13476. threeCodeStr.Add(start);
  13477. threeCodeStr.Add(end);
  13478. }
  13479. }
  13480. }
  13481. }
  13482. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13483. var last = threeCodeStr.Last();
  13484. foreach (var item in threeCodeStr)
  13485. {
  13486. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13487. if (item.Equals(last))
  13488. {
  13489. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13490. }
  13491. }
  13492. cityPath = cityPath.Trim('-');
  13493. }
  13494. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13495. appro.Diid = diid ?? -1;
  13496. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13497. appro.Id = thisId;
  13498. appro.CreateUserId = dto.UserId;
  13499. appro.CreateTime = DateTime.Now;
  13500. content.Add(appro);
  13501. }
  13502. _sqlSugar.CommitTran();
  13503. }
  13504. foreach (var x in content)
  13505. {
  13506. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  13507. if (chiList.Count < chiNumber)
  13508. {
  13509. for (int i = chiList.Count; i < chiNumber; i++)
  13510. {
  13511. chiList.Add(new Grp_ApprovalTravelDetails());
  13512. }
  13513. }
  13514. resultArr.Add(new
  13515. {
  13516. x.Id,
  13517. x.Date,
  13518. x.Diid,
  13519. chiList = chiList.Select(x1 => new
  13520. {
  13521. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13522. x1.Details,
  13523. x1.ParentId,
  13524. x1.Id
  13525. })
  13526. });
  13527. }
  13528. data = data with
  13529. {
  13530. content = resultArr,
  13531. };
  13532. jw = JsonView(true, "获取成功!", data);
  13533. return Ok(jw);
  13534. }
  13535. /// <summary>
  13536. /// 报批行程删除
  13537. /// </summary>
  13538. /// <param name="dto"></param>
  13539. /// <returns></returns>
  13540. [HttpPost]
  13541. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  13542. {
  13543. var jw = JsonView(false);
  13544. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13545. if (group == null)
  13546. {
  13547. jw.Msg = "团组参数有误!";
  13548. return Ok(jw);
  13549. }
  13550. try
  13551. {
  13552. _sqlSugar.BeginTran();
  13553. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  13554. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  13555. {
  13556. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13557. DeleteUserId = dto.uesrId,
  13558. IsDel = 1
  13559. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  13560. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  13561. {
  13562. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13563. DeleteUserId = dto.uesrId,
  13564. IsDel = 1
  13565. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  13566. _sqlSugar.CommitTran();
  13567. jw = JsonView(true, "删除成功");
  13568. }
  13569. catch (Exception ex)
  13570. {
  13571. jw = JsonView(false, ex.Message);
  13572. }
  13573. return Ok(jw);
  13574. }
  13575. /// <summary>
  13576. /// 报批行程保存
  13577. /// </summary>
  13578. /// <param name="dto"></param>
  13579. /// <returns></returns>
  13580. [HttpPost]
  13581. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  13582. {
  13583. var jw = JsonView(false);
  13584. var Find = dto.Arr.Find(x => x.id == 0);
  13585. if (Find != null)
  13586. {
  13587. jw.Msg = "生成的ID为0!";
  13588. return Ok(jw);
  13589. }
  13590. foreach (var item in dto.Arr)
  13591. {
  13592. foreach (var chi in item.chiList)
  13593. {
  13594. if (chi.parentId == 0)
  13595. {
  13596. chi.parentId = item.id;
  13597. }
  13598. }
  13599. }
  13600. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  13601. _sqlSugar.BeginTran();
  13602. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  13603. {
  13604. var parentIds = dto.Arr.Select(x => x.id).ToList();
  13605. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  13606. {
  13607. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13608. DeleteUserId = dto.UserId,
  13609. IsDel = 1
  13610. }).ExecuteCommand();
  13611. }
  13612. try
  13613. {
  13614. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  13615. {
  13616. CreateTime = DateTime.Now,
  13617. CreateUserId = dto.UserId,
  13618. Details = x.details,
  13619. ParentId = x.parentId,
  13620. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13621. Remark = "",
  13622. IsDel = 0
  13623. }).ToList()).ExecuteCommand();
  13624. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  13625. {
  13626. Id = x.id,
  13627. Details = x.details,
  13628. ParentId = x.parentId,
  13629. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13630. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  13631. {
  13632. Details = x.Details,
  13633. ParentId = x.ParentId,
  13634. Time = x.Time
  13635. }).ExecuteCommand();
  13636. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  13637. {
  13638. Id = x.id,
  13639. Date = x.date,
  13640. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13641. {
  13642. Date = x.Date
  13643. }).ExecuteCommand();
  13644. _sqlSugar.CommitTran();
  13645. jw = JsonView(true, "保存成功!");
  13646. }
  13647. catch (Exception ex)
  13648. {
  13649. _sqlSugar.RollbackTran();
  13650. jw = JsonView(false, "保存失败!" + ex.Message);
  13651. }
  13652. return Ok(jw);
  13653. }
  13654. /// <summary>
  13655. /// 报批行程生成
  13656. /// </summary>
  13657. /// <param name="dto"></param>
  13658. /// <returns></returns>
  13659. [HttpPost]
  13660. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13661. {
  13662. var jw = JsonView(false);
  13663. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13664. if (group == null)
  13665. {
  13666. jw.Msg = "暂无该团组!";
  13667. return Ok(jw);
  13668. }
  13669. //黑屏代码数据
  13670. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13671. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13672. {
  13673. jw.Msg = "黑屏代码有误!";
  13674. return Ok(jw);
  13675. }
  13676. foreach (DataRow row in dtBlack.Rows)
  13677. {
  13678. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13679. {
  13680. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13681. return Ok(jw);
  13682. }
  13683. }
  13684. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13685. var resultArr = new ArrayList();
  13686. if (officialActivitiesArr.Count == 0)
  13687. {
  13688. jw.Msg = "暂无公务出访信息!";
  13689. return Ok(jw);
  13690. }
  13691. try
  13692. {
  13693. _sqlSugar.BeginTran();
  13694. DeleteApprovalJourney(new
  13695. Domain.Dtos.Groups.DeleteApprovalJourney
  13696. {
  13697. Diid = dto.Diid,
  13698. uesrId = dto.Userid
  13699. });
  13700. var stay = "-";
  13701. var cityPath = "-";
  13702. //添加城市路径以及住宿地
  13703. //黑屏代码获取时间区间
  13704. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13705. var empty = "【未收入该三字码!请机票同事录入】";
  13706. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13707. for (int i = 0; i < timeArr.Count; i++)
  13708. {
  13709. stay = "-";
  13710. cityPath = "-";
  13711. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13712. DateTime NewData = DateTime.Parse(timeArr[i]);
  13713. 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();
  13714. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13715. if (tbSelect.Length > 0)
  13716. {
  13717. List<string> threeCodeStr = new List<string>();
  13718. bool isTrade = false;
  13719. string trip = string.Empty;
  13720. var rowLast = tbSelect.Last();
  13721. var rowFirst = tbSelect.First();
  13722. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13723. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13724. var takeOffTime = DateTime.Parse(timeArr[i]);
  13725. var fallToTime = DateTime.Parse(timeArr[i]);
  13726. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13727. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13728. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13729. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13730. foreach (var item in tbSelect)
  13731. {
  13732. var start = string.Empty;
  13733. var end = string.Empty;
  13734. var threeCode = item["Three"].ToString() ?? "";
  13735. if (threeCode.Length == 6)
  13736. {
  13737. start = threeCode.Substring(0, 3);
  13738. end = threeCode.Substring(3, 3);
  13739. if (threeCodeStr.Count == 0)
  13740. {
  13741. threeCodeStr.Add(start);
  13742. threeCodeStr.Add(end);
  13743. }
  13744. else
  13745. {
  13746. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13747. {
  13748. threeCodeStr.Add(end);
  13749. }
  13750. else
  13751. {
  13752. threeCodeStr.Add(start);
  13753. threeCodeStr.Add(end);
  13754. }
  13755. }
  13756. }
  13757. //处理机票信息
  13758. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13759. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13760. if (start_Object == null)
  13761. {
  13762. start_Object = new Res_ThreeCode()
  13763. {
  13764. AirPort = empty,
  13765. AirPort_En = empty,
  13766. City = empty,
  13767. Country = empty,
  13768. Four = empty,
  13769. Three = empty,
  13770. };
  13771. }
  13772. if (end_Object == null)
  13773. {
  13774. end_Object = new Res_ThreeCode()
  13775. {
  13776. AirPort = empty,
  13777. AirPort_En = empty,
  13778. City = empty,
  13779. Country = empty,
  13780. Four = empty,
  13781. Three = empty,
  13782. };
  13783. }
  13784. //机型判断
  13785. string airModel = item["AirModel"].ToString();
  13786. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13787. string flightTime = item["FlightTime"].ToString();
  13788. if (flightTime!.Contains(":"))
  13789. {
  13790. flightTime = flightTime.Replace(":", "小时");
  13791. flightTime += "分钟";
  13792. }
  13793. if (flightTime.Contains("H"))
  13794. {
  13795. flightTime = flightTime.Replace("H", "小时");
  13796. }
  13797. if (flightTime.Contains("M"))
  13798. {
  13799. flightTime = flightTime.Replace("M", "分钟");
  13800. }
  13801. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13802. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13803. {
  13804. flightTime = flightDataTime.Hour > 0
  13805. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13806. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13807. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13808. }
  13809. //航班号
  13810. string flightcode = item["Fliagtcode"].ToString();
  13811. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13812. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13813. if (aircompany == null)
  13814. {
  13815. aircompany = new Res_AirCompany
  13816. {
  13817. CnName = hsEmpty,
  13818. EnName = hsEmpty,
  13819. ShortCode = hsEmpty,
  13820. };
  13821. }
  13822. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13823. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13824. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13825. if (isTrade)
  13826. {
  13827. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13828. }
  13829. else
  13830. {
  13831. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13832. }
  13833. }
  13834. chiarr.Add(new Grp_ApprovalTravelDetails
  13835. {
  13836. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13837. CreateTime = DateTime.Now,
  13838. CreateUserId = dto.Userid,
  13839. ParentId = 0,
  13840. Details = trip
  13841. });
  13842. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13843. var last = threeCodeStr.Last();
  13844. foreach (var item in threeCodeStr)
  13845. {
  13846. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13847. if (item.Equals(last))
  13848. {
  13849. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13850. }
  13851. }
  13852. cityPath = cityPath.Trim('-');
  13853. }
  13854. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13855. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13856. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13857. appro.Diid = dto.Diid;
  13858. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13859. appro.Id = thisId;
  13860. appro.CreateUserId = dto.Userid;
  13861. appro.CreateTime = DateTime.Now;
  13862. foreach (var item in gwinfo)
  13863. {
  13864. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13865. chi.Details = "拜访" + item.Client;
  13866. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13867. {
  13868. chi.Details += "," + item.ReqSample;
  13869. }
  13870. chi.ParentId = thisId;
  13871. chi.Time = item.Time;
  13872. chiarr.Add(chi);
  13873. }
  13874. if (chiarr.Count < 5)
  13875. {
  13876. for (int j = chiarr.Count; j < 5; j++)
  13877. {
  13878. chiarr.Add(new
  13879. Grp_ApprovalTravelDetails());
  13880. }
  13881. }
  13882. resultArr.Add(new
  13883. {
  13884. appro.Id,
  13885. appro.Date,
  13886. appro.Diid,
  13887. chiList = chiarr.Select(x1 => new
  13888. {
  13889. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13890. x1.Details,
  13891. x1.ParentId,
  13892. x1.Id
  13893. })
  13894. });
  13895. }
  13896. _sqlSugar.CommitTran();
  13897. jw = JsonView(true, "生成成功!", resultArr);
  13898. }
  13899. catch (Exception ex)
  13900. {
  13901. jw.Code = 400;
  13902. jw.Msg = "生成失败!" + ex.Message;
  13903. }
  13904. return Ok(jw);
  13905. }
  13906. /// <summary>
  13907. /// 报批行程word导出
  13908. /// </summary>
  13909. /// <param name="dto"></param>
  13910. /// <returns></returns>
  13911. [HttpPost]
  13912. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13913. {
  13914. var jw = JsonView(false);
  13915. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13916. if (group == null)
  13917. {
  13918. jw.Msg = "暂无该团组!";
  13919. return Ok(jw);
  13920. }
  13921. //模板路径
  13922. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13923. //载入模板
  13924. Document doc = new Document(tempPath);
  13925. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13926. //获取所填表格的序数
  13927. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13928. Aspose.Words.Tables.Row titleRowClone = null;
  13929. Aspose.Words.Tables.Row CenterRowClone = null;
  13930. int index = 0;
  13931. int indexChi = 0;
  13932. int SetIndex = 0;
  13933. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13934. //获取数据,放到datatable
  13935. foreach (var item in ApprovalTravelArr)
  13936. {
  13937. if (index > 0)
  13938. {
  13939. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13940. tableOne.AppendChild(titleRowClone);
  13941. }
  13942. var textTime = item.Date;
  13943. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13944. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13945. SetIndex++;
  13946. if (ChiRep.Count > 0)
  13947. {
  13948. foreach (var itemChi in ChiRep)
  13949. {
  13950. var txtTime = itemChi.Time;
  13951. var txtDetail = itemChi.Details;
  13952. if (indexChi > 0)
  13953. {
  13954. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13955. tableOne.AppendChild(CenterRowClone);
  13956. }
  13957. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13958. {
  13959. SetCells(tableOne, doc, SetIndex, 0, "");
  13960. SetCells(tableOne, doc, SetIndex, 1, "");
  13961. indexChi++;
  13962. SetIndex++;
  13963. break;
  13964. }
  13965. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13966. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13967. indexChi++;
  13968. SetIndex++;
  13969. }
  13970. }
  13971. else
  13972. {
  13973. if (indexChi > 0)
  13974. {
  13975. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13976. tableOne.AppendChild(CenterRowClone);
  13977. }
  13978. SetCells(tableOne, doc, SetIndex, 0, "");
  13979. SetCells(tableOne, doc, SetIndex, 1, "");
  13980. indexChi++;
  13981. SetIndex++;
  13982. }
  13983. index++;
  13984. }
  13985. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13986. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13987. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13988. jw.Code = 200;
  13989. jw.Msg = "";
  13990. return Ok(jw);
  13991. }
  13992. private string intToString(int numberVal)
  13993. {
  13994. string numberval = numberVal.ToString();
  13995. Dictionary<char, string> Number = new Dictionary<char, string>();
  13996. Number.Add('1', "一");
  13997. Number.Add('2', "二");
  13998. Number.Add('3', "三");
  13999. Number.Add('4', "四");
  14000. Number.Add('5', "五");
  14001. Number.Add('6', "六");
  14002. Number.Add('7', "七");
  14003. Number.Add('8', "八");
  14004. Number.Add('9', "九");
  14005. string stringNumberVal = string.Empty;
  14006. for (int i = 0; i < numberval.Length; i++)
  14007. {
  14008. if (i == 0)
  14009. {
  14010. stringNumberVal += Number[numberval[i]];
  14011. }
  14012. else if (i >= 1)
  14013. {
  14014. if (numberval[i] == '0')
  14015. {
  14016. stringNumberVal = "十";
  14017. }
  14018. else
  14019. {
  14020. stringNumberVal += "十" + Number[numberval[i]];
  14021. }
  14022. }
  14023. }
  14024. return stringNumberVal;
  14025. }
  14026. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  14027. {
  14028. //获取table中的某个单元格,从0开始
  14029. Cell lshCell = table.Rows[rows].Cells[cells];
  14030. //将单元格中段落移除
  14031. foreach (Node item in lshCell.Paragraphs)
  14032. {
  14033. lshCell.Paragraphs.Remove(item);
  14034. }
  14035. if (val.Contains("\r\n"))
  14036. {
  14037. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  14038. foreach (var item in spArr)
  14039. {
  14040. //新建一个段落
  14041. Paragraph p = new Paragraph(doc);
  14042. var r = new Run(doc, item);
  14043. //把设置的值赋给之前新建的段落
  14044. p.AppendChild(r);
  14045. //将此段落加到单元格内
  14046. lshCell.AppendChild(p);
  14047. }
  14048. }
  14049. else
  14050. {
  14051. //新建一个段落
  14052. Paragraph p = new Paragraph(doc);
  14053. var r = new Run(doc, val);
  14054. //把设置的值赋给之前新建的段落
  14055. p.AppendChild(r);
  14056. //将此段落加到单元格内
  14057. lshCell.AppendChild(p);
  14058. }
  14059. }
  14060. [HttpPost]
  14061. public async Task<IActionResult> ServerHttp(string paramStr)
  14062. {
  14063. paramStr = paramStr.TrimEnd('\'');
  14064. paramStr = paramStr.TrimStart('\'');
  14065. JsonView jw = JsonView(false);
  14066. JObject param = JObject.Parse(paramStr);
  14067. if (!param.ContainsKey("url"))
  14068. {
  14069. jw.Msg = "url null";
  14070. return Ok(jw);
  14071. }
  14072. string url = param["url"]!.ToString();
  14073. var methon = "get";
  14074. Dictionary<string, string> headValues = null;
  14075. string bodyStr = string.Empty;
  14076. if (param.ContainsKey("methon"))
  14077. {
  14078. methon = param["methon"]!.ToString().ToLower();
  14079. }
  14080. if (param.ContainsKey("header"))
  14081. {
  14082. var header = param["header"]!.ToString();
  14083. JObject headerJobject = JObject.Parse(header);
  14084. headValues = new Dictionary<string, string>();
  14085. foreach (JProperty item in headerJobject.Properties())
  14086. {
  14087. var value = item.Value.ToString();
  14088. var head = item.Path;
  14089. headValues.Add(head, value);
  14090. }
  14091. }
  14092. HttpClient client = new HttpClient();
  14093. string responseString = string.Empty;
  14094. StringContent content = null;
  14095. if (headValues != null)
  14096. {
  14097. foreach (var item in headValues.Keys)
  14098. {
  14099. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  14100. {
  14101. if (param.ContainsKey("body"))
  14102. {
  14103. bodyStr = param["body"]!.ToString();
  14104. }
  14105. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  14106. }
  14107. else
  14108. {
  14109. client.DefaultRequestHeaders.Add(item, headValues[item]);
  14110. }
  14111. }
  14112. }
  14113. try
  14114. {
  14115. if (methon == "get")
  14116. {
  14117. responseString = await client.GetStringAsync(url);
  14118. }
  14119. else if (methon == "post")
  14120. {
  14121. var request = new HttpRequestMessage(HttpMethod.Post, url)
  14122. {
  14123. Content = content
  14124. };
  14125. var response = await client.SendAsync(request);
  14126. try
  14127. {
  14128. Stream responseStream = await response.Content.ReadAsStreamAsync();
  14129. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  14130. {
  14131. using (StreamReader reader = new StreamReader(gzipStream))
  14132. {
  14133. responseString = await reader.ReadToEndAsync();
  14134. }
  14135. }
  14136. }
  14137. catch (Exception)
  14138. {
  14139. responseString = await response.Content.ReadAsStringAsync();
  14140. }
  14141. }
  14142. else
  14143. {
  14144. responseString = "methon error";
  14145. }
  14146. jw = JsonView(true, "success", responseString);
  14147. }
  14148. catch (Exception ex)
  14149. {
  14150. jw.Msg = "error " + ex.Message;
  14151. jw.Data = ex.StackTrace;
  14152. }
  14153. finally
  14154. {
  14155. client.Dispose();
  14156. }
  14157. return Ok(jw);
  14158. }
  14159. #endregion
  14160. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  14161. /// <summary>
  14162. /// 团组接待意见调查 - 信息管理
  14163. /// 基础数据(团组)
  14164. /// </summary>
  14165. /// <param name="dto"></param>
  14166. /// <returns></returns>
  14167. [HttpGet]
  14168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14169. public async Task<IActionResult> OpinionaireInit()
  14170. {
  14171. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  14172. .Select(x => new
  14173. {
  14174. x.Id,
  14175. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  14176. })
  14177. .OrderByDescending(x => x.Id)
  14178. .ToListAsync();
  14179. return Ok(JsonView(groupData, groupData.Count));
  14180. }
  14181. /// <summary>
  14182. /// 团组接待意见调查 - 信息管理
  14183. /// 列表
  14184. /// </summary>
  14185. /// <param name="groupId"></param>
  14186. /// <returns></returns>
  14187. [HttpGet("{groupId}")]
  14188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14189. public async Task<IActionResult> OpinionaireManageList(int groupId)
  14190. {
  14191. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14192. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  14193. .Select(x => new
  14194. {
  14195. x.Id,
  14196. x.TourGuideName,
  14197. x.CityName,
  14198. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  14199. x.CreateTime
  14200. })
  14201. .OrderBy(x => x.Id)
  14202. .ToListAsync();
  14203. return Ok(JsonView(data));
  14204. }
  14205. /// <summary>
  14206. /// 团组接待意见调查 - 信息管理
  14207. /// 保存
  14208. /// </summary>
  14209. /// <param name="dto"></param>
  14210. /// <returns></returns>
  14211. [HttpPost]
  14212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14213. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  14214. {
  14215. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  14216. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14217. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14218. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  14219. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  14220. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  14221. _opinionaireRep.BeginTran();
  14222. if (addData != null && addData.Count > 0)
  14223. {
  14224. foreach (var item in addData)
  14225. {
  14226. item.CreateUserId = currUserInfo.UserId;
  14227. item.DiId = dto.DiId;
  14228. }
  14229. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  14230. }
  14231. if (updData != null && updData.Count > 0)
  14232. {
  14233. var upd = await _opinionaireRep._sqlSugar
  14234. .Updateable(updData)
  14235. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  14236. .WhereColumns(x => new { x.Id })
  14237. .ExecuteCommandAsync();
  14238. }
  14239. _opinionaireRep.CommitTran();
  14240. return Ok(JsonView("操作成功!"));
  14241. }
  14242. /// <summary>
  14243. /// 团组接待意见调查 - 信息管理
  14244. /// 删除
  14245. /// </summary>
  14246. /// <param name="id"></param>
  14247. /// <returns></returns>
  14248. [HttpDelete("{id}")]
  14249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14250. public async Task<IActionResult> OpinionaireManageDel(int id)
  14251. {
  14252. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  14253. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  14254. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  14255. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  14256. if (!del) return Ok(JsonView("操作失败!"));
  14257. return Ok(JsonView("操作成功!"));
  14258. }
  14259. /// <summary>
  14260. /// 团组接待意见调查 - 用户
  14261. /// 列表
  14262. /// </summary>
  14263. /// <param name="id"></param>
  14264. /// <returns></returns>
  14265. [HttpGet("{diId}")]
  14266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14267. public async Task<IActionResult> OpinionaireUserList(int diId)
  14268. {
  14269. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  14270. var sql = string.Format(@"
  14271. SELECT
  14272. o.Id,
  14273. o.DiId,
  14274. di.TeamName AS 'GroupName',
  14275. di.VisitPNumber AS 'PeopleNumber',
  14276. di.ClientName AS 'LeadGroup',
  14277. di.VisitCountry AS 'Travel',
  14278. di.VisitDays AS 'Days',
  14279. o.CityName,
  14280. o.TourGuideName,
  14281. o.Catering,
  14282. o.CateringReason,
  14283. o.Stay,
  14284. o.StayReason,
  14285. o.[Route],
  14286. o.RouteReason,
  14287. o.OfficialActivity,
  14288. o.OfficialActivityReason,
  14289. o.TourGuide,
  14290. o.TourGuideReason,
  14291. o.[Translate],
  14292. o.TranslateReason,
  14293. o.Trip,
  14294. o.TripReason,
  14295. o.ESFileName,
  14296. o.SignatureDate,
  14297. o.Remark
  14298. FROM
  14299. Grp_Opinionaire o
  14300. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  14301. WHERE
  14302. o.IsDel = 0
  14303. AND o.DiId = {0}
  14304. ORDER BY
  14305. o.Id ASC", diId);
  14306. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  14307. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  14308. return Ok(JsonView(data));
  14309. }
  14310. /// <summary>
  14311. /// 团组接待意见调查 - 用户
  14312. /// 保存
  14313. /// </summary>
  14314. /// <param name="id"></param>
  14315. /// <returns></returns>
  14316. [HttpPost]
  14317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14318. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  14319. {
  14320. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  14321. foreach (var item in dto)
  14322. {
  14323. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  14324. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  14325. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  14326. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  14327. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  14328. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  14329. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  14330. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  14331. }
  14332. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  14333. if (!Directory.Exists(filePathBase))
  14334. {
  14335. Directory.CreateDirectory(filePathBase);
  14336. }
  14337. #region 上传文件
  14338. var filePaths = new List<string>();
  14339. foreach (var item in dto)
  14340. {
  14341. var file = item.File;
  14342. // 将文件保存到指定位置
  14343. var filePath = Path.Combine(filePathBase, file.FileName);
  14344. using (var stream = new FileStream(filePath, FileMode.Create))
  14345. {
  14346. await file.CopyToAsync(stream);
  14347. }
  14348. //验证文件是否上传成功
  14349. if (!System.IO.File.Exists(filePath))
  14350. {
  14351. foreach (var filePathStr in filePaths)
  14352. {
  14353. System.IO.File.Delete(filePathStr);
  14354. }
  14355. return Ok(JsonView(false, "文件上传失败!"));
  14356. }
  14357. item.ESFileName = file.FileName;
  14358. }
  14359. #endregion
  14360. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  14361. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  14362. .UpdateColumns(x => new
  14363. {
  14364. x.Catering,
  14365. x.CateringReason,
  14366. x.Stay,
  14367. x.StayReason,
  14368. x.Route,
  14369. x.RouteReason,
  14370. x.OfficialActivity,
  14371. x.OfficialActivityReason,
  14372. x.TourGuide,
  14373. x.TourGuideReason,
  14374. x.Translate,
  14375. x.TranslateReason,
  14376. x.Trip,
  14377. x.TripReason,
  14378. x.ESFileName,
  14379. x.SignatureDate,
  14380. x.Remark
  14381. })
  14382. .WhereColumns(x => new { x.Id })
  14383. .ExecuteCommandAsync();
  14384. if (upd < 1)
  14385. {
  14386. foreach (var filePathStr in filePaths)
  14387. {
  14388. System.IO.File.Delete(filePathStr);
  14389. }
  14390. return Ok(JsonView(false));
  14391. }
  14392. return Ok(JsonView(true));
  14393. }
  14394. #endregion
  14395. // /// <summary>
  14396. // ///
  14397. // /// </summary>
  14398. // /// <param name="_dto"></param>
  14399. // /// <returns></returns>
  14400. // [HttpPost]
  14401. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14402. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14403. // {
  14404. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14405. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  14406. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  14407. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14408. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  14409. // dic_psg.Add("客人", 974);
  14410. // dic_psg.Add("司机", 975);
  14411. // dic_psg.Add("导游", 976);
  14412. // dic_psg.Add("公司内部人员", 977);
  14413. // dic_psg.Add("司机/导游/公司内部人员", 978);
  14414. // foreach (var item in list_visa)
  14415. // {
  14416. // Grp_VisaInfo temp = new Grp_VisaInfo();
  14417. // temp.Id = item.Id;
  14418. // temp.DIId = item.DIId;
  14419. // temp.VisaClient = item.VisaClient;
  14420. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  14421. // temp.VisaCurrency = item.VisaCurrency;
  14422. // temp.IsThird = item.IsThird;
  14423. // if (dic_psg.ContainsKey(item.PassengerType))
  14424. // {
  14425. // temp.PassengerType = dic_psg[item.PassengerType];
  14426. // }
  14427. // else {
  14428. // temp.PassengerType = -1;
  14429. // }
  14430. // temp.VisaNumber = item.VisaNumber;
  14431. // temp.VisaFreeNumber = item.VisaFreeNumber;
  14432. // temp.CreateUserId = item.Operators;
  14433. // DateTime dt_ct;
  14434. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  14435. // if (b_ct)
  14436. // {
  14437. // temp.CreateTime = dt_ct;
  14438. // }
  14439. // else
  14440. // {
  14441. // temp.CreateTime = DateTime.Now;
  14442. // }
  14443. // temp.DeleteTime = "";
  14444. // temp.DeleteUserId = 0;
  14445. // temp.Remark = item.Remark;
  14446. // if (string.IsNullOrEmpty(temp.Remark)) {
  14447. // temp.Remark = "";
  14448. // }
  14449. // temp.IsDel = item.IsDel;
  14450. // temp.VisaDescription = item.VisaAttachment;
  14451. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  14452. //([Id]
  14453. // ,[DIId]
  14454. // ,[VisaClient]
  14455. // ,[VisaPrice]
  14456. // ,[VisaCurrency]
  14457. // ,[IsThird]
  14458. // ,[PassengerType]
  14459. // ,[VisaNumber]
  14460. // ,[VisaFreeNumber]
  14461. // ,[CreateUserId]
  14462. // ,[CreateTime]
  14463. // ,[DeleteTime]
  14464. // ,[DeleteUserId]
  14465. // ,[Remark]
  14466. // ,[IsDel]
  14467. // ,[visaDescription])
  14468. // VALUES
  14469. // ({0},{1},'{2}',{3},{4}
  14470. //,{5},{6},{7},{8},{9}
  14471. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  14472. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  14473. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  14474. //);
  14475. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  14476. // }
  14477. // return Ok(JsonView(true, "操作成功!"));
  14478. // }
  14479. /// <summary>
  14480. /// 123132123
  14481. /// </summary>
  14482. /// <param name="_dto"></param>
  14483. /// <returns></returns>
  14484. [HttpPost]
  14485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14486. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14487. {
  14488. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14489. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  14490. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  14491. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14492. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  14493. dicDetail.Add(789, 1034);
  14494. dicDetail.Add(790, 1035);
  14495. dicDetail.Add(791, 1036);
  14496. dicDetail.Add(792, 1037);
  14497. dicDetail.Add(793, 1038);
  14498. dicDetail.Add(794, 1039);
  14499. dicDetail.Add(795, 1040);
  14500. dicDetail.Add(796, 1041);
  14501. dicDetail.Add(797, 1042);
  14502. dicDetail.Add(798, 1043);
  14503. dicDetail.Add(801, 1044);
  14504. dicDetail.Add(802, 1045);
  14505. dicDetail.Add(803, 1046);
  14506. Dictionary<int, int> dic = new Dictionary<int, int>();
  14507. dic.Add(806, 1027);
  14508. dic.Add(807, 1028);
  14509. dic.Add(808, 1029);
  14510. dic.Add(809, 1030);
  14511. dic.Add(810, 1031);
  14512. dic.Add(811, 1032);
  14513. dic.Add(812, 1033);
  14514. foreach (var item in list_visa)
  14515. {
  14516. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  14517. temp.Coefficient = item.coefficient;
  14518. DateTime dtCrt;
  14519. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  14520. if (b1)
  14521. {
  14522. temp.CreateTime = dtCrt;
  14523. }
  14524. else
  14525. {
  14526. temp.CreateTime = DateTime.Now;
  14527. }
  14528. temp.CreateUserId = item.Operators;
  14529. temp.DeleteTime = "";
  14530. temp.DeleteUserId = 0;
  14531. temp.DiId = int.Parse(item.DIID);
  14532. temp.FilePath = item.FilePath;
  14533. temp.IsDel = item.IsDel;
  14534. temp.Price = item.Price;
  14535. temp.PriceCount = 1;
  14536. temp.PriceCurrency = item.Currency;
  14537. int detailId = 0;
  14538. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  14539. {
  14540. detailId = dicDetail[item.PriceTypeDetail];
  14541. }
  14542. temp.PriceDetailType = detailId;
  14543. temp.PriceDt = DateTime.Now;
  14544. temp.PriceName = item.PriceName;
  14545. temp.PriceSum = item.Price;
  14546. int tid = 0;
  14547. if (dic.ContainsKey(item.PriceType))
  14548. {
  14549. tid = dic[item.PriceType];
  14550. }
  14551. temp.PriceType = tid;
  14552. temp.Remark = item.Remark;
  14553. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  14554. }
  14555. return Ok(JsonView(true, "操作成功!"));
  14556. }
  14557. }
  14558. }