GroupsController.cs 711 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using Microsoft.AspNetCore.SignalR;
  6. using MySqlX.XDevAPI.Relational;
  7. using NPOI.HSSF.UserModel;
  8. using NPOI.SS.Format;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.File;
  14. using OASystem.API.OAMethodLib.Hub.HubClients;
  15. using OASystem.API.OAMethodLib.Hub.Hubs;
  16. using OASystem.API.OAMethodLib.JuHeAPI;
  17. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  18. using OASystem.Domain.Dtos.CRM;
  19. using OASystem.Domain.Dtos.FileDto;
  20. using OASystem.Domain.Dtos.Financial;
  21. using OASystem.Domain.Dtos.Groups;
  22. using OASystem.Domain.Entities.Customer;
  23. using OASystem.Domain.Entities.Financial;
  24. using OASystem.Domain.Entities.Groups;
  25. using OASystem.Domain.ViewModels.Groups;
  26. using OASystem.Infrastructure.Repositories.Financial;
  27. using OASystem.Infrastructure.Repositories.Groups;
  28. using Quartz.Util;
  29. using SqlSugar;
  30. using SqlSugar.Extensions;
  31. using System.Collections;
  32. using System.Data;
  33. using System.Diagnostics;
  34. using System.Globalization;
  35. using System.IO;
  36. using System.Reflection.PortableExecutable;
  37. using Ubiety.Dns.Core;
  38. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  39. using Bookmark = Aspose.Words.Bookmark;
  40. using Cell = Aspose.Words.Tables.Cell;
  41. using Table = Aspose.Words.Tables.Table;
  42. namespace OASystem.API.Controllers
  43. {
  44. /// <summary>
  45. /// 团组相关
  46. /// </summary>
  47. //[Authorize]
  48. [Route("api/[controller]/[action]")]
  49. public class GroupsController : ControllerBase
  50. {
  51. private readonly ILogger<GroupsController> _logger;
  52. private readonly GrpScheduleRepository _grpScheduleRep;
  53. private readonly IMapper _mapper;
  54. private readonly DelegationInfoRepository _groupRepository;
  55. private readonly TaskAssignmentRepository _taskAssignmentRep;
  56. private readonly AirTicketResRepository _airTicketResRep;
  57. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  58. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  59. private readonly DelegationEnDataRepository _delegationEnDataRep;
  60. private readonly DelegationVisaRepository _delegationVisaRep;
  61. private readonly VisaPriceRepository _visaPriceRep;
  62. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  63. private readonly HotelPriceRepository _hotelPriceRep;
  64. private readonly CustomersRepository _customersRep;
  65. private readonly MessageRepository _message;
  66. private readonly SqlSugarClient _sqlSugar;
  67. private readonly TourClientListRepository _tourClientListRep;
  68. private readonly TeamRateRepository _teamRateRep;
  69. #region 成本相关
  70. private readonly CheckBoxsRepository _checkBoxs;
  71. private readonly GroupCostRepository _GroupCostRepository;
  72. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  73. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  74. #endregion
  75. private readonly SetDataRepository _setDataRep;
  76. private string url;
  77. private string path;
  78. private readonly EnterExitCostRepository _enterExitCostRep;
  79. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  80. private readonly UsersRepository _usersRep;
  81. private readonly IJuHeApiService _juHeApi;
  82. private readonly InvertedListRepository _invertedListRep;
  83. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  84. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  85. private readonly ThreeCodeRepository _threeCodeRepository;
  86. private readonly HotelInquiryRepository _hotelInquiryRep;
  87. private readonly FeeAuditRepository _feeAuditRep;
  88. private readonly VisaCommissionRepository _visaCommissionRep;
  89. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  90. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  91. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  92. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  93. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  94. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  95. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  96. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  97. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  98. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep)
  99. {
  100. _logger = logger;
  101. _mapper = mapper;
  102. _grpScheduleRep = grpScheduleRep;
  103. _groupRepository = groupRepository;
  104. _taskAssignmentRep = taskAssignmentRep;
  105. _airTicketResRep = airTicketResRep;
  106. _sqlSugar = sqlSugar;
  107. url = AppSettingsHelper.Get("ExcelBaseUrl");
  108. path = AppSettingsHelper.Get("ExcelBasePath");
  109. if (!System.IO.Directory.Exists(path))
  110. {
  111. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  112. }
  113. _decreasePaymentsRep = decreasePaymentsRep;
  114. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  115. _delegationEnDataRep = delegationEnDataRep;
  116. _enterExitCostRep = enterExitCostRep;
  117. _delegationVisaRep = delegationVisaRep;
  118. _message = message;
  119. _visaPriceRep = visaPriceRep;
  120. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  121. _checkBoxs = checkBoxs;
  122. _GroupCostRepository = GroupCostRepository;
  123. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  124. _GroupCostParameterRepository = GroupCostParameterRepository;
  125. _hotelPriceRep = hotelPriceRep;
  126. _customersRep = customersRep;
  127. _setDataRep = setDataRep;
  128. _tourClientListRep = tourClientListRep;
  129. _teamRateRep = teamRateRep;
  130. _hubContext = hubContext;
  131. _usersRep = usersRep;
  132. _juHeApi = juHeApi;
  133. _invertedListRep = invertedListRep;
  134. _visaFeeInfoRep = visaFeeInfoRep;
  135. _ticketBlackCodeRep = ticketBlackCodeRep;
  136. _hotelInquiryRep = hotelInquiryRep;
  137. _threeCodeRepository = threeCodeRepository;
  138. _feeAuditRep = feeAuditRep;
  139. _visaCommissionRep = visaCommissionRep;
  140. _ffrRep = ffrRep;
  141. }
  142. #region 流程管控
  143. /// <summary>
  144. /// 获取团组流程管控信息
  145. /// </summary>
  146. /// <param name="paras">参数Json字符串</param>
  147. /// <returns></returns>
  148. [HttpPost]
  149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  150. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  151. {
  152. if (string.IsNullOrEmpty(_jsonDto.Paras))
  153. {
  154. return Ok(JsonView(false, "参数为空"));
  155. }
  156. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  157. if (_ScheduleDto != null)
  158. {
  159. if (_ScheduleDto.SearchType == 2)//获取列表
  160. {
  161. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  162. return Ok(JsonView(_grpScheduleViewList));
  163. }
  164. else//获取对象
  165. {
  166. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  167. if (_grpScheduleView != null)
  168. {
  169. return Ok(JsonView(_grpScheduleView));
  170. }
  171. }
  172. }
  173. else
  174. {
  175. return Ok(JsonView(false, "参数反序列化失败"));
  176. }
  177. return Ok(JsonView(false, "暂无数据!"));
  178. }
  179. /// <summary>
  180. /// 修改团组流程管控详细表数据
  181. /// </summary>
  182. /// <param name="paras"></param>
  183. /// <returns></returns>
  184. [HttpPost]
  185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  186. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  187. {
  188. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  189. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  190. .SetColumns(it => it.Duty == _detail.Duty)
  191. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  192. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  193. .SetColumns(it => it.JobContent == _detail.JobContent)
  194. .SetColumns(it => it.Remark == _detail.Remark)
  195. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  196. .Where(s => s.Id == dto.Id)
  197. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  198. .ExecuteCommandAsync();
  199. if (result > 0)
  200. {
  201. return Ok(JsonView(true, "保存成功!"));
  202. }
  203. return Ok(JsonView(false, "保存失败!"));
  204. }
  205. /// <summary>
  206. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  207. /// </summary>
  208. /// <param name="dto"></param>
  209. /// <returns></returns>
  210. [HttpPost]
  211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  212. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  213. {
  214. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  215. _detail.IsDel = 1;
  216. _detail.DeleteUserId = dto.Duty;
  217. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  218. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  219. .SetColumns(it => it.IsDel == _detail.IsDel)
  220. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  221. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  222. .Where(it => it.Id == dto.Id)
  223. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  224. //.WhereColumns(s => s.Id == dto.Id)
  225. .ExecuteCommandAsync();
  226. if (result > 0)
  227. {
  228. return Ok(JsonView(true, "删除成功!"));
  229. }
  230. return Ok(JsonView(false, "删除失败!"));
  231. }
  232. /// <summary>
  233. /// 增加团组流程管控详细表数据
  234. /// </summary>
  235. /// <param name="dto"></param>
  236. /// <returns></returns>
  237. [HttpPost]
  238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  239. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  240. {
  241. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  242. if (DateTime.Now < _detail.ExpectBeginDt)
  243. {
  244. _detail.StepStatus = 0;
  245. }
  246. else
  247. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  248. _detail.StepStatus = 1;
  249. }
  250. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  251. if (result > 0)
  252. {
  253. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  254. return Ok(JsonView(true, "添加成功!", _result));
  255. }
  256. return Ok(JsonView(false, "添加失败!"));
  257. }
  258. #endregion
  259. #region 团组基本信息
  260. /// <summary>
  261. /// 接团信息列表
  262. /// </summary>
  263. /// <param name="dto">团组列表请求dto</param>
  264. /// <returns></returns>
  265. [HttpPost]
  266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  267. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  268. {
  269. var groupData = await _groupRepository.GetGroupList(dto);
  270. if (groupData.Code != 0)
  271. {
  272. return Ok(JsonView(false, groupData.Msg));
  273. }
  274. return Ok(JsonView(groupData.Data));
  275. }
  276. /// <summary>
  277. /// 分页查询团组列表
  278. /// </summary>
  279. /// <param name="dto"></param>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  284. {
  285. var watch = new Stopwatch();
  286. watch.Start();
  287. RefAsync<int> total = 0;
  288. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  289. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  290. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  291. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  292. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  293. .Distinct()
  294. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  295. watch.Stop();
  296. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  297. }
  298. /// <summary>
  299. /// 接团信息列表 Page
  300. /// </summary>
  301. /// <param name="dto">团组列表请求dto</param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  305. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  306. {
  307. #region 参数验证
  308. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  309. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  310. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  311. #region 页面操作权限验证
  312. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  313. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  314. #endregion
  315. #endregion
  316. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  317. {
  318. string sqlWhere = string.Empty;
  319. if (dto.IsSure == 0) //未完成
  320. {
  321. sqlWhere += string.Format(@" And IsSure = 0");
  322. }
  323. else if (dto.IsSure == 1) //已完成
  324. {
  325. sqlWhere += string.Format(@" And IsSure = 1");
  326. }
  327. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  328. {
  329. string tj = dto.SearchCriteria;
  330. 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}%')",
  331. tj, tj, tj, tj, tj);
  332. }
  333. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  334. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  335. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  336. JietuanOperator,IsSure,CreateTime,IsBid
  337. From (
  338. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  339. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  340. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  341. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  342. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  343. From Grp_DelegationInfo gdi
  344. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  345. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  346. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  347. Where gdi.IsDel = 0 {0}
  348. ) temp", sqlWhere);
  349. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  350. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  351. #region 处理所属部门
  352. /*
  353. * 1.sq 和 gyy 等显示 市场部
  354. * 2.王鸽和主管及张总还有管理员号统一国交部
  355. * 2-1. 4 管理员 ,21 张海麟
  356. */
  357. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  358. List<int> userIds1 = new List<int>() { 4, 21 };
  359. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  360. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  361. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  362. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  363. .ToList();
  364. foreach (var item in _DelegationList)
  365. {
  366. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  367. }
  368. #endregion
  369. var _view = new
  370. {
  371. PageFuncAuth = pageFunAuthView,
  372. Data = _DelegationList
  373. };
  374. return Ok(JsonView(true, "查询成功!", _view, total));
  375. }
  376. else
  377. {
  378. return Ok(JsonView(false, "查询失败"));
  379. }
  380. }
  381. /// <summary>
  382. /// 团组列表
  383. /// </summary>
  384. /// <returns></returns>
  385. [HttpPost]
  386. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  387. {
  388. #region 参数验证
  389. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  390. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  391. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  392. #region 页面操作权限验证
  393. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  394. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  395. #endregion
  396. #endregion
  397. if (dto.PortType != 1 && dto.PortType != 2)
  398. {
  399. return Ok(JsonView(false, "查询失败!"));
  400. }
  401. string orderbyStr = "order by gdi.CreateTime Desc";
  402. string sqlWhere = string.Empty;
  403. if (dto.IsSure == 0) //未完成
  404. {
  405. sqlWhere += string.Format(@" And IsSure = 0");
  406. }
  407. else if (dto.IsSure == 1) //已完成
  408. {
  409. sqlWhere += string.Format(@" And IsSure = 1");
  410. }
  411. //团组类型
  412. if (dto.TeamDid > 0)
  413. {
  414. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  415. }
  416. //团组名称
  417. if (!string.IsNullOrEmpty(dto.TeamName))
  418. {
  419. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  420. }
  421. //客户名称
  422. if (!string.IsNullOrEmpty(dto.ClientName))
  423. {
  424. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  425. }
  426. //客户单位
  427. if (!string.IsNullOrEmpty(dto.ClientUnit))
  428. {
  429. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  430. }
  431. //出访时间
  432. if (!string.IsNullOrEmpty(dto.visitDataTime))
  433. {
  434. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  435. orderbyStr = "order by gdi.VisitDate";
  436. }
  437. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  438. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  439. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  440. JietuanOperator,IsSure,CreateTime
  441. From (
  442. Select row_number() over({0}) as Row_Number,
  443. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  444. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  445. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  446. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  447. From Grp_DelegationInfo gdi
  448. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  449. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  450. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  451. Where gdi.IsDel = 0 {1}
  452. ) temp ", orderbyStr, sqlWhere);
  453. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  454. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  455. #region 处理所属部门
  456. /*
  457. * 1.sq 和 gyy 等显示 市场部
  458. * 2.王鸽和主管及张总还有管理员号统一国交部
  459. * 2-1. 4 管理员 ,21 张海麟
  460. */
  461. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  462. List<int> userIds1 = new List<int>() { 4, 21 };
  463. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  464. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  465. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  466. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  467. .ToList();
  468. foreach (var item in _DelegationList)
  469. {
  470. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  471. }
  472. #endregion
  473. var _view = new
  474. {
  475. PageFuncAuth = pageFunAuthView,
  476. Data = _DelegationList
  477. };
  478. return Ok(JsonView(true, "查询成功!", _view, total));
  479. }
  480. /// <summary>
  481. /// 接团信息详情
  482. /// </summary>
  483. /// <param name="dto">团组info请求dto</param>
  484. /// <returns></returns>
  485. [HttpPost]
  486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  487. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  488. {
  489. var groupData = await _groupRepository.GetGroupInfo(dto);
  490. if (groupData.Code != 0)
  491. {
  492. return Ok(JsonView(false, groupData.Msg));
  493. }
  494. return Ok(JsonView(groupData.Data));
  495. }
  496. /// <summary>
  497. /// 接团信息 编辑添加
  498. /// 基础信息数据源
  499. /// </summary>
  500. /// <param name="dto"></param>
  501. /// <returns></returns>
  502. [HttpPost]
  503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  504. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  505. {
  506. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  507. if (groupData.Code != 0)
  508. {
  509. return Ok(JsonView(false, groupData.Msg));
  510. }
  511. return Ok(JsonView(groupData.Data));
  512. }
  513. /// <summary>
  514. /// 接团信息 操作(增改)
  515. /// </summary>
  516. /// <param name="dto"></param>
  517. /// <returns></returns>
  518. [HttpPost]
  519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  520. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  521. {
  522. try
  523. {
  524. decimal ffrPrice = 0.00M;
  525. DateTime? visitDt = null;
  526. if (dto.Status == 2)
  527. {
  528. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  529. if (groupInfo != null)
  530. {
  531. ffrPrice = groupInfo.PaymentMoney;
  532. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  533. }
  534. }
  535. var groupData = await _groupRepository.GroupOperation(dto);
  536. if (groupData.Code != 0)
  537. {
  538. return Ok(JsonView(false, groupData.Msg));
  539. }
  540. int diId = 0;
  541. //添加时 默认加入团组汇率
  542. if (dto.Status == 1) //添加
  543. {
  544. diId = groupData.Data;
  545. //添加默认币种
  546. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  547. //默认分配权限
  548. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  549. //消息提示 王鸽 主管号
  550. List<int> _managerIds = new List<int>() { 22, 32 };
  551. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  552. if (userIds.Count > 0)
  553. {
  554. userIds.Add(208);
  555. //创建团组管控
  556. GroupStepForDelegation.CreateWorkStep(diId);
  557. //发送消息
  558. string groupName = dto.TeamName;
  559. string createGroupUser = string.Empty;
  560. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  561. if (userInfo != null) createGroupUser = userInfo.CnName;
  562. string title = $"系统通知";
  563. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  564. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  565. }
  566. //默认创建倒推表
  567. await _invertedListRep._Create(dto.UserId, diId);
  568. }
  569. else if (dto.Status == 2)
  570. {
  571. diId = dto.Id;
  572. }
  573. #region 团组操作默认添加/修改收款账单
  574. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  575. {
  576. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  577. .Where(x => x.IsDel == 0 &&
  578. x.Diid == diId &&
  579. x.Remark.Equals("预付款")
  580. )
  581. .WhereIF(ffrPrice > 0 , x => x.ItemSumPrice == ffrPrice)
  582. .WhereIF(visitDt != null, x=> x.CreateTime == visitDt)
  583. .FirstAsync();
  584. ffrInfo.Diid = diId;
  585. ffrInfo.PriceName = dto.ClientUnit;
  586. ffrInfo.Price = dto.PaymentMoney;
  587. ffrInfo.Count = 1;
  588. ffrInfo.Unit = $"元";
  589. ffrInfo.ItemSumPrice = dto.PaymentMoney;
  590. ffrInfo.Rate = 1.0000M;
  591. ffrInfo.Currency = 836;
  592. ffrInfo.AddingWay = 0;
  593. ffrInfo.CreateUserId = dto.UserId;
  594. ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
  595. ffrInfo.Remark = $"预付款";
  596. if (ffrInfo == null) //Add
  597. {
  598. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  599. }
  600. else //修改
  601. {
  602. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  603. .UpdateColumns(x => new
  604. {
  605. x.PriceName,
  606. x.Price,
  607. x.ItemSumPrice,
  608. x.CreateTime,
  609. x.CreateUserId
  610. })
  611. .WhereColumns(x => x.Id)
  612. .ExecuteCommandAsync();
  613. }
  614. }
  615. #endregion
  616. return Ok(JsonView(true, "操作成功!", diId));
  617. }
  618. catch (Exception ex)
  619. {
  620. Logs("[response]" + JsonConvert.SerializeObject(dto));
  621. Logs(ex.Message);
  622. return Ok(JsonView(false, ex.Message));
  623. }
  624. }
  625. /// <summary>
  626. /// 接团流程操作(增改)
  627. /// 安卓端使用 建团时添加客户名单
  628. /// </summary>
  629. /// <param name="dto"></param>
  630. /// <returns></returns>
  631. [HttpPost]
  632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  633. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  634. {
  635. try
  636. {
  637. #region 参数验证
  638. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  639. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  640. #region 页面操作权限验证
  641. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  642. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  643. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  644. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  645. #endregion
  646. #endregion
  647. _sqlSugar.BeginTran();
  648. decimal ffrPrice = 0.00M;
  649. DateTime? visitDt = null;
  650. if (dto.Status == 2)
  651. {
  652. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  653. if (groupInfo != null)
  654. {
  655. ffrPrice = groupInfo.PaymentMoney;
  656. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  657. }
  658. }
  659. var _dto = new GroupOperationDto();
  660. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  661. var groupData = await _groupRepository.GroupOperation(_dto);
  662. if (groupData.Code != 0)
  663. {
  664. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  665. }
  666. int diId = 0;
  667. //添加时 默认加入团组汇率
  668. if (dto.Status == 1) //添加
  669. {
  670. diId = groupData.Data;
  671. //添加默认币种
  672. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  673. //默认分配权限
  674. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  675. //消息提示 王鸽 主管号
  676. List<int> _managerIds = new List<int>() { 22, 32 };
  677. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  678. if (userIds.Count > 0)
  679. {
  680. userIds.Add(208);
  681. //创建团组管控
  682. GroupStepForDelegation.CreateWorkStep(diId);
  683. //发送消息
  684. string groupName = dto.TeamName;
  685. string createGroupUser = string.Empty;
  686. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  687. if (userInfo != null) createGroupUser = userInfo.CnName;
  688. string title = $"系统通知";
  689. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  690. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  691. }
  692. //默认创建倒推表
  693. await _invertedListRep._Create(dto.UserId, diId);
  694. }
  695. if (dto.Status == 2)
  696. {
  697. diId = dto.Id;
  698. if (diId == 0)
  699. {
  700. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  701. }
  702. }
  703. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  704. if (viewData.Code != 0)
  705. {
  706. _sqlSugar.RollbackTran();
  707. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  708. }
  709. #region 团组操作默认添加/修改收款账单
  710. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  711. {
  712. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  713. .Where(x => x.IsDel == 0 &&
  714. x.Diid == diId &&
  715. x.Remark.Equals("预付款")
  716. )
  717. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  718. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  719. .FirstAsync();
  720. ffrInfo.Diid = diId;
  721. ffrInfo.PriceName = dto.ClientUnit;
  722. ffrInfo.Price = dto.PaymentMoney;
  723. ffrInfo.Count = 1;
  724. ffrInfo.Unit = $"元";
  725. ffrInfo.ItemSumPrice = dto.PaymentMoney;
  726. ffrInfo.Rate = 1.0000M;
  727. ffrInfo.Currency = 836;
  728. ffrInfo.AddingWay = 0;
  729. ffrInfo.CreateUserId = dto.UserId;
  730. ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
  731. ffrInfo.Remark = $"预付款";
  732. if (ffrInfo == null) //Add
  733. {
  734. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  735. }
  736. else //修改
  737. {
  738. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  739. .UpdateColumns(x => new
  740. {
  741. x.PriceName,
  742. x.Price,
  743. x.ItemSumPrice,
  744. x.CreateTime,
  745. x.CreateUserId
  746. })
  747. .WhereColumns(x => x.Id)
  748. .ExecuteCommandAsync();
  749. }
  750. }
  751. #endregion
  752. _sqlSugar.CommitTran();
  753. return Ok(JsonView(true, "添加成功"));
  754. }
  755. catch (Exception ex)
  756. {
  757. _sqlSugar.RollbackTran();
  758. return Ok(JsonView(false, ex.Message));
  759. }
  760. }
  761. /// <summary>
  762. /// 接团信息 操作(删除)
  763. /// </summary>
  764. /// <param name="dto"></param>
  765. /// <returns></returns>
  766. [HttpPost]
  767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  768. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  769. {
  770. try
  771. {
  772. var groupData = await _groupRepository.GroupDel(dto);
  773. if (groupData.Code != 0)
  774. {
  775. return Ok(JsonView(false, groupData.Msg));
  776. }
  777. return Ok(JsonView(true));
  778. }
  779. catch (Exception ex)
  780. {
  781. Logs("[response]" + JsonConvert.SerializeObject(dto));
  782. Logs(ex.Message);
  783. return Ok(JsonView(false, ex.Message));
  784. }
  785. }
  786. /// <summary>
  787. /// 获取团组销售报价号
  788. /// 团组添加时 使用
  789. /// </summary>
  790. /// <returns></returns>
  791. [HttpPost]
  792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  793. public async Task<IActionResult> GetGroupSalesQuoteNo()
  794. {
  795. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  796. if (groupData.Code != 0)
  797. {
  798. return Ok(JsonView(false, groupData.Msg));
  799. }
  800. object salesQuoteNo = new
  801. {
  802. SalesQuoteNo = groupData.Data
  803. };
  804. return Ok(JsonView(salesQuoteNo));
  805. }
  806. /// <summary>
  807. /// 设置确认出团
  808. /// </summary>
  809. /// <param name="dto"></param>
  810. /// <returns></returns>
  811. [HttpPost]
  812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  813. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  814. {
  815. var groupData = await _groupRepository.ConfirmationGroup(dto);
  816. if (groupData.Code != 0)
  817. {
  818. return Ok(JsonView(false, groupData.Msg));
  819. }
  820. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  821. #region OA消息推送
  822. try
  823. {
  824. string groupName = groupInfo.TeamName;
  825. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  826. List<int> userIds = new List<int>();
  827. listUser.ForEach(s => userIds.Add(s.Id));
  828. string title = $"系统通知";
  829. string content = $"团组[{groupName}]已确认出团!";
  830. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  831. }
  832. catch (Exception ex)
  833. {
  834. }
  835. #endregion
  836. #region 应用推送
  837. try
  838. {
  839. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  840. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  841. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  842. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  843. {
  844. List<string> userList = new List<string>() { users.QiyeChatUserId };
  845. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  846. }
  847. }
  848. catch (Exception ex)
  849. {
  850. }
  851. #endregion
  852. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  853. return Ok(JsonView(true, "操作成功!", groupData.Data));
  854. }
  855. /// <summary>
  856. /// 获取团组名称data And 签证国别Data
  857. /// </summary>
  858. /// <param name="dto"></param>
  859. /// <returns></returns>
  860. [HttpPost]
  861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  862. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  863. {
  864. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  865. if (groupData.Code != 0)
  866. {
  867. return Ok(JsonView(false, groupData.Msg));
  868. }
  869. return Ok(JsonView(groupData.Data));
  870. }
  871. /// <summary>
  872. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  873. /// </summary>
  874. /// <returns></returns>
  875. [HttpPost]
  876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  877. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  878. {
  879. try
  880. {
  881. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  882. if (groupData.Code != 0)
  883. {
  884. return Ok(JsonView(false, groupData.Msg));
  885. }
  886. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  887. }
  888. catch (Exception ex)
  889. {
  890. return Ok(JsonView(false, "程序错误!"));
  891. throw;
  892. }
  893. }
  894. /// <summary>
  895. /// 团组清单 Excel
  896. /// </summary>
  897. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  898. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  899. /// <returns></returns>
  900. [HttpGet]
  901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  902. public async Task<IActionResult> GroupListFile([FromQuery]string beginDt, [FromQuery] string endDt)
  903. {
  904. DateTime _beginDt, _endDt;
  905. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  906. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  907. if (!beginBool && !endBool)
  908. {
  909. return Ok(JsonView(false, "开始或结束时间不正确!"));
  910. }
  911. string sql = string.Format(@"
  912. SELECT
  913. ROW_NUMBER,
  914. Id,
  915. SalesQuoteNo,
  916. TourCode,
  917. TeamTypeId,
  918. TeamType,
  919. TeamLevId,
  920. TeamLev,
  921. TeamName,
  922. ClientName,
  923. ClientUnit,
  924. VisitDate,
  925. VisitDays,
  926. VisitPNumber,
  927. JietuanOperatorId,
  928. JietuanOperator,
  929. IsSure,
  930. CreateTime,
  931. IsBid
  932. FROM
  933. (
  934. SELECT
  935. ROW_NUMBER() OVER(
  936. ORDER BY
  937. gdi.CreateTime Desc
  938. ) AS ROW_NUMBER,
  939. gdi.Id,
  940. SalesQuoteNo,
  941. TourCode,
  942. ssd.Id TeamTypeId,
  943. ssd.Name TeamType,
  944. ssd1.Id TeamLevId,
  945. ssd1.Name TeamLev,
  946. TeamName,
  947. ClientName,
  948. ClientUnit,
  949. VisitDate,
  950. VisitDays,
  951. VisitPNumber,
  952. JietuanOperator JietuanOperatorId,
  953. su.CnName JietuanOperator,
  954. IsSure,
  955. gdi.CreateTime,
  956. gdi.IsBid
  957. FROM
  958. Grp_DelegationInfo gdi
  959. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  960. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  961. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  962. WHERE
  963. gdi.IsDel = 0
  964. AND gdi.IsBid = 0
  965. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  966. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  967. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  968. #region 处理所属部门
  969. /*
  970. * 1.sq 和 gyy 等显示 市场部
  971. * 2.王鸽和主管及张总还有管理员号统一国交部
  972. * 2-1. 4 管理员 ,21 张海麟
  973. */
  974. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  975. List<int> userIds1 = new List<int>() { 4, 21 };
  976. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  977. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  978. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  979. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  980. .ToListAsync();
  981. foreach (var item in groupList)
  982. {
  983. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  984. }
  985. #endregion
  986. #region Excel
  987. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  988. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  989. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  990. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  991. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  992. //载入模板
  993. WorkbookDesigner designer = new WorkbookDesigner();
  994. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  995. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  996. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  997. dt.TableName = "GroupList";
  998. designer.SetDataSource(dt);
  999. designer.Process();
  1000. if (!Directory.Exists(savePath))
  1001. {
  1002. Directory.CreateDirectory(savePath);
  1003. }
  1004. string serverPath = $"{savePath}{fileName}";
  1005. designer.Workbook.Save(serverPath);
  1006. string rst =$"{servicePath}{ftpPath}{fileName}";
  1007. #endregion
  1008. return Ok(JsonView(true, "操作成功!", rst));
  1009. }
  1010. #endregion
  1011. #region 团组&签证
  1012. /// <summary>
  1013. /// 根据团组Id获取签证客户信息List
  1014. /// </summary>
  1015. /// <param name="dto">请求dto</param>
  1016. /// <returns></returns>
  1017. [HttpPost]
  1018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1019. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1020. {
  1021. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1022. if (groupData.Code != 0)
  1023. {
  1024. return Ok(JsonView(false, groupData.Msg));
  1025. }
  1026. return Ok(JsonView(groupData.Data));
  1027. }
  1028. /// <summary>
  1029. /// IOS获取团组签证拍照上传进度01(团组列表)
  1030. /// </summary>
  1031. /// <param name="dto">请求dto</param>
  1032. /// <returns></returns>
  1033. [HttpPost]
  1034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1035. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1036. {
  1037. if (dto == null)
  1038. {
  1039. return Ok(JsonView(false, "参数为空"));
  1040. }
  1041. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1042. return Ok(JsonView(visaList));
  1043. }
  1044. /// <summary>
  1045. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1046. /// </summary>
  1047. /// <returns></returns>
  1048. [HttpPost]
  1049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1050. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1051. {
  1052. if (dto == null)
  1053. {
  1054. return Ok(JsonView(false, "请求错误:"));
  1055. }
  1056. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1057. return Ok(JsonView(list));
  1058. }
  1059. /// <summary>
  1060. /// IOS获取团组签证拍照上传进度03(相册)
  1061. /// </summary>
  1062. /// <returns></returns>
  1063. [HttpPost]
  1064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1065. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1066. {
  1067. if (dto == null)
  1068. {
  1069. return Ok(JsonView(false, "请求错误:"));
  1070. }
  1071. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1072. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1073. list.ForEach(s => s.url = url);
  1074. return Ok(JsonView(list));
  1075. }
  1076. /// <summary>
  1077. /// IOS获取团组签证拍照上传进度04(图片上传)
  1078. /// </summary>
  1079. /// <param name="dto"></param>
  1080. /// <returns></returns>
  1081. [HttpPost]
  1082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1083. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1084. {
  1085. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1086. //if (!string.IsNullOrEmpty(result))
  1087. //{
  1088. //}
  1089. //else {
  1090. // return Ok(JsonView(false, "上传失败"));
  1091. //}
  1092. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1093. int sucNum = 0;
  1094. try
  1095. {
  1096. foreach (var item in dto.base64DataList)
  1097. {
  1098. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1099. string result = decodeBase64ToImage(item, imageName);
  1100. if (!string.IsNullOrEmpty(result))
  1101. {
  1102. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1103. pic.CreateUserId = dto.CreateUserId;
  1104. pic.PicName = imageName;
  1105. pic.PicPath = result;
  1106. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1107. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1108. if (insertResult > 0)
  1109. {
  1110. sucNum++;
  1111. }
  1112. }
  1113. }
  1114. }
  1115. catch (Exception ex)
  1116. {
  1117. return Ok(JsonView(false, ex.Message));
  1118. }
  1119. string msg = string.Format(@"成功上传{0}张", sucNum);
  1120. return Ok(JsonView(true, msg));
  1121. }
  1122. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1123. {
  1124. string filename = "";//声明一个string类型的相对路径
  1125. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1126. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1127. try//会有异常抛出,try,catch一下
  1128. {
  1129. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1130. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1131. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1132. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1133. //文件名称
  1134. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1135. //上传的文件的路径
  1136. string filePath = "";
  1137. if (!Directory.Exists(fileDir))
  1138. {
  1139. Directory.CreateDirectory(fileDir);
  1140. }
  1141. //上传的文件的路径
  1142. filePath = fileDir + filename;
  1143. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1144. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1145. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1146. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1147. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1148. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1149. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1150. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1151. bitmap.Dispose();
  1152. }
  1153. catch (Exception e)
  1154. {
  1155. string massage = e.Message;
  1156. Logs("IOS图片上传Error:" + massage);
  1157. //filename = e.Message;
  1158. }
  1159. return filename;//返回相对路径
  1160. }
  1161. /// <summary>
  1162. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1163. /// </summary>
  1164. /// <param name="dto"></param>
  1165. /// <returns></returns>
  1166. [HttpPost]
  1167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1168. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1169. {
  1170. if (dto == null)
  1171. {
  1172. return Ok(JsonView(false, "请求错误:"));
  1173. }
  1174. string msg = "参数错误";
  1175. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1176. {
  1177. try
  1178. {
  1179. //_delegationVisaRep.BeginTran();
  1180. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1181. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1182. .Where(s => s.Id == dto.visaProgressCustomerId)
  1183. .ExecuteCommandAsync();
  1184. if (updCount > 0 && dto.publishCode == 1)
  1185. {
  1186. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1187. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1188. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1189. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1190. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1191. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1192. if (groupData == null)
  1193. {
  1194. _delegationVisaRep.RollbackTran();
  1195. }
  1196. string title = string.Format(@"[签证进度更新]");
  1197. string content = string.Format(@"测试文本");
  1198. bool rst = await _message.AddMsg(new MessageDto()
  1199. {
  1200. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1201. IssuerId = dto.publisher,
  1202. Title = title,
  1203. Content = content,
  1204. ReleaseTime = DateTime.Now,
  1205. UIdList = new List<int> {
  1206. 234
  1207. }
  1208. });
  1209. if (rst)
  1210. {
  1211. return Ok(JsonView(true, "发送通知成功"));
  1212. }
  1213. }
  1214. //_delegationVisaRep.CommitTran();
  1215. }
  1216. catch (Exception)
  1217. {
  1218. //_delegationVisaRep.RollbackTran();
  1219. }
  1220. }
  1221. return Ok(JsonView(true, msg));
  1222. }
  1223. #endregion
  1224. #region 团组任务分配
  1225. /// <summary>
  1226. /// 团组任务分配初始化
  1227. /// </summary>
  1228. /// <param name="dto"></param>
  1229. /// <returns></returns>
  1230. [HttpPost]
  1231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1232. public async Task<IActionResult> GetTaskAssignmen()
  1233. {
  1234. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1235. if (groupData.Code != 0)
  1236. {
  1237. return Ok(JsonView(false, groupData.Msg));
  1238. }
  1239. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1240. }
  1241. /// <summary>
  1242. /// 团组任务分配查询
  1243. /// </summary>
  1244. /// <param name="dto"></param>
  1245. /// <returns></returns>
  1246. [HttpPost]
  1247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1248. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1249. {
  1250. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1251. if (groupData.Code != 0)
  1252. {
  1253. return Ok(JsonView(false, groupData.Msg));
  1254. }
  1255. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1256. }
  1257. /// <summary>
  1258. /// 团组任务分配操作
  1259. /// </summary>
  1260. /// <param name="dto"></param>
  1261. /// <returns></returns>
  1262. [HttpPost]
  1263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1264. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1265. {
  1266. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1267. if (groupData.Code != 0)
  1268. {
  1269. return Ok(JsonView(false, groupData.Msg));
  1270. }
  1271. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1272. }
  1273. /// <summary>
  1274. /// 团组任务分配
  1275. /// 批量分配
  1276. /// 查询团组
  1277. /// </summary>
  1278. /// <param name="dto"></param>
  1279. /// <returns></returns>
  1280. [HttpPost]
  1281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1282. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1283. {
  1284. //参数验证
  1285. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1286. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1287. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1288. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1289. }
  1290. /// <summary>
  1291. /// 团组任务分配
  1292. /// 批量分配
  1293. /// </summary>
  1294. /// <param name="dto"></param>
  1295. /// <returns></returns>
  1296. [HttpPost]
  1297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1298. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1299. {
  1300. //参数验证
  1301. if (dto.UserIds.Length < 1 ) return Ok(JsonView(false, $"请选择分配人员!"));
  1302. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1303. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1304. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1305. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1306. }
  1307. #endregion
  1308. #region 团组费用审核
  1309. /// <summary>
  1310. /// 费用审核
  1311. /// 团组列表 Page
  1312. /// </summary>
  1313. /// <param name="_dto">团组列表请求dto</param>
  1314. /// <returns></returns>
  1315. [HttpPost]
  1316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1317. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1318. {
  1319. #region 参数验证
  1320. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1321. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1322. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1323. #region 页面操作权限验证
  1324. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1325. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1326. #endregion
  1327. #endregion
  1328. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1329. {
  1330. string sqlWhere = string.Empty;
  1331. if (_dto.IsSure == 0) //未完成
  1332. {
  1333. sqlWhere += string.Format(@" And IsSure = 0");
  1334. }
  1335. else if (_dto.IsSure == 1) //已完成
  1336. {
  1337. sqlWhere += string.Format(@" And IsSure = 1");
  1338. }
  1339. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1340. {
  1341. string tj = _dto.SearchCriteria;
  1342. 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}%')",
  1343. tj, tj, tj, tj, tj);
  1344. }
  1345. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1346. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1347. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1348. From (
  1349. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1350. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1351. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1352. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1353. From Grp_DelegationInfo gdi
  1354. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1355. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1356. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1357. Where gdi.IsDel = 0 {0}
  1358. ) temp ", sqlWhere);
  1359. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1360. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1361. var _view = new
  1362. {
  1363. PageFuncAuth = pageFunAuthView,
  1364. Data = _DelegationList
  1365. };
  1366. return Ok(JsonView(true, "查询成功!", _view, total));
  1367. }
  1368. else
  1369. {
  1370. return Ok(JsonView(false, "查询失败"));
  1371. }
  1372. }
  1373. /// <summary>
  1374. /// 获取团组费用审核
  1375. /// </summary>
  1376. /// <param name="paras">参数Json字符串</param>
  1377. /// <returns></returns>
  1378. [HttpPost]
  1379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1380. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1381. {
  1382. try
  1383. {
  1384. #region 参数验证
  1385. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1386. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1387. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1388. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1389. #region 页面操作权限验证
  1390. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1391. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1392. #endregion
  1393. #endregion
  1394. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1395. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1396. #region 费用清单
  1397. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1398. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1399. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1400. List<Grp_CreditCardPayment> entityList = _groupRepository
  1401. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1402. .Where(exp.ToExpression())
  1403. .ToList();
  1404. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1405. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1406. /*
  1407. * 76://酒店预订
  1408. */
  1409. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1410. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1411. .ToListAsync();
  1412. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1413. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1414. .ToListAsync();
  1415. /*
  1416. * 79://车/导游地接
  1417. */
  1418. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1419. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1420. .ToListAsync();
  1421. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1422. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1423. .ToListAsync();
  1424. /*
  1425. * 80: //签证
  1426. */
  1427. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1428. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1429. .ToListAsync();
  1430. /*
  1431. *81: //邀请/公务活动
  1432. */
  1433. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1434. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1435. .ToListAsync();
  1436. /*
  1437. * 82: //团组客户保险
  1438. */
  1439. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1440. /*
  1441. * Lable = 85 机票预订
  1442. */
  1443. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1444. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1445. .ToListAsync();
  1446. /*
  1447. * 85 机票预定
  1448. */
  1449. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1450. /*
  1451. * 98 其他款项
  1452. */
  1453. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1454. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1455. .ToListAsync();
  1456. /*
  1457. * 285:收款退还
  1458. */
  1459. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1460. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1461. .ToListAsync();
  1462. /*
  1463. * 1015: //超支费用
  1464. */
  1465. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1466. /*
  1467. * 币种信息
  1468. */
  1469. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1470. /*
  1471. * 车/导游地接 费用类型
  1472. */
  1473. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1474. /*
  1475. * 车/导游地接 费用类型
  1476. */
  1477. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1478. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1479. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1480. /*
  1481. * 用户信息
  1482. */
  1483. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1484. /*
  1485. * 费用模块
  1486. */
  1487. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1488. string priceModule = string.Empty;
  1489. if (sdPriceName != null)
  1490. {
  1491. priceModule = sdPriceName.Name;
  1492. }
  1493. /*
  1494. * 成本信息
  1495. */
  1496. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1497. decimal _groupRate = 0.0000M;
  1498. string _groupCurrencyCode = "-";
  1499. if (groupCost != null)
  1500. {
  1501. _groupRate = groupCost.Rate;
  1502. if (int.TryParse(groupCost.Currency, out int _currency))
  1503. {
  1504. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1505. }
  1506. else _groupCurrencyCode = groupCost.Currency;
  1507. }
  1508. string costContentSql = $"Select * From Grp_GroupCost";
  1509. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1510. //处理日期为空的天数
  1511. for (int i = 0; i < groupCostDetails.Count; i++)
  1512. if (i != 0)
  1513. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1514. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1515. /*
  1516. * 处理详情数据
  1517. */
  1518. foreach (var entity in entityList)
  1519. {
  1520. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1521. _detail.Id = entity.Id;
  1522. _detail.PriceName = priceModule;
  1523. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1524. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1525. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1526. /*
  1527. * 应付款金额
  1528. */
  1529. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1530. string PaymentCurrency_WaitPay = "Unknown";
  1531. string hotelCurrncyCode = "Unknown";
  1532. string hotelCurrncyName = "Unknown";
  1533. if (sdPaymentCurrency_WaitPay != null)
  1534. {
  1535. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1536. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1537. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1538. if (hotelCurrncyCode.Equals("CNY"))
  1539. {
  1540. entity.DayRate = 1.0000M;
  1541. }
  1542. }
  1543. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1544. /*
  1545. * 此次付款金额
  1546. */
  1547. decimal CurrPayStr = 0.00M,
  1548. OriginalCurrPay = 0.00M;
  1549. if (entity.PayPercentage == 0)
  1550. {
  1551. if (entity.PayThenMoney != 0)
  1552. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1553. }
  1554. else
  1555. {
  1556. if (entity.PayMoney != 0)
  1557. {
  1558. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1559. }
  1560. }
  1561. if (_dto.Label == 79)
  1562. {
  1563. string original = string.Empty;
  1564. if (hotelCurrncyCode.Equals("CNY"))
  1565. {
  1566. OriginalCurrPay = CurrPayStr;
  1567. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1568. }
  1569. else
  1570. {
  1571. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1572. //760 EUR(7600.00 CNY)
  1573. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1574. }
  1575. }
  1576. else
  1577. {
  1578. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1579. }
  1580. /*
  1581. * 剩余尾款
  1582. */
  1583. decimal BalanceStr = 0;
  1584. if (CurrPayStr != 0)
  1585. {
  1586. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1587. BalanceStr = 0;
  1588. else
  1589. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1590. }
  1591. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1592. /*
  1593. * Bus名称
  1594. */
  1595. _detail.BusName = "待增加";
  1596. /*
  1597. *费用所属
  1598. */
  1599. switch (entity.CTable)
  1600. {
  1601. case 76://酒店预订
  1602. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1603. if (hotelReservations != null)
  1604. {
  1605. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1606. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1607. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1608. string roomFeeStr = "", roomFeestr1 = "";
  1609. //是否比较房型价格
  1610. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1611. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1612. roomFeeStr += $"<br/>";
  1613. if (hotelReservations.SingleRoomPrice > 0)
  1614. {
  1615. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1616. __isSingle = true;
  1617. }
  1618. if (hotelReservations.DoubleRoomPrice > 0)
  1619. {
  1620. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1621. __isDouble = true;
  1622. }
  1623. if (hotelReservations.SuiteRoomPrice > 0)
  1624. {
  1625. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1626. __isSuite = true;
  1627. }
  1628. if (hotelReservations.OtherRoomPrice > 0)
  1629. {
  1630. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1631. __isOther = true;
  1632. }
  1633. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1634. else roomFeeStr += " 0.00 * 0";
  1635. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1636. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1637. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1638. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1639. /*
  1640. * 费用类型
  1641. * 1:房费
  1642. * 2:早餐
  1643. * 3:地税
  1644. * 4:城市税
  1645. * </summary>
  1646. */
  1647. //地税
  1648. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1649. if (governmentRentData != null)
  1650. {
  1651. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1652. governmentRentFee = governmentRentData.Price;
  1653. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1654. if (governmentRentCurrData != null)
  1655. {
  1656. governmentRentCode = governmentRentCurrData.Name;
  1657. governmentRentName = $"({governmentRentCurrData.Remark})";
  1658. }
  1659. }
  1660. //城市税
  1661. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1662. if (cityTaxData != null)
  1663. {
  1664. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1665. cityTaxFee = cityTaxData.Price;
  1666. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1667. if (cityTaxCurrData != null)
  1668. {
  1669. cityTaxCode = cityTaxCurrData.Name;
  1670. cityTaxName = $"({cityTaxCurrData.Remark})";
  1671. }
  1672. }
  1673. //酒店早餐
  1674. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1675. if (breakfastData != null)
  1676. {
  1677. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1678. breakfastFee = breakfastData.Price;
  1679. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1680. if (breakfastCurrData != null)
  1681. {
  1682. breakfastCode = breakfastCurrData.Name;
  1683. breakfastName = $"({breakfastCurrData.Remark})";
  1684. }
  1685. }
  1686. //房间费用
  1687. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1688. if (roomData != null)
  1689. {
  1690. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1691. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1692. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1693. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1694. roomFee = roomData.Price;
  1695. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1696. if (roomCurrData != null)
  1697. {
  1698. roomCode = roomCurrData.Name;
  1699. roomName = $"({roomCurrData.Remark})";
  1700. }
  1701. }
  1702. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1703. string hotelCostStr = "";
  1704. decimal hotelCsotTotal = 0.00M;
  1705. if (groupCost != null)
  1706. {
  1707. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1708. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1709. }
  1710. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1711. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1712. string hotelCost_day = "";
  1713. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1714. foreach (var item in hotelCostDetails1)
  1715. {
  1716. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1717. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1718. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1719. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1720. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1721. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1722. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1723. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1724. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1725. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1726. hotelCost_day += @$"</br>";
  1727. }
  1728. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1729. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1730. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1731. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1732. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1733. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1734. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1735. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1736. $"房间说明: {hotelReservations.Remark} <br/>" +
  1737. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1738. $"{hotelBreakfastStr}" +
  1739. $"{hotelGovernmentRentStr}" +
  1740. $"{hotelCityTaxStr}";
  1741. _detail.PriceNameContent = hotelReservations.HotelName;
  1742. }
  1743. break;
  1744. case 79://车/导游地接
  1745. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1746. if (touristGuideGroundReservations != null)
  1747. {
  1748. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1749. {
  1750. _detail.BusName = touristGuideGroundReservations.BusName;
  1751. }
  1752. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1753. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1754. //if (isInt)
  1755. //{
  1756. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1757. // if (cityInfo != null)
  1758. // {
  1759. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1760. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1761. // if (carFeeItem != null)
  1762. // {
  1763. // nameContent += $@"({carFeeItem.Name})";
  1764. // }
  1765. // _detail.PriceNameContent = nameContent;
  1766. // }
  1767. //}
  1768. //else
  1769. //{
  1770. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1771. //}
  1772. var touristGuideGroundReservationsContents =
  1773. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1774. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1775. foreach (var item in touristGuideGroundReservationsContents)
  1776. {
  1777. string typeName = "Unknown";
  1778. string carCurrencyCode = "Unknown";
  1779. string carCurrencyName = "Unknown";
  1780. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1781. if (carTypeData != null) typeName = carTypeData.Name;
  1782. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1783. if (currencyData != null)
  1784. {
  1785. carCurrencyCode = currencyData.Name;
  1786. carCurrencyName = currencyData.Remark;
  1787. }
  1788. //op、成本 币种是否一致
  1789. bool IsCurrencyAgreement = false;
  1790. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1791. string opCostStr = string.Empty;
  1792. decimal opCostTypePrice = 0.00M;
  1793. #region 处理成本各项费用
  1794. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1795. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1796. if (opCost.Count > 0)
  1797. {
  1798. switch (item.SId)
  1799. {
  1800. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1801. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1802. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1803. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1804. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1805. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1806. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1807. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1808. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1809. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1810. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1811. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1812. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1813. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1814. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1815. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1816. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1817. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1818. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1819. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1820. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1821. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1822. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1823. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1824. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1825. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1826. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1827. }
  1828. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1829. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1830. }
  1831. #endregion
  1832. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1833. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1834. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1835. $"{opTypeStr} {opCostStr}<br/>" +
  1836. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1837. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1838. }
  1839. _detail.PriceMsgContent = priceMsg;
  1840. }
  1841. break;
  1842. case 80: //签证
  1843. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1844. if (visaInfo != null)
  1845. {
  1846. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1847. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1848. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1849. }
  1850. break;
  1851. case 81: //邀请/公务活动
  1852. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1853. if (_ioa != null)
  1854. {
  1855. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1856. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1857. sendCurrName = "Unknown", //快递费用币种 Name
  1858. sendCurrCode = "Unknown", //快递费用币种 Code
  1859. eventsCurrName = "Unknown", //公务活动费币种 Name
  1860. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1861. translateCurrName = "Unknown", //公务翻译费 Name
  1862. translateCurrCode = "Unknown"; //公务翻译费 Code
  1863. #region 处理费用币种
  1864. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1865. if (inviteCurrData != null)
  1866. {
  1867. inviteCurrName = inviteCurrData.Remark;
  1868. inviteCurrCode = inviteCurrData.Name;
  1869. }
  1870. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1871. if (sendCurrData != null)
  1872. {
  1873. sendCurrName = sendCurrData.Remark;
  1874. sendCurrCode = sendCurrData.Name;
  1875. }
  1876. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1877. if (eventsCurrData != null)
  1878. {
  1879. eventsCurrName = eventsCurrData.Remark;
  1880. eventsCurrCode = eventsCurrData.Name;
  1881. }
  1882. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1883. if (translateCurrData != null)
  1884. {
  1885. translateCurrName = translateCurrData.Remark;
  1886. translateCurrCode = translateCurrData.Name;
  1887. }
  1888. #endregion
  1889. _detail.PriceNameContent = _ioa.InviterArea;
  1890. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1891. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1892. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1893. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1894. $@"备注:" + _ioa.Remark + "<br/>";
  1895. }
  1896. break;
  1897. case 82: //团组客户保险
  1898. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1899. if (customers != null)
  1900. {
  1901. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1902. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1903. }
  1904. break;
  1905. case 85: //机票预订
  1906. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1907. if (jpRes != null)
  1908. {
  1909. string FlightsDescription = jpRes.FlightsDescription;
  1910. string PriceDescription = jpRes.PriceDescription;
  1911. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1912. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1913. }
  1914. break;
  1915. case 98://其他款项
  1916. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1917. if (gdpRes != null)
  1918. {
  1919. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1920. _detail.PriceNameContent = gdpRes.PriceName;
  1921. }
  1922. break;
  1923. case 285://收款退还
  1924. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1925. if (refundAndOtherMoney != null)
  1926. {
  1927. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1928. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1929. }
  1930. break;
  1931. case 751://酒店早餐
  1932. break;
  1933. case 1015://超支费用
  1934. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1935. if (groupExtraCost != null)
  1936. {
  1937. _detail.PriceNameContent = groupExtraCost.PriceName;
  1938. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1939. }
  1940. break;
  1941. default:
  1942. break;
  1943. }
  1944. /*
  1945. * 申请人
  1946. */
  1947. string operatorName = " - ";
  1948. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1949. if (_opUser != null)
  1950. {
  1951. operatorName = _opUser.CnName;
  1952. }
  1953. _detail.OperatorName = operatorName;
  1954. /*
  1955. * 审核人
  1956. */
  1957. string auditOperatorName = "Unknown";
  1958. if (entity.AuditGMOperate == 0)
  1959. auditOperatorName = " - ";
  1960. else if (entity.AuditGMOperate == 4)
  1961. auditOperatorName = "自动审核";
  1962. else
  1963. {
  1964. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1965. if (_adUser != null)
  1966. {
  1967. auditOperatorName = _adUser.CnName;
  1968. }
  1969. }
  1970. _detail.AuditOperatorName = auditOperatorName;
  1971. /*
  1972. * 超预算比例
  1973. */
  1974. string overBudgetStr = "";
  1975. if (entity.ExceedBudget == -1)
  1976. overBudgetStr = sdPriceName.Name + "尚无预算";
  1977. else if (entity.ExceedBudget == 0)
  1978. {
  1979. if (entity.CTable == 76 || entity.CTable == 79)
  1980. {
  1981. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1982. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1983. }
  1984. else
  1985. {
  1986. overBudgetStr = "未超预算";
  1987. }
  1988. }
  1989. else
  1990. overBudgetStr = entity.ExceedBudget.ToString("P");
  1991. _detail.OverBudget = overBudgetStr;
  1992. /*
  1993. * 已审核金额
  1994. */
  1995. decimal auditFee = 0.00M;
  1996. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  1997. /*
  1998. * 费用总计
  1999. */
  2000. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2001. {
  2002. CurrencyId = entity.PaymentCurrency,
  2003. CurrencyName = PaymentCurrency_WaitPay,
  2004. AmountPayable = entity.PayMoney,
  2005. ThisPayment = OriginalCurrPay,
  2006. BalancePayment = BalanceStr,
  2007. AuditedFunds = auditFee
  2008. });
  2009. _detail.IsAuditGM = entity.IsAuditGM;
  2010. detailList.Add(_detail);
  2011. }
  2012. #endregion
  2013. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2014. /*
  2015. * 下方描述处理
  2016. */
  2017. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2018. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2019. if (ccpCurrencyPrice != null)
  2020. {
  2021. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2022. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2023. }
  2024. else
  2025. {
  2026. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2027. }
  2028. string amountPayableStr = string.Format(@"应付款总金额: ");
  2029. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2030. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2031. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2032. foreach (var item in nonDuplicat)
  2033. {
  2034. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2035. if (strs.Count > 0)
  2036. {
  2037. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2038. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2039. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2040. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2041. //单独处理此次付款金额
  2042. if (item.CurrencyId == 836) //人民币
  2043. {
  2044. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2045. }
  2046. else
  2047. {
  2048. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2049. }
  2050. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2051. //单独处理已审核费用
  2052. if (item.CurrencyId == 836) //人民币
  2053. {
  2054. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2055. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2056. }
  2057. else
  2058. {
  2059. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2060. }
  2061. }
  2062. }
  2063. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2064. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2065. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2066. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2067. var _view1 = new
  2068. {
  2069. PageFuncAuth = pageFunAuthView,
  2070. Data = _view
  2071. };
  2072. return Ok(JsonView(_view1));
  2073. }
  2074. catch (Exception ex)
  2075. {
  2076. return Ok(JsonView(false, ex.Message));
  2077. }
  2078. }
  2079. /// <summary>
  2080. /// 费用审核
  2081. /// 修改团组费用审核状态
  2082. /// </summary>
  2083. /// <param name="_dto">参数Json字符串</param>
  2084. /// <returns></returns>
  2085. [HttpPost]
  2086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2087. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2088. {
  2089. #region 参数验证
  2090. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2091. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2092. #endregion
  2093. #region 页面操作权限验证
  2094. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2095. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2096. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2097. #endregion
  2098. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2099. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2100. DateTime dtNow = DateTime.Now;
  2101. _groupRepository.BeginTran();
  2102. int rst = 0;
  2103. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2104. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2105. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2106. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2107. List<dynamic> msgDatas = new List<dynamic>();
  2108. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2109. foreach (var item in idList)
  2110. {
  2111. int CreditId = int.Parse(item);
  2112. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2113. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2114. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2115. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2116. .Where(s => s.Id == CreditId)
  2117. .ExecuteCommandAsync();
  2118. if (result < 1)
  2119. {
  2120. rst = -1;
  2121. _groupRepository.RollbackTran();
  2122. return Ok(JsonView(false, "操作失败并回滚!"));
  2123. }
  2124. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2125. if (creditData != null)
  2126. {
  2127. #region 应用通知配置
  2128. try
  2129. {
  2130. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2131. }
  2132. catch (Exception ex)
  2133. {
  2134. }
  2135. #endregion
  2136. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2137. string groupNameStr = string.Empty;
  2138. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2139. if (groupData != null) groupNameStr = groupData.TeamName;
  2140. string creditTypeStr = string.Empty;
  2141. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2142. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2143. string creditCurrency = string.Empty;
  2144. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2145. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2146. if (creditCurrency.Equals("CNY"))
  2147. {
  2148. creditData.DayRate = 1.0000M;
  2149. }
  2150. if (creditData.PayPercentage == 0.00M)
  2151. {
  2152. creditData.PayPercentage = 100M;
  2153. }
  2154. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2155. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2156. string msgContent = "";
  2157. if (creditCurrency.Equals("CNY"))
  2158. {
  2159. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2160. }
  2161. else
  2162. {
  2163. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2164. }
  2165. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2166. }
  2167. }
  2168. if (rst == 0)
  2169. {
  2170. _groupRepository.CommitTran();
  2171. foreach (var item in msgDatas)
  2172. {
  2173. //发送消息
  2174. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2175. }
  2176. #region 应用推送
  2177. try
  2178. {
  2179. foreach (var ccpId in dic_ccp_user.Keys)
  2180. {
  2181. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2182. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2183. }
  2184. }
  2185. catch (Exception)
  2186. {
  2187. }
  2188. #endregion
  2189. return Ok(JsonView(true, "操作成功!"));
  2190. }
  2191. return Ok(JsonView(false, "操作失败!"));
  2192. }
  2193. #endregion
  2194. #region 机票费用录入
  2195. /// <summary>
  2196. /// 机票录入当前登录人可操作团组
  2197. /// </summary>
  2198. /// <param name="dto"></param>
  2199. /// <returns></returns>
  2200. [HttpPost]
  2201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2202. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2203. {
  2204. try
  2205. {
  2206. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2207. if (groupData.Code != 0)
  2208. {
  2209. return Ok(JsonView(false, groupData.Msg));
  2210. }
  2211. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2212. }
  2213. catch (Exception ex)
  2214. {
  2215. return Ok(JsonView(false, "程序错误!"));
  2216. throw;
  2217. }
  2218. }
  2219. /// <summary>
  2220. /// 机票费用录入列表
  2221. /// </summary>
  2222. /// <param name="dto"></param>
  2223. /// <returns></returns>
  2224. [HttpPost]
  2225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2226. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2227. {
  2228. try
  2229. {
  2230. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2231. if (groupData.Code != 0)
  2232. {
  2233. return Ok(JsonView(false, groupData.Msg));
  2234. }
  2235. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2236. }
  2237. catch (Exception ex)
  2238. {
  2239. return Ok(JsonView(false, ex.Message));
  2240. throw;
  2241. }
  2242. }
  2243. /// <summary>
  2244. /// 根据id查询费用录入信息
  2245. /// </summary>
  2246. /// <param name="dto"></param>
  2247. /// <returns></returns>
  2248. [HttpPost]
  2249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2250. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2251. {
  2252. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2253. if (groupData.Code != 0)
  2254. {
  2255. return Ok(JsonView(false, groupData.Msg));
  2256. }
  2257. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2258. }
  2259. /// <summary>
  2260. /// 机票费用录入操作(Status:1.新增,2.修改)
  2261. /// </summary>
  2262. /// <param name="dto"></param>
  2263. /// <returns></returns>
  2264. [HttpPost]
  2265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2266. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2267. {
  2268. try
  2269. {
  2270. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2271. if (groupData.Code != 0)
  2272. {
  2273. return Ok(JsonView(false, groupData.Msg));
  2274. }
  2275. #region 应用推送
  2276. try
  2277. {
  2278. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2279. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2280. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2281. }
  2282. catch (Exception ex)
  2283. {
  2284. }
  2285. #endregion
  2286. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2287. }
  2288. catch (Exception ex)
  2289. {
  2290. return Ok(JsonView(false, "程序错误!"));
  2291. throw;
  2292. }
  2293. }
  2294. /// <summary>
  2295. /// 根据舱位类型查询接团客户名单信息
  2296. /// </summary>
  2297. /// <param name="dto"></param>
  2298. /// <returns></returns>
  2299. [HttpPost]
  2300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2301. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2302. {
  2303. try
  2304. {
  2305. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2306. if (crm_Groups.Count != 0)
  2307. {
  2308. List<dynamic> Customer = new List<dynamic>();
  2309. foreach (var item in crm_Groups)
  2310. {
  2311. var data = new
  2312. {
  2313. Id = item.Id,
  2314. Pinyin = item.Pinyin,
  2315. Name = item.LastName + item.FirstName
  2316. };
  2317. Customer.Add(data);
  2318. }
  2319. return Ok(JsonView(true, "查询成功!", Customer));
  2320. }
  2321. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2322. }
  2323. catch (Exception ex)
  2324. {
  2325. return Ok(JsonView(false, "程序错误!"));
  2326. throw;
  2327. }
  2328. }
  2329. /// <summary>
  2330. /// 根据团号获取客户信息
  2331. /// </summary>
  2332. /// <param name="dto"></param>
  2333. /// <returns></returns>
  2334. [HttpPost]
  2335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2336. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2337. {
  2338. var jw = JsonView(false);
  2339. if (dto.DIID < 1)
  2340. {
  2341. jw.Msg += "请输入正确的diid";
  2342. return Ok(jw);
  2343. }
  2344. var arr = getSimplClientList(dto.DIID);
  2345. jw = JsonView(true, "获取成功!", arr);
  2346. return Ok(jw);
  2347. }
  2348. private List<SimplClientInfo> getSimplClientList(int diId)
  2349. {
  2350. 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);
  2351. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2352. return arr;
  2353. }
  2354. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2355. {
  2356. string result = origin;
  2357. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2358. {
  2359. string[] temparr = origin.Split(',');
  2360. string fistrStr = temparr[0];
  2361. int count = temparr.Count();
  2362. int tempId;
  2363. bool success = int.TryParse(fistrStr, out tempId);
  2364. if (success)
  2365. {
  2366. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2367. if (tempInfo != null)
  2368. {
  2369. if (count > 1)
  2370. {
  2371. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2372. }
  2373. else
  2374. {
  2375. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2376. }
  2377. }
  2378. }
  2379. }
  2380. return result;
  2381. }
  2382. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2383. {
  2384. string result = origin;
  2385. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2386. {
  2387. string[] temparr = origin.Split(',');
  2388. result = "";
  2389. foreach (var item in temparr)
  2390. {
  2391. int tempId;
  2392. bool success = int.TryParse(item, out tempId);
  2393. if (success)
  2394. {
  2395. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2396. if (tempInfo != null)
  2397. {
  2398. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2399. }
  2400. }
  2401. }
  2402. }
  2403. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2404. return result;
  2405. }
  2406. /// <summary>
  2407. /// 机票费用录入,删除
  2408. /// </summary>
  2409. /// <param name="dto"></param>
  2410. /// <returns></returns>
  2411. [HttpPost]
  2412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2413. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2414. {
  2415. try
  2416. {
  2417. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2418. if (res)
  2419. {
  2420. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2421. {
  2422. IsDel = 1,
  2423. DeleteUserId = dto.DeleteUserId,
  2424. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2425. }).ExecuteCommandAsync();
  2426. return Ok(JsonView(true, "删除成功!"));
  2427. }
  2428. return Ok(JsonView(false, "删除失败!"));
  2429. }
  2430. catch (Exception ex)
  2431. {
  2432. return Ok(JsonView(false, "程序错误!"));
  2433. throw;
  2434. }
  2435. }
  2436. /// <summary>
  2437. /// 导出机票录入报表
  2438. /// </summary>
  2439. /// <param name="dto"></param>
  2440. /// <returns></returns>
  2441. [HttpPost]
  2442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2443. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2444. {
  2445. try
  2446. {
  2447. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2448. if (groupData.Code != 0)
  2449. {
  2450. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2451. }
  2452. else
  2453. {
  2454. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2455. if (AirTicketReservations.Count != 0)
  2456. {
  2457. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2458. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2459. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2460. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2461. WorkbookDesigner designer = new WorkbookDesigner();
  2462. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2463. decimal countCost = 0;
  2464. foreach (var item in AirTicketReservations)
  2465. {
  2466. #region 处理客人姓名
  2467. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2468. item.ClientName = clientNames;
  2469. #endregion
  2470. if (item.BankType == "其他")
  2471. {
  2472. item.BankNo = "--";
  2473. }
  2474. else
  2475. {
  2476. if (!string.IsNullOrEmpty(item.BankType))
  2477. {
  2478. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2479. }
  2480. }
  2481. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2482. item.Price = System.Decimal.Round(item.Price, 2);
  2483. countCost += Convert.ToDecimal(item.Price);
  2484. }
  2485. designer.SetDataSource("Export", AirTicketReservations);
  2486. designer.SetDataSource("ExportDiCode", diCode);
  2487. designer.SetDataSource("ExportDiName", diName);
  2488. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2489. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2490. designer.Process();
  2491. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2492. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2493. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2494. return Ok(JsonView(true, "成功", url = rst));
  2495. }
  2496. else
  2497. {
  2498. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2499. }
  2500. }
  2501. }
  2502. catch (Exception ex)
  2503. {
  2504. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2505. throw;
  2506. }
  2507. }
  2508. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2509. /// <summary>
  2510. /// 行程单导出
  2511. /// </summary>
  2512. /// <param name="dto"></param>
  2513. /// <returns></returns>
  2514. [HttpPost]
  2515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2516. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2517. {
  2518. try
  2519. {
  2520. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2521. if (groupData.Code != 0)
  2522. {
  2523. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2524. }
  2525. else
  2526. {
  2527. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2528. if (dto.Language == "CN")
  2529. {
  2530. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2531. DocumentBuilder builder = new DocumentBuilder(doc);
  2532. int tableIndex = 0;//表格索引
  2533. //得到文档中的第一个表格
  2534. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2535. foreach (var item in _AirTicketReservations)
  2536. {
  2537. #region 处理固定数据
  2538. string[] FlightsCode = item.FlightsCode.Split('/');
  2539. if (FlightsCode.Length != 0)
  2540. {
  2541. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2542. if (_AirCompany != null)
  2543. {
  2544. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2545. }
  2546. else
  2547. {
  2548. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2549. }
  2550. }
  2551. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2552. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2553. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2554. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2555. string name = "";
  2556. foreach (string clientName in nameArray)
  2557. {
  2558. if (!name.Contains(clientName))
  2559. {
  2560. name += clientName + ",";
  2561. }
  2562. }
  2563. if (!string.IsNullOrWhiteSpace(name))
  2564. {
  2565. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2566. }
  2567. else
  2568. {
  2569. table.Range.Bookmarks["ClientName"].Text = "--";
  2570. }
  2571. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2572. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2573. table.Range.Bookmarks["JointTicket"].Text = "--";
  2574. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2575. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2576. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2577. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2578. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2579. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2580. #endregion
  2581. #region 循环数据处理
  2582. List<AirInfo> airs = new List<AirInfo>();
  2583. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2584. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2585. for (int i = 0; i < FlightsCode.Length; i++)
  2586. {
  2587. AirInfo air = new AirInfo();
  2588. string[] tempstr = DayArray[i]
  2589. .Replace("\r\n", string.Empty)
  2590. .Replace("\\r\\n", string.Empty)
  2591. .TrimStart().TrimEnd()
  2592. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2593. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2594. string starCity = "";
  2595. if (star_Three != null)
  2596. {
  2597. starCity = star_Three.AirPort;
  2598. }
  2599. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2600. string EndCity = "";
  2601. if (End_Three != null)
  2602. {
  2603. EndCity = End_Three.AirPort;
  2604. }
  2605. air.Destination = starCity + "/" + EndCity;
  2606. air.Flight = FlightsCode[i];
  2607. air.SeatingClass = item.CTypeName;
  2608. string dateTime = tempstr[2];
  2609. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2610. air.FlightDate = DateTemp;
  2611. air.DepartureTime = tempstr[5];
  2612. air.LandingTime = tempstr[6];
  2613. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2614. air.TicketStatus = "--";
  2615. air.Luggage = "--";
  2616. air.DepartureTerminal = "--";
  2617. air.LandingTerminal = "--";
  2618. airs.Add(air);
  2619. }
  2620. int row = 13;
  2621. for (int i = 0; i < airs.Count; i++)
  2622. {
  2623. if (airs.Count > 2)
  2624. {
  2625. for (int j = 0; j < airs.Count - 2; j++)
  2626. {
  2627. var CopyRow = table.Rows[12].Clone(true);
  2628. table.Rows.Add(CopyRow);
  2629. }
  2630. }
  2631. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2632. int index = 0;
  2633. foreach (PropertyInfo property in properties)
  2634. {
  2635. string value = property.GetValue(airs[i]).ToString();
  2636. Cell ishcel0 = table.Rows[row].Cells[index];
  2637. Paragraph p = new Paragraph(doc);
  2638. string s = value;
  2639. p.AppendChild(new Run(doc, s));
  2640. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2641. ishcel0.AppendChild(p);
  2642. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2643. index++;
  2644. }
  2645. row++;
  2646. }
  2647. #endregion
  2648. Paragraph lastParagraph = new Paragraph(doc);
  2649. //第一个表格末尾加段落
  2650. table.ParentNode.InsertAfter(lastParagraph, table);
  2651. //复制第一个表格
  2652. Table cloneTable = (Table)table.Clone(true);
  2653. //在文档末尾段落后面加入复制的表格
  2654. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2655. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2656. {
  2657. int rownewsIndex = 13;
  2658. for (int i = 0; i < 2; i++)
  2659. {
  2660. var CopyRow = table.Rows[12].Clone(true);
  2661. table.Rows.RemoveAt(13);
  2662. table.Rows.Add(CopyRow);
  2663. rownewsIndex++;
  2664. }
  2665. }
  2666. else
  2667. {
  2668. table.Rows.RemoveAt(12);
  2669. }
  2670. cloneTable.Rows.RemoveAt(12);
  2671. }
  2672. if (_AirTicketReservations.Count != 0)
  2673. {
  2674. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2675. if (FlightsCode.Length != 0)
  2676. {
  2677. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2678. if (_AirCompany != null)
  2679. {
  2680. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2681. }
  2682. else
  2683. {
  2684. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2685. }
  2686. }
  2687. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2688. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2689. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2690. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2691. string name = "";
  2692. foreach (string clientName in nameArray)
  2693. {
  2694. if (!name.Contains(clientName))
  2695. {
  2696. name += clientName + ",";
  2697. }
  2698. }
  2699. if (!string.IsNullOrWhiteSpace(name))
  2700. {
  2701. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2702. }
  2703. else
  2704. {
  2705. table.Range.Bookmarks["ClientName"].Text = "--";
  2706. }
  2707. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2708. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2709. table.Range.Bookmarks["JointTicket"].Text = "--";
  2710. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2711. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2712. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2713. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2714. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2715. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2716. }
  2717. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2718. //保存合并后的文档
  2719. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2720. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2721. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2722. return Ok(JsonView(true, "成功!", rst));
  2723. }
  2724. else
  2725. {
  2726. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2727. DocumentBuilder builder = new DocumentBuilder(doc);
  2728. int tableIndex = 0;//表格索引
  2729. //得到文档中的第一个表格
  2730. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2731. List<string> texts = new List<string>();
  2732. foreach (var item in _AirTicketReservations)
  2733. {
  2734. string[] FlightsCode = item.FlightsCode.Split('/');
  2735. if (FlightsCode.Length != 0)
  2736. {
  2737. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2738. if (_AirCompany != null)
  2739. {
  2740. if (!transDic.ContainsKey(_AirCompany.CnName))
  2741. {
  2742. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2743. }
  2744. }
  2745. else
  2746. {
  2747. if (!transDic.ContainsKey("--"))
  2748. {
  2749. transDic.Add("--", "--");
  2750. }
  2751. }
  2752. }
  2753. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2754. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2755. string name = "";
  2756. foreach (string clientName in nameArray)
  2757. {
  2758. name += clientName + ",";
  2759. }
  2760. if (!texts.Contains(name))
  2761. {
  2762. texts.Add(name);
  2763. }
  2764. List<AirInfo> airs = new List<AirInfo>();
  2765. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2766. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2767. for (int i = 0; i < FlightsCode.Length; i++)
  2768. {
  2769. AirInfo air = new AirInfo();
  2770. string[] tempstr = DayArray[i]
  2771. .Replace("\r\n", string.Empty)
  2772. .Replace("\\r\\n", string.Empty)
  2773. .TrimStart().TrimEnd()
  2774. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2775. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2776. if (star_Three != null)
  2777. {
  2778. if (!transDic.ContainsKey(star_Three.AirPort))
  2779. {
  2780. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2781. }
  2782. }
  2783. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2784. if (End_Three != null)
  2785. {
  2786. if (!transDic.ContainsKey(End_Three.AirPort))
  2787. {
  2788. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2789. }
  2790. }
  2791. if (!texts.Contains(item.CTypeName))
  2792. {
  2793. texts.Add(item.CTypeName);
  2794. }
  2795. }
  2796. }
  2797. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2798. if (transData.Count > 0)
  2799. {
  2800. foreach (TranslateResult item in transData)
  2801. {
  2802. if (!transDic.ContainsKey(item.Query))
  2803. {
  2804. transDic.Add(item.Query, item.Translation);
  2805. }
  2806. }
  2807. }
  2808. foreach (var item in _AirTicketReservations)
  2809. {
  2810. #region 处理固定数据
  2811. string[] FlightsCode = item.FlightsCode.Split('/');
  2812. if (FlightsCode.Length != 0)
  2813. {
  2814. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2815. if (_AirCompany != null)
  2816. {
  2817. string str = "--";
  2818. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2819. if (!string.IsNullOrEmpty(translateResult))
  2820. {
  2821. str = translateResult;
  2822. str = _airTicketResRep.Processing(str);
  2823. }
  2824. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2825. }
  2826. else
  2827. {
  2828. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2829. }
  2830. }
  2831. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2832. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2833. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2834. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2835. string names = "";
  2836. foreach (string clientName in nameArray)
  2837. {
  2838. names += clientName + ",";
  2839. }
  2840. if (!string.IsNullOrWhiteSpace(names))
  2841. {
  2842. string str = "--";
  2843. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2844. if (!string.IsNullOrEmpty(translateResult))
  2845. {
  2846. str = translateResult;
  2847. str = _airTicketResRep.Processing(str);
  2848. }
  2849. table.Range.Bookmarks["ClientName"].Text = str;
  2850. }
  2851. else
  2852. {
  2853. table.Range.Bookmarks["ClientName"].Text = "--";
  2854. }
  2855. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2856. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2857. table.Range.Bookmarks["JointTicket"].Text = "--";
  2858. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2859. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2860. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2861. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2862. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2863. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2864. #endregion
  2865. #region 循环数据处理
  2866. List<AirInfo> airs = new List<AirInfo>();
  2867. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2868. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2869. for (int i = 0; i < FlightsCode.Length; i++)
  2870. {
  2871. AirInfo air = new AirInfo();
  2872. string[] tempstr = DayArray[i]
  2873. .Replace("\r\n", string.Empty)
  2874. .Replace("\\r\\n", string.Empty)
  2875. .TrimStart().TrimEnd()
  2876. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2877. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2878. string starCity = "";
  2879. if (star_Three != null)
  2880. {
  2881. string str2 = "--";
  2882. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2883. if (!string.IsNullOrEmpty(translateResult2))
  2884. {
  2885. str2 = translateResult2;
  2886. str2 = _airTicketResRep.Processing(str2);
  2887. }
  2888. starCity = str2;
  2889. }
  2890. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2891. string EndCity = "";
  2892. if (End_Three != null)
  2893. {
  2894. string str1 = "--";
  2895. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2896. if (!string.IsNullOrEmpty(translateResult1))
  2897. {
  2898. str1 = translateResult1;
  2899. str1 = _airTicketResRep.Processing(str1);
  2900. }
  2901. EndCity = str1;
  2902. }
  2903. air.Destination = starCity + "/" + EndCity;
  2904. air.Flight = FlightsCode[i];
  2905. string str = "--";
  2906. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2907. if (!string.IsNullOrEmpty(translateResult))
  2908. {
  2909. str = translateResult;
  2910. str = _airTicketResRep.Processing(str);
  2911. }
  2912. air.SeatingClass = str;
  2913. string dateTime = tempstr[2];
  2914. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2915. air.FlightDate = DateTemp;
  2916. air.DepartureTime = tempstr[5];
  2917. air.LandingTime = tempstr[6];
  2918. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2919. air.TicketStatus = "--";
  2920. air.Luggage = "--";
  2921. air.DepartureTerminal = "--";
  2922. air.LandingTerminal = "--";
  2923. airs.Add(air);
  2924. }
  2925. int row = 13;
  2926. for (int i = 0; i < airs.Count; i++)
  2927. {
  2928. if (airs.Count > 2)
  2929. {
  2930. for (int j = 0; j < airs.Count - 2; j++)
  2931. {
  2932. var CopyRow = table.Rows[12].Clone(true);
  2933. table.Rows.Add(CopyRow);
  2934. }
  2935. }
  2936. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2937. int index = 0;
  2938. foreach (PropertyInfo property in properties)
  2939. {
  2940. string value = property.GetValue(airs[i]).ToString();
  2941. Cell ishcel0 = table.Rows[row].Cells[index];
  2942. Paragraph p = new Paragraph(doc);
  2943. string s = value;
  2944. p.AppendChild(new Run(doc, s));
  2945. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2946. ishcel0.AppendChild(p);
  2947. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2948. //ishcel0.CellFormat.VerticalAlignment=
  2949. index++;
  2950. }
  2951. row++;
  2952. }
  2953. #endregion
  2954. Paragraph lastParagraph = new Paragraph(doc);
  2955. //第一个表格末尾加段落
  2956. table.ParentNode.InsertAfter(lastParagraph, table);
  2957. //复制第一个表格
  2958. Table cloneTable = (Table)table.Clone(true);
  2959. //在文档末尾段落后面加入复制的表格
  2960. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2961. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2962. {
  2963. int rownewsIndex = 13;
  2964. for (int i = 0; i < 2; i++)
  2965. {
  2966. var CopyRow = table.Rows[12].Clone(true);
  2967. table.Rows.RemoveAt(13);
  2968. table.Rows.Add(CopyRow);
  2969. rownewsIndex++;
  2970. }
  2971. }
  2972. else
  2973. {
  2974. table.Rows.RemoveAt(12);
  2975. }
  2976. cloneTable.Rows.RemoveAt(12);
  2977. }
  2978. if (_AirTicketReservations.Count != 0)
  2979. {
  2980. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2981. if (FlightsCode.Length != 0)
  2982. {
  2983. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2984. if (_AirCompany != null)
  2985. {
  2986. string str = "--";
  2987. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2988. if (!string.IsNullOrEmpty(translateResult))
  2989. {
  2990. str = translateResult;
  2991. str = _airTicketResRep.Processing(str);
  2992. }
  2993. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2994. }
  2995. else
  2996. {
  2997. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2998. }
  2999. }
  3000. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3001. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3002. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3003. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3004. string names = "";
  3005. foreach (string clientName in nameArray)
  3006. {
  3007. names += clientName + ",";
  3008. }
  3009. if (!string.IsNullOrWhiteSpace(names))
  3010. {
  3011. string str = "--";
  3012. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3013. if (!string.IsNullOrEmpty(translateResult))
  3014. {
  3015. str = translateResult;
  3016. str = _airTicketResRep.Processing(str);
  3017. }
  3018. table.Range.Bookmarks["ClientName"].Text = str;
  3019. }
  3020. else
  3021. {
  3022. table.Range.Bookmarks["ClientName"].Text = "--";
  3023. }
  3024. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3025. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3026. table.Range.Bookmarks["JointTicket"].Text = "--";
  3027. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3028. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3029. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3030. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3031. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3032. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3033. }
  3034. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3035. //保存合并后的文档
  3036. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3037. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3038. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3039. return Ok(JsonView(true, "成功!", rst));
  3040. }
  3041. }
  3042. }
  3043. catch (Exception ex)
  3044. {
  3045. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3046. throw;
  3047. }
  3048. }
  3049. #endregion
  3050. #region 团组增减款项 --> 其他款项
  3051. /// <summary>
  3052. /// 团组增减款项下拉框绑定
  3053. /// </summary>
  3054. /// <param name="dto"></param>
  3055. /// <returns></returns>
  3056. [HttpPost]
  3057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3058. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3059. {
  3060. #region 参数验证
  3061. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3062. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3063. #endregion
  3064. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3065. }
  3066. /// <summary>
  3067. /// 根据团组Id查询团组增减款项
  3068. /// </summary>
  3069. /// <param name="dto"></param>
  3070. /// <returns></returns>
  3071. [HttpPost]
  3072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3073. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3074. {
  3075. #region 参数验证
  3076. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3077. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3078. #endregion
  3079. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3080. }
  3081. /// <summary>
  3082. /// 团组增减款项操作(Status:1.新增,2.修改)
  3083. /// </summary>
  3084. /// <param name="dto"></param>
  3085. /// <returns></returns>
  3086. [HttpPost]
  3087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3088. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3089. {
  3090. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3091. if (groupData.Code != 200)
  3092. {
  3093. return Ok(JsonView(false, groupData.Msg));
  3094. }
  3095. #region 应用推送
  3096. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3097. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3098. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3099. #endregion
  3100. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3101. }
  3102. /// <summary>
  3103. /// 团组增减款项操作 删除
  3104. /// </summary>
  3105. /// <param name="dto"></param>
  3106. /// <returns></returns>
  3107. [HttpPost]
  3108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3109. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3110. {
  3111. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3112. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3113. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3114. if (res.Code == 0)
  3115. {
  3116. return Ok(JsonView(true, "删除成功!"));
  3117. }
  3118. return Ok(JsonView(false, "删除失败!"));
  3119. }
  3120. /// <summary>
  3121. /// 根据团组增减款项Id查询
  3122. /// </summary>
  3123. /// <param name="dto"></param>
  3124. /// <returns></returns>
  3125. [HttpPost]
  3126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3127. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3128. {
  3129. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3130. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3131. }
  3132. /// <summary>
  3133. /// 查询供应商名称
  3134. /// </summary>
  3135. /// <param name="dto"></param>
  3136. /// <returns></returns>
  3137. [HttpPost]
  3138. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3139. {
  3140. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3141. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3142. ?? new List<Grp_DecreasePayments>();
  3143. dbResult = dbResult.Distinct(new
  3144. ProductComparer()).ToList();
  3145. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3146. {
  3147. x.Id,
  3148. x.SupplierAddress,
  3149. x.SupplierArea,
  3150. x.SupplierContact,
  3151. x.SupplierContactNumber,
  3152. x.SupplierEmail,
  3153. x.SupplierName,
  3154. x.SupplierSocialAccount,
  3155. x.SupplierTypeId,
  3156. }).ToList());
  3157. return Ok(jw);
  3158. }
  3159. #endregion
  3160. #region 文件上传、删除
  3161. /// <summary>
  3162. /// region 文件上传 可以带参数
  3163. /// </summary>
  3164. /// <param name="file"></param>
  3165. /// <returns></returns>
  3166. [HttpPost]
  3167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3168. public async Task<IActionResult> UploadProject(IFormFile file)
  3169. {
  3170. //var TypeName = Request.Headers["TypeName"].ToString();
  3171. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3172. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3173. ////文件名称
  3174. //string projectFileName = file.FileName;
  3175. ////上传的文件的路径
  3176. //string filePath = $"{fileDir}/{projectFileName}";
  3177. //if (TypeName == "A")//A代表团组增减款项
  3178. //{
  3179. // filePath = fileDir + $@"\团组增减款项相关文件";
  3180. // if (!Directory.Exists(filePath))
  3181. // {
  3182. // Directory.CreateDirectory(filePath);
  3183. // }
  3184. // //上传的文件的路径
  3185. // filePath += $@"\{projectFileName}";
  3186. //}
  3187. //else if (TypeName == "B")//B代表商邀相关文件
  3188. //{
  3189. // //上传的文件的路径
  3190. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3191. // if (!Directory.Exists(filePath))
  3192. // {
  3193. // Directory.CreateDirectory(filePath);
  3194. // }
  3195. // //上传的文件的路径
  3196. // filePath = $@"\{projectFileName}";
  3197. //}
  3198. //try
  3199. //{
  3200. // using (FileStream fs = System.IO.File.Create(filePath))
  3201. // {
  3202. // file.CopyTo(fs);
  3203. // fs.Flush();
  3204. // }
  3205. //}
  3206. //catch (Exception ex)
  3207. //{
  3208. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3209. //}
  3210. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3211. try
  3212. {
  3213. var TypeName = Request.Headers["TypeName"].ToString();
  3214. if (file != null)
  3215. {
  3216. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3217. //文件名称
  3218. string projectFileName = file.FileName;
  3219. //上传的文件的路径
  3220. string filePath = $"{fileDir}/{projectFileName}";
  3221. if (TypeName == "A")//A代表团组增减款项
  3222. {
  3223. if (!Directory.Exists(fileDir))
  3224. {
  3225. Directory.CreateDirectory(fileDir);
  3226. }
  3227. //上传的文件的路径
  3228. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3229. }
  3230. else if (TypeName == "B")//B代表商邀相关文件
  3231. {
  3232. if (!Directory.Exists(fileDir))
  3233. {
  3234. Directory.CreateDirectory(fileDir);
  3235. }
  3236. //上传的文件的路径
  3237. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3238. }
  3239. using (FileStream fs = System.IO.File.Create(filePath))
  3240. {
  3241. file.CopyTo(fs);
  3242. fs.Flush();
  3243. }
  3244. return Ok(JsonView(true, "上传成功!", projectFileName));
  3245. }
  3246. else
  3247. {
  3248. return Ok(JsonView(false, "上传失败!"));
  3249. }
  3250. }
  3251. catch (Exception ex)
  3252. {
  3253. return Ok(JsonView(false, "程序错误!"));
  3254. }
  3255. }
  3256. /// <summary>
  3257. /// 删除指定文件
  3258. /// </summary>
  3259. /// <param name="dto"></param>
  3260. /// <returns></returns>
  3261. [HttpPost]
  3262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3263. public async Task<IActionResult> DelFile(DelFileDto dto)
  3264. {
  3265. try
  3266. {
  3267. var TypeName = Request.Headers["TypeName"].ToString();
  3268. string filePath = "";
  3269. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3270. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3271. int id = 0;
  3272. if (TypeName == "A")
  3273. {
  3274. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3275. // 删除该文件
  3276. System.IO.File.Delete(filePath);
  3277. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  3278. }
  3279. else if (TypeName == "B")
  3280. {
  3281. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3282. // 删除该文件
  3283. System.IO.File.Delete(filePath);
  3284. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  3285. }
  3286. if (id != 0)
  3287. {
  3288. return Ok(JsonView(true, "成功!"));
  3289. }
  3290. else
  3291. {
  3292. return Ok(JsonView(false, "失败!"));
  3293. }
  3294. }
  3295. catch (Exception ex)
  3296. {
  3297. return Ok(JsonView(false, "程序错误!"));
  3298. throw;
  3299. }
  3300. }
  3301. #endregion
  3302. #region 商邀费用录入
  3303. /// <summary>
  3304. /// 根据团组Id查询商邀费用列表
  3305. /// </summary>
  3306. /// <param name="dto"></param>
  3307. /// <returns></returns>
  3308. [HttpPost]
  3309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3310. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3311. {
  3312. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3313. if (groupData.Code != 0)
  3314. {
  3315. return Ok(JsonView(false, groupData.Msg));
  3316. }
  3317. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3318. }
  3319. //
  3320. /// <summary>
  3321. /// 商邀费用 Info Page 基础数据源
  3322. /// </summary>
  3323. /// <param name="dto"></param>
  3324. /// <returns></returns>
  3325. [HttpPost]
  3326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3327. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3328. {
  3329. try
  3330. {
  3331. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3332. if (groupData.Code != 0)
  3333. {
  3334. return Ok(JsonView(false, groupData.Msg));
  3335. }
  3336. return Ok(JsonView(true, "操作成功", groupData.Data));
  3337. }
  3338. catch (Exception ex)
  3339. {
  3340. return Ok(JsonView(false, ex.Message));
  3341. throw;
  3342. }
  3343. }
  3344. /// <summary>
  3345. /// 根据商邀费用ID查询C表和商邀费用数据
  3346. /// </summary>
  3347. /// <param name="dto"></param>
  3348. /// <returns></returns>
  3349. [HttpPost]
  3350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3351. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3352. {
  3353. try
  3354. {
  3355. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3356. if (groupData.Code != 0)
  3357. {
  3358. return Ok(JsonView(false, groupData.Msg));
  3359. }
  3360. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3361. }
  3362. catch (Exception ex)
  3363. {
  3364. return Ok(JsonView(false, ex.Message));
  3365. throw;
  3366. }
  3367. }
  3368. /// <summary>
  3369. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3370. /// </summary>
  3371. /// <param name="dto"></param>
  3372. /// <returns></returns>
  3373. [HttpPost]
  3374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3375. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3376. {
  3377. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3378. if (groupData.Code != 0)
  3379. {
  3380. return Ok(JsonView(false, groupData.Msg));
  3381. }
  3382. #region 应用推送
  3383. try
  3384. {
  3385. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3386. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3387. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3388. }
  3389. catch (Exception ex)
  3390. {
  3391. }
  3392. #endregion
  3393. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3394. }
  3395. /// <summary>
  3396. /// 商邀删除
  3397. /// </summary>
  3398. /// <param name="dto"></param>
  3399. /// <returns></returns>
  3400. [HttpPost]
  3401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3402. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3403. {
  3404. try
  3405. {
  3406. _sqlSugar.BeginTran();
  3407. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3408. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3409. {
  3410. IsDel = 1,
  3411. DeleteUserId = dto.DeleteUserId,
  3412. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3413. })
  3414. .Where(it => it.Id == dto.Id)
  3415. .ExecuteCommand();
  3416. if (res1 > 0)
  3417. {
  3418. int _diId = 0;
  3419. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3420. if (_ioaInfo != null)
  3421. {
  3422. _diId = _ioaInfo.DiId;
  3423. }
  3424. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3425. .SetColumns(a => new Grp_CreditCardPayment()
  3426. {
  3427. IsDel = 1,
  3428. DeleteUserId = dto.DeleteUserId,
  3429. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3430. })
  3431. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3432. .ExecuteCommand();
  3433. if (res2 > 0)
  3434. {
  3435. _sqlSugar.CommitTran();
  3436. return Ok(JsonView(true, "删除成功!"));
  3437. }
  3438. }
  3439. _sqlSugar.RollbackTran();
  3440. return Ok(JsonView(false, "删除失败"));
  3441. }
  3442. catch (Exception ex)
  3443. {
  3444. _sqlSugar.RollbackTran();
  3445. return Ok(JsonView(false, ex.Message));
  3446. }
  3447. }
  3448. /// <summary>
  3449. /// 团组模块文件上传
  3450. /// </summary>
  3451. /// <param name="dto"></param>
  3452. /// <returns></returns>
  3453. [HttpPost]
  3454. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3455. {
  3456. var jw = JsonView(false);
  3457. long M = 1024 * 1024;
  3458. if (dto.Files == null || dto.Files.Count == 0)
  3459. {
  3460. jw.Msg = "无文件信息!";
  3461. return Ok(jw);
  3462. }
  3463. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3464. {
  3465. jw.Msg = "文件大小超过20M!";
  3466. return Ok(jw);
  3467. }
  3468. //var nameSp = dto.File.FileName.Split(".");
  3469. //if (nameSp.Length < 2)
  3470. //{
  3471. // jw.Msg = "拓展名称有误!";
  3472. // return Ok(jw);
  3473. //}
  3474. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3475. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3476. //{
  3477. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3478. // return Ok(jw);
  3479. //}
  3480. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3481. if (Ctable == null)
  3482. {
  3483. jw.Msg = "Ctable指向有误!";
  3484. return Ok(jw);
  3485. }
  3486. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3487. if (groupInfo == null)
  3488. {
  3489. jw.Msg = "团组信息不存在!";
  3490. return Ok(jw);
  3491. }
  3492. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3493. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3494. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3495. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3496. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3497. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3498. try
  3499. {
  3500. if (!Directory.Exists(fileBase))
  3501. {
  3502. Directory.CreateDirectory(fileBase);
  3503. }
  3504. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3505. foreach (var fileStream in dto.Files)
  3506. {
  3507. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3508. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3509. {
  3510. Cid = dto.Cid,
  3511. CreateTime = DateTime.Now,
  3512. CreateUserId = dto.Userid,
  3513. Ctable = dto.Ctable,
  3514. Diid = dto.Diid,
  3515. IsDel = 0,
  3516. FilePath = saveFilePath,
  3517. FileName = fileStream.FileName
  3518. };
  3519. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3520. {
  3521. fileStream.CopyTo(fs);
  3522. fs.Flush();
  3523. }
  3524. saveArr.Add(file);
  3525. }
  3526. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3527. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3528. jw = JsonView(true, "保存成功!", new
  3529. {
  3530. count = addResult,
  3531. filesName = saveArr.Select(x => x.FileName)
  3532. }) ;
  3533. }
  3534. catch (Exception ex)
  3535. {
  3536. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3537. {
  3538. count = 0,
  3539. filesName = new string[0],
  3540. }) ;
  3541. }
  3542. return Ok(jw);
  3543. }
  3544. /// <summary>
  3545. /// 查询各模块已保存文件
  3546. /// </summary>
  3547. /// <param name="dto"></param>
  3548. /// <returns></returns>
  3549. [HttpPost]
  3550. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3551. {
  3552. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3553. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3554. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3555. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3556. {
  3557. expression = Expressionable.Create<Grp_GroupModelFile>()
  3558. .And(x=>visaIds.Contains(x.CreateUserId));
  3559. }
  3560. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3561. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3562. .Where(expression.ToExpression())
  3563. .ToList();
  3564. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3565. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3566. {
  3567. x.FileName,
  3568. x.Id,
  3569. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3570. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3571. })));
  3572. }
  3573. /// <summary>
  3574. /// 下载该团组下的所有文件
  3575. /// </summary>
  3576. /// <param name="dto"></param>
  3577. /// <returns></returns>
  3578. [HttpPost]
  3579. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3580. {
  3581. var jw = JsonView(false);
  3582. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3583. if (groupInfo == null)
  3584. {
  3585. jw.Msg = "团组信息不存在!";
  3586. return Ok(jw);
  3587. }
  3588. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3589. var isModule = Convert.ToBoolean(dto.isModule);
  3590. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3591. IOOperatorHelper io = new IOOperatorHelper();
  3592. if (isModule)
  3593. {
  3594. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3595. foreach (var moduleArr in moduleGroup)
  3596. {
  3597. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3598. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3599. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3600. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3601. foreach (var item in moduleArr)
  3602. {
  3603. if (System.IO.File.Exists(item.FilePath))
  3604. {
  3605. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3606. {
  3607. byte[] bytes = new byte[fileStream.Length];
  3608. fileStream.Read(bytes, 0, bytes.Length);
  3609. fileStream.Close();
  3610. Stream stream = new MemoryStream(bytes);
  3611. chiZips.Add(item.FileName, stream);
  3612. }
  3613. }
  3614. }
  3615. if (chiZips.Count > 0)
  3616. {
  3617. var byts = io.ConvertZipStream(chiZips);
  3618. Stream stream = new MemoryStream(byts);
  3619. Zips.Add(key.Name+"_.zip", stream);
  3620. }
  3621. }
  3622. }
  3623. else
  3624. {
  3625. foreach (var item in dbQuery)
  3626. {
  3627. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3628. {
  3629. byte[] bytes = new byte[fileStream.Length];
  3630. fileStream.Read(bytes, 0, bytes.Length);
  3631. fileStream.Close();
  3632. Stream stream = new MemoryStream(bytes);
  3633. while (Zips.Keys.Contains(item.FileName))
  3634. {
  3635. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3636. }
  3637. Zips.Add(item.FileName, stream);
  3638. }
  3639. }
  3640. }
  3641. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3642. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3643. if (Zips.Count > 0)
  3644. {
  3645. var byts = io.ConvertZipStream(Zips);
  3646. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3647. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3648. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3649. }
  3650. else
  3651. {
  3652. jw.Msg = "暂无生成文件!";
  3653. }
  3654. return Ok(jw);
  3655. }
  3656. /// <summary>
  3657. /// 下载该团组下此模块的所有文件
  3658. /// </summary>
  3659. /// <param name="dto"></param>
  3660. /// <returns></returns>
  3661. [HttpPost]
  3662. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3663. {
  3664. var jw = JsonView(false);
  3665. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3666. if (groupInfo == null)
  3667. {
  3668. jw.Msg = "团组信息不存在!";
  3669. return Ok(jw);
  3670. }
  3671. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3672. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3673. && x.IsDel == 0);
  3674. if (key == null)
  3675. {
  3676. jw.Msg = "Ctable指向错误!";
  3677. return Ok(jw);
  3678. }
  3679. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3680. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3681. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3682. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3683. IOOperatorHelper io = new IOOperatorHelper();
  3684. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3685. foreach (var item in dbQuery)
  3686. {
  3687. if (System.IO.File.Exists(item.FilePath))
  3688. {
  3689. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3690. {
  3691. byte[] bytes = new byte[fileStream.Length];
  3692. fileStream.Read(bytes, 0, bytes.Length);
  3693. fileStream.Close();
  3694. Stream stream = new MemoryStream(bytes);
  3695. while (Zips.Keys.Contains(item.FileName))
  3696. {
  3697. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3698. }
  3699. Zips.Add(item.FileName, stream);
  3700. }
  3701. }
  3702. }
  3703. if (Zips.Count > 0)
  3704. {
  3705. var byts = io.ConvertZipStream(Zips);
  3706. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3707. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3708. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3709. }
  3710. else
  3711. {
  3712. jw.Msg = "暂无生成文件!";
  3713. }
  3714. return Ok(jw);
  3715. }
  3716. /// <summary>
  3717. /// 删除该团组下的指定文件
  3718. /// </summary>
  3719. /// <param name="dto"></param>
  3720. /// <returns></returns>
  3721. [HttpPost]
  3722. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3723. {
  3724. var jw = JsonView(false);
  3725. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3726. if (sing == null)
  3727. {
  3728. jw.Msg = "暂无";
  3729. return Ok(jw);
  3730. }
  3731. if (System.IO.File.Exists(sing.FilePath))
  3732. {
  3733. try
  3734. {
  3735. System.IO.File.Delete(sing.FilePath);
  3736. }
  3737. catch (Exception ex)
  3738. {
  3739. jw.Msg = "删除失败!" + ex.Message;
  3740. return Ok(jw);
  3741. }
  3742. }
  3743. sing.IsDel = 1;
  3744. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3745. sing.DeleteUserId = dto.UserId;
  3746. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3747. jw = JsonView(true, "删除成功!");
  3748. return Ok(jw);
  3749. }
  3750. #endregion
  3751. #region 团组英文资料
  3752. /// <summary>
  3753. /// 查询团组英文所有资料
  3754. /// </summary>
  3755. /// <param name="dto"></param>
  3756. /// <returns></returns>
  3757. [HttpPost]
  3758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3759. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3760. {
  3761. try
  3762. {
  3763. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3764. if (groupData.Code != 0)
  3765. {
  3766. return Ok(JsonView(false, groupData.Msg));
  3767. }
  3768. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3769. }
  3770. catch (Exception ex)
  3771. {
  3772. return Ok(JsonView(false, "程序错误!"));
  3773. throw;
  3774. }
  3775. }
  3776. /// <summary>
  3777. /// 团组英文资料操作(Status:1.新增,2.修改)
  3778. /// </summary>
  3779. /// <param name="dto"></param>
  3780. /// <returns></returns>
  3781. [HttpPost]
  3782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3783. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3784. {
  3785. try
  3786. {
  3787. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3788. if (groupData.Code != 0)
  3789. {
  3790. return Ok(JsonView(false, groupData.Msg));
  3791. }
  3792. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3793. }
  3794. catch (Exception ex)
  3795. {
  3796. return Ok(JsonView(false, "程序错误!"));
  3797. throw;
  3798. }
  3799. }
  3800. /// <summary>
  3801. /// 团组英文资料Id查询数据
  3802. /// </summary>
  3803. /// <param name="dto"></param>
  3804. /// <returns></returns>
  3805. [HttpPost]
  3806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3807. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3808. {
  3809. try
  3810. {
  3811. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3812. if (_DelegationEnData != null)
  3813. {
  3814. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3815. }
  3816. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3817. }
  3818. catch (Exception ex)
  3819. {
  3820. return Ok(JsonView(false, "程序错误!"));
  3821. throw;
  3822. }
  3823. }
  3824. /// <summary>
  3825. /// 团组英文资料删除
  3826. /// </summary>
  3827. /// <param name="dto"></param>
  3828. /// <returns></returns>
  3829. [HttpPost]
  3830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3831. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3832. {
  3833. try
  3834. {
  3835. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3836. if (!res)
  3837. {
  3838. return Ok(JsonView(false, "删除失败"));
  3839. }
  3840. return Ok(JsonView(true, "删除成功!"));
  3841. }
  3842. catch (Exception ex)
  3843. {
  3844. return Ok(JsonView(false, "程序错误!"));
  3845. throw;
  3846. }
  3847. }
  3848. #endregion
  3849. #region 导出邀请函
  3850. /// <summary>
  3851. /// 导出邀请函页面初始化
  3852. /// </summary>
  3853. /// <param name="dto"></param>
  3854. /// <returns></returns>
  3855. [HttpPost]
  3856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3857. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3858. {
  3859. try
  3860. {
  3861. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3862. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3863. if (dto.DiId == 0)
  3864. {
  3865. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3866. }
  3867. else
  3868. {
  3869. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3870. }
  3871. return Ok(JsonView(true, "查询成功!", new
  3872. {
  3873. deleClient = crm_Deles,
  3874. delegations = grp_Delegations
  3875. }));
  3876. }
  3877. catch (Exception ex)
  3878. {
  3879. return Ok(JsonView(false, "程序错误!"));
  3880. throw;
  3881. }
  3882. }
  3883. /// <summary>
  3884. /// 导出邀请函
  3885. /// </summary>
  3886. /// <param name="dto"></param>
  3887. /// <returns></returns>
  3888. [HttpPost]
  3889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3890. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3891. {
  3892. #region 参数验证
  3893. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3894. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3895. #endregion
  3896. try
  3897. {
  3898. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3899. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3900. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3901. From Grp_TourClientList tcl
  3902. Left Join
  3903. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3904. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3905. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3906. From Crm_DeleClient dc
  3907. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3908. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3909. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3910. Where dc.IsDel = 0) temp
  3911. On temp.DcId =tcl.ClientId
  3912. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3913. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3914. List<string> texts = new List<string>();
  3915. if (datas.Count != 0)
  3916. {
  3917. foreach (TourClientListDetailsView item in datas)
  3918. {
  3919. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3920. {
  3921. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3922. }
  3923. else
  3924. {
  3925. string name = item.LastName + item.FirstName;
  3926. texts.Add(name);
  3927. }
  3928. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3929. {
  3930. if (!transDic.ContainsKey(item.Job))
  3931. {
  3932. texts.Add(item.Job);
  3933. }
  3934. }
  3935. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3936. {
  3937. texts.Add(item.CompanyFullName);
  3938. }
  3939. }
  3940. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3941. if (transData.Count > 0)
  3942. {
  3943. foreach (TranslateResult item in transData)
  3944. {
  3945. if (!transDic.ContainsKey(item.Query))
  3946. {
  3947. transDic.Add(item.Query, item.Translation);
  3948. }
  3949. }
  3950. }
  3951. List<GuestList> list = new List<GuestList>();
  3952. foreach (TourClientListDetailsView dele in datas)
  3953. {
  3954. GuestList guestList = new GuestList();
  3955. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3956. {
  3957. guestList.Name = dele.Pinyin;
  3958. }
  3959. else
  3960. {
  3961. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3962. guestList.Name = Name;
  3963. }
  3964. if (dele.Sex == 0)
  3965. {
  3966. guestList.Sex = "Male";
  3967. }
  3968. else if (dele.Sex == 1)
  3969. {
  3970. guestList.Sex = "Female";
  3971. }
  3972. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3973. if (!string.IsNullOrEmpty(dele.Job))
  3974. {
  3975. guestList.Job = dele.Job;
  3976. }
  3977. list.Add(guestList);
  3978. }
  3979. //载入模板
  3980. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3981. DocumentBuilder builder = new DocumentBuilder(doc);
  3982. //获取word里所有表格
  3983. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3984. //获取所填表格的序数
  3985. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3986. var rowStart = tableOne.Rows[0]; //获取第1行
  3987. //循环赋值
  3988. for (int i = 0; i < list.Count; i++)
  3989. {
  3990. builder.MoveToCell(0, i + 1, 0, 0);
  3991. builder.Write(list[i].Name.ToString());
  3992. builder.MoveToCell(0, i + 1, 1, 0);
  3993. builder.Write(list[i].Sex.ToString());
  3994. builder.MoveToCell(0, i + 1, 2, 0);
  3995. builder.Write(list[i].DOB.ToString());
  3996. builder.MoveToCell(0, i + 1, 3, 0);
  3997. builder.Write(list[i].Job.ToString());
  3998. }
  3999. //删除多余行
  4000. while (tableOne.Rows.Count > list.Count + 1)
  4001. {
  4002. tableOne.Rows.RemoveAt(list.Count + 1);
  4003. }
  4004. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4005. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4006. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4007. doc.Save(filePath);
  4008. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4009. return Ok(JsonView(true, "操作成功!", Url));
  4010. }
  4011. else
  4012. {
  4013. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4014. }
  4015. }
  4016. catch (Exception ex)
  4017. {
  4018. return Ok(JsonView(false, ex.Message));
  4019. throw;
  4020. }
  4021. }
  4022. #endregion
  4023. #region 团组经理模块 出入境费用
  4024. ///// <summary>
  4025. ///// 团组模块 - 出入境费用
  4026. ///// </summary>
  4027. ///// <returns></returns>
  4028. //[HttpPost]
  4029. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4030. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4031. //{
  4032. // try
  4033. // {
  4034. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4035. // if (data.Code != 0)
  4036. // {
  4037. // return Ok(JsonView(false, data.Msg));
  4038. // }
  4039. // return Ok(JsonView(true, "查询成功!"));
  4040. // }
  4041. // catch (Exception ex)
  4042. // {
  4043. // return Ok(JsonView(false, ex.Message));
  4044. // throw;
  4045. // }
  4046. //}
  4047. /// <summary>
  4048. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4049. /// </summary>
  4050. /// <returns></returns>
  4051. [HttpPost]
  4052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4053. public async Task<IActionResult> SetDayAndCostAreaChange()
  4054. {
  4055. try
  4056. {
  4057. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4058. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4059. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4060. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4061. foreach (var item in unite) //处理交集数据
  4062. {
  4063. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4064. }
  4065. foreach (var item in merge) //处理差集数据
  4066. {
  4067. int nationalTravelFeeId = 0;
  4068. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4069. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4070. else
  4071. {
  4072. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4073. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4074. }
  4075. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4076. }
  4077. //只更新dayAndCost 的 nationalTravelFeeId;
  4078. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4079. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4080. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4081. }
  4082. catch (Exception ex)
  4083. {
  4084. return Ok(JsonView(false, ex.Message));
  4085. throw;
  4086. }
  4087. }
  4088. /// <summary>
  4089. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4090. /// </summary>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4094. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4095. {
  4096. try
  4097. {
  4098. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4099. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4100. //SetDataInfoView
  4101. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4102. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4103. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4104. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4105. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4106. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4107. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4108. //默认币种显示
  4109. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4110. {
  4111. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4112. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4113. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4114. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4115. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4116. };
  4117. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4118. if (_currencyRate.Count > 0)
  4119. {
  4120. foreach (var item in _currencyInfos)
  4121. {
  4122. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4123. if (rateInfo != null)
  4124. {
  4125. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4126. rate1 *= 1.035M;
  4127. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4128. }
  4129. }
  4130. }
  4131. return Ok(JsonView(true, "查询成功!", new
  4132. {
  4133. GroupNameData = groupNameData.Data,
  4134. CurrencyData = _CurrencyData,
  4135. WordTypeData = _WordTypeData,
  4136. ExcelTypeData = _ExcelTypeData,
  4137. CurrencyInit = _currencyInfos
  4138. }));
  4139. }
  4140. catch (Exception ex)
  4141. {
  4142. return Ok(JsonView(false, ex.Message));
  4143. throw;
  4144. }
  4145. }
  4146. /// <summary>
  4147. /// 团组模块 - 出入境费用
  4148. /// 实时汇率 tips
  4149. /// 签证费用 tips
  4150. /// </summary>
  4151. /// <returns></returns>
  4152. [HttpPost]
  4153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4154. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4155. {
  4156. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4157. //默认币种显示
  4158. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4159. {
  4160. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4161. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4162. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4163. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4164. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4165. };
  4166. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4167. List<dynamic> reteInfos = new List<dynamic>();
  4168. if (_currencyRate.Count > 0)
  4169. {
  4170. foreach (var item in _currencyInfos)
  4171. {
  4172. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4173. if (rateInfo != null)
  4174. {
  4175. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4176. decimal rate1 = item.Rate;
  4177. rate1 *= 1.03M;
  4178. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4179. reteInfos.Add(new
  4180. {
  4181. currCode = item.CurrencyCode,
  4182. currName = item.CurrencyName,
  4183. rate = rate2,
  4184. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4185. });
  4186. }
  4187. }
  4188. }
  4189. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4190. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4191. return Ok(JsonView(true, "查询成功!", new
  4192. {
  4193. //GroupNameData = groupNameData.Data,
  4194. visaData = visaData.Data,
  4195. airData = airData.Data,
  4196. reteInfos = reteInfos
  4197. }));
  4198. }
  4199. /// <summary>
  4200. /// 团组模块 - 出入境费用 - Info
  4201. /// </summary>
  4202. /// <returns></returns>
  4203. [HttpPost]
  4204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4205. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4206. {
  4207. try
  4208. {
  4209. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4210. if (data.Code != 0)
  4211. {
  4212. return Ok(JsonView(false, data.Msg));
  4213. }
  4214. return Ok(JsonView(true, "查询成功!", data.Data));
  4215. }
  4216. catch (Exception ex)
  4217. {
  4218. return Ok(JsonView(false, ex.Message));
  4219. }
  4220. }
  4221. /// <summary>
  4222. /// 团组模块 - 出入境费用 - Add And Update
  4223. /// </summary>
  4224. /// <returns></returns>
  4225. [HttpPost]
  4226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4227. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4228. {
  4229. try
  4230. {
  4231. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4232. if (data.Code != 0)
  4233. {
  4234. return Ok(JsonView(false, data.Msg));
  4235. }
  4236. //生成默认文件pdf并且通知人员
  4237. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4238. {
  4239. DiId = dto.DiId,
  4240. ExportType = 1,
  4241. SubTypeId = 1005
  4242. }, "pdf");
  4243. //发送通知
  4244. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4245. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4246. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4247. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  4248. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  4249. return Ok(JsonView(true, data.Msg, data.Data));
  4250. }
  4251. catch (Exception ex)
  4252. {
  4253. return Ok(JsonView(false, ex.Message));
  4254. }
  4255. }
  4256. /// <summary>
  4257. /// 团组模块 - 出入境费用 - Confirm 费用
  4258. /// </summary>
  4259. /// <returns></returns>
  4260. [HttpPost]
  4261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4262. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4263. {
  4264. //TODO:测试完毕需把对应的用户ID更改
  4265. //1、数据表添加字段
  4266. //2、更改字段接口()
  4267. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4268. //3、确认成功 给财务发送消息
  4269. if (_view.Code == 200)
  4270. {
  4271. if (dto.Type == 1)
  4272. {
  4273. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4274. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4275. }
  4276. }
  4277. return Ok(_view);
  4278. }
  4279. /// <summary>
  4280. /// 团组模块 - 出入境费用 - File downlaod
  4281. /// </summary>
  4282. /// <param name="dto"></param>
  4283. /// <returns></returns>
  4284. [HttpPost]
  4285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4286. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4287. {
  4288. try
  4289. {
  4290. if (dto.DiId < 1)
  4291. {
  4292. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4293. }
  4294. if (dto.ExportType < 1)
  4295. {
  4296. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4297. }
  4298. if (dto.SubTypeId < 1)
  4299. {
  4300. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4301. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4302. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4303. 3 团组成员名单 1 团组成员名单"));
  4304. }
  4305. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4306. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4307. if (_EnterExitCosts == null)
  4308. {
  4309. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4310. }
  4311. //数据源
  4312. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4313. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4314. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4315. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4316. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4317. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4318. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4319. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4320. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4321. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4322. .Select((tcl, dc, cc) => new
  4323. {
  4324. Name = dc.LastName + dc.FirstName,
  4325. Sex = dc.Sex,
  4326. Birthday = dc.BirthDay,
  4327. Company = cc.CompanyFullName,
  4328. Job = dc.Job
  4329. })
  4330. .ToList();
  4331. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4332. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4333. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4334. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4335. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4336. if (dto.ExportType == 1) //明细表
  4337. {
  4338. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4339. {
  4340. //获取模板
  4341. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4342. //载入模板
  4343. Document doc = new Document(tempPath);
  4344. DocumentBuilder builder = new DocumentBuilder(doc);
  4345. //利用键值对存放数据
  4346. Dictionary<string, string> dic = new Dictionary<string, string>();
  4347. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4348. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4349. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4350. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4351. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4352. //境内费用(其他费用)
  4353. if (_EnterExitCosts.ChoiceOne == 1)
  4354. {
  4355. string row1_1 = "";
  4356. if (_EnterExitCosts.Visa > 0)
  4357. {
  4358. //insidePayTotal += _EnterExitCosts.Visa;
  4359. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4360. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4361. {
  4362. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4363. }
  4364. }
  4365. string row1_2 = "";
  4366. if (_EnterExitCosts.YiMiao > 0)
  4367. {
  4368. //insidePayTotal += _EnterExitCosts.YiMiao;
  4369. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4370. }
  4371. if (_EnterExitCosts.HeSuan > 0)
  4372. {
  4373. //insidePayTotal += _EnterExitCosts.HeSuan;
  4374. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4375. }
  4376. if (_EnterExitCosts.Service > 0)
  4377. {
  4378. //insidePayTotal += _EnterExitCosts.Service;
  4379. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4380. }
  4381. string row1_3 = "";
  4382. if (_EnterExitCosts.Safe > 0)
  4383. {
  4384. //insidePayTotal += _EnterExitCosts.Safe;
  4385. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4386. }
  4387. if (_EnterExitCosts.Ticket > 0)
  4388. {
  4389. //insidePayTotal += _EnterExitCosts.Ticket;
  4390. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4391. }
  4392. string row1 = "";
  4393. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4394. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4395. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4396. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4397. dic.Add("Row1Str", row1);
  4398. }
  4399. string airTotalStr = string.Empty,
  4400. airPriceStr = string.Empty;
  4401. //经济舱
  4402. if (_EnterExitCosts.SumJJC == 1)
  4403. {
  4404. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4405. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4406. }
  4407. //公务舱
  4408. if (_EnterExitCosts.SumGWC == 1)
  4409. {
  4410. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4411. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4412. }
  4413. //头等舱
  4414. if (_EnterExitCosts.SumTDC == 1)
  4415. {
  4416. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4417. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4418. }
  4419. dic.Add("AirTotalStr", airTotalStr);
  4420. dic.Add("AirPriceStr", airPriceStr);
  4421. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4422. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4423. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4424. int table1Row = 0,
  4425. table2Row = 0,
  4426. table3Row = 0,
  4427. table4Row = 0;
  4428. //住宿费
  4429. if (_EnterExitCosts.ChoiceThree == 1)
  4430. {
  4431. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4432. table1Row = dac1.Count;
  4433. #region 填充word表格内容
  4434. for (int i = 0; i < dac1.Count; i++)
  4435. {
  4436. Grp_DayAndCost dac = dac1[i];
  4437. if (dac == null) continue;
  4438. builder.MoveToCell(0, i, 0, 0);
  4439. builder.Write("第" + dac.Days.ToString() + "晚:");
  4440. builder.MoveToCell(0, i, 1, 0);
  4441. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4442. //builder.Write(dac.Place == null ? "" : dac.Place);
  4443. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4444. builder.MoveToCell(0, i, 2, 0);
  4445. builder.Write("费用标准:");
  4446. string curr = "";
  4447. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4448. if (currData != null)
  4449. {
  4450. curr = currData.Name;
  4451. }
  4452. builder.MoveToCell(0, i, 3, 0);
  4453. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4454. builder.MoveToCell(0, i, 4, 0);
  4455. builder.Write("费用小计:");
  4456. builder.MoveToCell(0, i, 5, 0);
  4457. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4458. }
  4459. #endregion
  4460. }else dic.Add("SubZS","0.00");
  4461. //删除多余行
  4462. while (table1.Rows.Count > table1Row)
  4463. {
  4464. table1.Rows.RemoveAt(table1Row);
  4465. }
  4466. //伙食费
  4467. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4468. if (_EnterExitCosts.ChoiceFour == 1)
  4469. {
  4470. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4471. table2Row = dac2.Count;
  4472. #region 填充word表格内容
  4473. for (int i = 0; i < dac2.Count; i++)
  4474. {
  4475. Grp_DayAndCost dac = dac2[i];
  4476. if (dac == null) continue;
  4477. builder.MoveToCell(1, i, 0, 0);
  4478. builder.Write("第" + dac.Days.ToString() + "天:");
  4479. builder.MoveToCell(1, i, 1, 0);
  4480. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4481. builder.MoveToCell(1, i, 2, 0);
  4482. builder.Write("费用标准:");
  4483. string curr = "";
  4484. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4485. if (currData != null)
  4486. {
  4487. curr = currData.Name;
  4488. }
  4489. builder.MoveToCell(1, i, 3, 0);
  4490. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4491. builder.MoveToCell(1, i, 4, 0);
  4492. builder.Write("费用小计:");
  4493. builder.MoveToCell(1, i, 5, 0);
  4494. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4495. }
  4496. #endregion
  4497. }else dic.Add("SubHS","0.00");
  4498. //删除多余行
  4499. while (table2.Rows.Count > table2Row)
  4500. {
  4501. table2.Rows.RemoveAt(table2Row);
  4502. }
  4503. //公杂费
  4504. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4505. if (_EnterExitCosts.ChoiceFive == 1)
  4506. {
  4507. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4508. table3Row = dac3.Count;
  4509. #region 填充word表格内容
  4510. for (int i = 0; i < dac3.Count; i++)
  4511. {
  4512. Grp_DayAndCost dac = dac3[i];
  4513. if (dac == null) continue;
  4514. builder.MoveToCell(2, i, 0, 0);
  4515. builder.Write("第" + dac.Days.ToString() + "天:");
  4516. builder.MoveToCell(2, i, 1, 0);
  4517. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4518. builder.MoveToCell(2, i, 2, 0);
  4519. builder.Write("费用标准:");
  4520. string curr = "";
  4521. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4522. if (currData != null)
  4523. {
  4524. curr = currData.Name;
  4525. }
  4526. builder.MoveToCell(2, i, 3, 0);
  4527. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4528. builder.MoveToCell(2, i, 4, 0);
  4529. builder.Write("费用小计:");
  4530. builder.MoveToCell(2, i, 5, 0);
  4531. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4532. }
  4533. //删除多余行
  4534. while (table3.Rows.Count > table3Row)
  4535. {
  4536. table3.Rows.RemoveAt(table3Row);
  4537. }
  4538. #endregion
  4539. }else dic.Add("SubGZF", "0.00");
  4540. //删除多余行
  4541. while (table3.Rows.Count > table3Row)
  4542. {
  4543. table3.Rows.RemoveAt(table3Row);
  4544. }
  4545. //培训费
  4546. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4547. if (_EnterExitCosts.ChoiceSix == 1)
  4548. {
  4549. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4550. dic.Add("SubPX", pxStr);
  4551. table4Row = dac4.Count;
  4552. #region 填充word表格内容
  4553. for (int i = 0; i < dac4.Count; i++)
  4554. {
  4555. Grp_DayAndCost dac = dac4[i];
  4556. if (dac == null) continue;
  4557. builder.MoveToCell(3, i, 0, 0);
  4558. builder.Write("第" + dac.Days.ToString() + "天:");
  4559. builder.MoveToCell(3, i, 1, 0);
  4560. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4561. builder.MoveToCell(3, i, 2, 0);
  4562. builder.Write("费用标准:");
  4563. string curr = "";
  4564. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4565. if (currData != null)
  4566. {
  4567. curr = currData.Name;
  4568. }
  4569. builder.MoveToCell(3, i, 3, 0);
  4570. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4571. builder.MoveToCell(3, i, 4, 0);
  4572. builder.Write("费用小计:");
  4573. builder.MoveToCell(3, i, 5, 0);
  4574. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4575. }
  4576. #endregion
  4577. }
  4578. //else dic.Add("SubPX","0.00");
  4579. //删除多余行
  4580. while (table4.Rows.Count > table4Row)
  4581. {
  4582. table4.Rows.RemoveAt(table4Row);
  4583. }
  4584. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4585. decimal subJJC = 0.00M,
  4586. subGWC = 0.00M,
  4587. subTDC = 0.00M;
  4588. //经济舱
  4589. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4590. //公务舱
  4591. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4592. //头等舱
  4593. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4594. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4595. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4596. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4597. #region 填充word模板书签内容
  4598. foreach (var key in dic.Keys)
  4599. {
  4600. builder.MoveToBookmark(key);
  4601. builder.Write(dic[key]);
  4602. }
  4603. #endregion
  4604. //文件名
  4605. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4606. AsposeHelper.removewatermark_v2180();
  4607. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4608. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4609. return Ok(JsonView(true, "成功", new { Url = url }));
  4610. }
  4611. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4612. {
  4613. //获取模板
  4614. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4615. //载入模板
  4616. Document doc = new Document(tempPath);
  4617. DocumentBuilder builder = new DocumentBuilder(doc);
  4618. Dictionary<string, string> dic = new Dictionary<string, string>();
  4619. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4620. {
  4621. List<string> list = new List<string>();
  4622. try
  4623. {
  4624. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4625. foreach (var item in spilitArr)
  4626. {
  4627. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4628. var depCode = spDotandEmpty[2].Substring(0, 3);
  4629. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4630. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4631. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4632. list.Add(depName);
  4633. list.Add(arrName);
  4634. }
  4635. list = list.Distinct().ToList();
  4636. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4637. }
  4638. catch (Exception)
  4639. {
  4640. dic.Add("ReturnCode", "行程录入不正确!");
  4641. }
  4642. }
  4643. else
  4644. {
  4645. dic.Add("ReturnCode", "未录入行程!");
  4646. }
  4647. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4648. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4649. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4650. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4651. {
  4652. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4653. dic.Add("Day", sp.Days.ToString());
  4654. }
  4655. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4656. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4657. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4658. //dic.Add("Names", Names);
  4659. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4660. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4661. decimal dac1totalPrice = 0.00M;
  4662. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4663. foreach (var dac in dac1)
  4664. {
  4665. if (dac.SubTotal == 0.00M)
  4666. {
  4667. continue;
  4668. }
  4669. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4670. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4671. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4672. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4673. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4674. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4675. builder.Write(currency);//币种
  4676. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4677. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4678. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4679. builder.Write("");//人数
  4680. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4681. builder.Write("");//天数
  4682. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4683. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4684. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4685. decimal rate = 0.00M;
  4686. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4687. builder.Write(rate.ToString("#0.0000"));//汇率
  4688. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4689. decimal rbmPrice = dac.SubTotal;
  4690. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4691. accommodationStartIndex++;
  4692. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4693. }
  4694. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4695. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4696. {
  4697. table1.Rows.RemoveAt(i - 1);
  4698. foodandotherStartIndex--;
  4699. }
  4700. if (dac2.Count == dac3.Count)//国家 币种 金额
  4701. {
  4702. for (int i = 0; i < dac2.Count; i++)
  4703. {
  4704. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4705. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4706. }
  4707. }
  4708. decimal dac2totalPrice = 0.00M;
  4709. foreach (var dac in dac2)
  4710. {
  4711. if (dac.SubTotal == 0)
  4712. {
  4713. continue;
  4714. }
  4715. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4716. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4717. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4718. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4719. builder.Write(currency);//币种
  4720. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4721. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4722. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4723. builder.Write("");//人数
  4724. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4725. builder.Write("");//天数
  4726. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4727. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4728. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4729. decimal rate = 0.00M;
  4730. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4731. builder.Write(rate.ToString("#0.0000"));//汇率
  4732. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4733. decimal rbmPrice = dac.SubTotal;
  4734. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4735. foodandotherStartIndex++;
  4736. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4737. }
  4738. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4739. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4740. {
  4741. table1.Rows.RemoveAt(i - 1);
  4742. }
  4743. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4744. string otherFeeStr = "";
  4745. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4746. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4747. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4748. if (otherFeeStr.Length > 0)
  4749. {
  4750. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4751. otherFeeStr = $"({otherFeeStr})";
  4752. dic.Add("OtherFeeStr", otherFeeStr);
  4753. }
  4754. //总计
  4755. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4756. //国际旅费
  4757. string outsideAir = string.Empty;
  4758. string allPriceAir = string.Empty;
  4759. if (_EnterExitCosts.SumJJC == 1)
  4760. {
  4761. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4762. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4763. }
  4764. if (_EnterExitCosts.SumGWC == 1)
  4765. {
  4766. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4767. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4768. }
  4769. if (_EnterExitCosts.SumTDC == 1)
  4770. {
  4771. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4772. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4773. }
  4774. dic.Add("InTravelPrice", $"({outsideAir})");
  4775. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4776. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4777. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4778. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4779. foreach (var key in dic.Keys)
  4780. {
  4781. builder.MoveToBookmark(key);
  4782. builder.Write(dic[key]);
  4783. }
  4784. //模板文件名
  4785. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4786. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4787. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4788. return Ok(JsonView(true, "成功", new { Url = url }));
  4789. }
  4790. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4791. {
  4792. //获取模板
  4793. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4794. //载入模板
  4795. WorkbookDesigner designer = new WorkbookDesigner();
  4796. designer.Workbook = new Workbook(tempPath);
  4797. Dictionary<string, string> dic = new Dictionary<string, string>();
  4798. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4799. {
  4800. List<string> list = new List<string>();
  4801. try
  4802. {
  4803. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4804. foreach (var item in spilitArr)
  4805. {
  4806. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4807. var depCode = spDotandEmpty[2].Substring(0, 3);
  4808. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4809. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4810. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4811. list.Add(depName);
  4812. list.Add(arrName);
  4813. }
  4814. list = list.Distinct().ToList();
  4815. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4816. }
  4817. catch (Exception)
  4818. {
  4819. dic.Add("ReturnCode", "行程录入不正确!");
  4820. }
  4821. }
  4822. else
  4823. {
  4824. dic.Add("ReturnCode", "未录入行程!");
  4825. }
  4826. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4827. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4828. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4829. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4830. {
  4831. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4832. dic.Add("Day", sp.Days.ToString());
  4833. }
  4834. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4835. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4836. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4837. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4838. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4839. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4840. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4841. designer.SetDataSource("Name", Names);
  4842. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4843. designer.SetDataSource("Day", dic["Day"] + "天");
  4844. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4845. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4846. int startIndex = 10;
  4847. const int startIndexcopy = 10;
  4848. if (dac2.Count == dac3.Count)//国家 币种 金额
  4849. {
  4850. for (int i = 0; i < dac2.Count; i++)
  4851. {
  4852. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4853. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4854. }
  4855. }
  4856. DataTable dtdac1 = new DataTable();
  4857. List<string> place = new List<string>();
  4858. dtdac1.Columns.AddRange(new DataColumn[] {
  4859. new DataColumn(){ ColumnName = "city"},
  4860. new DataColumn(){ ColumnName = "curr"},
  4861. new DataColumn(){ ColumnName = "criterion"},
  4862. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4863. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4864. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4865. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4866. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4867. });
  4868. DataTable dtdac2 = new DataTable();
  4869. dtdac2.Columns.AddRange(new DataColumn[] {
  4870. new DataColumn(){ ColumnName = "city"},
  4871. new DataColumn(){ ColumnName = "curr"},
  4872. new DataColumn(){ ColumnName = "criterion"},
  4873. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4874. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4875. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4876. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4877. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4878. });
  4879. dtdac1.TableName = "tb1";
  4880. dtdac2.TableName = "tb2";
  4881. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4882. foreach (var item in dac1)
  4883. {
  4884. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4885. if (place.Contains(item.Place))
  4886. {
  4887. continue;
  4888. }
  4889. DataRow row = dtdac1.NewRow();
  4890. row["city"] = item.Place;
  4891. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4892. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4893. row["curr"] = currency;
  4894. row["rate"] = rate.ToString("#0.0000");
  4895. row["criterion"] = item.Cost.ToString("#0.00");
  4896. row["number"] = 1;
  4897. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4898. //row["costRMB"] = rbmPrice;
  4899. dtdac1.Rows.Add(row);
  4900. place.Add(item.Place);
  4901. }
  4902. place = new List<string>();
  4903. foreach (var item in dac2)
  4904. {
  4905. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4906. if (place.Contains(item.Place))
  4907. {
  4908. continue;
  4909. }
  4910. DataRow row = dtdac2.NewRow();
  4911. row["city"] = item.Place;
  4912. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4913. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4914. row["curr"] = currency;
  4915. row["rate"] = rate.ToString("#0.0000");
  4916. row["criterion"] = item.Cost.ToString("#0.00");
  4917. row["number"] = 1;
  4918. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4919. //row["cost"] = item.SubTotal;
  4920. //row["costRMB"] = rbmPrice;
  4921. dtdac2.Rows.Add(row);
  4922. place.Add(item.Place);
  4923. //dac2totalPrice += rbmPrice;
  4924. }
  4925. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4926. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4927. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4928. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4929. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4930. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4931. string cell4Str1 = string.Empty;
  4932. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4933. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4934. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4935. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4936. string cellStr = $" 5.其他费用(";
  4937. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4938. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4939. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4940. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4941. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4942. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4943. if (cellStr.Length > 8)
  4944. {
  4945. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4946. }
  4947. cellStr += ")";
  4948. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4949. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4950. decimal pxFee = dac4.Sum(it => it.Cost);
  4951. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4952. string celllastStr1 = "";
  4953. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4954. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4955. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4956. celllastStr1 += $",国际旅费 元";
  4957. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4958. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4959. designer.SetDataSource("cell4Str", cell4Str);
  4960. designer.SetDataSource("cellStr", cellStr);
  4961. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4962. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4963. designer.SetDataSource("celllastStr", celllastStr);
  4964. Workbook wb = designer.Workbook;
  4965. var sheet = wb.Worksheets[0];
  4966. //绑定datatable数据集
  4967. designer.SetDataSource(dtdac1);
  4968. designer.SetDataSource(dtdac2);
  4969. designer.Process();
  4970. var rowStart = dtdac1.Rows.Count;
  4971. while (rowStart > 0)
  4972. {
  4973. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4974. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4975. startIndex++;
  4976. rowStart--;
  4977. }
  4978. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4979. startIndex += 1; //总计行
  4980. rowStart = dtdac2.Rows.Count;
  4981. while (rowStart > 0)
  4982. {
  4983. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4984. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4985. startIndex++;
  4986. rowStart--;
  4987. }
  4988. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4989. wb.CalculateFormula(true);
  4990. //模板文件名
  4991. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4992. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4993. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4994. return Ok(JsonView(true, "成功", new { Url = url }));
  4995. }
  4996. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4997. {
  4998. //获取模板
  4999. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5000. //载入模板
  5001. Document doc = new Document(tempPath);
  5002. DocumentBuilder builder = new DocumentBuilder(doc);
  5003. Dictionary<string, string> dic = new Dictionary<string, string>();
  5004. dic.Add("GroupName", _DelegationInfo.TeamName);
  5005. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5006. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5007. string missionLeaderJob = "";//负责人job
  5008. int groupNumber = 0; //团人数
  5009. if (DeleClientList.Count > 0)
  5010. {
  5011. missionLeader = DeleClientList[0]?.Name ?? "";
  5012. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5013. }
  5014. dic.Add("MissionLeader", missionLeader); //团负责人
  5015. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5016. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5017. #region MyRegion
  5018. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5019. //{
  5020. // List<string> list = new List<string>();
  5021. // try
  5022. // {
  5023. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5024. // foreach (var item in spilitArr)
  5025. // {
  5026. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5027. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5028. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5029. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5030. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5031. // list.Add(depName);
  5032. // list.Add(arrName);
  5033. // }
  5034. // list = list.Distinct().ToList();
  5035. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5036. // }
  5037. // catch (Exception)
  5038. // {
  5039. // dic.Add("ReturnCode", "行程录入不正确!");
  5040. // }
  5041. //}
  5042. //else
  5043. //{
  5044. // dic.Add("ReturnCode", "未录入行程!");
  5045. //}
  5046. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5047. dic.Add("ReturnCode", string.Join("、", countrys));
  5048. #endregion
  5049. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5050. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5051. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5052. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5053. //{
  5054. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5055. // dic.Add("Day", sp.Days.ToString());
  5056. //}
  5057. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5058. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5059. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5060. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5061. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5062. //培训人员名单
  5063. int cultivateRowIndex = 7;
  5064. foreach (var item in DeleClientList)
  5065. {
  5066. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5067. builder.Write(item.Name);
  5068. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5069. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5070. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5071. string birthDay = "";
  5072. if (item.Birthday != null)
  5073. {
  5074. DateTime dt = Convert.ToDateTime(item.Birthday);
  5075. birthDay = $"{dt.Year}.{dt.Month}";
  5076. }
  5077. builder.Write(birthDay);
  5078. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5079. builder.Write(item.Company);
  5080. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5081. builder.Write(item.Job);
  5082. cultivateRowIndex++;
  5083. }
  5084. //删除多余行
  5085. //cultivateRowIndex -= 2;
  5086. int delRows = 10 + 7 - cultivateRowIndex;
  5087. if (delRows > 0)
  5088. {
  5089. for (int i = 0; i < delRows; i++)
  5090. {
  5091. table1.Rows.RemoveAt(cultivateRowIndex);
  5092. //cultivateRowIndex++;
  5093. }
  5094. }
  5095. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5096. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5097. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5098. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5099. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5100. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5101. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5102. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5103. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5104. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5105. //其他费用
  5106. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5107. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5108. //其他费用合计
  5109. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5110. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5111. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5112. //公务舱合计
  5113. //国际旅费
  5114. string outsideJJ = "";
  5115. string allPriceJJ = "";
  5116. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5117. {
  5118. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5119. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5120. }
  5121. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5122. {
  5123. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5124. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5125. }
  5126. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5127. {
  5128. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5129. dic.Add("AirFeeTotal", airFeeTotalStr);
  5130. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5131. dic.Add("FeeTotal", feeTotalStr);
  5132. }
  5133. foreach (var key in dic.Keys)
  5134. {
  5135. builder.MoveToBookmark(key);
  5136. builder.Write(dic[key]);
  5137. }
  5138. //模板文件名
  5139. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5140. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5141. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5142. return Ok(JsonView(true, "成功", new { Url = url }));
  5143. }
  5144. }
  5145. else if (dto.ExportType == 2) //表格
  5146. {
  5147. //利用键值对存放数据
  5148. Dictionary<string, string> dic = new Dictionary<string, string>();
  5149. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5150. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5151. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5152. dic.Add("Day", sp.Days.ToString());
  5153. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5154. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5155. {
  5156. //获取模板
  5157. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5158. //载入模板
  5159. Document doc = new Document(tempPath);
  5160. DocumentBuilder builder = new DocumentBuilder(doc);
  5161. dic.Add("TeamName", _DelegationInfo.TeamName);
  5162. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5163. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5164. string missionLeaderName = "",
  5165. missionLeaderJob = "";
  5166. if (DeleClientList.Count > 0)
  5167. {
  5168. missionLeaderName = DeleClientList[0].Name;
  5169. missionLeaderJob = DeleClientList[0].Job;
  5170. }
  5171. dic.Add("MissionLeaderName", missionLeaderName);
  5172. dic.Add("MissionLeaderJob", missionLeaderJob);
  5173. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5174. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5175. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5176. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5177. int rowCount = 10;//总人数行
  5178. int startRowIndex = 7; //起始行
  5179. for (int i = 0; i < DeleClientList.Count; i++)
  5180. {
  5181. builder.MoveToCell(0, startRowIndex, 0, 0);
  5182. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5183. builder.MoveToCell(0, startRowIndex, 1, 0);
  5184. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5185. builder.Write(sex);//性别
  5186. builder.MoveToCell(0, startRowIndex, 2, 0);
  5187. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5188. builder.MoveToCell(0, startRowIndex, 3, 0);
  5189. builder.Write(DeleClientList[i].Company);//工作单位
  5190. builder.MoveToCell(0, startRowIndex, 4, 0);
  5191. builder.Write(DeleClientList[i].Job);//职务及级别
  5192. builder.MoveToCell(0, startRowIndex, 5, 0);
  5193. builder.Write("");//人员属性
  5194. builder.MoveToCell(0, startRowIndex, 6, 0);
  5195. builder.Write("");//上次出国时间
  5196. startRowIndex++;
  5197. }
  5198. int nullRow = rowCount - DeleClientList.Count;//空行
  5199. for (int i = 0; i < nullRow; i++)
  5200. {
  5201. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5202. }
  5203. foreach (var key in dic.Keys)
  5204. {
  5205. builder.MoveToBookmark(key);
  5206. builder.Write(dic[key]);
  5207. }
  5208. //模板文件名
  5209. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5210. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5211. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5212. return Ok(JsonView(true, "成功", new { Url = url }));
  5213. }
  5214. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5215. {
  5216. //获取模板
  5217. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5218. //载入模板
  5219. Document doc = new Document(tempPath);
  5220. DocumentBuilder builder = new DocumentBuilder(doc);
  5221. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5222. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5223. dic.Add("Names", Names);
  5224. int accommodationRows = 12, foodandotherRows = 12;
  5225. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5226. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5227. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5228. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5229. int accommodationStartIndex = 6;
  5230. decimal dac1totalPrice = 0.00M;
  5231. foreach (var dac in dac1)
  5232. {
  5233. if (dac.SubTotal == 0)
  5234. {
  5235. continue;
  5236. }
  5237. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5238. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5239. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5240. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5241. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5242. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5243. builder.Write(currency);//币种
  5244. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5245. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5246. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5247. builder.Write("");//人数
  5248. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5249. builder.Write("");//天数
  5250. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5251. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5252. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5253. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5254. builder.Write(rate.ToString("#0.0000"));//汇率
  5255. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5256. decimal rbmPrice = rate * dac.SubTotal;
  5257. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5258. accommodationStartIndex++;
  5259. dac1totalPrice += rbmPrice;
  5260. }
  5261. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5262. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5263. builder.Write("小计");
  5264. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5265. builder.Write(dac1totalPrice.ToString("#0.00"));
  5266. accommodationStartIndex++;
  5267. int nullRow = accommodationRows - dac1.Count;
  5268. //删除空行
  5269. //if (nullRow > 0)
  5270. //{
  5271. // int rowIndex = accommodationStartIndex;
  5272. // for (int i = 0; i < nullRow; i++)
  5273. // {
  5274. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5275. // row.Remove();
  5276. // rowIndex++;
  5277. // }
  5278. //}
  5279. if (dac2.Count == dac3.Count)//国家 币种 金额
  5280. {
  5281. for (int i = 0; i < dac2.Count; i++)
  5282. {
  5283. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5284. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5285. }
  5286. }
  5287. int foodandotherStartIndex = 19;//
  5288. decimal dac2totalPrice = 0.00M;
  5289. foreach (var dac in dac2)
  5290. {
  5291. if (dac.SubTotal == 0)
  5292. {
  5293. continue;
  5294. }
  5295. //foodandotherStartIndex = 12;
  5296. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5297. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5298. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5299. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5300. builder.Write(currency);//币种
  5301. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5302. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5303. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5304. builder.Write("");//人数
  5305. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5306. builder.Write("");//天数
  5307. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5308. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5309. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5310. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5311. builder.Write(rate.ToString("#0.0000"));//汇率
  5312. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5313. decimal rbmPrice = rate * dac.SubTotal;
  5314. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5315. foodandotherStartIndex++;
  5316. dac2totalPrice += rbmPrice;
  5317. }
  5318. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5319. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5320. //删除空行
  5321. //if (dac2.Count < foodandotherRows)
  5322. //{
  5323. // while (table2.Rows.Count > dac2.Count)
  5324. // {
  5325. // table2.Rows.RemoveAt(dac2.Count);
  5326. // }
  5327. //}
  5328. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5329. string otherFeeStr = "";
  5330. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5331. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5332. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5333. if (otherFeeStr.Length > 0)
  5334. {
  5335. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5336. otherFeeStr = $"({otherFeeStr})";
  5337. dic.Add("OtherFeeStr", otherFeeStr);
  5338. }
  5339. foreach (var key in dic.Keys)
  5340. {
  5341. builder.MoveToBookmark(key);
  5342. builder.Write(dic[key]);
  5343. }
  5344. //模板文件名
  5345. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5346. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5347. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5348. return Ok(JsonView(true, "成功", new { Url = url }));
  5349. }
  5350. }
  5351. else if (dto.ExportType == 3)
  5352. {
  5353. if (dto.SubTypeId == 1) //团组成员名单
  5354. {
  5355. if (DeleClientList.Count < 1)
  5356. {
  5357. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5358. }
  5359. //获取模板
  5360. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5361. //载入模板
  5362. Document doc = new Document(tempPath);
  5363. DocumentBuilder builder = new DocumentBuilder(doc);
  5364. //获取word里所有表格
  5365. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5366. //获取所填表格的序数
  5367. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5368. var rowStart = tableOne.Rows[0]; //获取第1行
  5369. //循环赋值
  5370. for (int i = 0; i < DeleClientList.Count; i++)
  5371. {
  5372. builder.MoveToCell(0, i + 1, 0, 0);
  5373. builder.Write(DeleClientList[i].Name);
  5374. builder.MoveToCell(0, i + 1, 1, 0);
  5375. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5376. builder.Write(sex);
  5377. builder.MoveToCell(0, i + 1, 2, 0);
  5378. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5379. builder.MoveToCell(0, i + 1, 3, 0);
  5380. builder.Write(DeleClientList[i].Company);
  5381. builder.MoveToCell(0, i + 1, 4, 0);
  5382. builder.Write(DeleClientList[i].Job);
  5383. }
  5384. //删除多余行
  5385. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5386. {
  5387. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5388. }
  5389. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5390. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5391. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5392. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5393. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5394. return Ok(JsonView(true, "成功", new { Url = url }));
  5395. }
  5396. }
  5397. return Ok(JsonView(false, "操作失败!"));
  5398. }
  5399. catch (Exception ex)
  5400. {
  5401. return Ok(JsonView(false, ex.Message));
  5402. }
  5403. }
  5404. /// <summary>
  5405. /// 获取三公费用标准city
  5406. /// </summary>
  5407. /// <param name="placeData"></param>
  5408. /// <param name="nationalTravelFeeId"></param>
  5409. /// <returns></returns>
  5410. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5411. {
  5412. string _city = string.Empty;
  5413. if (placeData.Count < 1) return _city;
  5414. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5415. if (data == null) return _city;
  5416. string country = data.Country;
  5417. string city = data.City;
  5418. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5419. else _city = city;
  5420. return _city;
  5421. }
  5422. /// <summary>
  5423. /// 团组模块 - 出入境费用 - 明细表导出
  5424. /// </summary>
  5425. /// <returns></returns>
  5426. [HttpPost]
  5427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5428. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5429. {
  5430. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5431. if (data.Code != 0)
  5432. {
  5433. return Ok(JsonView(false, data.Msg));
  5434. }
  5435. return Ok(JsonView(true, data.Msg, data.Data));
  5436. }
  5437. /// <summary>
  5438. /// 团组模块 - 出入境费用 - 一键清空
  5439. /// </summary>
  5440. /// <returns></returns>
  5441. [HttpPost]
  5442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5443. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5444. {
  5445. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5446. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5447. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5448. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5449. if (_view.Code == 0)
  5450. {
  5451. return Ok(JsonView(true, "操作成功"));
  5452. }
  5453. return Ok(JsonView(false, "操作失败"));
  5454. }
  5455. /// <summary>
  5456. /// 团组模块 - 出入境费用 - 子项删除
  5457. /// </summary>
  5458. /// <returns></returns>
  5459. [HttpPost]
  5460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5461. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5462. {
  5463. try
  5464. {
  5465. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5466. if (data.Code != 0)
  5467. {
  5468. return Ok(JsonView(false, data.Msg));
  5469. }
  5470. return Ok(JsonView(true, "操作成功!", data.Data));
  5471. }
  5472. catch (Exception ex)
  5473. {
  5474. return Ok(JsonView(false, ex.Message));
  5475. }
  5476. }
  5477. /// <summary>
  5478. /// 团组模块 - 出入境国家费用标准 List
  5479. /// </summary>
  5480. /// <returns></returns>
  5481. [HttpPost]
  5482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5483. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5484. {
  5485. try
  5486. {
  5487. Stopwatch sw = new Stopwatch();
  5488. sw.Start();
  5489. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5490. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5491. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5492. Where gntf.Isdel = 0");
  5493. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5494. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5495. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5496. //foreach (var item in nationalTravel)
  5497. //{
  5498. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5499. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5500. // if (otherData != null)
  5501. // {
  5502. // cityData.Remove(otherData);
  5503. // cityData.Add(otherData);
  5504. // }
  5505. // nationalTravelFeeData1.Add(new
  5506. // {
  5507. // Country = item.Country,
  5508. // CityData = cityData
  5509. // });
  5510. //}
  5511. sw.Stop();
  5512. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5513. }
  5514. catch (Exception ex)
  5515. {
  5516. return Ok(JsonView(false, ex.Message));
  5517. throw;
  5518. }
  5519. }
  5520. /// <summary>
  5521. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5522. /// </summary>
  5523. /// <returns></returns>
  5524. [HttpPost]
  5525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5526. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5527. {
  5528. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5529. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5530. List<string> countryData = new List<string>();
  5531. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5532. countryData = countryData.Distinct().ToList();
  5533. List<dynamic> dataSource = new List<dynamic>();
  5534. foreach (var item in countryData)
  5535. {
  5536. List<string> cityData1 = new List<string>();
  5537. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5538. var countryData2 = new
  5539. {
  5540. CountryName = item,
  5541. CityData = cityData1
  5542. };
  5543. dataSource.Add(countryData2);
  5544. }
  5545. return Ok(JsonView(true, "查询成功!", dataSource));
  5546. }
  5547. /// <summary>
  5548. /// 团组模块 - 出入境国家费用标准 Page List
  5549. /// </summary>
  5550. /// <returns></returns>
  5551. [HttpPost]
  5552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5553. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5554. {
  5555. int portId = dto.PortType;
  5556. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5557. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5558. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5559. string whereSql = string.Empty;
  5560. if (!string.IsNullOrEmpty(dto.Country))
  5561. {
  5562. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5563. }
  5564. if (!string.IsNullOrEmpty(dto.City))
  5565. {
  5566. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5567. }
  5568. string pageSql = string.Format(@"Select * From (
  5569. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5570. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5571. From Grp_NationalTravelFee gntf
  5572. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5573. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5574. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5575. RefAsync<int> total = 0;
  5576. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5577. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5578. }
  5579. /// <summary>
  5580. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5581. /// </summary>
  5582. /// <returns></returns>
  5583. [HttpPost]
  5584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5585. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5586. {
  5587. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5588. int portId = dto.PortType;
  5589. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5590. string whereSql = string.Empty;
  5591. if (!string.IsNullOrEmpty(dto.Country))
  5592. {
  5593. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5594. }
  5595. if (!string.IsNullOrEmpty(dto.City))
  5596. {
  5597. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5598. }
  5599. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5600. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5601. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5602. From Grp_NationalTravelFee gntf
  5603. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5604. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5605. Where gntf.Isdel = 0 {0} ", whereSql);
  5606. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5607. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5608. }
  5609. /// <summary>
  5610. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5611. /// </summary>
  5612. /// <returns></returns>
  5613. [HttpPost]
  5614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5615. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5616. {
  5617. try
  5618. {
  5619. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5620. if (data.Code != 0)
  5621. {
  5622. return Ok(JsonView(false, data.Msg));
  5623. }
  5624. return Ok(JsonView(true, "操作成功!", data.Data));
  5625. }
  5626. catch (Exception ex)
  5627. {
  5628. return Ok(JsonView(false, ex.Message));
  5629. }
  5630. }
  5631. /// <summary>
  5632. /// 团组模块 - 出入境国家费用标准 - Del
  5633. /// </summary>
  5634. /// <returns></returns>
  5635. [HttpPost]
  5636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5637. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5638. {
  5639. try
  5640. {
  5641. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5642. {
  5643. Id = dto.Id,
  5644. DeleteUserId = dto.DeleteUserId,
  5645. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5646. IsDel = 1
  5647. };
  5648. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5649. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5650. .WhereColumns(it => new { it.Id })
  5651. .ExecuteCommandAsync();
  5652. if (delStatus <= 0)
  5653. {
  5654. return Ok(JsonView(false, "删除失败!"));
  5655. }
  5656. return Ok(JsonView(true, "操作成功!"));
  5657. }
  5658. catch (Exception ex)
  5659. {
  5660. return Ok(JsonView(false, ex.Message));
  5661. }
  5662. }
  5663. #endregion
  5664. #region 签证费用录入
  5665. /// <summary>
  5666. /// 根据diid查询签证费用列表
  5667. /// </summary>
  5668. /// <param name="dto"></param>
  5669. /// <returns></returns>
  5670. [HttpPost]
  5671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5672. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5673. {
  5674. try
  5675. {
  5676. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5677. if (groupData.Code != 0)
  5678. {
  5679. return Ok(JsonView(false, groupData.Msg));
  5680. }
  5681. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5682. }
  5683. catch (Exception ex)
  5684. {
  5685. return Ok(JsonView(false, ex.Message));
  5686. }
  5687. }
  5688. /// <summary>
  5689. /// 根据签证费用Id查询单条数据及c表数据
  5690. /// </summary>
  5691. /// <param name="dto"></param>
  5692. /// <returns></returns>
  5693. [HttpPost]
  5694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5695. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5696. {
  5697. try
  5698. {
  5699. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5700. if (groupData.Code != 0)
  5701. {
  5702. return Ok(JsonView(false, groupData.Msg));
  5703. }
  5704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5705. }
  5706. catch (Exception ex)
  5707. {
  5708. return Ok(JsonView(false, ex.Message));
  5709. }
  5710. }
  5711. /// <summary>
  5712. /// 签证费用删除
  5713. /// </summary>
  5714. /// <param name="dto"></param>
  5715. /// <returns></returns>
  5716. [HttpPost]
  5717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5718. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5719. {
  5720. _sqlSugar.BeginTran();
  5721. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5722. if (!res)
  5723. {
  5724. _sqlSugar.RollbackTran();
  5725. return Ok(JsonView(false, "删除失败"));
  5726. }
  5727. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5728. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5729. .SetColumns(a => new Grp_CreditCardPayment()
  5730. {
  5731. IsDel = 1,
  5732. DeleteUserId = dto.DeleteUserId,
  5733. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5734. })
  5735. .ExecuteCommand();
  5736. if (resSub < 1)
  5737. {
  5738. _sqlSugar.RollbackTran();
  5739. return Ok(JsonView(false, "删除失败"));
  5740. }
  5741. _sqlSugar.CommitTran();
  5742. return Ok(JsonView(true, "删除成功!"));
  5743. }
  5744. /// <summary>
  5745. /// 签证费用录入下拉框初始化
  5746. /// </summary>
  5747. /// <returns></returns>
  5748. [HttpPost]
  5749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5750. public async Task<IActionResult> VisaPriceAddSelect()
  5751. {
  5752. //支付方式
  5753. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5754. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5755. //币种
  5756. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5757. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5758. //乘客类型
  5759. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5760. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5761. //卡类型
  5762. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5763. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5764. var data = new
  5765. {
  5766. Payment = _Payment,
  5767. CurrencyList = _CurrencyList,
  5768. PassengerType = _PassengerType,
  5769. BankCard = _BankCard
  5770. };
  5771. return Ok(JsonView(true, "查询成功!", data));
  5772. }
  5773. /// <summary>
  5774. /// 签证费用录入操作(Status:1.新增,2.修改)
  5775. /// </summary>
  5776. /// <param name="dto"></param>
  5777. /// <returns></returns>
  5778. [HttpPost]
  5779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5780. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5781. {
  5782. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5783. if (groupData.Code != 0)
  5784. {
  5785. return Ok(JsonView(false, groupData.Msg));
  5786. }
  5787. #region 应用推送
  5788. try
  5789. {
  5790. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5791. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5792. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5793. }
  5794. catch (Exception ex)
  5795. {
  5796. }
  5797. #endregion
  5798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5799. }
  5800. #endregion
  5801. #region 签证提成录入
  5802. /// <summary>
  5803. /// 签证提成录入
  5804. /// 基础数据
  5805. /// </summary>
  5806. /// <param name="_dto"></param>
  5807. /// <returns></returns>
  5808. [HttpGet]
  5809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5810. public async Task<IActionResult> VisaCommissionInit()
  5811. {
  5812. return Ok(await _visaCommissionRep.Init());
  5813. }
  5814. /// <summary>
  5815. /// 签证提成录入
  5816. /// Item
  5817. /// </summary>
  5818. /// <param name="_dto"></param>
  5819. /// <returns></returns>
  5820. [HttpPost]
  5821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5822. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5823. {
  5824. var validator = new VisaCommissionItemDtoValidator();
  5825. var validatorRes = await validator.ValidateAsync(_dto);
  5826. if (!validatorRes.IsValid)
  5827. {
  5828. StringBuilder sb = new StringBuilder();
  5829. foreach (var item in validatorRes.Errors)
  5830. {
  5831. sb.AppendLine(item.ErrorMessage);
  5832. }
  5833. return Ok(JsonView(false, sb.ToString()));
  5834. }
  5835. return Ok(await _visaCommissionRep.Item(_dto));
  5836. }
  5837. /// <summary>
  5838. /// 签证提成录入
  5839. /// Save
  5840. /// </summary>
  5841. /// <param name="_dto"></param>
  5842. /// <returns></returns>
  5843. [HttpPost]
  5844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5845. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  5846. {
  5847. //参数验证
  5848. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  5849. foreach (var item in _dto.Items)
  5850. {
  5851. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  5852. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  5853. if (string.IsNullOrEmpty( item.Country) ) return Ok(JsonView(false, "国家为空!"));
  5854. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  5855. }
  5856. return Ok(await _visaCommissionRep.Save(_dto));
  5857. }
  5858. /// <summary>
  5859. /// 签证提成录入
  5860. /// Create
  5861. /// </summary>
  5862. /// <param name="_dto"></param>
  5863. /// <returns></returns>
  5864. [HttpPost]
  5865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5866. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  5867. {
  5868. var validator = new VisaCommissionCreateDtoValidator();
  5869. var validatorRes = await validator.ValidateAsync(_dto);
  5870. if (!validatorRes.IsValid)
  5871. {
  5872. StringBuilder sb = new StringBuilder();
  5873. foreach (var item in validatorRes.Errors)
  5874. {
  5875. sb.AppendLine(item.ErrorMessage);
  5876. }
  5877. return Ok(JsonView(false, sb.ToString()));
  5878. }
  5879. return Ok(await _visaCommissionRep.Create(_dto));
  5880. }
  5881. /// <summary>
  5882. /// 签证提成录入
  5883. /// Put(编辑)
  5884. /// </summary>
  5885. /// <param name="id"></param>
  5886. /// <param name="_dto"></param>
  5887. /// <returns></returns>
  5888. [HttpPut]
  5889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5890. public async Task<IActionResult> VisaCommissionEdit(int id,VisaCommissionCreateDto _dto)
  5891. {
  5892. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5893. var validator = new VisaCommissionCreateDtoValidator();
  5894. var validatorRes = await validator.ValidateAsync(_dto);
  5895. if (!validatorRes.IsValid)
  5896. {
  5897. StringBuilder sb = new StringBuilder();
  5898. foreach (var item in validatorRes.Errors)
  5899. {
  5900. sb.AppendLine(item.ErrorMessage);
  5901. }
  5902. return Ok(JsonView(false, sb.ToString()));
  5903. }
  5904. return Ok(await _visaCommissionRep.Edit(id,_dto));
  5905. }
  5906. /// <summary>
  5907. /// 签证提成录入
  5908. /// Del
  5909. /// </summary>
  5910. /// <param name="id"></param>
  5911. /// <param name="currUserId"></param>
  5912. /// <returns></returns>
  5913. [HttpPost]
  5914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5915. public async Task<IActionResult> VisaCommissionDel(int id,int currUserId)
  5916. {
  5917. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5918. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  5919. return Ok(await _visaCommissionRep.Del(id, currUserId));
  5920. }
  5921. #endregion
  5922. #region op费用录入
  5923. /// <summary>
  5924. /// 根据diid查询op费用列表
  5925. /// </summary>
  5926. /// <param name="dto"></param>
  5927. /// <returns></returns>
  5928. [HttpPost]
  5929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5930. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5931. {
  5932. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5933. if (groupData.Code != 0)
  5934. {
  5935. return Ok(JsonView(false, groupData.Msg));
  5936. }
  5937. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5938. }
  5939. /// <summary>
  5940. /// 根据op费用Id查询单条数据及c表数据
  5941. /// </summary>
  5942. /// <param name="dto"></param>
  5943. /// <returns></returns>
  5944. [HttpPost]
  5945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5946. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5947. {
  5948. try
  5949. {
  5950. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5951. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5952. var data = new
  5953. {
  5954. CarTouristGuideGround = _groupData,
  5955. CreditCardPayment = _creditCardPayment
  5956. };
  5957. return Ok(JsonView(true, "查询成功!", data));
  5958. }
  5959. catch (Exception ex)
  5960. {
  5961. return Ok(JsonView(false, "程序错误!"));
  5962. }
  5963. }
  5964. /// <summary>
  5965. /// op费用删除
  5966. /// </summary>
  5967. /// <param name="dto"></param>
  5968. /// <returns></returns>
  5969. [HttpPost]
  5970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5971. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5972. {
  5973. try
  5974. {
  5975. _sqlSugar.BeginTran();
  5976. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5977. if (!res)
  5978. {
  5979. return Ok(JsonView(false, "删除失败"));
  5980. }
  5981. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5982. {
  5983. IsDel = 1,
  5984. DeleteUserId = dto.DeleteUserId,
  5985. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5986. }).ExecuteCommandAsync();
  5987. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5988. {
  5989. IsDel = 1,
  5990. DeleteUserId = dto.DeleteUserId,
  5991. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5992. }).ExecuteCommandAsync();
  5993. #region 删除超支相关数据
  5994. //删除导入的超支数据
  5995. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5996. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5997. {
  5998. IsDel = 1,
  5999. DeleteUserId = dto.DeleteUserId,
  6000. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6001. }).ExecuteCommand();
  6002. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6003. {
  6004. IsDel = 1,
  6005. DeleteUserId = dto.DeleteUserId,
  6006. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6007. }).ExecuteCommand() ;
  6008. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6009. {
  6010. IsDel = 1,
  6011. DeleteUserId = dto.DeleteUserId,
  6012. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6013. }).ExecuteCommand();
  6014. #endregion
  6015. _sqlSugar.CommitTran();
  6016. return Ok(JsonView(true, "删除成功!"));
  6017. }
  6018. catch (Exception ex)
  6019. {
  6020. _sqlSugar.RollbackTran();
  6021. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6022. }
  6023. }
  6024. /// <summary>
  6025. /// op费用录入操作(Status:1.新增,2.修改)
  6026. /// </summary>
  6027. /// <param name="dto"></param>
  6028. /// <returns></returns>
  6029. [HttpPost]
  6030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6031. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6032. {
  6033. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6034. if (groupData.Code != 0)
  6035. {
  6036. return Ok(JsonView(false, groupData.Msg));
  6037. }
  6038. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6039. }
  6040. /// <summary>
  6041. /// 填写费用详细页面初始化绑定
  6042. /// </summary>
  6043. /// <param name="dto"></param>
  6044. /// <returns></returns>
  6045. [HttpPost]
  6046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6047. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6048. {
  6049. try
  6050. {
  6051. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6052. if (groupData.Code != 0)
  6053. {
  6054. return Ok(JsonView(false, groupData.Msg));
  6055. }
  6056. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6057. }
  6058. catch (Exception ex)
  6059. {
  6060. return Ok(JsonView(false, ex.Message));
  6061. }
  6062. }
  6063. /// <summary>
  6064. /// 根据op费用Id查询详细数据
  6065. /// </summary>
  6066. /// <param name="dto"></param>
  6067. /// <returns></returns>
  6068. [HttpPost]
  6069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6070. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6071. {
  6072. try
  6073. {
  6074. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6075. if (groupData.Code != 0)
  6076. {
  6077. return Ok(JsonView(false, groupData.Msg));
  6078. }
  6079. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6080. }
  6081. catch (Exception ex)
  6082. {
  6083. return Ok(JsonView(false, ex.Message));
  6084. }
  6085. }
  6086. /// <summary>
  6087. /// OP费用录入填写详情
  6088. /// </summary>
  6089. /// <param name="dto"></param>
  6090. /// <returns></returns>
  6091. [HttpPost]
  6092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6093. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6094. {
  6095. try
  6096. {
  6097. #region 参数校验
  6098. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6099. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6100. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6101. #endregion
  6102. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6103. if (groupData.Code != 0)
  6104. {
  6105. return Ok(JsonView(false, groupData.Msg));
  6106. }
  6107. //自动审核
  6108. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6109. #region 应用推送
  6110. try
  6111. {
  6112. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6113. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6114. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6115. }
  6116. catch (Exception ex)
  6117. {
  6118. }
  6119. #endregion
  6120. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6121. }
  6122. catch (Exception ex)
  6123. {
  6124. return Ok(JsonView(false, ex.Message));
  6125. }
  6126. }
  6127. /// <summary>
  6128. /// 获取三公详细所有城市
  6129. /// </summary>
  6130. /// <returns></returns>
  6131. [HttpGet]
  6132. public IActionResult OpCarCityResult()
  6133. {
  6134. var jw = JsonView(false);
  6135. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6136. {
  6137. x.Id,
  6138. x.Country,
  6139. x.City,
  6140. }).ToList();
  6141. if (data.Count > 0)
  6142. {
  6143. jw = JsonView(true, "获取成功!", data);
  6144. }
  6145. else
  6146. {
  6147. jw.Msg = "城市数据为空!";
  6148. jw.Data = new string[0];
  6149. }
  6150. return Ok(jw);
  6151. }
  6152. /// <summary>
  6153. /// 导出地接费用明细
  6154. /// </summary>
  6155. /// <param name="dto"></param>
  6156. /// <returns></returns>
  6157. [HttpPost]
  6158. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6159. {
  6160. var jw = JsonView(false);
  6161. if (dto.Diid < 1)
  6162. {
  6163. jw.Msg = "请输入正确的diid!";
  6164. return Ok(jw);
  6165. }
  6166. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6167. if (group == null)
  6168. {
  6169. jw.Msg = "未找到团组信息!";
  6170. return Ok(jw);
  6171. }
  6172. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6173. if (localGuideArr.Count == 0)
  6174. {
  6175. jw.Msg = "该团组暂无地接信息!";
  6176. return Ok(jw);
  6177. }
  6178. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6179. var overspendSoure = new Dictionary<int, int>
  6180. {
  6181. { 91, 982 }, //车
  6182. { 92 , 1059} ,//导游
  6183. { 994 , 1073}, //翻译
  6184. { 988 , 1074 }, //早餐
  6185. { 93 , 1075 }, //午餐
  6186. { 989 , 1076 }, //晚餐
  6187. };
  6188. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6189. foreach (var groupArr in localGroup)
  6190. {
  6191. var keyValue = groupArr.Key;
  6192. if (int.TryParse(keyValue, out int cityid))
  6193. {
  6194. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6195. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6196. }
  6197. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6198. foreach (var item in groupArr)
  6199. {
  6200. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6201. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6202. new Grp_CarTouristGuideGroundReservationsContentExtend
  6203. {
  6204. Count = a.Count,
  6205. CreateTime = a.CreateTime,
  6206. CreateUserId = a.CreateUserId,
  6207. CTGGRId = a.CTGGRId,
  6208. Currency = a.Currency,
  6209. DatePrice = a.DatePrice,
  6210. DeleteTime = a.DeleteTime,
  6211. DeleteUserId = a.DeleteUserId,
  6212. DiId = a.DiId,
  6213. Id = a.Id,
  6214. IsDel = a.IsDel,
  6215. Price = a.Price,
  6216. PriceContent = a.PriceContent,
  6217. Remark = a.Remark,
  6218. SId = a.SId,
  6219. SidName = b.Name,
  6220. Units = a.Units,
  6221. }
  6222. ).ToList();
  6223. if (content.Count > 0)
  6224. {
  6225. contentArr.Add(content);
  6226. }
  6227. }
  6228. //open excel
  6229. //set excel
  6230. //save excel
  6231. try
  6232. {
  6233. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6234. IWorkbook workbook;
  6235. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6236. {
  6237. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6238. }
  6239. else
  6240. {
  6241. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6242. }
  6243. ISheet sheet = workbook.GetSheetAt(0);
  6244. var rowStartIndex = 2;
  6245. var clounmCount = 10;
  6246. var initStyleRow = sheet.GetRow(2);
  6247. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6248. //var overspendArrDetail =
  6249. var existsId = new List<CarCompare>();
  6250. var lastElem = arr.Last();
  6251. var thisSid = -1;
  6252. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6253. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6254. {
  6255. Name = "未知币种!",
  6256. Remark = "未知币种!",
  6257. };
  6258. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6259. Action cloneRowFn = () =>
  6260. {
  6261. rowStartIndex++;
  6262. var cloneRow = sheet.CreateRow(rowStartIndex);
  6263. // 复制样式
  6264. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6265. {
  6266. ICell sourceCell = initStyleRow.GetCell(i);
  6267. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6268. // 确保单元格存在样式
  6269. if (sourceCell.CellStyle != null)
  6270. {
  6271. targetCell.CellStyle = sourceCell.CellStyle;
  6272. }
  6273. }
  6274. };
  6275. var mergeRow = () =>
  6276. {
  6277. for (int i = 2; i < sheet.LastRowNum; i++)
  6278. {
  6279. var row = sheet.GetRow(i);
  6280. var cellFirst = row.GetCell(0);
  6281. var thisIndex = i + 1;
  6282. while (thisIndex < sheet.LastRowNum)
  6283. {
  6284. var nextRow = sheet.GetRow(thisIndex);
  6285. var nextCellFirst = nextRow.GetCell(0);
  6286. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6287. {
  6288. thisIndex++;
  6289. }
  6290. else
  6291. {
  6292. break;
  6293. }
  6294. }
  6295. thisIndex--;
  6296. if (thisIndex != i)
  6297. {
  6298. //合并row
  6299. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6300. i, // 起始行索引(0-based)
  6301. thisIndex, // 结束行索引(0-based)
  6302. 0, // 起始列索引(0-based)
  6303. 0 // 结束列索引(0-based)
  6304. );
  6305. sheet.AddMergedRegion(cellRangeAddress);
  6306. i = thisIndex;
  6307. }
  6308. }
  6309. };
  6310. var chaoshiNumber = 0;
  6311. var totalNumber = 0.00M;
  6312. string lastStr = "";
  6313. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6314. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6315. {
  6316. b.IsAuditGM,
  6317. x.Id,
  6318. x.Area,
  6319. b.PayPercentage,
  6320. b.PayMoney,
  6321. }).ToList();
  6322. string yesPayment = "", noPayment = "";
  6323. foreach (var item in queryCarArrByCityAndDiid)
  6324. {
  6325. if (item.IsAuditGM == 1)
  6326. {
  6327. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6328. }
  6329. else
  6330. {
  6331. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6332. }
  6333. }
  6334. lastStr = yesPayment + noPayment;
  6335. foreach (var item in arr)
  6336. {
  6337. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6338. {
  6339. if (thisSid != item.SId)
  6340. {
  6341. if (thisSid == -1)
  6342. {
  6343. thisSid = item.SId;
  6344. }
  6345. else
  6346. {
  6347. //合并小计行
  6348. //创建合并区域的实例
  6349. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6350. rowStartIndex, // 起始行索引(0-based)
  6351. rowStartIndex, // 结束行索引(0-based)
  6352. 0, // 起始列索引(0-based)
  6353. 3 // 结束列索引(0-based)
  6354. );
  6355. sheet.AddMergedRegion(cellRangeAddress);
  6356. var CellStyle = workbook.CreateCellStyle();
  6357. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6358. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6359. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6360. for (int i = 0; i <= clounmCount; i++)
  6361. {
  6362. if (i > 6)
  6363. {
  6364. var CellStyle1 = workbook.CreateCellStyle();
  6365. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6366. IFont Font = workbook.CreateFont(); // 创建字体
  6367. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6368. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6369. CellStyle1.SetFont(Font);
  6370. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6371. }
  6372. else
  6373. {
  6374. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6375. }
  6376. }
  6377. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6378. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6379. //超时合计
  6380. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6381. //超时数
  6382. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6383. //超时合计费用
  6384. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6385. thisSid = item.SId;
  6386. cloneRowFn();
  6387. chaoshiNumber = 0;
  6388. totalNumber = 0;
  6389. }
  6390. }
  6391. IRow row = sheet.GetRow(rowStartIndex);
  6392. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6393. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6394. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6395. if (isOpenOverspendSoure)
  6396. {
  6397. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6398. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6399. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6400. }
  6401. for (int i = 0; i <= clounmCount; i++)
  6402. {
  6403. var cell = row.GetCell(i);
  6404. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6405. if (cell == null)
  6406. {
  6407. cell = row.CreateCell(i);
  6408. }
  6409. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6410. fontRed.CloneStyleFrom(cell.CellStyle);
  6411. IFont Font = workbook.CreateFont(); // 创建字体
  6412. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6413. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6414. fontRed.SetFont(Font);
  6415. byte[] rgb = new byte[3] { 255, 242, 204 };
  6416. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6417. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6418. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6419. if (workbook is XSSFWorkbook)
  6420. {
  6421. BackgroundColor255_242_204.FillForegroundColor = 0;
  6422. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6423. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6424. }
  6425. else
  6426. {
  6427. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6428. }
  6429. if (i == 1 || i > 6)
  6430. {
  6431. if (i > 6)
  6432. {
  6433. fontRed.FillForegroundColor = 0;
  6434. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6435. fontRed.FillPattern = FillPattern.SolidForeground;
  6436. }
  6437. cell.CellStyle = fontRed;
  6438. }
  6439. if (i > 2 && i < 7)
  6440. {
  6441. cell.CellStyle = BackgroundColor255_242_204;
  6442. }
  6443. cell.SetCellValue(setCellValue); //写入单元格
  6444. }
  6445. if (overspendSoure.ContainsKey(thisSid))
  6446. {
  6447. var overspendId = overspendSoure[thisSid];
  6448. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6449. }
  6450. cloneRowFn();
  6451. existsId.Add(new CarCompare
  6452. {
  6453. DataPrice = item.DatePrice.ObjToDate(),
  6454. Sid = item.SId
  6455. });
  6456. }
  6457. if (item.Equals(lastElem))
  6458. {
  6459. //合并小计行
  6460. //创建合并区域的实例
  6461. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6462. rowStartIndex, // 起始行索引(0-based)
  6463. rowStartIndex, // 结束行索引(0-based)
  6464. 0, // 起始列索引(0-based)
  6465. 3 // 结束列索引(0-based)
  6466. );
  6467. sheet.AddMergedRegion(cellRangeAddress);
  6468. var CellStyle = workbook.CreateCellStyle();
  6469. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6470. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6471. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6472. for (int i = 0; i <= clounmCount; i++)
  6473. {
  6474. if (i > 6)
  6475. {
  6476. var CellStyle1 = workbook.CreateCellStyle();
  6477. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6478. IFont Font = workbook.CreateFont(); // 创建字体
  6479. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6480. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6481. CellStyle1.SetFont(Font);
  6482. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6483. }
  6484. else
  6485. {
  6486. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6487. }
  6488. }
  6489. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6490. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6491. //超时合计
  6492. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6493. //超时数
  6494. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6495. //超时合计费用
  6496. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6497. cloneRowFn();
  6498. // 创建合并区域的实例
  6499. cellRangeAddress = new CellRangeAddress(
  6500. rowStartIndex, // 起始行索引(0-based)
  6501. rowStartIndex, // 结束行索引(0-based)
  6502. 0, // 起始列索引(0-based)
  6503. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6504. );
  6505. // 添加合并区域
  6506. sheet.AddMergedRegion(cellRangeAddress);
  6507. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6508. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6509. }
  6510. }
  6511. mergeRow();
  6512. // 保存修改后的Excel文件到新文件
  6513. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6514. // new FileStream(newFilePath, FileMode.CreateNew)
  6515. using (var stream = new MemoryStream())
  6516. {
  6517. workbook.Write(stream, true);
  6518. stream.Flush();
  6519. stream.Seek(0, SeekOrigin.Begin);
  6520. MemoryStream memoryStream = new MemoryStream();
  6521. stream.CopyTo(memoryStream);
  6522. memoryStream.Seek(0, SeekOrigin.Begin);
  6523. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6524. }
  6525. workbook.Close();
  6526. workbook.Dispose();
  6527. }
  6528. catch (Exception ex)
  6529. {
  6530. jw.Msg = "出现异常!" + ex.Message;
  6531. return Ok(jw);
  6532. }
  6533. }
  6534. if (Zips.Count > 0)
  6535. {
  6536. IOOperatorHelper io = new IOOperatorHelper();
  6537. var byts = io.ConvertZipStream(Zips);
  6538. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6539. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6540. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6541. }
  6542. else
  6543. {
  6544. jw.Msg = "暂无生成文件!";
  6545. }
  6546. return Ok(jw);
  6547. }
  6548. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6549. {
  6550. string outStr = string.Empty;
  6551. switch (i)
  6552. {
  6553. case 0:
  6554. outStr = arr[0].SidName;
  6555. break;
  6556. case 1:
  6557. outStr = arr[0].DataPriceStr;
  6558. break;
  6559. case 2:
  6560. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6561. break;
  6562. case 4:
  6563. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6564. break;
  6565. case 7:
  6566. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6567. {
  6568. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6569. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6570. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6571. }
  6572. break;
  6573. case 8:
  6574. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6575. {
  6576. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6577. }
  6578. break;
  6579. case 9:
  6580. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6581. {
  6582. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6583. }
  6584. break;
  6585. case 10:
  6586. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6587. {
  6588. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6589. }
  6590. break;
  6591. }
  6592. return outStr;
  6593. }
  6594. #region OP行程单
  6595. /// <summary>
  6596. /// OP行程单初始化
  6597. /// </summary>
  6598. /// <param name="dto"></param>
  6599. /// <returns></returns>
  6600. [HttpPost]
  6601. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6602. {
  6603. var jw = JsonView(false);
  6604. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6605. var group = groupList.First();
  6606. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6607. if (group == null)
  6608. {
  6609. jw.Msg = "暂无团组!";
  6610. return Ok(jw);
  6611. }
  6612. group = groupList.Find(x => x.Id == diid);
  6613. if (group == null)
  6614. {
  6615. jw.Msg = "请输入正确的团组ID!";
  6616. return Ok(jw);
  6617. }
  6618. string city = string.Empty;
  6619. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6620. if (blackCode.Count > 0)
  6621. {
  6622. var black = blackCode.First();
  6623. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6624. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6625. if (blackSp.Length > 0)
  6626. {
  6627. try
  6628. {
  6629. var cityArrCode = new List<string>(20);
  6630. foreach (var item in blackSp)
  6631. {
  6632. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6633. var IndexSelect = itemSp[2];
  6634. var cityArrCodeLength = cityArrCode.Count - 1;
  6635. var startCity = IndexSelect.Substring(0, 3);
  6636. if (cityArrCodeLength > 0)
  6637. {
  6638. var arrEndCity = cityArrCode[cityArrCodeLength];
  6639. if (arrEndCity != startCity)
  6640. {
  6641. cityArrCode.Add(startCity.ToUpper());
  6642. }
  6643. }
  6644. else
  6645. {
  6646. cityArrCode.Add(startCity.ToUpper());
  6647. }
  6648. var endCity = IndexSelect.Substring(3, 3);
  6649. cityArrCode.Add(endCity.ToUpper());
  6650. }
  6651. var cityThree = string.Empty;
  6652. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6653. cityThree = cityThree.TrimEnd(',');
  6654. if (string.IsNullOrWhiteSpace(cityThree))
  6655. {
  6656. throw new
  6657. Exception("error");
  6658. }
  6659. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6660. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6661. foreach (var item in cityArrCode)
  6662. {
  6663. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6664. if (find != null)
  6665. {
  6666. city += find.City + "/";
  6667. }
  6668. else
  6669. {
  6670. city += item + "三字码未收入/";
  6671. }
  6672. }
  6673. city = city.TrimEnd('/');
  6674. }
  6675. catch (Exception e)
  6676. {
  6677. city = "黑屏代码格式不正确!";
  6678. }
  6679. }
  6680. }
  6681. else
  6682. {
  6683. city = "未录入黑屏代码";
  6684. }
  6685. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6686. {
  6687. Date = x.Date,
  6688. Days = x.Days,
  6689. Diffgroup = x.Diffgroup,
  6690. Diid = x.Diid,
  6691. Traffic_First = x.Traffic_First,
  6692. Traffic_Second = x.Traffic_Second,
  6693. Trip = x.Trip,
  6694. WeekDay = x.WeekDay,
  6695. Id = x.Id
  6696. }).ToList();
  6697. jw.Data = new
  6698. {
  6699. groupList = groupList.Select(x => new
  6700. {
  6701. x.Id,
  6702. x.TeamName,
  6703. x.TourCode
  6704. }).ToList(),
  6705. groupInfo = new
  6706. {
  6707. group.VisitDays,
  6708. group.TourCode,
  6709. group.VisitPNumber,
  6710. group.TeamName,
  6711. city
  6712. },
  6713. OpTravelList
  6714. };
  6715. jw.Code = 200;
  6716. jw.Msg = "操作成功!";
  6717. return Ok(jw);
  6718. }
  6719. /// <summary>
  6720. /// 删除团组行程单
  6721. /// </summary>
  6722. /// <returns></returns>
  6723. [HttpPost]
  6724. public IActionResult DelTravel(DelOpTravelDto dto)
  6725. {
  6726. var jw = JsonView(false);
  6727. if (dto.UserId <= 0 || dto.Diid <= 0)
  6728. {
  6729. jw.Msg = "请输入正确的参数!";
  6730. return Ok(jw);
  6731. }
  6732. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6733. .SetColumns(x => new Grp_TravelList
  6734. {
  6735. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6736. DeleteUserId = dto.UserId,
  6737. IsDel = 1,
  6738. }).ExecuteCommand();
  6739. jw = JsonView(true);
  6740. return Ok(jw);
  6741. }
  6742. /// <summary>
  6743. /// 行程单保存
  6744. /// </summary>
  6745. /// <returns></returns>
  6746. [HttpPost]
  6747. public IActionResult TravelSave(TravelSaveDto dto)
  6748. {
  6749. var jw = JsonView(false);
  6750. if (dto.Arr.Count > 0)
  6751. {
  6752. try
  6753. {
  6754. _sqlSugar.BeginTran();
  6755. foreach (var item in dto.Arr)
  6756. {
  6757. if (item.Id == 0)
  6758. {
  6759. throw new Exception("请传入正确的Id");
  6760. }
  6761. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6762. .SetColumns(x => new Grp_TravelList
  6763. {
  6764. Trip = item.Trip
  6765. }).ExecuteCommand();
  6766. }
  6767. _sqlSugar.CommitTran();
  6768. jw = JsonView(true);
  6769. }
  6770. catch (Exception ex)
  6771. {
  6772. _sqlSugar.RollbackTran();
  6773. jw.Msg = "程序异常!" + ex.Message;
  6774. }
  6775. }
  6776. else
  6777. {
  6778. jw.Msg = "请传入正确的参数!";
  6779. }
  6780. return Ok(jw);
  6781. }
  6782. /// <summary>
  6783. /// 导出行程单
  6784. /// </summary>
  6785. /// <param name="dto"></param>
  6786. /// <returns></returns>
  6787. [HttpPost]
  6788. public IActionResult ExportTravel(ExportTravelDto dto)
  6789. {
  6790. var jw = JsonView(false);
  6791. jw.Data = "";
  6792. int diid = 0;
  6793. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6794. if (Find == null)
  6795. {
  6796. jw.Msg = "请选择正确的团组!";
  6797. return Ok(jw);
  6798. }
  6799. else
  6800. {
  6801. diid = Find.Id;
  6802. }
  6803. //数据源
  6804. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6805. DataTable dtBlack = null;
  6806. try
  6807. {
  6808. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6809. }
  6810. catch (Exception)
  6811. {
  6812. jw.Msg = "机票黑屏代码有误!";
  6813. return Ok(jw);
  6814. }
  6815. string CityStr = string.Empty;
  6816. if (dtBlack.Rows.Count == 0)
  6817. {
  6818. jw.Msg = "机票黑屏代码有误!";
  6819. return Ok(jw);
  6820. }
  6821. else
  6822. {
  6823. foreach (DataRow row in dtBlack.Rows)
  6824. {
  6825. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6826. {
  6827. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6828. return Ok(jw);
  6829. }
  6830. }
  6831. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6832. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6833. }
  6834. //创建数据源Table
  6835. DataTable dtSource = new DataTable();
  6836. dtSource.Columns.Add("Days", typeof(string));
  6837. dtSource.Columns.Add("Date", typeof(string));
  6838. dtSource.Columns.Add("Week", typeof(string));
  6839. dtSource.Columns.Add("Traffic", typeof(string));
  6840. dtSource.Columns.Add("Trip", typeof(string));
  6841. //获取数据,放到datatable
  6842. foreach (var item in _travelList)
  6843. {
  6844. DataRow dr = dtSource.NewRow();
  6845. dr["Days"] = item.Days;
  6846. dr["Date"] = item.Date;
  6847. dr["Week"] = item.WeekDay;
  6848. dr["Traffic"] = item.Traffic_First
  6849. + "\r\n"
  6850. + item.Traffic_Second;
  6851. dr["Trip"] = item.Trip;
  6852. dtSource.Rows.Add(dr);
  6853. }
  6854. Dictionary<string, string> dic = new Dictionary<string, string>();
  6855. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6856. dic.Add("City", CityStr);
  6857. dic.Add("Days", Find.VisitDays.ToString());
  6858. dic.Add("DeleCode", Find.TourCode);
  6859. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6860. //模板路径
  6861. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6862. //载入模板
  6863. Document doc = null;
  6864. DocumentBuilder builder = null;
  6865. try
  6866. {
  6867. //载入模板
  6868. doc = new Document(tempPath);
  6869. builder = new DocumentBuilder(doc);
  6870. }
  6871. catch (Exception)
  6872. {
  6873. jw.Msg = "模板位置不存在!";
  6874. return Ok(jw);
  6875. }
  6876. foreach (var key in dic.Keys)
  6877. {
  6878. Bookmark bookmark = doc.Range.Bookmarks[key];
  6879. if (bookmark != null)
  6880. {
  6881. builder.MoveToBookmark(key);
  6882. builder.Write(dic[key]);
  6883. }
  6884. }
  6885. //获取word里所有表格
  6886. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6887. //获取所填表格的序数
  6888. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6889. try
  6890. {
  6891. //循环赋值
  6892. for (int i = 0; i < dtSource.Rows.Count; i++)
  6893. {
  6894. builder.MoveToCell(0, i + 1, 0, 0);
  6895. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6896. builder.MoveToCell(0, i + 1, 1, 0);
  6897. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6898. builder.MoveToCell(0, i + 1, 2, 0);
  6899. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6900. var trip = dtSource.Rows[i]["Trip"].ToString();
  6901. builder.MoveToCell(0, i + 1, 3, 0);
  6902. builder.Write(trip);
  6903. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6904. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6905. // 获取特定索引的段落
  6906. Paragraph paragraph = (Paragraph)paragraphs[0];
  6907. Run run = paragraph.Runs[0];
  6908. Aspose.Words.Font font = run.Font;
  6909. font.Name = "黑体";
  6910. //设置双休红色
  6911. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6912. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6913. paragraph = (Paragraph)paragraphs[1];
  6914. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6915. {
  6916. run = paragraph.Runs[0];
  6917. font = run.Font;
  6918. font.Color = Color.Red;
  6919. }
  6920. }
  6921. }
  6922. catch (Exception ex)
  6923. {
  6924. }
  6925. //删除多余行
  6926. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6927. {
  6928. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6929. }
  6930. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6931. if (!Directory.Exists(savePath))
  6932. {
  6933. try
  6934. {
  6935. Directory.CreateDirectory(savePath);
  6936. }
  6937. catch
  6938. {
  6939. }
  6940. }
  6941. string path = savePath + Find.TeamName + "出访日程";
  6942. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6943. try
  6944. {
  6945. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6946. string postfix = ".docx";
  6947. if (dto.IsPDF == 1)
  6948. {
  6949. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6950. postfix = ".pdf";
  6951. }
  6952. doc.Save(path + postfix, saveFormat);
  6953. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6954. }
  6955. catch (Exception)
  6956. {
  6957. jw = JsonView(false);
  6958. }
  6959. return Ok(jw);
  6960. }
  6961. /// <summary>
  6962. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6963. /// </summary>
  6964. /// <param name="num"></param>
  6965. /// <returns></returns>
  6966. string GetNum(string num)
  6967. {
  6968. string str = "";
  6969. switch (num)
  6970. {
  6971. case "1":
  6972. str = "一";
  6973. break;
  6974. case "2":
  6975. str = "二";
  6976. break;
  6977. case "3":
  6978. str = "三";
  6979. break;
  6980. case "4":
  6981. str = "四";
  6982. break;
  6983. case "5":
  6984. str = "五";
  6985. break;
  6986. case "6":
  6987. str = "六";
  6988. break;
  6989. case "7":
  6990. str = "七";
  6991. break;
  6992. case "8":
  6993. str = "八";
  6994. break;
  6995. case "9":
  6996. str = "九";
  6997. break;
  6998. case "10":
  6999. str = "十";
  7000. break;
  7001. case "11":
  7002. str = "十一";
  7003. break;
  7004. case "12":
  7005. str = "十二";
  7006. break;
  7007. case "一":
  7008. str = "1";
  7009. break;
  7010. case "二":
  7011. str = "2";
  7012. break;
  7013. case "三":
  7014. str = "3";
  7015. break;
  7016. case "四":
  7017. str = "4";
  7018. break;
  7019. case "五":
  7020. str = "5";
  7021. break;
  7022. case "六":
  7023. str = "6";
  7024. break;
  7025. case "七":
  7026. str = "7";
  7027. break;
  7028. case "八":
  7029. str = "8";
  7030. break;
  7031. case "九":
  7032. str = "9";
  7033. break;
  7034. case "十":
  7035. str = "10";
  7036. break;
  7037. case "十一":
  7038. str = "11";
  7039. break;
  7040. case "十二":
  7041. str = "12";
  7042. break;
  7043. }
  7044. return str;
  7045. }
  7046. #endregion
  7047. #endregion
  7048. #region 团组成本
  7049. /// <summary>
  7050. /// 团组成本数据初始化
  7051. /// </summary>
  7052. /// <param name="dto"></param>
  7053. /// <returns></returns>
  7054. [HttpPost]
  7055. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7056. {
  7057. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7058. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7059. WHEN COUNT(*) >= 0 THEN 'True'
  7060. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7061. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7062. ").ToList(); //团组列表
  7063. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7064. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7065. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7066. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7067. if (groupinfoValue != null)
  7068. {
  7069. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7070. var spArr = new string[1] { countryArr };
  7071. if (countryArr.Contains("|"))
  7072. {
  7073. spArr = countryArr.Split("|");
  7074. }
  7075. else if (countryArr.Contains("、"))
  7076. {
  7077. spArr = countryArr.Split("、");
  7078. }
  7079. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7080. {
  7081. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7082. if (dbQueryCountry != null)
  7083. {
  7084. visaCountryInfoArr.Add(dbQueryCountry);
  7085. }
  7086. }
  7087. }
  7088. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7089. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7090. var create = _GroupCostRepository.
  7091. CreateGroupCostByBlackCode(dto.Diid);
  7092. if (groupCost.Count == 0 && create.Code == 0)
  7093. {
  7094. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7095. }
  7096. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7097. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7098. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7099. groupCostMap = groupCostMap.Select(x =>
  7100. {
  7101. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7102. {
  7103. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7104. }
  7105. return x;
  7106. }).ToList();
  7107. //GroupCostParameter.Add(new
  7108. // Grp_GroupCostParameter());
  7109. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7110. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7111. return Ok(JsonView(new
  7112. {
  7113. groupList,
  7114. groupInfo,
  7115. groupChecks,
  7116. groupCost = groupCostMap,
  7117. hotelNumber,
  7118. GroupCostParameter = GroupCostParameterMap,
  7119. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7120. {
  7121. x.VisaCountry,
  7122. x.VisaPrice,
  7123. x.Id,
  7124. }).ToList(),
  7125. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7126. blackCodeIsTrue = create.Code == 0 ? true : false,
  7127. hotelIsTrue = hotelIsTrue,
  7128. }));
  7129. }
  7130. /// <summary>
  7131. /// 团组成本信息保存
  7132. /// </summary>
  7133. /// <param name="dto"></param>
  7134. /// <returns></returns>
  7135. [HttpPost]
  7136. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7137. {
  7138. if (dto.Diid <= 0 || dto.Userid <= 0)
  7139. {
  7140. return Ok(JsonView(false));
  7141. }
  7142. JsonView jw = null;
  7143. bool isTrue = false;
  7144. #region 复制团组成本
  7145. //if (dto.Diid == 2581)
  7146. //{
  7147. // dto.Diid = 2599;
  7148. // dto.CheckBoxs.ForEach(x =>
  7149. // {
  7150. // x.Diid = 2599;
  7151. // });
  7152. // dto.GroupCosts.ForEach(x =>
  7153. // {
  7154. // x.Diid = 2599;
  7155. // });
  7156. // dto.CostTypeHotelNumbers.ForEach(x =>
  7157. // {
  7158. // x.Diid = 2599;
  7159. // });
  7160. // dto.GroupCostParameters.ForEach(x =>
  7161. // {
  7162. // x.DiId = 2599;
  7163. // });
  7164. //}
  7165. #endregion
  7166. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7167. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7168. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7169. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7170. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7171. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7172. try
  7173. {
  7174. _sqlSugar.BeginTran();
  7175. isTrue = await _GroupCostRepository.
  7176. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7177. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7178. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7179. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7180. _sqlSugar.CommitTran();
  7181. jw = JsonView(true, "保存成功!", isTrue);
  7182. }
  7183. catch (Exception)
  7184. {
  7185. _sqlSugar.RollbackTran();
  7186. jw = JsonView(false);
  7187. }
  7188. return Ok(jw);
  7189. }
  7190. /// <summary>
  7191. /// 司兼导数据
  7192. /// </summary>
  7193. /// <param name="dto"></param>
  7194. /// <returns></returns>
  7195. [HttpPost]
  7196. public IActionResult GetCarGuides(CarGuidesDto dto)
  7197. {
  7198. JsonView jw = null;
  7199. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7200. jw = JsonView(true, "获取成功!", Data);
  7201. return Ok(jw);
  7202. }
  7203. /// <summary>
  7204. /// 导游数据
  7205. /// </summary>
  7206. /// <param name="dto"></param>
  7207. /// <returns></returns>
  7208. [HttpPost]
  7209. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7210. {
  7211. JsonView jw = null;
  7212. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7213. // 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
  7214. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7215. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7216. jw = JsonView(true, "获取成功!", Data);
  7217. return Ok(jw);
  7218. }
  7219. /// <summary>
  7220. /// 成本车数据
  7221. /// </summary>
  7222. /// <param name="dto"></param>
  7223. /// <returns></returns>
  7224. [HttpPost]
  7225. public IActionResult GetCarInfo(CarGuidesDto dto)
  7226. {
  7227. JsonView jw = null;
  7228. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7229. jw = JsonView(true, "获取成功!", Data);
  7230. return Ok(jw);
  7231. }
  7232. /// <summary>
  7233. /// 景点数据
  7234. /// </summary>
  7235. /// <param name="dto"></param>
  7236. /// <returns></returns>
  7237. [HttpPost]
  7238. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7239. {
  7240. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7241. return Ok(JsonView(true, "获取成功!", Data));
  7242. }
  7243. /// <summary>
  7244. /// 成本通知
  7245. /// </summary>
  7246. /// <param name="dto"></param>
  7247. /// <returns></returns>
  7248. [HttpPost]
  7249. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7250. {
  7251. if (dto.Diid < 0)
  7252. {
  7253. return Ok(JsonView(false));
  7254. }
  7255. JsonView jw = null;
  7256. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7257. if (GroupCostParameter != null)
  7258. {
  7259. int IsShare = 0;
  7260. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7261. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7262. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7263. string msg = string.Empty;
  7264. if (isTrue)
  7265. {
  7266. if (IsShare == 0)
  7267. {
  7268. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7269. }
  7270. else
  7271. {
  7272. #region 企微通知对应岗位用户
  7273. try
  7274. {
  7275. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7276. }
  7277. catch (Exception ex)
  7278. {
  7279. }
  7280. #endregion
  7281. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7282. }
  7283. jw = JsonView(isTrue, msg, new { IsShare });
  7284. }
  7285. else
  7286. {
  7287. msg = "修改失败!";
  7288. jw = JsonView(isTrue, msg);
  7289. }
  7290. }
  7291. else
  7292. {
  7293. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7294. }
  7295. return Ok(jw);
  7296. }
  7297. /// <summary>
  7298. /// 导出报价单
  7299. /// </summary>
  7300. /// <param name="dto"></param>
  7301. /// <returns></returns>
  7302. [HttpPost]
  7303. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7304. {
  7305. if (dto.Diid == 0)
  7306. {
  7307. return Ok(JsonView(false, "请传递团组id"));
  7308. }
  7309. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7310. if (deleInfo.Code != 0)
  7311. {
  7312. return Ok(JsonView(false, "团组信息查询失败!"));
  7313. }
  7314. var di = deleInfo.Data as DelegationInfoWebView;
  7315. if (di != null)
  7316. {
  7317. di.TeamName = di.TeamName.Replace("|","、");
  7318. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7319. //文件名
  7320. string strFileName = di.TeamName + "-收款账单.doc";
  7321. //获取模板
  7322. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7323. //载入模板
  7324. Document doc = new Document(tmppath);
  7325. decimal TotalPrice = 0.00M;
  7326. string itemStr = string.Empty;
  7327. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7328. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7329. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7330. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7331. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7332. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7333. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7334. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7335. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7336. foreach (var cost in groupCostType)
  7337. {
  7338. var List = cost.ToList();
  7339. if (cost.Key == "A")
  7340. {
  7341. foreach (var ListItem in List)
  7342. {
  7343. if (ListItem.number > 0)
  7344. {
  7345. if (ListItem.code.Contains("TBR"))
  7346. {
  7347. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7348. }
  7349. else
  7350. {
  7351. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7352. }
  7353. TotalPrice += (ListItem.number * ListItem.price);
  7354. }
  7355. }
  7356. }
  7357. else
  7358. {
  7359. itemStr = itemStr.Insert(0, "A段\r\n");
  7360. itemStr += "B段\r\n";
  7361. foreach (var ListItem in List)
  7362. {
  7363. if (ListItem.number > 0)
  7364. {
  7365. if (ListItem.code.Contains("TBR"))
  7366. {
  7367. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7368. }
  7369. else
  7370. {
  7371. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7372. }
  7373. TotalPrice += (ListItem.number * ListItem.price);
  7374. }
  7375. }
  7376. }
  7377. }
  7378. #region 替换Word模板书签内容
  7379. Dictionary<string, string> marks = new Dictionary<string, string>();
  7380. marks.Add("To", di.ClientUnit);//付款方
  7381. marks.Add("ToTel", di.TellPhone);//付款方电话
  7382. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7383. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7384. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7385. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7386. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7387. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7388. marks.Add("PayItemContent", itemStr);//详细信息
  7389. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7390. #endregion
  7391. ////注
  7392. //if (doc.Range.Bookmarks["Attention"] != null)
  7393. //{
  7394. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7395. // mark.Text = frList[0].Attention;
  7396. //}
  7397. foreach (var item in marks.Keys)
  7398. {
  7399. if (doc.Range.Bookmarks[item] != null)
  7400. {
  7401. Bookmark mark = doc.Range.Bookmarks[item];
  7402. mark.Text = marks[item];
  7403. }
  7404. }
  7405. byte[] bytes = null;
  7406. using (MemoryStream stream = new MemoryStream())
  7407. {
  7408. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7409. bytes = stream.ToArray();
  7410. }
  7411. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7412. return Ok(JsonView(true, "", new
  7413. {
  7414. Data = bytes,
  7415. strFileName,
  7416. }));
  7417. }
  7418. else
  7419. {
  7420. return Ok(JsonView(false, "团组信息不存在!"));
  7421. }
  7422. }
  7423. /// <summary>
  7424. /// 导出团组成本
  7425. /// </summary>
  7426. /// <param name="dto"></param>
  7427. /// <returns></returns>
  7428. [HttpPost]
  7429. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7430. {
  7431. var jw = JsonView(false);
  7432. if (dto.Diid == 0)
  7433. {
  7434. return Ok(JsonView(false, "请传递团组id"));
  7435. }
  7436. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7437. if (deleInfo.Code != 0)
  7438. {
  7439. return Ok(JsonView(false, "团组信息查询失败!"));
  7440. }
  7441. var di = deleInfo.Data as DelegationInfoWebView;
  7442. if (di == null)
  7443. {
  7444. return Ok(JsonView(false, "团组信息查询失败!"));
  7445. }
  7446. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7447. WorkbookDesigner designer = new WorkbookDesigner();
  7448. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7449. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7450. for (int i = 0; i < List_GC.Count; i++)
  7451. {
  7452. GroupCost_Excel gc = new GroupCost_Excel();
  7453. gc.Id = List_GC[i].Id;
  7454. gc.Diid = List_GC[i].Diid.ToString();
  7455. gc.DAY = List_GC[i].DAY;
  7456. string week = "";
  7457. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7458. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7459. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7460. gc.ITIN = List_GC[i].ITIN;
  7461. gc.CarType = List_GC[i].CarType;
  7462. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7463. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7464. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7465. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7466. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7467. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7468. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7469. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7470. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7471. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7472. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7473. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7474. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7475. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7476. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7477. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7478. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7479. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7480. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7481. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7482. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7483. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7484. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7485. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7486. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7487. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7488. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7489. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7490. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7491. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7492. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7493. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7494. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7495. List_GC1.Add(gc);
  7496. }
  7497. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7498. dt.TableName = "TB";
  7499. //报表标题等不用dt的值
  7500. designer.SetDataSource("TeamName", dto.title.TeamName);
  7501. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7502. designer.SetDataSource("Tax", dto.title.Tax);
  7503. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7504. designer.SetDataSource("Currency", dto.title.Currency);
  7505. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7506. designer.SetDataSource("Rate", dto.title.Rate);
  7507. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7508. var Aparams = hotels.Find(x => x.Type == "Default");
  7509. if (Aparams == null)
  7510. {
  7511. return Ok(jw);
  7512. }
  7513. //酒店数量
  7514. var txtSGRNumber = Aparams.SGR.ToString();
  7515. var txtTBRNumber = Aparams.TBR.ToString();
  7516. var txtJSESNumber = Aparams.JSES.ToString();
  7517. var txtSUITENumbe = Aparams.SUITE.ToString();
  7518. if (dto.costType == "B")
  7519. {
  7520. Aparams = hotels.Find(x => x.Type == "A");
  7521. var Bparams = hotels.Find(x => x.Type == "B");
  7522. if (Aparams == null || Bparams == null)
  7523. {
  7524. return Ok(jw);
  7525. }
  7526. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7527. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7528. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7529. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7530. }
  7531. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7532. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7533. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7534. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7535. var ws = designer.Workbook.Worksheets[0];
  7536. int Row = List_GC.Count;
  7537. int startIndex = 11;
  7538. int HideRows = 0;
  7539. List<int> hideRowsList = new List<int>();
  7540. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7541. #region A段left数据
  7542. var left = dto.leftInfo.Find(x => x.Type == "A");
  7543. if (left == null)
  7544. {
  7545. return Ok(jw);
  7546. }
  7547. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7548. if (leftBindData != null)
  7549. {
  7550. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7551. designer.SetDataSource("VisaRS", leftBindData.rs);
  7552. designer.SetDataSource("VisaXS", leftBindData.xs);
  7553. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7554. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7555. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7556. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7557. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7558. }
  7559. else
  7560. {
  7561. hideRowsList.Add(Row + startIndex + HideRows);
  7562. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7563. }
  7564. HideRows += 2;
  7565. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7566. if (leftBindData != null)
  7567. {
  7568. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7569. designer.SetDataSource("BXRS", leftBindData.rs);
  7570. designer.SetDataSource("BXXS", leftBindData.xs);
  7571. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7572. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7573. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7574. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7575. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7576. }
  7577. else
  7578. {
  7579. hideRowsList.Add(Row + startIndex + HideRows);
  7580. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7581. }
  7582. HideRows += 2;
  7583. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7584. if (leftBindData != null)
  7585. {
  7586. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7587. designer.SetDataSource("HSRS", leftBindData.rs);
  7588. designer.SetDataSource("HSXS", leftBindData.xs);
  7589. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7590. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7591. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7592. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7593. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7594. }
  7595. else
  7596. {
  7597. hideRowsList.Add(Row + startIndex + HideRows);
  7598. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7599. }
  7600. HideRows += 2;
  7601. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7602. if (leftBindData != null)
  7603. {
  7604. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7605. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7606. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7607. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7608. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7609. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7610. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7611. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7612. }
  7613. else
  7614. {
  7615. hideRowsList.Add(Row + startIndex + HideRows);
  7616. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7617. }
  7618. HideRows += 2;
  7619. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7620. if (leftBindData != null)
  7621. {
  7622. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7623. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7624. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7625. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7626. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7627. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7628. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7629. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7630. }
  7631. else
  7632. {
  7633. hideRowsList.Add(Row + startIndex + HideRows);
  7634. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7635. }
  7636. HideRows += 2;
  7637. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7638. if (leftBindData != null)
  7639. {
  7640. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7641. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7642. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7643. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7644. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7645. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7646. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7647. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7648. }
  7649. else
  7650. {
  7651. hideRowsList.Add(Row + startIndex + HideRows);
  7652. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7653. }
  7654. HideRows += 2;
  7655. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7656. if (leftBindData != null)
  7657. {
  7658. ////TBR
  7659. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7660. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7661. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7662. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7663. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7664. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7665. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7666. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7667. }
  7668. else
  7669. {
  7670. hideRowsList.Add(Row + startIndex + HideRows);
  7671. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7672. }
  7673. HideRows += 2;
  7674. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7675. if (leftBindData != null)
  7676. {
  7677. ////SGR
  7678. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7679. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7680. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7681. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7682. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7683. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7684. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7685. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7686. }
  7687. else
  7688. {
  7689. hideRowsList.Add(Row + startIndex + HideRows);
  7690. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7691. }
  7692. HideRows += 2;
  7693. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7694. if (leftBindData != null)
  7695. {
  7696. ////JS/ES
  7697. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7698. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7699. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7700. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7701. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7702. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7703. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7704. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7705. }
  7706. else
  7707. {
  7708. hideRowsList.Add(Row + startIndex + HideRows);
  7709. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7710. }
  7711. HideRows += 2;
  7712. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7713. if (leftBindData != null)
  7714. {
  7715. ////SUITE
  7716. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7717. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7718. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7719. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7720. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7721. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7722. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7723. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7724. }
  7725. else
  7726. {
  7727. hideRowsList.Add(Row + startIndex + HideRows);
  7728. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7729. }
  7730. HideRows += 2;
  7731. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7732. if (leftBindData != null)
  7733. {
  7734. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7735. designer.SetDataSource("DJRS", leftBindData.rs);
  7736. designer.SetDataSource("DJXS", leftBindData.xs);
  7737. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7738. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7739. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7740. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7741. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7742. }
  7743. else
  7744. {
  7745. hideRowsList.Add(Row + startIndex + HideRows);
  7746. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7747. }
  7748. HideRows += 2;
  7749. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7750. if (leftBindData != null)
  7751. {
  7752. designer.SetDataSource("HCPCB", leftBindData.cb);
  7753. designer.SetDataSource("HCPRS", leftBindData.rs);
  7754. designer.SetDataSource("HCPXS", leftBindData.xs);
  7755. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7756. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7757. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7758. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7759. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7760. }
  7761. else
  7762. {
  7763. hideRowsList.Add(Row + startIndex + HideRows);
  7764. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7765. }
  7766. HideRows += 2;
  7767. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7768. if (leftBindData != null)
  7769. {
  7770. designer.SetDataSource("CPCB", leftBindData.cb);
  7771. designer.SetDataSource("CPRS", leftBindData.rs);
  7772. designer.SetDataSource("CPXS", leftBindData.xs);
  7773. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7774. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7775. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7776. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7777. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7778. }
  7779. else
  7780. {
  7781. hideRowsList.Add(Row + startIndex + HideRows);
  7782. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7783. }
  7784. HideRows += 2;
  7785. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7786. if (leftBindData != null)
  7787. {
  7788. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7789. designer.SetDataSource("GWRS", leftBindData.rs);
  7790. designer.SetDataSource("GWXS", leftBindData.xs);
  7791. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7792. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7793. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7794. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7795. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7796. }
  7797. else
  7798. {
  7799. hideRowsList.Add(Row + startIndex + HideRows);
  7800. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7801. }
  7802. HideRows += 2;
  7803. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7804. if (leftBindData != null)
  7805. {
  7806. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7807. designer.SetDataSource("LYJRS", leftBindData.rs);
  7808. designer.SetDataSource("LYJXS", leftBindData.xs);
  7809. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7810. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7811. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7812. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7813. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7814. }
  7815. else
  7816. {
  7817. hideRowsList.Add(Row + startIndex + HideRows);
  7818. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7819. }
  7820. #endregion
  7821. #region A段Right信息
  7822. var right = dto.rightInfo.Find(x => x.Type == "A");
  7823. if (right == null)
  7824. {
  7825. return Ok(jw);
  7826. }
  7827. HideRows += 4;
  7828. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7829. if (rightBindData != null)
  7830. {
  7831. //经济舱 + 双人间 TBR
  7832. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7833. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7834. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7835. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7836. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7837. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7838. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7839. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7840. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7841. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7842. }
  7843. else
  7844. {
  7845. hideRowsList.Add(Row + startIndex + HideRows);
  7846. }
  7847. HideRows += 2;
  7848. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7849. if (rightBindData != null)
  7850. {
  7851. //经济舱 + 单人间 SGR
  7852. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7853. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7854. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7855. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7856. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7857. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7858. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7859. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7860. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7861. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7862. }
  7863. else
  7864. {
  7865. hideRowsList.Add(Row + startIndex + HideRows);
  7866. }
  7867. HideRows += 2;
  7868. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7869. if (rightBindData != null)
  7870. {
  7871. //公务舱 + 单人间 SGR
  7872. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7873. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7874. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7875. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7876. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7877. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7878. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7879. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7880. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7881. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7882. }
  7883. else
  7884. {
  7885. hideRowsList.Add(Row + startIndex + HideRows);
  7886. }
  7887. HideRows += 2;
  7888. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7889. if (rightBindData != null)
  7890. {
  7891. //公务舱 + 小套房 JSES
  7892. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7893. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7894. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7895. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7896. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7897. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7898. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7899. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7900. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7901. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7902. }
  7903. else
  7904. {
  7905. hideRowsList.Add(Row + startIndex + HideRows);
  7906. }
  7907. HideRows += 2;
  7908. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7909. if (rightBindData != null)
  7910. {
  7911. //公务舱 + 小套房 JSES
  7912. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7913. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7914. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7915. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7916. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7917. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7918. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7919. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7920. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7921. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7922. }
  7923. else
  7924. {
  7925. hideRowsList.Add(Row + startIndex + HideRows);
  7926. }
  7927. HideRows += 2;
  7928. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7929. if (rightBindData != null)
  7930. {
  7931. //经济舱 + 大套房
  7932. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7933. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7934. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7935. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7936. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7937. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7938. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7939. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7940. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7941. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7942. }
  7943. else
  7944. {
  7945. hideRowsList.Add(Row + startIndex + HideRows);
  7946. }
  7947. HideRows += 2;
  7948. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7949. if (rightBindData != null)
  7950. {
  7951. //头等舱 + 小套房 JSES
  7952. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7953. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7954. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7955. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7956. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7957. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7958. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7959. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7960. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7961. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7962. }
  7963. else
  7964. {
  7965. hideRowsList.Add(Row + startIndex + HideRows);
  7966. }
  7967. HideRows += 2;
  7968. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7969. if (rightBindData != null)
  7970. {
  7971. //头等舱 + 大套房
  7972. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7973. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7974. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7975. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7976. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7977. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7978. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7979. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7980. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7981. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7982. }
  7983. else
  7984. {
  7985. hideRowsList.Add(Row + startIndex + HideRows);
  7986. }
  7987. #endregion
  7988. #region B段标题清空
  7989. designer.SetDataSource("CostBDRCB", "");
  7990. designer.SetDataSource("CostBRS", "");
  7991. designer.SetDataSource("CostBXS", "");
  7992. designer.SetDataSource("CostBZCB", "");
  7993. designer.SetDataSource("CostBDRBJ", "");
  7994. designer.SetDataSource("CostBZBJ", "");
  7995. designer.SetDataSource("CostBDRLR", "");
  7996. designer.SetDataSource("CostBZLR", "");
  7997. designer.SetDataSource("CostBDRCBOM", "");
  7998. designer.SetDataSource("CostBRSOM", "");
  7999. designer.SetDataSource("CostBZCBOM", "");
  8000. designer.SetDataSource("CostBDRBJOM", "");
  8001. designer.SetDataSource("CostBZBJOM", "");
  8002. designer.SetDataSource("CostBDRLROM", "");
  8003. designer.SetDataSource("CostBZLROM", "");
  8004. #endregion
  8005. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8006. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8007. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8008. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8009. designer.SetDataSource("DJName", "地接(CNY)");
  8010. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8011. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8012. designer.SetDataSource("GWName", "公务(CNY)");
  8013. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8014. designer.SetDataSource("LYJName", "零用金(CNY)");
  8015. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8016. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8017. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8018. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8019. designer.SetDataSource("BXName", "保险(CNY)");
  8020. designer.SetDataSource("VisaName", "签证(CNY)");
  8021. #region B段基本数据
  8022. if (dto.costType == "B")
  8023. {
  8024. left = dto.leftInfo.Find(x => x.Type == "B");
  8025. if (left == null)
  8026. {
  8027. return Ok(jw);
  8028. }
  8029. #region B段left数据
  8030. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8031. if (leftBindData != null)
  8032. {
  8033. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8034. designer.SetDataSource("BHSRS", leftBindData.rs);
  8035. designer.SetDataSource("BHSXS", leftBindData.xs);
  8036. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8037. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8038. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8039. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8040. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8041. }
  8042. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8043. if (leftBindData != null)
  8044. {
  8045. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8046. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8047. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8048. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8049. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8050. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8051. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8052. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8053. }
  8054. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8055. if (leftBindData != null)
  8056. {
  8057. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8058. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8059. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8060. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8061. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8062. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8063. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8064. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8065. }
  8066. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8067. if (leftBindData != null)
  8068. {
  8069. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8070. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8071. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8072. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8073. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8074. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8075. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8076. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8077. }
  8078. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8079. if (leftBindData != null)
  8080. {
  8081. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8082. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8083. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8084. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8085. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8086. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8087. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8088. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8089. }
  8090. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8091. if (leftBindData != null)
  8092. {
  8093. designer.SetDataSource("BCPCB", leftBindData.cb);
  8094. designer.SetDataSource("BCPRS", leftBindData.rs);
  8095. designer.SetDataSource("BCPXS", leftBindData.xs);
  8096. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8097. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8098. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8099. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8100. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8101. }
  8102. //TBR
  8103. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8104. if (leftBindData != null)
  8105. {
  8106. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8107. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8108. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8109. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8110. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8111. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8112. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8113. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8114. }
  8115. //SGR
  8116. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8117. if (leftBindData != null)
  8118. {
  8119. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8120. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8121. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8122. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8123. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8124. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8125. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8126. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8127. }
  8128. //JS/ES
  8129. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8130. if (leftBindData != null)
  8131. {
  8132. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8133. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8134. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8135. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8136. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8137. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8138. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8139. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8140. }
  8141. //SUITE
  8142. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8143. if (leftBindData != null)
  8144. {
  8145. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8146. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8147. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8148. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8149. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8150. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8151. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8152. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8153. }
  8154. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8155. if (leftBindData != null)
  8156. {
  8157. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8158. designer.SetDataSource("BDJRS", leftBindData.rs);
  8159. designer.SetDataSource("BDJXS", leftBindData.xs);
  8160. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8161. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8162. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8163. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8164. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8165. }
  8166. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8167. if (leftBindData != null)
  8168. {
  8169. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8170. designer.SetDataSource("BGWRS", leftBindData.rs);
  8171. designer.SetDataSource("BGWXS", leftBindData.xs);
  8172. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8173. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8174. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8175. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8176. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8177. }
  8178. #region 优化方案
  8179. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8180. //excelBind.Add("零用金", new {
  8181. //cb="",
  8182. //rs="",
  8183. //xs ="",
  8184. //zcb = "",
  8185. //});
  8186. #endregion
  8187. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8188. if (leftBindData != null)
  8189. {
  8190. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8191. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8192. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8193. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8194. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8195. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8196. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8197. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8198. }
  8199. #endregion
  8200. #region B段Right信息
  8201. right = dto.rightInfo.Find(x => x.Type == "B");
  8202. if (right == null)
  8203. {
  8204. return Ok(jw);
  8205. }
  8206. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8207. if (rightBindData != null)
  8208. {
  8209. //经济舱 + 双人间 TBR
  8210. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8211. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8212. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8213. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8214. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8215. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8216. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8217. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8218. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8219. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8220. }
  8221. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8222. if (rightBindData != null)
  8223. {
  8224. //经济舱 + 单人间 SGR
  8225. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8226. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8227. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8228. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8229. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8230. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8231. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8232. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8233. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8234. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8235. }
  8236. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8237. if (rightBindData != null)
  8238. {
  8239. //公务舱 + 单人间 SGR
  8240. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8241. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8242. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8243. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8244. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8245. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8246. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8247. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8248. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8249. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8250. }
  8251. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8252. if (rightBindData != null)
  8253. {
  8254. //公务舱 + 小套房 JSES
  8255. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8256. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8257. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8258. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8259. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8260. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8261. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8262. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8263. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8264. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8265. }
  8266. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8267. if (rightBindData != null)
  8268. {
  8269. //公务舱 + 小套房 JSES
  8270. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8271. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8272. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8273. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8274. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8275. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8276. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8277. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8278. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8279. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8280. }
  8281. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8282. if (rightBindData != null)
  8283. {
  8284. //经济舱 + 大套房
  8285. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8286. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8287. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8288. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8289. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8290. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8291. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8292. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8293. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8294. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8295. }
  8296. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8297. if (rightBindData != null)
  8298. {
  8299. //头等舱 + 小套房 JSES
  8300. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8301. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8302. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8303. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8304. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8305. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8306. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8307. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8308. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8309. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8310. }
  8311. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8312. if (rightBindData != null)
  8313. {
  8314. //头等舱 + 大套房
  8315. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8316. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8317. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8318. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8319. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8320. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8321. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8322. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8323. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8324. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8325. }
  8326. #endregion
  8327. #region 标题
  8328. designer.SetDataSource("CostBDRCB", "单人成本");
  8329. designer.SetDataSource("CostBRS", "人数");
  8330. designer.SetDataSource("CostBXS", "系数");
  8331. designer.SetDataSource("CostBZCB", "总成本");
  8332. designer.SetDataSource("CostBDRBJ", "单人报价");
  8333. designer.SetDataSource("CostBZBJ", "总报价");
  8334. designer.SetDataSource("CostBDRLR", "单人利润");
  8335. designer.SetDataSource("CostBZLR", "总利润");
  8336. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8337. designer.SetDataSource("CostBRSOM", "人数");
  8338. designer.SetDataSource("CostBZCBOM", "总成本");
  8339. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8340. designer.SetDataSource("CostBZBJOM", "总报价");
  8341. designer.SetDataSource("CostBDRLROM", "单人利润");
  8342. designer.SetDataSource("CostBZLROM", "总利润");
  8343. #endregion
  8344. }
  8345. #endregion
  8346. designer.SetDataSource("TzZCB2", TzZCB2);
  8347. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8348. designer.SetDataSource("TzZLR2", TzZLR2);
  8349. string[] dataSourceKeys = new string[]
  8350. {
  8351. "VF",
  8352. "TGS",
  8353. "TGOF",
  8354. "TGM",
  8355. "TGA",
  8356. "TGTF",
  8357. "TGEF",
  8358. "CFM",
  8359. "CFOF",
  8360. "B",
  8361. "L",
  8362. "D",
  8363. "TBR",
  8364. "SGR",
  8365. "JSES",
  8366. "Suite",
  8367. "TV",
  8368. "1L",
  8369. "IF",
  8370. "EF",
  8371. "BRF",
  8372. "TE",
  8373. "TGT",
  8374. "DRVT",
  8375. "PC",
  8376. "TLF",
  8377. "ECT"
  8378. };
  8379. foreach (var item in dataSourceKeys)
  8380. {
  8381. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8382. if (find != null)
  8383. {
  8384. designer.SetDataSource(item, find.text);
  8385. }
  8386. else
  8387. {
  8388. designer.SetDataSource(item, 0);
  8389. }
  8390. }
  8391. designer.SetDataSource(dt);
  8392. //根据数据源处理生成报表内容
  8393. designer.Process();
  8394. designer.Workbook.Worksheets[0].Name = "清单";
  8395. Worksheet sheet = designer.Workbook.Worksheets[0];
  8396. foreach (var Rowindex in hideRowsList)
  8397. {
  8398. ws.Cells.HideRows(Rowindex, 2);
  8399. }
  8400. byte[] bytes = null;
  8401. string strFileName = di.TeamName + "-团组-成本.xls";
  8402. using (MemoryStream stream = new MemoryStream())
  8403. {
  8404. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8405. bytes = stream.ToArray();
  8406. }
  8407. return Ok(JsonView(true, "", new
  8408. {
  8409. Data = bytes,
  8410. strFileName,
  8411. }));
  8412. }
  8413. /// <summary>
  8414. /// 导出客户报表
  8415. /// </summary>
  8416. /// <returns></returns>
  8417. [HttpPost]
  8418. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8419. {
  8420. var jw = JsonView(false);
  8421. if (dto.Diid == 0)
  8422. {
  8423. return Ok(JsonView(false, "请传递团组id"));
  8424. }
  8425. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8426. if (deleInfo.Code != 0)
  8427. {
  8428. return Ok(JsonView(false, "团组信息查询失败!"));
  8429. }
  8430. var di = deleInfo.Data as DelegationInfoWebView;
  8431. if (di == null)
  8432. {
  8433. return Ok(JsonView(false, "团组信息查询失败!"));
  8434. }
  8435. //文件名
  8436. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8437. //获取模板
  8438. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8439. //载入模板
  8440. Document doc = new Document(tmppath);
  8441. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8442. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8443. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8444. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8445. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8446. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8447. if (AParameter == null)
  8448. {
  8449. return Ok(JsonView(false, "系数不存在!"));
  8450. }
  8451. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8452. , TzAirDesc, TzZCost;
  8453. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8454. = TzAirDesc = TzZCost = string.Empty;
  8455. TzNumber = AParameter.CostTypenumber.ToString();
  8456. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8457. CarGuides1 = dto.CarGuides1;
  8458. Meal = dto.Meal;
  8459. SubsidizedMeals = dto.SubsidizedMeals;
  8460. NightRepair = dto.NightRepair;
  8461. AttractionsTickets = dto.AttractionsTickets;
  8462. MiscellaneousFees = dto.MiscellaneousFees;
  8463. ATip = dto.ATip;
  8464. TzHotelDesc = "";
  8465. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8466. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8467. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8468. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8469. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8470. TzAirDesc = "";
  8471. TzZCost = dto.TzZCost;
  8472. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8473. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8474. var index = 1;
  8475. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8476. foreach (var item in TzHotelDescArr)
  8477. {
  8478. if (AinfoArr != null)
  8479. {
  8480. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8481. if (Ainfo != null)
  8482. {
  8483. if (int.Parse(Ainfo.rs) <= 0)
  8484. {
  8485. continue;
  8486. }
  8487. var hotelText = string.Empty;
  8488. switch (item)
  8489. {
  8490. case "SGR":
  8491. hotelText = "单人间";
  8492. break;
  8493. case "JSES":
  8494. hotelText = "小套房";
  8495. break;
  8496. case "SUITE":
  8497. hotelText = "套房";
  8498. break;
  8499. case "TBR":
  8500. hotelText = "双人间";
  8501. break;
  8502. }
  8503. if (item != "TBR")
  8504. {
  8505. 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";
  8506. }
  8507. else
  8508. {
  8509. 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";
  8510. }
  8511. index++;
  8512. }
  8513. }
  8514. }
  8515. index = 1;
  8516. foreach (var item in TzAirDescArr)
  8517. {
  8518. if (AinfoArr != null)
  8519. {
  8520. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8521. if (Ainfo != null)
  8522. {
  8523. if (int.Parse(Ainfo.rs) <= 0)
  8524. {
  8525. continue;
  8526. }
  8527. 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";
  8528. index++;
  8529. }
  8530. }
  8531. }
  8532. if (dto.costType == "B")
  8533. {
  8534. if (BParameter == null)
  8535. {
  8536. return Ok(JsonView(false, "B段系数不存在!"));
  8537. }
  8538. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8539. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8540. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8541. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8542. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8543. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8544. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8545. foreach (var item in TzHotelDescArr)
  8546. {
  8547. if (AinfoArr != null)
  8548. {
  8549. TzHotelDesc += "B段信息 \r\n";
  8550. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8551. if (Ainfo != null)
  8552. {
  8553. if (int.Parse(Ainfo.rs) <= 0)
  8554. {
  8555. continue;
  8556. }
  8557. var hotelText = string.Empty;
  8558. switch (item)
  8559. {
  8560. case "SGR":
  8561. hotelText = "单人间";
  8562. break;
  8563. case "JSES":
  8564. hotelText = "小套房";
  8565. break;
  8566. case "SUITE":
  8567. hotelText = "套房";
  8568. break;
  8569. case "TBR":
  8570. hotelText = "双人间";
  8571. break;
  8572. }
  8573. if (item != "TBR")
  8574. {
  8575. 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";
  8576. }
  8577. else
  8578. {
  8579. 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";
  8580. }
  8581. index++;
  8582. }
  8583. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8584. }
  8585. }
  8586. index = 1;
  8587. foreach (var item in TzAirDescArr)
  8588. {
  8589. if (AinfoArr != null)
  8590. {
  8591. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8592. if (Ainfo != null)
  8593. {
  8594. if (int.Parse(Ainfo.rs) <= 0)
  8595. {
  8596. continue;
  8597. }
  8598. 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";
  8599. index++;
  8600. }
  8601. }
  8602. }
  8603. }
  8604. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8605. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8606. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8607. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8608. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8609. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8610. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8611. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8612. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8613. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8614. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8615. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8616. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8617. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8618. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8619. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8620. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8621. DickeyValue.Add("TzZCost", TzZCost);
  8622. foreach (var key in DickeyValue.Keys)
  8623. {
  8624. if (doc.Range.Bookmarks[key] != null)
  8625. {
  8626. Bookmark mark = doc.Range.Bookmarks[key];
  8627. mark.Text = DickeyValue[key];
  8628. }
  8629. }
  8630. byte[] bytes = null;
  8631. string strFileName = di.TeamName + "-客户报价.doc";
  8632. using (MemoryStream stream = new MemoryStream())
  8633. {
  8634. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8635. bytes = stream.ToArray();
  8636. }
  8637. return Ok(JsonView(true, "", new
  8638. {
  8639. Data = bytes,
  8640. strFileName,
  8641. }));
  8642. }
  8643. /// <summary>
  8644. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8645. /// </summary>
  8646. /// <param name="dto"></param>
  8647. /// <returns></returns>
  8648. [HttpPost]
  8649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8650. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8651. {
  8652. try
  8653. {
  8654. #region 参数验证
  8655. if (dto.DiId < 0)
  8656. {
  8657. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8658. }
  8659. List<int> cTableIds = new List<int>() {
  8660. 76 ,//酒店预订
  8661. 77 ,//行程
  8662. 79 ,//车/导游地接
  8663. 80 ,//签证
  8664. 81 ,//邀请/公务活
  8665. 82 ,//团组客户保险
  8666. 85 ,//机票预订
  8667. 98 ,//其他款项
  8668. 285 ,//收款退还
  8669. 751 ,//酒店早餐
  8670. 1015 // 超支费用
  8671. };
  8672. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8673. {
  8674. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8675. }
  8676. #endregion
  8677. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8678. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8679. if (_GroupCostParameters.Count <= 0)
  8680. {
  8681. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8682. }
  8683. if (_GroupCostParameters[0].IsShare == 0)
  8684. {
  8685. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8686. }
  8687. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8688. //处理date为空问题
  8689. if (_GroupCosts.Count > 0)
  8690. {
  8691. for (int i = 0; i < _GroupCosts.Count; i++)
  8692. {
  8693. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8694. {
  8695. if (i > 0)
  8696. {
  8697. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8698. }
  8699. }
  8700. }
  8701. }
  8702. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8703. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8704. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8705. string currCode = "";
  8706. #region currCode 验证
  8707. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8708. if (isInt)
  8709. {
  8710. var currData = currDatas.Find(it => it.Id == intCurrency);
  8711. if (currData != null)
  8712. {
  8713. currCode = currData.Name;
  8714. }
  8715. }
  8716. else
  8717. {
  8718. currCode = _GroupCostParameters[0].Currency.Trim();
  8719. }
  8720. #endregion
  8721. //op,酒店单段模式存储
  8722. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8723. {
  8724. CurrencyCode = currCode,
  8725. Rate = _GroupCostParameters[0].Rate,
  8726. CostType = _GroupCostParameters[0].CostType,
  8727. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8728. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8729. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8730. };
  8731. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8732. if (_GroupCostParameters.Count == 2)
  8733. {
  8734. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8735. }
  8736. foreach (var item in _GroupCostParameters)
  8737. {
  8738. decimal _rate = 1;
  8739. decimal _rate1 = item.Rate;
  8740. decimal _scale = 1;
  8741. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8742. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8743. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8744. //if (userInfo != null)
  8745. //{
  8746. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8747. // {
  8748. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8749. // {
  8750. // _scale = 1.00M;
  8751. // }
  8752. // }
  8753. //}
  8754. #endregion
  8755. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8756. {
  8757. CurrencyCode = currCode,
  8758. Rate = _rate1,
  8759. CostType = item.CostType,
  8760. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8761. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8762. CostTypeNumber = item.CostTypenumber
  8763. };
  8764. if (_GroupCostParameters.Count > 1)
  8765. {
  8766. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8767. }
  8768. else
  8769. {
  8770. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8771. }
  8772. if (dto.CTable == 79)//
  8773. {
  8774. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8775. modulePromptInfo.TotalCost = item.DJCB;
  8776. }
  8777. List<string> costTypes = new List<string>() { "A", "B" };
  8778. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8779. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8780. if (_GroupCostsDuplicates.Count() == 1)
  8781. {
  8782. _GroupCostsTypeData = _GroupCosts;
  8783. }
  8784. else
  8785. {
  8786. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8787. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8788. }
  8789. /*
  8790. * 76 酒店预订
  8791. * 77 行程
  8792. * 79 车/导游地接
  8793. * 80 签证
  8794. * 81 邀请/公务活动
  8795. * 82 团组客户保险
  8796. * 85 机票预订
  8797. * 98 其他款项
  8798. * 285 收款退还
  8799. * 751 酒店早餐
  8800. * 1015 超支费用
  8801. */
  8802. switch (dto.CTable)
  8803. {
  8804. case 76: // 酒店预订
  8805. _ModuleSubPromptInfo.AddRange(
  8806. _GroupCostsTypeData.Select(it => new
  8807. {
  8808. it.DAY,
  8809. it.Date,
  8810. it.ACCON,
  8811. it.ITIN,
  8812. it.SGR,
  8813. it.TBR,
  8814. it.JS_ES,
  8815. it.Suite
  8816. })
  8817. );
  8818. break;
  8819. case 79: // 车/导游地接
  8820. _ModuleSubPromptInfo.AddRange(
  8821. _GroupCostsTypeData.Select(it => new
  8822. {
  8823. Date = it.Date, //日期
  8824. CarFee = it.CarCost * _rate * _scale, //车费用
  8825. CarType = it.CarType, //车型
  8826. DriverFee = it.CFS * _rate * _scale, //司机工资
  8827. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8828. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8829. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8830. GuideFee = it.TGS * _rate * _scale, //导游费用
  8831. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8832. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8833. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8834. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8835. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8836. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8837. Breakfast = it.B * _rate * _scale, //早餐费
  8838. Lunch = it.L * _rate * _scale, //午餐费
  8839. Dinner = it.D * _rate * _scale, //晚餐费
  8840. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8841. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8842. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8843. TicketFee = it.EF * _rate * _scale, //门票费
  8844. TicketRemark = it.EFR, //门票费描述
  8845. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8846. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8847. SpentCash = it.PC * _rate * _scale, //零用金
  8848. LeadersFee = it.TLF * _rate * _scale, //领队费
  8849. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8850. })
  8851. );
  8852. break;
  8853. case 85: // 机票
  8854. List<dynamic> datas = new List<dynamic>();
  8855. datas.Add(
  8856. new
  8857. {
  8858. AirType = "经济舱",
  8859. AirNum = item.JJCRS,
  8860. AirDRCB = item.JJCCB,
  8861. AirZCB = (item.JJCRS * item.JJCCB)
  8862. }
  8863. );
  8864. datas.Add(
  8865. new
  8866. {
  8867. AirType = "公务舱",
  8868. AirNum = item.GWCRS,
  8869. AirDRCB = item.GWCCB,
  8870. AirZCB = (item.GWCRS * item.GWCCB)
  8871. }
  8872. );
  8873. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8874. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8875. modulePromptInfo.Data = new
  8876. {
  8877. airFeeData = datas,
  8878. airInitData = initDatas
  8879. };
  8880. _ModulePromptInfos.Add(modulePromptInfo);
  8881. break;
  8882. default:
  8883. break;
  8884. }
  8885. }
  8886. if (dto.CTable != 85)
  8887. {
  8888. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8889. _ModulePromptInfos.Add(_ModulePromptInfo);
  8890. }
  8891. _view.ModulePromptInfos = _ModulePromptInfos;
  8892. return Ok(JsonView(true, "操作成功!", _view));
  8893. }
  8894. catch (Exception ex)
  8895. {
  8896. return Ok(JsonView(false, ex.Message));
  8897. }
  8898. }
  8899. /// <summary>
  8900. /// 根据黑屏代码重新生成行程
  8901. /// </summary>
  8902. /// <param name="dto"></param>
  8903. /// <returns></returns>
  8904. [HttpPost]
  8905. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8906. {
  8907. var jw = JsonView(false);
  8908. var Create = _GroupCostRepository.
  8909. CreateGroupCostByBlackCode(dto.Diid);
  8910. jw.Msg = Create.Msg;
  8911. if (Create.Code == 0)
  8912. {
  8913. jw.Code = 200;
  8914. jw.Data = new
  8915. {
  8916. groupCost = Create.Data,
  8917. blackCodeIsTrue = true
  8918. };
  8919. }
  8920. else
  8921. {
  8922. jw.Code = 400;
  8923. jw.Data = new
  8924. {
  8925. groupCost = Create.Data,
  8926. blackCodeIsTrue = false,
  8927. };
  8928. }
  8929. return Ok(jw);
  8930. }
  8931. /// <summary>
  8932. /// 成本获取OP历史车费用
  8933. /// </summary>
  8934. /// <param name="dto"></param>
  8935. /// <returns></returns>
  8936. [HttpPost]
  8937. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8938. {
  8939. var jw = JsonView(false);
  8940. try
  8941. {
  8942. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8943. //获取现有所有车的数据
  8944. if (!dto.Param.IsNullOrWhiteSpace())
  8945. {
  8946. string sql = $@"
  8947. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8948. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8949. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8950. 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
  8951. AND gctggr.ServiceEndTime is not NULL
  8952. ORDER by gctggrc.id DESC
  8953. ";
  8954. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8955. var numeberResult = await Task.Run(() =>
  8956. {
  8957. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8958. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8959. return numberArr;
  8960. });
  8961. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8962. foreach (var item in numeberResult)
  8963. {
  8964. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8965. {
  8966. Country = "数据异常!",
  8967. City = string.Empty,
  8968. };
  8969. item.Area = find.Country + " " + find.City;
  8970. }
  8971. dbResult.AddRange(numeberResult);
  8972. if (dto.Param.Contains("、"))
  8973. {
  8974. var sp = dto.Param.Split("、");
  8975. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8976. .Where(x =>
  8977. {
  8978. return System.Array.Exists(sp, e =>
  8979. {
  8980. bool where = false;
  8981. if (x.Area != null)
  8982. {
  8983. where = x.Area.Contains(e);
  8984. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8985. {
  8986. return false;
  8987. }
  8988. }
  8989. if (x.PriceName != null && !where)
  8990. {
  8991. where = x.PriceName.Contains(e);
  8992. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8993. {
  8994. return false;
  8995. }
  8996. }
  8997. return where;
  8998. });
  8999. }).ToList();
  9000. }
  9001. else
  9002. {
  9003. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9004. .Where(x =>
  9005. {
  9006. bool where = false;
  9007. if (x.Area != null)
  9008. {
  9009. where = x.Area.Contains(dto.Param);
  9010. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9011. {
  9012. return false;
  9013. }
  9014. }
  9015. if (x.PriceName != null && !where)
  9016. {
  9017. where = x.PriceName.Contains(dto.Param);
  9018. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9019. {
  9020. return false;
  9021. }
  9022. }
  9023. return where;
  9024. }
  9025. )
  9026. .ToList();
  9027. }
  9028. }
  9029. var view = dbResult.Select(x =>
  9030. {
  9031. decimal dp = 0.00M;
  9032. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9033. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9034. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9035. {
  9036. if (startB && endB)
  9037. {
  9038. var timesp = endD.Subtract(startD);
  9039. if ((timesp.Days + 1) != 0)
  9040. {
  9041. dp = x.Price / (timesp.Days + 1);
  9042. }
  9043. }
  9044. }
  9045. else
  9046. {
  9047. dp = x.Price;
  9048. }
  9049. return new
  9050. {
  9051. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9052. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9053. x.Area,
  9054. x.id,
  9055. price = x.Price.ToString("F2"),
  9056. x.PriceName,
  9057. x.PriceContent,
  9058. x.TeamName,
  9059. x.DatePrice,
  9060. dayPrice = dp.ToString("F2"),
  9061. };
  9062. }).OrderByDescending(x => x.id).ToList();
  9063. jw = JsonView(true, "获取成功!", view);
  9064. }
  9065. catch (Exception e)
  9066. {
  9067. jw = JsonView(false, e.Message);
  9068. }
  9069. return Ok(jw);
  9070. }
  9071. #endregion
  9072. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9073. /// <summary>
  9074. /// 酒店预订
  9075. /// 酒店费用列表 根据团组Id查询
  9076. /// </summary>
  9077. /// <param name="_dto"></param>
  9078. /// <returns></returns>
  9079. [HttpPost]
  9080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9081. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9082. {
  9083. #region 参数验证
  9084. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9085. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9086. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9087. #region 团组操作权限验证 76 酒店预定模块
  9088. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9089. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9090. #endregion
  9091. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9092. #region 页面操作权限验证
  9093. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9094. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9095. #endregion
  9096. #endregion
  9097. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9098. }
  9099. /// <summary>
  9100. /// 酒店预订
  9101. /// 基础数据
  9102. /// </summary>
  9103. /// <param name="_dto"></param>
  9104. /// <returns></returns>
  9105. [HttpPost]
  9106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9107. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9108. {
  9109. #region 参数验证
  9110. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9111. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9112. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9113. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9114. #region 页面操作权限验证
  9115. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9116. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9117. #endregion
  9118. #region 团组操作权限验证 76 酒店预定模块
  9119. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9120. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9121. #endregion
  9122. #endregion
  9123. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9124. }
  9125. /// <summary>
  9126. /// 酒店预订
  9127. /// 创建 入住卷号码
  9128. /// </summary>
  9129. /// <param name="_dto"></param>
  9130. /// <returns></returns>
  9131. [HttpPost]
  9132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9133. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9134. {
  9135. #region 参数验证
  9136. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9137. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9138. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9139. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9140. #region 页面操作权限验证
  9141. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9142. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9143. #endregion
  9144. #region 团组操作权限验证 76 酒店预定模块
  9145. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9146. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9147. #endregion
  9148. #endregion
  9149. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9150. if (data.Code != 0)
  9151. {
  9152. return Ok(JsonView(false, data.Msg));
  9153. }
  9154. return Ok(JsonView(true, data.Msg, data.Data));
  9155. }
  9156. /// <summary>
  9157. /// 酒店预订
  9158. /// 详情
  9159. /// </summary>
  9160. /// <param name="_dto"></param>
  9161. /// <returns></returns>
  9162. [HttpPost]
  9163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9164. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9165. {
  9166. #region 参数验证
  9167. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9168. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9169. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9170. #region 团组操作权限验证 76 酒店预定模块
  9171. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9172. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9173. #endregion
  9174. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9175. #region 页面操作权限验证
  9176. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9177. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9178. #endregion
  9179. #endregion
  9180. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9181. }
  9182. /// <summary>
  9183. /// 酒店预订
  9184. /// Add Or Edit
  9185. /// </summary>
  9186. /// <param name="_dto"></param>
  9187. /// <returns></returns>
  9188. [HttpPost]
  9189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9190. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9191. {
  9192. #region 参数验证
  9193. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9194. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9195. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9196. #region 团组操作权限验证 76 酒店预定模块
  9197. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9198. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9199. #endregion
  9200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9201. #region 页面操作权限验证
  9202. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9203. if (_dto.Id == 0) // Add
  9204. {
  9205. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9206. }
  9207. else if (_dto.Id > 1) // Edit
  9208. {
  9209. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9210. }
  9211. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9212. #endregion
  9213. #endregion
  9214. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9215. if (_view.Code != 200)
  9216. {
  9217. return Ok(_view);
  9218. }
  9219. #region 应用推送
  9220. try
  9221. {
  9222. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9223. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9224. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9225. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9226. //自动审核
  9227. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9228. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9229. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9230. }
  9231. catch (Exception ex)
  9232. {
  9233. }
  9234. #endregion
  9235. return Ok(_view);
  9236. }
  9237. /// <summary>
  9238. /// 酒店自动审核测试
  9239. /// Add Or Edit
  9240. /// </summary>
  9241. /// <param name="_dto"></param>
  9242. /// <returns></returns>
  9243. [HttpPost]
  9244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9245. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  9246. {
  9247. #region 应用推送
  9248. try
  9249. {
  9250. //自动审核
  9251. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9252. }
  9253. catch (Exception ex)
  9254. {
  9255. return Ok(JsonView(false, "操作失败"));
  9256. }
  9257. #endregion
  9258. return Ok(JsonView(false,"操作成功"));
  9259. }
  9260. /// <summary>
  9261. /// 酒店预订
  9262. /// Del
  9263. /// </summary>
  9264. /// <param name="_dto"></param>
  9265. /// <returns></returns>
  9266. [HttpPost]
  9267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9268. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9269. {
  9270. #region 参数验证
  9271. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9272. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9273. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9274. #region 团组操作权限验证 76 酒店预定模块
  9275. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9276. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9277. #endregion
  9278. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9279. #region 页面操作权限验证
  9280. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9281. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9282. #endregion
  9283. #endregion
  9284. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9285. }
  9286. /// <summary>
  9287. /// 酒店预订
  9288. /// 生成VOUCHER
  9289. /// 2024.05.06 之前版本
  9290. /// </summary>
  9291. /// <param name="_dto"></param>
  9292. /// <returns></returns>
  9293. [HttpPost]
  9294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9295. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9296. {
  9297. try
  9298. {
  9299. #region 参数验证
  9300. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9301. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9302. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9303. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9304. #region 团组操作权限验证 76 酒店预定模块
  9305. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9306. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9307. #endregion
  9308. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9309. #region 页面操作权限验证
  9310. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9311. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9312. #endregion
  9313. #endregion
  9314. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9315. //判断数据是否完整
  9316. if (hr != null)
  9317. {
  9318. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9319. {
  9320. string strFileName = "HotelStatement/";
  9321. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9322. if (dele != null)
  9323. strFileName += dele.TourCode;
  9324. //载入模板
  9325. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9326. Document doc = new Document(sss);
  9327. DocumentBuilder builder = new DocumentBuilder(doc);
  9328. #region 替换Word模板书签内容
  9329. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9330. //入住卷预定号码
  9331. if (doc.Range.Bookmarks["VNO"] != null)
  9332. {
  9333. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9334. mark.Text = hr.CheckNumber;
  9335. }
  9336. //酒店时间
  9337. if (doc.Range.Bookmarks["Date"] != null)
  9338. {
  9339. Bookmark mark = doc.Range.Bookmarks["Date"];
  9340. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9341. }
  9342. //团号
  9343. if (doc.Range.Bookmarks["TNo"] != null)
  9344. {
  9345. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9346. mark.Text = dele.TourCode;
  9347. }
  9348. //预定号码
  9349. if (doc.Range.Bookmarks["BookingId"] != null)
  9350. {
  9351. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9352. mark.Text = hr.ReservationsNo;
  9353. }
  9354. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9355. {
  9356. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9357. mark.Text = hr.DetermineNo;
  9358. }
  9359. //酒店城市
  9360. if (doc.Range.Bookmarks["City"] != null)
  9361. {
  9362. Bookmark mark = doc.Range.Bookmarks["City"];
  9363. mark.Text = hr.City;
  9364. }
  9365. //酒店名称
  9366. if (doc.Range.Bookmarks["HName"] != null)
  9367. {
  9368. Bookmark mark = doc.Range.Bookmarks["HName"];
  9369. mark.Text = hr.HotelName;
  9370. }
  9371. //酒店地址
  9372. if (doc.Range.Bookmarks["Address"] != null)
  9373. {
  9374. Bookmark mark = doc.Range.Bookmarks["Address"];
  9375. mark.Text = hr.HotelAddress;
  9376. }
  9377. //酒店电话
  9378. if (doc.Range.Bookmarks["Tel"] != null)
  9379. {
  9380. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9381. mark.Text = hr.HotelTel;
  9382. }
  9383. //酒店传真
  9384. if (doc.Range.Bookmarks["Fax"] != null)
  9385. {
  9386. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9387. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9388. {
  9389. mark.Text = hr.HotelFax;
  9390. }
  9391. }
  9392. //入住时间
  9393. if (doc.Range.Bookmarks["CIn"] != null)
  9394. {
  9395. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9396. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9397. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9398. }
  9399. //退房时间
  9400. if (doc.Range.Bookmarks["COut"] != null)
  9401. {
  9402. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9403. Bookmark mark = doc.Range.Bookmarks["COut"];
  9404. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9405. }
  9406. //客户名称
  9407. if (doc.Range.Bookmarks["GName"] != null)
  9408. {
  9409. string guestName = "";
  9410. string[] clients = new string[] { };
  9411. if (hr.GuestName.Contains(","))
  9412. {
  9413. clients = hr.GuestName.Split(",");
  9414. }
  9415. else
  9416. {
  9417. clients = new string[] { hr.GuestName };
  9418. }
  9419. List<int> clientIds_int = new List<int>();
  9420. if (clients.Length > 0)
  9421. {
  9422. foreach (var item in clients)
  9423. {
  9424. if (item.IsNumeric())
  9425. {
  9426. clientIds_int.Add(int.Parse(item));
  9427. }
  9428. }
  9429. }
  9430. if (clientIds_int.Count > 0)
  9431. {
  9432. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9433. foreach (var client in _clientDatas)
  9434. {
  9435. //男
  9436. if (client.Sex == 0) guestName += $"Mr.";
  9437. //女
  9438. else if (client.Sex == 1) guestName += $"Ms.";
  9439. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9440. {
  9441. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9442. }
  9443. //guestName += $"{client.Pinyin},";
  9444. }
  9445. if (guestName.Length > 0)
  9446. {
  9447. guestName = guestName.Substring(0, guestName.Length - 1);
  9448. }
  9449. }
  9450. else
  9451. {
  9452. guestName = hr.GuestName;
  9453. }
  9454. Bookmark mark = doc.Range.Bookmarks["GName"];
  9455. mark.Text = guestName;
  9456. }
  9457. //房间介绍
  9458. if (doc.Range.Bookmarks["ROOM"] != null)
  9459. {
  9460. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9461. mark.Text = hr.RoomExplanation;
  9462. }
  9463. //报价描述
  9464. if (doc.Range.Bookmarks["NOTE"] != null)
  9465. {
  9466. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9467. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9468. if (ss != null)
  9469. mark.Text = ss.Name;
  9470. }
  9471. //入住时间
  9472. if (doc.Range.Bookmarks["CheckIn"] != null)
  9473. {
  9474. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9475. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9476. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9477. }
  9478. //退房时间
  9479. if (doc.Range.Bookmarks["CheckOut"] != null)
  9480. {
  9481. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9482. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9483. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9484. }
  9485. //日期
  9486. if (doc.Range.Bookmarks["DT"] != null)
  9487. {
  9488. Bookmark mark = doc.Range.Bookmarks["DT"];
  9489. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9490. }
  9491. //名称
  9492. if (doc.Range.Bookmarks["VName"] != null)
  9493. {
  9494. Bookmark mark = doc.Range.Bookmarks["VName"];
  9495. mark.Text = hr.HotelName;
  9496. }
  9497. //号码
  9498. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9499. {
  9500. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9501. mark.Text = hr.CheckNumber;
  9502. }
  9503. #endregion
  9504. strFileName += "VOUCHER.doc";
  9505. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9506. doc.Save(fileDir);
  9507. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9508. return Ok(JsonView(true, "操作成功!", Url));
  9509. }
  9510. else
  9511. {
  9512. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9513. }
  9514. }
  9515. else
  9516. {
  9517. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9518. }
  9519. }
  9520. catch (Exception ex)
  9521. {
  9522. return Ok(JsonView(false, ex.Message));
  9523. }
  9524. }
  9525. /// <summary>
  9526. /// 酒店预订
  9527. /// 生成VOUCHER
  9528. /// 2024.05.06 之后版本
  9529. /// </summary>
  9530. /// <param name="_dto"></param>
  9531. /// <returns></returns>
  9532. [HttpPost]
  9533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9534. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9535. {
  9536. #region 参数验证
  9537. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9538. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9539. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9540. #region 团组操作权限验证 76 酒店预定模块
  9541. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9542. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9543. #endregion
  9544. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9545. #region 页面操作权限验证
  9546. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9547. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9548. #endregion
  9549. #endregion
  9550. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9551. //判断数据是否完整
  9552. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9553. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9554. string strFileName = "HotelStatement/";
  9555. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9556. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9557. #region 数据处理
  9558. List<int> guestIds = new List<int>();
  9559. int index = 0;
  9560. foreach (var item in hrDtas)
  9561. {
  9562. if (item.GuestName.Contains(","))
  9563. {
  9564. string[] guestIdArr = item.GuestName.Split(',');
  9565. foreach (var guestIdStr in guestIdArr)
  9566. {
  9567. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9568. if (guestBool)
  9569. {
  9570. guestIds.Add(guestId);
  9571. }
  9572. }
  9573. }
  9574. else guestNames += item.GuestName;
  9575. var voucherInfo = new HotelVoucherInfoView()
  9576. {
  9577. HotelName = item.HotelName,
  9578. CheckInDate = item.CheckInDate,
  9579. CheckOutDate = item.CheckOutDate,
  9580. ConfirmationNumber = item.DetermineNo.Trim(),
  9581. RoomType = item.RoomExplanation
  9582. };
  9583. vouchers.Add(voucherInfo);
  9584. }
  9585. if (guestIds.Count > 0)
  9586. {
  9587. guestIds = guestIds.Distinct().ToList();
  9588. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9589. if (guestDatas.Count > 0)
  9590. {
  9591. guestNames = "";
  9592. foreach (var guest in guestDatas)
  9593. {
  9594. string guestName = "";
  9595. if (guest.Sex == 0) guestName += @"MR.";
  9596. else if (guest.Sex == 1) guestName += @"MS.";
  9597. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9598. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9599. guestNames += @$"{guestName.Trim()}、";
  9600. }
  9601. if (guestNames.Length > 0)
  9602. {
  9603. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9604. }
  9605. }
  9606. }
  9607. #endregion
  9608. //载入模板
  9609. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9610. Document doc = new Document(sss);
  9611. DocumentBuilder builder = new DocumentBuilder(doc);
  9612. if (doc.Range.Bookmarks["GuestName"] != null)
  9613. {
  9614. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9615. mark.Text = guestNames;
  9616. }
  9617. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9618. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9619. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9620. for (int i = 1; i <= vouchers.Count; i++)
  9621. {
  9622. HotelVoucherInfoView hviv = vouchers[i - 1];
  9623. builder.MoveToCell(0, i, 0, 0);
  9624. builder.Write(hviv.HotelName);
  9625. builder.MoveToCell(0, i, 1, 0);
  9626. builder.Write(hviv.CheckInDate);
  9627. builder.MoveToCell(0, i, 2, 0);
  9628. builder.Write(hviv.CheckOutDate);
  9629. builder.MoveToCell(0, i, 3, 0);
  9630. builder.Write(hviv.RoomType);
  9631. builder.MoveToCell(0, i, 4, 0);
  9632. builder.Write(hviv.ConfirmationNumber);
  9633. }
  9634. //删除多余行
  9635. int currRowIndex = vouchers.Count + 1;
  9636. int delRows = 21 - currRowIndex;
  9637. if (delRows > 0)
  9638. {
  9639. for (int i = 0; i < delRows; i++)
  9640. {
  9641. table.Rows.RemoveAt(currRowIndex);
  9642. //cultivateRowIndex++;
  9643. }
  9644. }
  9645. strFileName += "VOUCHER.docx";
  9646. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9647. doc.Save(fileDir);
  9648. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9649. return Ok(JsonView(true, "操作成功!", Url));
  9650. }
  9651. /// <summary>
  9652. /// 酒店预订
  9653. /// 生成VOUCHER 批量生成
  9654. /// New
  9655. /// </summary>
  9656. /// <param name="_dto"></param>
  9657. /// <returns></returns>
  9658. [HttpPost]
  9659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9660. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9661. {
  9662. #region 参数验证
  9663. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9664. if (_dto.PageId < 1) _dto.PageId = 28;
  9665. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9666. #region 团组操作权限验证 76 酒店预定模块
  9667. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9668. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9669. #endregion
  9670. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9671. #region 页面操作权限验证
  9672. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9673. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9674. #endregion
  9675. #endregion
  9676. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9677. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9678. .OrderBy(x => x.CheckInDate)
  9679. .ToListAsync();
  9680. //判断数据是否完整
  9681. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9682. string strFileName = "HotelStatement/";
  9683. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9684. if (dele != null)
  9685. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9686. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9687. for (int i = 0; i < hrDtas.Count; i++)
  9688. {
  9689. string guestNames = string.Empty;
  9690. List<int> guestIds = new List<int>();
  9691. var item = hrDtas[i];
  9692. //处理客户姓名
  9693. if (item.GuestName.Contains(","))
  9694. {
  9695. string[] guestIdArr = item.GuestName.Split(',');
  9696. foreach (var guestIdStr in guestIdArr)
  9697. if (int.TryParse(guestIdStr, out int guestId))
  9698. guestIds.Add(guestId);
  9699. }
  9700. else {
  9701. bool guestIdBool = int.TryParse(item.GuestName,out int guestId);
  9702. if (guestIdBool)
  9703. {
  9704. guestIds.Add(guestId);
  9705. }
  9706. //NaN
  9707. if (item.GuestName.Contains("NaN"))
  9708. {
  9709. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9710. }
  9711. }
  9712. if (guestIds.Count > 0)
  9713. {
  9714. guestIds = guestIds.Distinct().ToList();
  9715. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9716. if (guestDatas1.Count > 0)
  9717. {
  9718. guestNames = "";
  9719. foreach (var guest in guestDatas1)
  9720. {
  9721. string guestName = "";
  9722. if (guest.Sex == 0) guestName += @"MR.";
  9723. else if (guest.Sex == 1) guestName += @"MS.";
  9724. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9725. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9726. guestNames += @$"{guestName.Trim()}、";
  9727. }
  9728. if (guestNames.Length > 0)
  9729. {
  9730. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9731. }
  9732. }
  9733. }
  9734. //if (!string.IsNullOrEmpty(guestNames))
  9735. //{
  9736. hrDtas[i].GuestName = guestNames;
  9737. //}
  9738. }
  9739. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9740. Document doc = new Document();
  9741. DocumentBuilder builder = new DocumentBuilder(doc);
  9742. try
  9743. {
  9744. builder.MoveToDocumentStart();
  9745. foreach (var item in hrDtas)
  9746. {
  9747. //标题
  9748. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9749. builder.ParagraphFormat.LineSpacing = 1;
  9750. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9751. builder.ParagraphFormat.Style.Font.Size = 9;
  9752. builder.ParagraphFormat.Style.Font.Bold = true;
  9753. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9754. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9755. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9756. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9757. builder.ParagraphFormat.LineSpacing = 1;
  9758. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9759. builder.ParagraphFormat.Style.Font.Size = 9;
  9760. builder.ParagraphFormat.Style.Font.Bold = true;
  9761. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9762. builder.StartTable();
  9763. // 设置边框颜色
  9764. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9765. //设置边框样式
  9766. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9767. //表格
  9768. #region 第一行
  9769. builder.InsertCell();
  9770. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9771. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9772. //builder.CellFormat.AllowAutoFit = false;
  9773. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9774. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9775. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9776. builder.CellFormat.WrapText = true; //自动换行
  9777. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9778. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  9779. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9780. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9781. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9782. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9783. builder.Write("TOUR NO:");
  9784. builder.InsertCell();
  9785. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9786. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9787. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9788. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9789. builder.ParagraphFormat.Style.Font.Bold = false;
  9790. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9791. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9792. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9793. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9794. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9795. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9796. builder.Write($"{dele?.TourCode ?? "-"}");
  9797. builder.InsertCell();
  9798. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9799. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9800. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9801. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9802. builder.ParagraphFormat.Style.Font.Bold = false;
  9803. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9804. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9805. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9806. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9807. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9808. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9809. builder.Write($"CITY:");
  9810. builder.InsertCell();
  9811. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9812. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9813. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9814. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9815. builder.ParagraphFormat.Style.Font.Bold = false;
  9816. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9817. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9818. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9819. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9820. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9821. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9822. builder.Write($"{item.City}");
  9823. builder.EndRow();
  9824. #endregion
  9825. #region 第二行
  9826. builder.InsertCell();
  9827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9828. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9829. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9830. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9831. builder.ParagraphFormat.Style.Font.Bold = false;
  9832. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9833. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9834. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9835. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9836. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9837. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9838. builder.Write("CONFIRMATION NO:");
  9839. builder.InsertCell();
  9840. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9841. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9842. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9843. builder.ParagraphFormat.Style.Font.Bold = false;
  9844. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9845. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9846. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9847. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9848. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9849. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9850. builder.CellFormat.VerticalMerge = CellMerge.None;
  9851. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9852. builder.Write($"{item.DetermineNo}");
  9853. builder.InsertCell();
  9854. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9855. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9856. builder.InsertCell();
  9857. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9858. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9859. builder.EndRow();
  9860. #endregion
  9861. #region 第三行
  9862. builder.InsertCell();
  9863. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9864. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9865. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9866. builder.ParagraphFormat.Style.Font.Bold = false;
  9867. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9868. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9869. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9870. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9871. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9872. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9873. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9874. builder.Write($"HOTEL NAME:");
  9875. builder.InsertCell();
  9876. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9877. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9878. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9879. builder.ParagraphFormat.Style.Font.Bold = false;
  9880. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9881. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9882. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9883. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9884. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9885. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9886. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9887. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9888. builder.Write($"{item.HotelName}");
  9889. builder.InsertCell();
  9890. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9891. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9892. builder.InsertCell();
  9893. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9894. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9895. builder.EndRow();
  9896. #endregion
  9897. #region 第四行
  9898. builder.InsertCell();
  9899. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9900. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9901. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9902. builder.ParagraphFormat.Style.Font.Bold = false;
  9903. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9904. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9905. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9906. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9907. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9908. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9909. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9910. builder.Write($"HOTEL ADDRESS:");
  9911. builder.InsertCell();
  9912. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9913. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9914. builder.ParagraphFormat.Style.Font.Size = 8;
  9915. builder.ParagraphFormat.Style.Font.Bold = false;
  9916. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9917. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9918. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9919. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9920. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9921. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9922. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9923. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9924. builder.Write($"{item.HotelAddress}");
  9925. builder.InsertCell();
  9926. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9927. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9928. builder.InsertCell();
  9929. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9930. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9931. builder.EndRow();
  9932. #endregion
  9933. #region 第五行
  9934. builder.InsertCell();
  9935. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9936. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9937. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9938. builder.ParagraphFormat.Style.Font.Bold = false;
  9939. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9940. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9941. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9942. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9943. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9944. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9945. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9946. builder.Write("TEL:");
  9947. builder.InsertCell();
  9948. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9949. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9950. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9951. builder.ParagraphFormat.Style.Font.Bold = false;
  9952. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9953. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9954. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9955. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9956. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9957. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9958. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9959. builder.Write($"{item.HotelTel}");
  9960. builder.InsertCell();
  9961. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9962. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9963. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9964. builder.ParagraphFormat.Style.Font.Bold = false;
  9965. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9966. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9967. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9968. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9969. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9970. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9971. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9972. builder.Write($"FAX:");
  9973. builder.InsertCell();
  9974. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9975. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9976. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9977. builder.ParagraphFormat.Style.Font.Bold = false;
  9978. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9979. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9980. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9981. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9982. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9983. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9984. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9985. builder.Write($"{item.HotelFax}");
  9986. builder.EndRow();
  9987. #endregion
  9988. #region 第六行
  9989. builder.InsertCell();
  9990. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9991. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9992. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9993. builder.ParagraphFormat.Style.Font.Bold = false;
  9994. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9995. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9996. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9997. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9998. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9999. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10000. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10001. builder.Write("CHECK IN:");
  10002. builder.InsertCell();
  10003. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10004. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10005. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10006. builder.ParagraphFormat.Style.Font.Bold = false;
  10007. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10008. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10009. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10010. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10011. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10012. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10013. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10014. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10015. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10016. builder.Write($"{checkInStr}");
  10017. builder.InsertCell();
  10018. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10019. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10020. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10021. builder.ParagraphFormat.Style.Font.Bold = false;
  10022. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10023. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10024. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10025. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10026. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10027. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10028. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10029. builder.Write($"CHECK OUT:");
  10030. builder.InsertCell();
  10031. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10032. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10033. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10034. builder.ParagraphFormat.Style.Font.Bold = false;
  10035. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10036. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10037. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10038. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10039. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10040. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10041. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10042. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10043. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10044. builder.Write($"{checkOutStr}");
  10045. builder.EndRow();
  10046. #endregion
  10047. #region 第七行
  10048. builder.InsertCell();
  10049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10050. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10051. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10052. builder.ParagraphFormat.Style.Font.Bold = false;
  10053. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10054. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10055. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10056. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10057. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10058. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10059. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10060. builder.Write($"GUEST NAME:");
  10061. builder.InsertCell();
  10062. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10063. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10064. builder.ParagraphFormat.Style.Font.Size = 8;
  10065. builder.ParagraphFormat.Style.Font.Bold = false;
  10066. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10067. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10068. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10069. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10070. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10071. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10072. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10073. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10074. builder.Write($"{item.GuestName}");
  10075. builder.InsertCell();
  10076. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10077. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10078. builder.InsertCell();
  10079. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10080. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10081. builder.EndRow();
  10082. #endregion
  10083. #region 第八行
  10084. builder.InsertCell();
  10085. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10086. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10087. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10088. builder.ParagraphFormat.Style.Font.Bold = false;
  10089. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10090. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10091. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10092. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10093. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10094. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10095. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10096. builder.Write($"ROOM TYPE:");
  10097. builder.InsertCell();
  10098. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10099. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10100. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10101. builder.ParagraphFormat.Style.Font.Bold = false;
  10102. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10103. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10104. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10105. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10106. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10107. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10108. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10109. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10110. builder.Write($"{item.RoomExplanation}");
  10111. builder.InsertCell();
  10112. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10113. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10114. builder.InsertCell();
  10115. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10116. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10117. builder.EndRow();
  10118. #endregion
  10119. #region 第九行
  10120. builder.InsertCell();
  10121. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10122. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10123. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10124. builder.ParagraphFormat.Style.Font.Bold = false;
  10125. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10126. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10127. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10128. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10129. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10130. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10131. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10132. builder.Write($"NOTE:");
  10133. builder.InsertCell();
  10134. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10135. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10136. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10137. builder.ParagraphFormat.Style.Font.Bold = false;
  10138. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10139. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10140. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10141. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10142. 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.");
  10143. builder.InsertCell();
  10144. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10145. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10146. builder.InsertCell();
  10147. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10148. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10149. builder.EndRow();
  10150. #endregion
  10151. builder.EndTable();
  10152. //换行
  10153. builder.Writeln("");
  10154. builder.Writeln("");
  10155. }
  10156. #region 获取文档中的所有表格 设置文字自适应
  10157. // 获取文档中的所有表格。
  10158. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10159. {
  10160. // 遍历表格中的所有行。
  10161. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10162. {
  10163. foreach (Cell cell in row.Cells)
  10164. {
  10165. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10166. cellFormat.Width = 0;
  10167. }
  10168. }
  10169. }
  10170. #endregion
  10171. #region 设置页眉
  10172. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10173. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10174. if (System.IO.File.Exists(voucherHeaderPath))
  10175. {
  10176. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10177. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10178. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10179. Shape shape = builder.InsertImage(imageBytes);
  10180. // 调整图片位置
  10181. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10182. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10183. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10184. shape.Left = 0; // 将图片距离页面左边缘的距离
  10185. shape.Width = 81; // 设置图片宽度
  10186. shape.Height = 36; // 设置图片高度
  10187. }
  10188. //靠右
  10189. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10190. //// 设置页脚上下边距
  10191. //builder.PageSetup.HeaderDistance = 42;
  10192. // 添加页眉线
  10193. Aspose.Words.Border borderHeader = null;
  10194. try
  10195. {
  10196. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10197. }
  10198. catch (Exception e)
  10199. {
  10200. // TODO Auto-generated catch block
  10201. //e.printStackTrace();
  10202. }
  10203. borderHeader.Shadow = true;
  10204. borderHeader.DistanceFromText = 2;
  10205. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10206. #endregion
  10207. }
  10208. catch (Exception ex)
  10209. {
  10210. }
  10211. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10212. doc.Save(fileDir);
  10213. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10214. return Ok(JsonView(true, "操作成功!", Url));
  10215. }
  10216. /// <summary>
  10217. /// 酒店预订
  10218. /// 生成 预定成本 Excel
  10219. /// </summary>
  10220. /// <param name="_dto"></param>
  10221. /// <returns></returns>
  10222. [HttpPost]
  10223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10224. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10225. {
  10226. #region 参数验证
  10227. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10228. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10229. if (!vadalitorRes.IsValid)
  10230. {
  10231. var errors = new StringBuilder();
  10232. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10233. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10234. }
  10235. #region 团组操作权限验证 76 酒店预定模块
  10236. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10237. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10238. #endregion
  10239. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10240. #region 页面操作权限验证
  10241. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10242. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10243. #endregion
  10244. #endregion
  10245. decimal _rate = 1.00M;
  10246. string _currency = "";
  10247. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10248. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10249. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10250. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10251. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10252. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10253. {
  10254. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10255. }
  10256. _currency = _GroupCostParameter.Currency;
  10257. bool isIntType = int.TryParse(_currency, out int currId);
  10258. if (isIntType)
  10259. {
  10260. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10261. }
  10262. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10263. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10264. if (currInfo == null)
  10265. {
  10266. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10267. }
  10268. if (!_currency.ToUpper().Equals("CNY"))
  10269. {
  10270. _rate = _GroupCostParameter.Rate;
  10271. }
  10272. _rate = currInfo.Rate;
  10273. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10274. string strFileName = "HotelStatement/";
  10275. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10276. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10277. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10278. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10279. #region 数据处理
  10280. foreach (var item in hrDtas)
  10281. {
  10282. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10283. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10284. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10285. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10286. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10287. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10288. string singleRoomFeeStr = string.Empty,
  10289. doubleRoomFeeStr = string.Empty,
  10290. suiteRoomFeeStr = string.Empty,
  10291. otherRoomFeeStr = string.Empty,
  10292. payMoneyStr = string.Empty,
  10293. cardPriceStr = string.Empty;
  10294. if (roomCurr.Equals(_currency))
  10295. {
  10296. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10297. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10298. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10299. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10300. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10301. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10302. }
  10303. else
  10304. {
  10305. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10306. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10307. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10308. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10309. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10310. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10311. }
  10312. string breakfastPriceStr = string.Empty,
  10313. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10314. governmentRentStr = string.Empty,
  10315. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10316. cityTaxStrStr = string.Empty,
  10317. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10318. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10319. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10320. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10321. int payDId = roomInfo?.PayDId ?? 0;
  10322. pcfds.Add(new HotelReservations_PCFD_View()
  10323. {
  10324. City = item.City,
  10325. HotelName = item.HotelName,
  10326. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10327. // SingleRoomCount = item.SingleRoomCount,
  10328. SingleRoomPrice = singleRoomFeeStr,
  10329. // DoubleRoomCount = item.DoubleRoomCount,
  10330. DoubleRoomPrice = doubleRoomFeeStr,
  10331. //SuiteRoomCount = item.SuiteRoomCount,
  10332. SuiteRoomPrice = suiteRoomFeeStr,
  10333. OtherRoomPrice = otherRoomFeeStr,
  10334. //OtherRoomCount = item.OtherRoomCount,
  10335. BreakfastPrice = breakfastPriceStr,
  10336. GovernmentRent = governmentRentStr,
  10337. CityTax = cityTaxStrStr,
  10338. RoomExplanation = item.RoomExplanation,
  10339. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10340. PayTime = roomInfo?.ConsumptionDate,
  10341. BankNo = roomInfo?.BankNo,
  10342. PayMoney = payMoneyStr,
  10343. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10344. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10345. CardPrice = cardPriceStr,
  10346. Remark = ccpInfo.Remark
  10347. });
  10348. }
  10349. #endregion
  10350. //载入模板
  10351. WorkbookDesigner designer = new WorkbookDesigner();
  10352. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10353. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10354. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10355. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10356. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10357. designer.SetDataSource("Opertor", userInfo.CnName);
  10358. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10359. dt.TableName = "ViewMyHotelReservations";
  10360. designer.SetDataSource(dt);
  10361. designer.Process();
  10362. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10363. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10364. designer.Workbook.Save(serverPath);
  10365. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10366. #region 删除指定行
  10367. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10368. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10369. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10370. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10371. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10372. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10373. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10374. cssIndex = dt.Columns["CityTax"].Ordinal,
  10375. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10376. remarkIndex = dt.Columns["Remark"].Ordinal;
  10377. //删除指定列
  10378. foreach (DataRow item in dt.Rows)
  10379. {
  10380. string singleStr = item["SingleRoomPrice"].ToString();
  10381. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10382. if (containsDigitButNotZero1) singleDel = false;
  10383. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10384. string doubleStr = item["DoubleRoomPrice"].ToString();
  10385. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10386. if (containsDigitButNotZero2) doubleDel = false;
  10387. string suiteStr = item["SuiteRoomPrice"].ToString();
  10388. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10389. if (containsDigitButNotZero3) suiteDel = false;
  10390. string otherStr = item["OtherRoomPrice"].ToString();
  10391. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10392. if (containsDigitButNotZero4) otherDel = false;
  10393. string zcStr = item["BreakfastPrice"].ToString();
  10394. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10395. if (containsDigitButNotZero5) zcDel = false;
  10396. string dsStr = item["GovernmentRent"].ToString();
  10397. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10398. if (containsDigitButNotZero6) dsDel = false;
  10399. string cssStr = item["CityTax"].ToString();
  10400. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10401. if (containsDigitButNotZero7) cssDel = false;
  10402. string cpStr = item["ConsumptionPatterns"].ToString();
  10403. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10404. string remarkStr = item["Remark"].ToString();
  10405. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10406. }
  10407. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10408. DeleteColumn(serverPath, cpIndex, cpDel);
  10409. DeleteColumn(serverPath, dsIndex, dsDel);
  10410. DeleteColumn(serverPath, cssIndex, cssDel);
  10411. DeleteColumn(serverPath, zcIndex, zcDel);
  10412. DeleteColumn(serverPath, otherIndex, otherDel);
  10413. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10414. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10415. DeleteColumn(serverPath, singleIndex, singleDel);
  10416. #endregion
  10417. //只保留第一个表格
  10418. DeleteSheet(serverPath);
  10419. return Ok(JsonView(true, "操作成功", url = rst));
  10420. }
  10421. /// <summary>
  10422. /// 删除指定列
  10423. /// </summary>
  10424. /// <param name="file"></param>
  10425. /// <param name="columnIndex"></param>
  10426. /// <param name="isDel"></param>
  10427. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10428. {
  10429. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10430. //wb.Save(file);
  10431. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10432. if (sheet1 != null)
  10433. {
  10434. if (isDel)
  10435. {
  10436. Cells cells = sheet1.Cells;
  10437. cells.DeleteColumn(columnIndex);
  10438. }
  10439. }
  10440. wb.Save(file);
  10441. }
  10442. /// <summary>
  10443. /// 删除sheet
  10444. /// </summary>
  10445. /// <param name="file"></param>
  10446. /// <param name="sheetName"></param>
  10447. private void DeleteSheet(string file, string sheetName = "")
  10448. {
  10449. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10450. //wb.Save(file);
  10451. List<string> sheets = new List<string>();
  10452. foreach (var item in wb.Worksheets)
  10453. {
  10454. sheets.Add(item.Name);
  10455. }
  10456. if (sheets.Count > 0)
  10457. {
  10458. sheets.RemoveAt(0);//不删除第一个sheet
  10459. foreach (var item in sheets)
  10460. {
  10461. wb.Worksheets.RemoveAt(item);
  10462. }
  10463. }
  10464. wb.Save(file);
  10465. }
  10466. /// <summary>
  10467. /// 酒店预订
  10468. /// 确认单
  10469. /// </summary>
  10470. /// <param name="_dto"></param>
  10471. /// <returns></returns>
  10472. [HttpPost]
  10473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10474. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10475. {
  10476. try
  10477. {
  10478. #region 参数验证
  10479. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10480. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10481. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10482. #region 团组操作权限验证 76 酒店预定模块
  10483. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10484. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10485. #endregion
  10486. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10487. #region 页面操作权限验证
  10488. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10489. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10490. #endregion
  10491. #endregion
  10492. //团组信息
  10493. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10494. //酒店数据
  10495. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10496. if (listhoteldata.Count < 0)
  10497. {
  10498. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10499. }
  10500. //利datatable存储
  10501. DataTable dt = new DataTable();
  10502. dt.Columns.Add("CheckInDate", typeof(string));
  10503. dt.Columns.Add("City", typeof(string));
  10504. dt.Columns.Add("Hotel", typeof(string));
  10505. dt.Columns.Add("Room", typeof(string));
  10506. for (int i = 0; i < listhoteldata.Count; i++)
  10507. {
  10508. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10509. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10510. while (dayStart < dayEnd)
  10511. {
  10512. string temp = "";
  10513. DataRow row = dt.NewRow();
  10514. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10515. row["City"] = listhoteldata[i].City;
  10516. row["Hotel"] = listhoteldata[i].HotelName;
  10517. if (listhoteldata[i].SingleRoomCount > 0)
  10518. {
  10519. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10520. }
  10521. if (listhoteldata[i].DoubleRoomCount > 0)
  10522. {
  10523. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10524. }
  10525. if (listhoteldata[i].SuiteRoomCount > 0)
  10526. {
  10527. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10528. }
  10529. if (listhoteldata[i].OtherRoomCount > 0)
  10530. {
  10531. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10532. }
  10533. row["Room"] = temp;
  10534. dt.Rows.Add(row);
  10535. dayStart = dayStart.AddDays(1);
  10536. }
  10537. }
  10538. Dictionary<string, string> dic = new Dictionary<string, string>();
  10539. dic.Add("Dele", di.TeamName);
  10540. dic.Add("City", di.VisitCountry);
  10541. //模板路径
  10542. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10543. //载入模板
  10544. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10545. DocumentBuilder builder = new DocumentBuilder(doc);
  10546. foreach (var key in dic.Keys)
  10547. {
  10548. builder.MoveToBookmark(key);
  10549. builder.Write(dic[key]);
  10550. }
  10551. //获取word里所有表格
  10552. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10553. //获取所填表格的序数
  10554. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10555. var rowStart = tableOne.Rows[0]; //获取第1行
  10556. //循环赋值
  10557. for (int i = 0; i < dt.Rows.Count; i++)
  10558. {
  10559. builder.MoveToCell(0, i + 1, 0, 0);
  10560. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10561. builder.MoveToCell(0, i + 1, 1, 0);
  10562. builder.Write(dt.Rows[i]["City"].ToString());
  10563. builder.MoveToCell(0, i + 1, 2, 0);
  10564. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10565. builder.MoveToCell(0, i + 1, 3, 0);
  10566. builder.Write(dt.Rows[i]["Room"].ToString());
  10567. }
  10568. //删除多余行
  10569. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10570. {
  10571. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10572. }
  10573. string strFileName = di.TeamName + "酒店确认单.doc";
  10574. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10575. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10576. return Ok(JsonView(true, "成功", url));
  10577. }
  10578. catch (Exception ex)
  10579. {
  10580. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10581. }
  10582. }
  10583. #endregion
  10584. #region 团组状态
  10585. /// <summary>
  10586. /// 团组状态列表 Page
  10587. /// </summary>
  10588. /// <param name="dto">团组列表请求dto</param>
  10589. /// <returns></returns>
  10590. [HttpPost]
  10591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10592. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10593. {
  10594. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10595. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10596. {
  10597. string sqlWhere = string.Empty;
  10598. if (dto.IsSure == 0) //未完成
  10599. {
  10600. sqlWhere += string.Format(@" And IsSure = 0");
  10601. }
  10602. else if (dto.IsSure == 1) //已完成
  10603. {
  10604. sqlWhere += string.Format(@" And IsSure = 1");
  10605. }
  10606. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10607. {
  10608. string tj = dto.SearchCriteria;
  10609. 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}%')",
  10610. tj, tj, tj, tj, tj);
  10611. }
  10612. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10613. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10614. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10615. From (
  10616. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10617. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10618. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10619. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10620. From Grp_DelegationInfo gdi
  10621. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10622. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10623. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10624. Where gdi.IsDel = 0 {0}
  10625. ) temp ", sqlWhere);
  10626. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10627. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10628. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10629. }
  10630. else
  10631. {
  10632. return Ok(JsonView(false, "查询失败"));
  10633. }
  10634. }
  10635. /// <summary>
  10636. /// 团组状态
  10637. /// 设置操作完成
  10638. /// </summary>
  10639. /// <param name="dto">团组列表请求dto</param>
  10640. /// <returns></returns>
  10641. [HttpPost]
  10642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10643. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10644. {
  10645. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10646. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10647. {
  10648. Id = dto.Id,
  10649. IsSure = 1
  10650. };
  10651. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10652. .UpdateColumns(it => new { it.IsSure })
  10653. .WhereColumns(it => new { it.Id })
  10654. .ExecuteCommandAsync();
  10655. if (result > 0)
  10656. {
  10657. return Ok(JsonView(true, "操作完成!"));
  10658. }
  10659. return Ok(JsonView(false, "操作失败!"));
  10660. }
  10661. #endregion
  10662. #region 保险费用录入
  10663. /// <summary>
  10664. /// 根据团组Id查询保险费用列表
  10665. /// </summary>
  10666. /// <param name="dto"></param>
  10667. /// <returns></returns>
  10668. [HttpPost]
  10669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10670. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10671. {
  10672. try
  10673. {
  10674. Result groupData = await _customersRep.CustomersByDiId(dto);
  10675. if (groupData.Code != 0)
  10676. {
  10677. return Ok(JsonView(false, groupData.Msg));
  10678. }
  10679. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10680. }
  10681. catch (Exception ex)
  10682. {
  10683. return Ok(JsonView(false, ex.Message));
  10684. }
  10685. }
  10686. /// <summary>
  10687. /// 根据保险费用Id查询保险费用详细
  10688. /// </summary>
  10689. /// <param name="dto"></param>
  10690. /// <returns></returns>
  10691. [HttpPost]
  10692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10693. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10694. {
  10695. try
  10696. {
  10697. Result groupData = await _customersRep.CustomersById(dto);
  10698. if (groupData.Code != 0)
  10699. {
  10700. return Ok(JsonView(false, groupData.Msg));
  10701. }
  10702. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10703. }
  10704. catch (Exception ex)
  10705. {
  10706. return Ok(JsonView(false, ex.Message));
  10707. }
  10708. }
  10709. /// <summary>
  10710. /// 保险费用录入页面初始化绑定
  10711. /// </summary>
  10712. /// <param name="dto"></param>
  10713. /// <returns></returns>
  10714. [HttpPost]
  10715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10716. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10717. {
  10718. try
  10719. {
  10720. Result groupData = await _customersRep.CustomersInitialize(dto);
  10721. if (groupData.Code != 0)
  10722. {
  10723. return Ok(JsonView(false, groupData.Msg));
  10724. }
  10725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10726. }
  10727. catch (Exception ex)
  10728. {
  10729. return Ok(JsonView(false, ex.Message));
  10730. }
  10731. }
  10732. /// <summary>
  10733. /// 保险费用操作(Status:1.新增,2.修改)
  10734. /// </summary>
  10735. /// <param name="dto"></param>
  10736. /// <returns></returns>
  10737. [HttpPost]
  10738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10739. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10740. {
  10741. Result groupData = await _customersRep.OpCustomers(dto);
  10742. if (groupData.Code != 0)
  10743. {
  10744. return Ok(JsonView(false, groupData.Msg));
  10745. }
  10746. #region 应用推送
  10747. try
  10748. {
  10749. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10750. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10751. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10752. }
  10753. catch (Exception ex)
  10754. {
  10755. }
  10756. #endregion
  10757. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10758. }
  10759. /// <summary>
  10760. /// 保险文件上传
  10761. /// </summary>
  10762. /// <param name="file"></param>
  10763. /// <returns></returns>
  10764. [HttpPost]
  10765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10766. public async Task<IActionResult> UploadCus(IFormFile file)
  10767. {
  10768. try
  10769. {
  10770. if (file != null)
  10771. {
  10772. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10773. //文件名称
  10774. string projectFileName = file.FileName;
  10775. //上传的文件的路径
  10776. string filePath = "";
  10777. if (!Directory.Exists(fileDir))
  10778. {
  10779. Directory.CreateDirectory(fileDir);
  10780. }
  10781. //上传的文件的路径
  10782. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10783. using (FileStream fs = System.IO.File.Create(filePath))
  10784. {
  10785. file.CopyTo(fs);
  10786. fs.Flush();
  10787. }
  10788. return Ok(JsonView(true, "上传成功!", projectFileName));
  10789. }
  10790. else
  10791. {
  10792. return Ok(JsonView(false, "上传失败!"));
  10793. }
  10794. }
  10795. catch (Exception ex)
  10796. {
  10797. return Ok(JsonView(false, "程序错误!"));
  10798. throw;
  10799. }
  10800. }
  10801. /// <summary>
  10802. /// 保险删除指定文件
  10803. /// </summary>
  10804. /// <param name="dto"></param>
  10805. /// <returns></returns>
  10806. [HttpPost]
  10807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10808. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10809. {
  10810. try
  10811. {
  10812. string filePath = "";
  10813. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10814. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10815. //int id = 0;
  10816. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10817. // 删除该文件
  10818. try
  10819. {
  10820. System.IO.File.Delete(filePath);
  10821. 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()
  10822. {
  10823. Attachment = "",
  10824. }).ExecuteCommandAsync();
  10825. if (result != 0)
  10826. {
  10827. return Ok(JsonView(true, "成功!"));
  10828. }
  10829. else
  10830. {
  10831. return Ok(JsonView(false, "失败!"));
  10832. }
  10833. }
  10834. catch (Exception)
  10835. {
  10836. 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()
  10837. {
  10838. Attachment = "",
  10839. }).ExecuteCommandAsync();
  10840. if (result != 0)
  10841. {
  10842. return Ok(JsonView(true, "成功!"));
  10843. }
  10844. else
  10845. {
  10846. return Ok(JsonView(false, "失败!"));
  10847. }
  10848. }
  10849. }
  10850. catch (Exception ex)
  10851. {
  10852. return Ok(JsonView(false, "程序错误!"));
  10853. throw;
  10854. }
  10855. }
  10856. /// <summary>
  10857. /// 保险费用操作(删除)
  10858. /// </summary>
  10859. /// <param name="dto"></param>
  10860. /// <returns></returns>
  10861. [HttpPost]
  10862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10863. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10864. {
  10865. try
  10866. {
  10867. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10868. if (!res)
  10869. {
  10870. return Ok(JsonView(false, "删除失败"));
  10871. }
  10872. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10873. {
  10874. IsDel = 1,
  10875. DeleteUserId = dto.DeleteUserId,
  10876. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10877. }).ExecuteCommandAsync();
  10878. return Ok(JsonView(true, "删除成功!"));
  10879. }
  10880. catch (Exception ex)
  10881. {
  10882. return Ok(JsonView(false, "程序错误!"));
  10883. throw;
  10884. }
  10885. }
  10886. #endregion
  10887. #region 接团客户名单 PageId 104
  10888. /// <summary>
  10889. /// 接团客户名单
  10890. /// 迁移数据(慎用!)
  10891. /// </summary>
  10892. /// <param name="dto"></param>
  10893. /// <returns></returns>
  10894. [HttpPost]
  10895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10896. public async Task<IActionResult> PostTourClientListChange()
  10897. {
  10898. try
  10899. {
  10900. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10901. //var groupClinetData1
  10902. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10903. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10904. int updateCount = 0;
  10905. if (oldOAClientList.Count > 0)
  10906. {
  10907. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10908. _sqlSugar.BeginTran();
  10909. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10910. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10911. foreach (var item in oldOAClientList)
  10912. {
  10913. int comId = 0;
  10914. string format = "yyyy-MM-dd HH:mm:ss";
  10915. string data11 = "1990-01-01 00:00";
  10916. var data1 = IsValidDate(item.OPdate, format);
  10917. if (data1) data11 = item.OPdate;
  10918. //客户公司验证
  10919. if (!string.IsNullOrEmpty(item.Company))
  10920. {
  10921. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10922. if (clientComInfo == null) // add
  10923. {
  10924. var addInfo = new Crm_CustomerCompany()
  10925. {
  10926. CompanyAbbreviation = "",
  10927. CompanyFullName = item.Company,
  10928. Address = "",
  10929. PostCodes = "",
  10930. LastedOpUserId = item.OPer,
  10931. LastedOpDt = Convert.ToDateTime(data11),
  10932. CreateUserId = item.OPer,
  10933. CreateTime = Convert.ToDateTime(data11),
  10934. IsDel = 0
  10935. };
  10936. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10937. if (comId1 > 0) comId = comId1;
  10938. }
  10939. else comId = clientComInfo.Id;
  10940. }
  10941. //客户人员验证
  10942. int clientId = 0;
  10943. string name = item.LastName + item.Name;
  10944. if (!string.IsNullOrEmpty(name))
  10945. {
  10946. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10947. if (clientInfo == null)
  10948. {
  10949. DateTime? dateTime = null;
  10950. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10951. if (isDt) dateTime = birthDayDt;
  10952. var addInfo1 = new Crm_DeleClient()
  10953. {
  10954. CrmCompanyId = comId,
  10955. DiId = -1,
  10956. LastName = item.LastName,
  10957. FirstName = item.Name,
  10958. OldName = "",
  10959. Pinyin = item.Pinyin,
  10960. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10961. Marriage = 0,
  10962. Phone = item.Phone,
  10963. Job = item.Job,
  10964. BirthDay = dateTime
  10965. };
  10966. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10967. if (clientId1 > 0) clientId = clientId1;
  10968. }
  10969. else clientId = clientInfo.Id;
  10970. }
  10971. if (clientId < 1)
  10972. {
  10973. continue;
  10974. }
  10975. int airType = 0;
  10976. if (item.AirType == "超经舱") airType = 459;
  10977. else if (item.AirType == "公务舱") airType = 458;
  10978. else if (item.AirType == "经济舱") airType = 460;
  10979. else if (item.AirType == "其他") airType = 565;
  10980. else if (item.AirType == "头等舱") airType = 457;
  10981. var _TourClientListEntity = new Grp_TourClientList()
  10982. {
  10983. DiId = item.Diid,
  10984. ClientId = clientId,
  10985. CreateUserId = item.OPer,
  10986. CreateTime = Convert.ToDateTime(data11),
  10987. Remark = item.Remark,
  10988. IsDel = item.Isdel,
  10989. ShippingSpaceTypeId = airType,
  10990. ShippingSpaceSpecialNeeds = item.AirRemark,
  10991. HotelSpecialNeeds = item.RoomType
  10992. };
  10993. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10994. if (_TourClientList > 0)
  10995. {
  10996. updateCount++;
  10997. }
  10998. }
  10999. _sqlSugar.CommitTran();
  11000. }
  11001. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11002. }
  11003. catch (Exception ex)
  11004. {
  11005. _sqlSugar.RollbackTran();
  11006. return Ok(JsonView(false, ex.Message));
  11007. }
  11008. return Ok(JsonView(true));
  11009. }
  11010. private bool IsValidDate(string dateString, string format)
  11011. {
  11012. DateTime dateValue;
  11013. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11014. return valid;
  11015. }
  11016. /// <summary>
  11017. /// 接团客户名单
  11018. /// 根据团组Id查询List
  11019. /// </summary>
  11020. /// <param name="dto"></param>
  11021. /// <returns></returns>
  11022. [HttpPost]
  11023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11024. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11025. {
  11026. #region 参数验证
  11027. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11028. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11029. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11030. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11031. #region 页面操作权限验证
  11032. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11033. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11034. #endregion
  11035. #endregion
  11036. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11037. if (viewData.Code != 0)
  11038. {
  11039. return Ok(JsonView(false, viewData.Msg));
  11040. }
  11041. return Ok(JsonView(viewData.Data));
  11042. }
  11043. /// <summary>
  11044. /// 接团客户名单
  11045. /// 基础数据 Init
  11046. /// </summary>
  11047. /// <param name="_dto"></param>
  11048. /// <returns></returns>
  11049. [HttpPost]
  11050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11051. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11052. {
  11053. #region 参数验证
  11054. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11055. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11056. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11057. #region 页面操作权限验证
  11058. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11059. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11060. #endregion
  11061. #endregion
  11062. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  11063. if (viewData.Code != 0)
  11064. {
  11065. return Ok(JsonView(false, viewData.Msg));
  11066. }
  11067. return Ok(JsonView(viewData.Data));
  11068. }
  11069. /// <summary>
  11070. /// 接团客户名单
  11071. /// 根据 Id查询 Details
  11072. /// </summary>
  11073. /// <param name="_dto"></param>
  11074. /// <returns></returns>
  11075. [HttpPost]
  11076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11077. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11078. {
  11079. #region 参数验证
  11080. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11081. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11082. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11083. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11084. #region 页面操作权限验证
  11085. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11086. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11087. #endregion
  11088. #endregion
  11089. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11090. if (viewData.Code != 0)
  11091. {
  11092. return Ok(JsonView(false, viewData.Msg));
  11093. }
  11094. return Ok(JsonView(viewData.Data));
  11095. }
  11096. /// <summary>
  11097. /// 接团客户名单
  11098. /// Add Or Edit
  11099. /// </summary>
  11100. /// <param name="_dto"></param>
  11101. /// <returns></returns>
  11102. [HttpPost]
  11103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11104. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11105. {
  11106. #region 参数验证
  11107. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11108. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11109. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11110. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11111. #region 页面操作权限验证
  11112. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11113. if (_dto.Id == 0) //添加
  11114. {
  11115. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11116. }
  11117. else if (_dto.Id >= 0) //修改
  11118. {
  11119. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11120. }
  11121. #endregion
  11122. #endregion
  11123. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11124. if (viewData.Code != 0)
  11125. {
  11126. return Ok(JsonView(false, viewData.Msg));
  11127. }
  11128. return Ok(JsonView(true));
  11129. }
  11130. /// <summary>
  11131. /// 接团客户名单
  11132. /// AddMultiple(添加多个)
  11133. /// </summary>
  11134. /// <param name="_dto"></param>
  11135. /// <returns></returns>
  11136. [HttpPost]
  11137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11138. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11139. {
  11140. #region 参数验证
  11141. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11142. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11143. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11144. #region 页面操作权限验证
  11145. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11146. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11147. #endregion
  11148. #endregion
  11149. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11150. if (viewData.Code != 0)
  11151. {
  11152. return Ok(JsonView(false, viewData.Msg));
  11153. }
  11154. return Ok(JsonView(true));
  11155. }
  11156. /// <summary>
  11157. /// 接团客户名单
  11158. /// Del
  11159. /// </summary>
  11160. /// <param name="_dto"></param>
  11161. /// <returns></returns>
  11162. [HttpPost]
  11163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11164. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11165. {
  11166. #region 参数验证
  11167. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11168. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11169. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11170. #region 页面操作权限验证
  11171. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11172. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11173. #endregion
  11174. #endregion
  11175. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11176. if (viewData.Code != 0)
  11177. {
  11178. return Ok(JsonView(false, viewData.Msg));
  11179. }
  11180. return Ok(JsonView(true));
  11181. }
  11182. /// <summary>
  11183. /// 接团客户名单
  11184. /// 文件下载 客户名单
  11185. /// </summary>
  11186. /// <param name="_dto"></param>
  11187. /// <returns></returns>
  11188. [HttpPost]
  11189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11190. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11191. {
  11192. #region 参数验证
  11193. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11194. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11195. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11196. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11197. #region 页面操作权限验证
  11198. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11199. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11200. #endregion
  11201. #endregion
  11202. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11203. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11204. From Grp_TourClientList tcl
  11205. Left Join
  11206. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11207. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11208. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11209. From Crm_DeleClient dc
  11210. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11211. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11212. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11213. Where dc.IsDel = 0) temp
  11214. On temp.DcId =tcl.ClientId
  11215. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11216. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11217. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11218. //载入模板
  11219. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11220. if (_dto.Language == 1)
  11221. {
  11222. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11223. }
  11224. //载入模板
  11225. var doc = new Document(tempPath);
  11226. DocumentBuilder builder = new DocumentBuilder(doc);
  11227. //获取word里所有表格
  11228. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11229. //获取所填表格的序数
  11230. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11231. var rowStart = tableOne.Rows[0]; //获取第1行
  11232. if (_dto.Language == 0)
  11233. {
  11234. //循环赋值
  11235. for (int i = 0; i < DcList.Count; i++)
  11236. {
  11237. builder.MoveToCell(0, i + 1, 0, 0);
  11238. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11239. builder.MoveToCell(0, i + 1, 1, 0);
  11240. int sex = DcList[i].Sex;
  11241. string sexStr = string.Empty;
  11242. if (sex == 0) sexStr = "男";
  11243. else if (sex == 1) sexStr = "女";
  11244. else sexStr = "未设置";
  11245. builder.Write(sexStr);
  11246. builder.MoveToCell(0, i + 1, 2, 0);
  11247. string birthDay = DcList[i].BirthDay;
  11248. string birthDayStr = string.Empty;
  11249. if (!string.IsNullOrEmpty(birthDay))
  11250. {
  11251. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11252. }
  11253. builder.Write(birthDayStr);
  11254. builder.MoveToCell(0, i + 1, 3, 0);
  11255. string company = "";
  11256. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11257. {
  11258. company = DcList[i].CompanyFullName.ToString();
  11259. }
  11260. builder.Write(company);
  11261. builder.MoveToCell(0, i + 1, 4, 0);
  11262. builder.Write(DcList[i].Job);
  11263. }
  11264. }
  11265. else if (_dto.Language == 1)
  11266. {
  11267. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11268. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11269. List<string> transArrayStr = new List<string>();
  11270. string transStrRes1 = "";
  11271. for (int i = 0; i < DcList.Count; i++)
  11272. {
  11273. var dc = DcList[i];
  11274. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11275. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11276. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11277. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11278. else transStrRes1 += $"{str1}|";
  11279. }
  11280. //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";
  11281. string transStrRes = "";
  11282. if (transStrRes1.Length > 0 )
  11283. {
  11284. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11285. }
  11286. //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
  11287. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11288. //List<string> transArray = new List<string> { };
  11289. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11290. if (transStrRes.Contains("|"))
  11291. {
  11292. string[] transArray1 = transStrRes.Split('|');
  11293. if (transArray1.Length > 0)
  11294. {
  11295. foreach (var item in transArray1)
  11296. {
  11297. if (item.Contains("&"))
  11298. {
  11299. string[] transArray2 = item.Split('&');
  11300. int index = 0;
  11301. string companyName = "", job = "";
  11302. if (transArray2.Length > 0)
  11303. {
  11304. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11305. if (1 < transArray2.Length) companyName = transArray2[1];
  11306. if (2 < transArray2.Length) job = transArray2[2];
  11307. }
  11308. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11309. }
  11310. }
  11311. }
  11312. }
  11313. //循环赋值
  11314. for (int i = 0; i < DcList.Count; i++)
  11315. {
  11316. string PYName = "";
  11317. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11318. {
  11319. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11320. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11321. PYName = PY_First + " " + PY_Last;
  11322. }
  11323. else
  11324. {
  11325. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11326. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11327. PYName = PY_First + " " + PY_Last;
  11328. }
  11329. builder.MoveToCell(0, i + 1, 0, 0);
  11330. builder.Write(PYName);
  11331. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11332. builder.MoveToCell(0, i + 1, 1, 0);
  11333. builder.Write(sex);
  11334. DateTime birthDt;
  11335. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11336. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11337. builder.MoveToCell(0, i + 1, 2, 0);
  11338. builder.Write(birthday);
  11339. string company = string.Empty,job = string.Empty;
  11340. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11341. if (dcTransInfo != null)
  11342. {
  11343. company = dcTransInfo.CompanyName;
  11344. job = dcTransInfo.Job;
  11345. }
  11346. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11347. {
  11348. //查询对照表
  11349. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11350. if (tempCec != null)
  11351. {
  11352. company = tempCec.enName;
  11353. }
  11354. //翻译
  11355. else
  11356. {
  11357. }
  11358. }
  11359. builder.MoveToCell(0, i + 1, 3, 0);
  11360. builder.Write(company);
  11361. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11362. {
  11363. //查询对照表
  11364. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11365. if (tempPec != null)
  11366. {
  11367. job = tempPec.enName;
  11368. }
  11369. //翻译
  11370. else
  11371. {
  11372. }
  11373. }
  11374. builder.MoveToCell(0, i + 1, 4, 0);
  11375. builder.Write(job);
  11376. }
  11377. }
  11378. //删除多余行
  11379. while (tableOne.Rows.Count > DcList.Count + 1)
  11380. {
  11381. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11382. }
  11383. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11384. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11385. doc.Save(fileDir);
  11386. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11387. return Ok(JsonView(true, "操作成功!", Url));
  11388. }
  11389. private class TranslateInfo
  11390. {
  11391. public int Index { get; set; }
  11392. public string CompanyName { get; set; }
  11393. public string Job { get; set; }
  11394. }
  11395. #endregion
  11396. #region 团组倒推表
  11397. /// <summary>
  11398. /// 倒推表基础数据
  11399. /// Init
  11400. /// </summary>
  11401. /// <param name="dto"></param>
  11402. /// <returns></returns>
  11403. [HttpPost]
  11404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11405. public async Task<IActionResult> PostInvertedListInit()
  11406. {
  11407. var viewData = await _invertedListRep._Init();
  11408. if (viewData.Code != 0)
  11409. {
  11410. return Ok(JsonView(false, viewData.Msg));
  11411. }
  11412. return Ok(JsonView(viewData.Data));
  11413. }
  11414. /// <summary>
  11415. /// 倒推表
  11416. /// Info
  11417. /// </summary>
  11418. /// <param name="dto"></param>
  11419. /// <returns></returns>
  11420. [HttpPost]
  11421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11422. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11423. {
  11424. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11425. if (viewData.Code != 0)
  11426. {
  11427. return Ok(JsonView(false, viewData.Msg));
  11428. }
  11429. return Ok(JsonView(viewData.Data));
  11430. }
  11431. /// <summary>
  11432. /// 倒推表
  11433. /// Create
  11434. /// </summary>
  11435. /// <param name="dto"></param>
  11436. /// <returns></returns>
  11437. [HttpPost]
  11438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11439. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11440. {
  11441. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11442. if (viewData.Code != 0)
  11443. {
  11444. return Ok(JsonView(false, viewData.Msg));
  11445. }
  11446. return Ok(JsonView(viewData.Data));
  11447. }
  11448. /// <summary>
  11449. /// 倒推表
  11450. /// Update
  11451. /// </summary>
  11452. /// <param name="dto"></param>
  11453. /// <returns></returns>
  11454. [HttpPost]
  11455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11456. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11457. {
  11458. var viewData = await _invertedListRep._Update(dto);
  11459. if (viewData.Code != 0)
  11460. {
  11461. return Ok(JsonView(false, viewData.Msg));
  11462. }
  11463. return Ok(JsonView(viewData.Data));
  11464. }
  11465. /// <summary>
  11466. /// 倒推表
  11467. /// File Download
  11468. /// </summary>
  11469. /// <param name="dto"></param>
  11470. /// <returns></returns>
  11471. [HttpPost]
  11472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11473. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11474. {
  11475. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11476. if (info2.Code != 0)
  11477. {
  11478. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11479. }
  11480. var info1 = info2.Data as InvertedListInfoView;
  11481. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11482. string teamName = "";
  11483. if (info != null) teamName = info.TeamName;
  11484. //载入模板
  11485. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11486. DocumentBuilder builder = new DocumentBuilder(doc);
  11487. //利用键值对存放数据
  11488. Dictionary<string, string> dic = new Dictionary<string, string>();
  11489. dic.Add("TeamName", teamName);
  11490. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11491. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11492. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11493. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11494. dic.Add("SQRemark", info1.ApprovalRemark);
  11495. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11496. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11497. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11498. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11499. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11500. dic.Add("QZRemark", info1.VisaInformationRemark);
  11501. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11502. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11503. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11504. dic.Add("CQRemark", info1.IssueVisaRemark);
  11505. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11506. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11507. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11508. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11509. #region 填充word模板书签内容
  11510. foreach (var key in dic.Keys)
  11511. {
  11512. builder.MoveToBookmark(key);
  11513. builder.Write(dic[key]);
  11514. }
  11515. #endregion
  11516. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11517. string fileName = $"{teamName}团出行准备流程表.doc";
  11518. string filePath = fileDir + $@"InvertedList/{fileName}";
  11519. doc.Save(filePath);
  11520. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11521. return Ok(JsonView(true, "操作成功!", Url));
  11522. }
  11523. #endregion
  11524. #region 三公签证费用(签证费、代办费)
  11525. /// <summary>
  11526. /// 三公签证费用(签证费、代办费)
  11527. /// List
  11528. /// </summary>
  11529. /// <returns></returns>
  11530. [HttpPost]
  11531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11532. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11533. {
  11534. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11535. if (_view.Code != 0)
  11536. {
  11537. return Ok(JsonView(false, _view.Msg));
  11538. }
  11539. return Ok(JsonView(true, "操作成功!", _view.Data));
  11540. }
  11541. /// <summary>
  11542. /// 三公签证费用(签证费、代办费)
  11543. /// Add Or Update
  11544. /// </summary>
  11545. /// <returns></returns>
  11546. [HttpPost]
  11547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11548. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11549. {
  11550. var _view = await _visaFeeInfoRep._Update(_dto);
  11551. if (_view.Code != 0)
  11552. {
  11553. return Ok(JsonView(false, _view.Msg));
  11554. }
  11555. return Ok(JsonView(true, _view.Msg));
  11556. }
  11557. #endregion
  11558. #region 酒店询价
  11559. /// <summary>
  11560. /// 酒店询价
  11561. /// Init
  11562. /// </summary>
  11563. /// <param name="dto"></param>
  11564. /// <returns></returns>
  11565. [HttpPost]
  11566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11567. public async Task<IActionResult> PostHotelInquiryInit()
  11568. {
  11569. var res = await _hotelInquiryRep._Init();
  11570. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11571. return Ok(JsonView(true, res.Msg, res.Data));
  11572. }
  11573. /// <summary>
  11574. /// 酒店询价
  11575. /// page Item
  11576. /// </summary>
  11577. /// <param name="_dto"></param>
  11578. /// <returns></returns>
  11579. [HttpPost]
  11580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11581. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11582. {
  11583. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11584. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11585. var view = res.Data as PageDataViewBase;
  11586. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11587. }
  11588. /// <summary>
  11589. /// 酒店询价
  11590. /// info
  11591. /// </summary>
  11592. /// <param name="_dto"></param>
  11593. /// <returns></returns>
  11594. [HttpPost]
  11595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11596. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11597. {
  11598. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11599. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11600. return Ok(JsonView(true, res.Msg, res.Data));
  11601. }
  11602. /// <summary>
  11603. /// 酒店询价
  11604. /// Add Or Edit
  11605. /// </summary>
  11606. /// <param name="_dto"></param>
  11607. /// <returns></returns>
  11608. [HttpPost]
  11609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11610. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11611. {
  11612. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11613. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11614. return Ok(JsonView(true, res.Msg, res.Data));
  11615. }
  11616. /// <summary>
  11617. /// 酒店询价
  11618. /// Del
  11619. /// </summary>
  11620. /// <param name="_dto"></param>
  11621. /// <returns></returns>
  11622. [HttpPost]
  11623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11624. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11625. {
  11626. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11627. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11628. return Ok(JsonView(true, res.Msg, res.Data));
  11629. }
  11630. #endregion
  11631. #region 下载匹配op行程单
  11632. /// <summary>
  11633. /// 匹配op行程单
  11634. /// Init
  11635. /// </summary>
  11636. /// <param name="dto">团组列表请求dto</param>
  11637. /// <returns></returns>
  11638. [HttpPost]
  11639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11640. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11641. {
  11642. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11643. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11644. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11645. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11646. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11647. .Where(it => it.IsDel == 0)
  11648. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11649. .OrderByDescending(it => it.CreateUserId)
  11650. .ToList();
  11651. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11652. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11653. var diids = groupInfos.Select(it => it.Id).ToList();
  11654. List<string> countrys = new List<string>();
  11655. foreach (var item in country)
  11656. {
  11657. var data = _groupRepository.FormartTeamName(item);
  11658. var dataArray = _groupRepository.GroupSplitCountry(data);
  11659. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11660. }
  11661. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11662. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11663. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11664. foreach (var item in areaItem)
  11665. {
  11666. string areaStr = item.Value;
  11667. if (!string.IsNullOrEmpty(areaStr))
  11668. {
  11669. string[] str1 = areaStr.Split("-");
  11670. if (str1.Length > 0)
  11671. {
  11672. areaArray.AddRange(str1);
  11673. }
  11674. }
  11675. }
  11676. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11677. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11678. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11679. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11680. .ToList();
  11681. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11682. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11683. .Where(it => countriesIds.Contains(it.Id))
  11684. .Select(it => new { it.Id, Name = it.Name_CN })
  11685. .ToList();
  11686. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11687. .Select(it => it.TeamName).ToList();
  11688. stopwatch.Stop();
  11689. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11690. }
  11691. ///// <summary>
  11692. ///// 匹配op行程单
  11693. ///// Init 查询区域数据
  11694. ///// </summary>
  11695. ///// <param name="dto">团组列表请求dto</param>
  11696. ///// <returns></returns>
  11697. //[HttpPost]
  11698. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11699. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11700. //{
  11701. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11702. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11703. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11704. // if (string.IsNullOrEmpty(countriesDataStr))
  11705. // {
  11706. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11707. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11708. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11709. // }
  11710. // else
  11711. // {
  11712. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11713. // }
  11714. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11715. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11716. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11717. // List<dynamic> childList = new List<dynamic>();
  11718. // int parentId = dto.CountriesId;
  11719. // if (provinceData.Count > 1)
  11720. // {
  11721. // foreach (var item1 in provinceData)
  11722. // {
  11723. // List<dynamic> childList1 = new List<dynamic>();
  11724. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11725. // foreach (var item2 in citiesData1)
  11726. // {
  11727. // List<dynamic> childList2 = new List<dynamic>();
  11728. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11729. // foreach (var item3 in countiesData1)
  11730. // {
  11731. // childList2.Add(new
  11732. // {
  11733. // id = item3.Id,
  11734. // parentId = item2.Id,
  11735. // level = "district",
  11736. // name = item3.Name_CN,
  11737. // });
  11738. // }
  11739. // childList1.Add(new
  11740. // {
  11741. // id = item2.Id,
  11742. // parentId = item1.Id,
  11743. // level = "city",
  11744. // name = item2.Name_CN,
  11745. // childList = childList2
  11746. // });
  11747. // }
  11748. // childList.Add(new
  11749. // {
  11750. // id = item1.Id,
  11751. // parentId = parentId,
  11752. // level = "province",
  11753. // name = item1.Name_CN,
  11754. // childList = childList1
  11755. // });
  11756. // }
  11757. // //城市
  11758. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11759. // foreach (var item2 in citiesData2)
  11760. // {
  11761. // List<dynamic> childList22 = new List<dynamic>();
  11762. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11763. // foreach (var item3 in countiesData1)
  11764. // {
  11765. // childList22.Add(new
  11766. // {
  11767. // id = item3.Id,
  11768. // parentId = item2.Id,
  11769. // level = "district",
  11770. // name = item3.Name_CN,
  11771. // });
  11772. // }
  11773. // childList.Add(new
  11774. // {
  11775. // id = item2.Id,
  11776. // parentId = parentId,
  11777. // level = "city",
  11778. // name = item2.Name_CN,
  11779. // childList = childList22
  11780. // });
  11781. // }
  11782. // }
  11783. // else
  11784. // {
  11785. // foreach (var item2 in citiesData)
  11786. // {
  11787. // string cname = item2.Name_CN;
  11788. // List<dynamic> childList1 = new List<dynamic>();
  11789. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11790. // foreach (var item3 in countiesData1)
  11791. // {
  11792. // childList1.Add(new
  11793. // {
  11794. // Id = item3.Id,
  11795. // parentId = item2.Id,
  11796. // level = "district",
  11797. // name = item3.Name_CN
  11798. // });
  11799. // }
  11800. // childList.Add(new
  11801. // {
  11802. // id = item2.Id,
  11803. // parentId = parentId,
  11804. // level = "city",
  11805. // name = item2.Name_CN,
  11806. // childList = childList1
  11807. // });
  11808. // }
  11809. // }
  11810. // stopwatch.Stop();
  11811. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11812. //}
  11813. /// <summary>
  11814. /// 匹配op行程单
  11815. /// 接团信息列表 Page
  11816. /// </summary>
  11817. /// <param name="dto">团组列表请求dto</param>
  11818. /// <returns></returns>
  11819. [HttpPost]
  11820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11821. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11822. {
  11823. var swatch = new Stopwatch();
  11824. swatch.Start();
  11825. #region 参数验证
  11826. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11827. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11828. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11829. #region 页面操作权限验证
  11830. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11831. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11832. #endregion
  11833. #endregion
  11834. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11835. {
  11836. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11837. string sqlWhere = "";
  11838. if (!string.IsNullOrEmpty(dto.Country))
  11839. {
  11840. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11841. }
  11842. if (!string.IsNullOrEmpty(dto.Area))
  11843. {
  11844. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11845. }
  11846. if (!string.IsNullOrEmpty(dto.TeamName))
  11847. {
  11848. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11849. }
  11850. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11851. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11852. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11853. swatch.Stop();
  11854. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11855. }
  11856. else
  11857. {
  11858. return Ok(JsonView(false, "查询失败"));
  11859. }
  11860. }
  11861. /// <summary>
  11862. /// 匹配op行程单
  11863. /// 行程单下载
  11864. /// </summary>
  11865. /// <param name="dto">团组列表请求dto</param>
  11866. /// <returns></returns>
  11867. [HttpPost]
  11868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11869. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11870. {
  11871. #region 参数验证
  11872. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11873. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11874. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11875. #region 页面操作权限验证
  11876. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11877. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11878. #endregion
  11879. #endregion
  11880. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11881. {
  11882. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11883. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11884. }
  11885. else
  11886. {
  11887. return Ok(JsonView(false, "下载失败!"));
  11888. }
  11889. }
  11890. #endregion
  11891. #region 国家信息 数据 注释
  11892. //[HttpPost]
  11893. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11894. //{
  11895. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11896. // foreach (var item in dto)
  11897. // {
  11898. // infos.Add(new Grp_GroupsTaskAssignment()
  11899. // {
  11900. // DIId = item,
  11901. // CTId = 82,
  11902. // UId = 248,
  11903. // IsEnable = 1,
  11904. // CreateUserId = 233,
  11905. // CreateTime = DateTime.Now,
  11906. // IsDel = 0
  11907. // });
  11908. // infos.Add(new Grp_GroupsTaskAssignment()
  11909. // {
  11910. // DIId = item,
  11911. // CTId = 82,
  11912. // UId = 286,
  11913. // IsEnable = 1,
  11914. // CreateUserId = 233,
  11915. // CreateTime = DateTime.Now,
  11916. // IsDel = 0
  11917. // });
  11918. // }
  11919. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11920. // return Ok("操作成功");
  11921. //}
  11922. //public class paramJsonDto
  11923. //{
  11924. // public List<CountriesInfo> str { get; set; }
  11925. //}
  11926. //[HttpPost]
  11927. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11928. //{
  11929. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11930. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11931. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11932. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11933. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11934. // _sqlSugar.BeginTran();
  11935. // int countitiesIndex = 0;
  11936. // foreach (var item in dto.str)
  11937. // {
  11938. // dynamic data = item.c;
  11939. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11940. // if (data != null)
  11941. // {
  11942. // countitiesIndex++;
  11943. // foreach (var item1 in data)
  11944. // {
  11945. // string cnname = item1.cn;
  11946. // string enname = item1.en;
  11947. // Sys_Cities provinceInfo = new Sys_Cities()
  11948. // {
  11949. // CountriesId = countriesId,
  11950. // Name_CN = cnname,
  11951. // Name_EN = enname,
  11952. // ParentId = 0,
  11953. // IsCapital = 1,
  11954. // CreateUserId = 208,
  11955. // CreateTime = DateTime.Now,
  11956. // IsDel = 0
  11957. // };
  11958. // if (item1.lv == "province") //省份
  11959. // {
  11960. // provinceInfo.Level = 1;
  11961. // int provinceId = 0;
  11962. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11963. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11964. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11965. // var data1 = item1.c;
  11966. // foreach (var item2 in data1)
  11967. // {
  11968. // if (item2.lv == "city")
  11969. // {
  11970. // string citycnname = item2.cn;
  11971. // string cityenname = item2.en;
  11972. // Sys_Cities cityInfo = new Sys_Cities()
  11973. // {
  11974. // CountriesId = countriesId,
  11975. // ParentId = provinceId,
  11976. // Level = 2,
  11977. // Name_CN = citycnname,
  11978. // Name_EN = cityenname,
  11979. // IsCapital = 1,
  11980. // CreateUserId = 208,
  11981. // CreateTime = DateTime.Now,
  11982. // IsDel = 0
  11983. // };
  11984. // if (item2.c != null)
  11985. // {
  11986. // int cityId = 0;
  11987. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11988. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11989. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11990. // foreach (var item3 in item2.c)
  11991. // {
  11992. // if (item3.lv == "district")
  11993. // {
  11994. // var districtInfo = new Sys_Cities()
  11995. // {
  11996. // CountriesId = countriesId,
  11997. // Name_CN = item3.cn,
  11998. // Name_EN = item3.en,
  11999. // Level = 3,
  12000. // ParentId = cityId,
  12001. // IsCapital = 1,
  12002. // CreateUserId = 208,
  12003. // CreateTime = DateTime.Now,
  12004. // IsDel = 0
  12005. // };
  12006. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12007. // //{
  12008. // districts.Add(districtInfo);
  12009. // //}
  12010. // }
  12011. // }
  12012. // }
  12013. // else
  12014. // {
  12015. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12016. // //{
  12017. // cities.Add(cityInfo);
  12018. // //}
  12019. // }
  12020. // }
  12021. // }
  12022. // }
  12023. // else if (item1.lv == "city")//城市
  12024. // {
  12025. // provinceInfo.Level = 2;
  12026. // if (item1.c != null)
  12027. // {
  12028. // int cityId = 0;
  12029. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12030. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12031. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12032. // foreach (var item3 in item1.c)
  12033. // {
  12034. // if (item3.lv == "district")
  12035. // {
  12036. // var districtInfo = new Sys_Cities()
  12037. // {
  12038. // CountriesId = countriesId,
  12039. // Name_CN = item3.cn,
  12040. // Name_EN = item3.en,
  12041. // Level = 3,
  12042. // ParentId = cityId,
  12043. // IsCapital = 1,
  12044. // CreateUserId = 208,
  12045. // CreateTime = DateTime.Now,
  12046. // IsDel = 0
  12047. // };
  12048. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12049. // //{
  12050. // districts.Add(districtInfo);
  12051. // //}
  12052. // }
  12053. // }
  12054. // }
  12055. // else
  12056. // {
  12057. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12058. // //{
  12059. // cities.Add(provinceInfo);
  12060. // //}
  12061. // }
  12062. // }
  12063. // }
  12064. // }
  12065. // }
  12066. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12067. // cities = cities.Distinct().ToList();
  12068. // districts = districts.Distinct().ToList();
  12069. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12070. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12071. // cities.AddRange(districts);
  12072. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12073. // //_sqlSugar.RollbackTran();
  12074. // _sqlSugar.CommitTran();
  12075. // return Ok(JsonView(false, "操作成功!"));
  12076. //}
  12077. //[HttpPost]
  12078. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12079. //{
  12080. // List<CountitiesInfo> infos = dto.MyProperty;
  12081. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12082. // _sqlSugar.BeginTran();
  12083. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12084. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12085. // foreach (var item in infos)
  12086. // {
  12087. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12088. // if (countryInfo != null)
  12089. // {
  12090. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12091. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12092. // if (cityInfo1 != null)
  12093. // {
  12094. // cityInfo1.IsCapital = 0;
  12095. // cityInfos.Add(cityInfo1);
  12096. // }
  12097. // }
  12098. // }
  12099. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12100. // .UpdateColumns(it => it.IsCapital)
  12101. // .WhereColumns(it => it.Id)
  12102. // .ExecuteCommand();
  12103. // //_sqlSugar.RollbackTran();
  12104. // _sqlSugar.CommitTran();
  12105. // return Ok(JsonView(false, "操作成功!"));
  12106. //}
  12107. //public class CounrtiesDto
  12108. //{
  12109. // public List<CountitiesInfo> MyProperty { get; set; }
  12110. //}
  12111. //public class CountitiesInfo
  12112. //{
  12113. // /// <summary>
  12114. // /// 圣约翰
  12115. // /// </summary>
  12116. // public string capital_name_chinese { get; set; }
  12117. // /// <summary>
  12118. // ///
  12119. // /// </summary>
  12120. // public string capital_name { get; set; }
  12121. // /// <summary>
  12122. // ///
  12123. // /// </summary>
  12124. // public string country_type { get; set; }
  12125. // /// <summary>
  12126. // /// 安提瓜和巴布达
  12127. // /// </summary>
  12128. // public string country_name_chinese { get; set; }
  12129. // /// <summary>
  12130. // /// 安提瓜和巴布达
  12131. // /// </summary>
  12132. // public string country_name_chinese_short { get; set; }
  12133. // /// <summary>
  12134. // /// 安提瓜和巴布达
  12135. // /// </summary>
  12136. // public string country_name_chinese_UN { get; set; }
  12137. // /// <summary>
  12138. // ///
  12139. // /// </summary>
  12140. // public string country_name_english_abbreviation { get; set; }
  12141. // /// <summary>
  12142. // ///
  12143. // /// </summary>
  12144. // public string country_name_english_formal { get; set; }
  12145. // /// <summary>
  12146. // ///
  12147. // /// </summary>
  12148. // public string country_name_english_UN { get; set; }
  12149. // /// <summary>
  12150. // ///
  12151. // /// </summary>
  12152. // public string continent_name { get; set; }
  12153. // /// <summary>
  12154. // ///
  12155. // /// </summary>
  12156. // public string subregion_name { get; set; }
  12157. // /// <summary>
  12158. // ///
  12159. // /// </summary>
  12160. // public string country_code2 { get; set; }
  12161. // /// <summary>
  12162. // ///
  12163. // /// </summary>
  12164. // public string country_code3 { get; set; }
  12165. // /// <summary>
  12166. // ///
  12167. // /// </summary>
  12168. // public string phone_code { get; set; }
  12169. //}
  12170. //public class CountriesInfo : BasicInfo
  12171. //{
  12172. // public List<CitiesInfo> c { get; set; }
  12173. //}
  12174. //public class CitiesInfo : BasicInfo
  12175. //{
  12176. // public List<AreaInfo> c { get; set; }
  12177. //}
  12178. //public class AreaInfo : BasicInfo
  12179. //{
  12180. // public List<AreaInfo> c { get; set; }
  12181. //}
  12182. //public class BasicInfo
  12183. //{
  12184. // public string code { get; set; }
  12185. // public string cn { get; set; }
  12186. // public string lv { get; set; }
  12187. // public string en { get; set; }
  12188. //}
  12189. #endregion
  12190. #region 查看邀请方
  12191. /// <summary>
  12192. /// 查看邀请方
  12193. /// 邀请方信息 Init
  12194. /// </summary>
  12195. /// <param name="dto"></param>
  12196. /// <returns></returns>
  12197. [HttpPost]
  12198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12199. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12200. {
  12201. string sqlWhere = string.Empty;
  12202. if (!string.IsNullOrEmpty(dto.Search))
  12203. {
  12204. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12205. }
  12206. string sql = string.Format($@"Select
  12207. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12208. Id,
  12209. UnitName
  12210. From Res_InvitationOfficialActivityData
  12211. Where IsDel = 0
  12212. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12213. RefAsync<int> total = 0;
  12214. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12215. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12216. }
  12217. /// <summary>
  12218. /// 查看邀请方
  12219. /// 国家信息 Init
  12220. /// </summary>
  12221. /// <param name="dto"></param>
  12222. /// <returns></returns>
  12223. [HttpPost]
  12224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12225. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12226. {
  12227. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12228. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12229. var diids = groupInfos.Select(it => it.Id).ToList();
  12230. List<string> countrys = new List<string>();
  12231. foreach (var item in country)
  12232. {
  12233. var data = _groupRepository.FormartTeamName(item);
  12234. var dataArray = _groupRepository.GroupSplitCountry(data);
  12235. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12236. }
  12237. countrys = countrys.Distinct().ToList();
  12238. for (int i = 0; i < countrys.Count; i++)
  12239. {
  12240. string item = countrys[i];
  12241. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12242. {
  12243. countrys.Remove(item);
  12244. i--;
  12245. }
  12246. }
  12247. RefAsync<int> total = 0;
  12248. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12249. .Where(it => countrys.Contains(it.Name_CN))
  12250. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12251. .Select(it => new { id = it.Id, name = it.Name_CN })
  12252. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12253. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12254. }
  12255. /// <summary>
  12256. /// 查看邀请方
  12257. /// 城市信息 Init
  12258. /// </summary>
  12259. /// <param name="dto"></param>
  12260. /// <returns></returns>
  12261. [HttpPost]
  12262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12263. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12264. {
  12265. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12266. RefAsync<int> total = 0;
  12267. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12268. .Where(it => it.CountriesId == dto.CountiesId)
  12269. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12270. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12271. .Select(it => new { id = it.Id, name = it.Name_CN })
  12272. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12273. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12274. }
  12275. /// <summary>
  12276. /// 查看邀请方
  12277. /// 团组名称 Init
  12278. /// </summary>
  12279. /// <param name="dto"></param>
  12280. /// <returns></returns>
  12281. [HttpPost]
  12282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12283. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12284. {
  12285. var watch = new Stopwatch();
  12286. watch.Start();
  12287. RefAsync<int> total = 0;
  12288. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12289. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12290. .Where((oa, di) => oa.IsDel == 0)
  12291. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12292. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12293. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12294. .Distinct()
  12295. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12296. watch.Stop();
  12297. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12298. }
  12299. /// <summary>
  12300. /// 查看邀请方
  12301. /// 团组 & 邀请方信息
  12302. /// </summary>
  12303. /// <param name="dto"></param>
  12304. /// <returns></returns>
  12305. [HttpPost]
  12306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12307. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12308. {
  12309. var watch = new Stopwatch();
  12310. watch.Start();
  12311. RefAsync<int> total = 0;
  12312. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12313. .AS("Grp_DelegationInfo")
  12314. .Includes(x => x.InvitingInfos)
  12315. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12316. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12317. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12318. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12319. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12320. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12321. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12322. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12323. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12324. infos.ForEach(x =>
  12325. {
  12326. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12327. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12328. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12329. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12330. });
  12331. watch.Stop();
  12332. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12333. }
  12334. #endregion
  12335. #region 报批行程
  12336. /// <summary>
  12337. /// 报批行程初始化
  12338. /// </summary>
  12339. /// <param name="dto"></param>
  12340. /// <returns></returns>
  12341. [HttpPost]
  12342. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12343. {
  12344. const int chiNumber = 5;
  12345. var jw = JsonView(false);
  12346. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12347. var group = groupList.First();
  12348. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12349. group = groupList.First(x => x.Id == diid);
  12350. if (group == null)
  12351. {
  12352. jw.Msg = "暂无团组!";
  12353. return Ok(jw);
  12354. }
  12355. var data = new
  12356. {
  12357. groupList = groupList.Select(x => new
  12358. {
  12359. x.TeamName,
  12360. x.Id
  12361. }),
  12362. content = new ArrayList(),
  12363. groupInfo = new
  12364. {
  12365. group.VisitDays,
  12366. group.TourCode,
  12367. group.VisitPNumber,
  12368. group.TeamName,
  12369. group.Id,
  12370. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12371. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12372. },
  12373. };
  12374. var resultArr = new ArrayList();
  12375. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12376. if (content.Count == 0)
  12377. {
  12378. var stay = "-";
  12379. var cityPath = "-";
  12380. //添加城市路径以及住宿地
  12381. //黑屏代码数据
  12382. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12383. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12384. {
  12385. jw = JsonView(true, "黑屏代码有误!", data);
  12386. return Ok(jw);
  12387. }
  12388. foreach (DataRow row in dtBlack.Rows)
  12389. {
  12390. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12391. {
  12392. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12393. return Ok(jw);
  12394. }
  12395. }
  12396. //黑屏代码获取时间区间
  12397. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12398. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12399. _sqlSugar.BeginTran();
  12400. for (int i = 0; i < timeArr.Count; i++)
  12401. {
  12402. stay = "-";
  12403. cityPath = "-";
  12404. DateTime NewData = DateTime.Parse(timeArr[i]);
  12405. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12406. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12407. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12408. if (tbSelect.Length > 0)
  12409. {
  12410. List<string> threeCodeStr = new List<string>();
  12411. foreach (var item in tbSelect)
  12412. {
  12413. var threeCode = item["Three"].ToString() ?? "";
  12414. if (threeCode.Length == 6)
  12415. {
  12416. var start = threeCode.Substring(0, 3);
  12417. var end = threeCode.Substring(3, 3);
  12418. if (threeCodeStr.Count == 0)
  12419. {
  12420. threeCodeStr.Add(start);
  12421. threeCodeStr.Add(end);
  12422. }
  12423. else
  12424. {
  12425. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12426. {
  12427. threeCodeStr.Add(end);
  12428. }
  12429. else
  12430. {
  12431. threeCodeStr.Add(start);
  12432. threeCodeStr.Add(end);
  12433. }
  12434. }
  12435. }
  12436. }
  12437. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12438. var last = threeCodeStr.Last();
  12439. foreach (var item in threeCodeStr)
  12440. {
  12441. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12442. if (item.Equals(last))
  12443. {
  12444. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12445. }
  12446. }
  12447. cityPath = cityPath.Trim('-');
  12448. }
  12449. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12450. appro.Diid = diid ?? -1;
  12451. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12452. appro.Id = thisId;
  12453. appro.CreateUserId = dto.UserId;
  12454. appro.CreateTime = DateTime.Now;
  12455. content.Add(appro);
  12456. }
  12457. _sqlSugar.CommitTran();
  12458. }
  12459. foreach (var x in content)
  12460. {
  12461. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12462. if (chiList.Count < chiNumber)
  12463. {
  12464. for (int i = chiList.Count; i < chiNumber; i++)
  12465. {
  12466. chiList.Add(new Grp_ApprovalTravelDetails());
  12467. }
  12468. }
  12469. resultArr.Add(new
  12470. {
  12471. x.Id,
  12472. x.Date,
  12473. x.Diid,
  12474. chiList = chiList.Select(x1 => new
  12475. {
  12476. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12477. x1.Details,
  12478. x1.ParentId,
  12479. x1.Id
  12480. })
  12481. });
  12482. }
  12483. data = data with
  12484. {
  12485. content = resultArr,
  12486. };
  12487. jw = JsonView(true, "获取成功!", data);
  12488. return Ok(jw);
  12489. }
  12490. /// <summary>
  12491. /// 报批行程删除
  12492. /// </summary>
  12493. /// <param name="dto"></param>
  12494. /// <returns></returns>
  12495. [HttpPost]
  12496. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12497. {
  12498. var jw = JsonView(false);
  12499. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12500. if (group == null)
  12501. {
  12502. jw.Msg = "团组参数有误!";
  12503. return Ok(jw);
  12504. }
  12505. try
  12506. {
  12507. _sqlSugar.BeginTran();
  12508. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12509. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12510. {
  12511. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12512. DeleteUserId = dto.uesrId,
  12513. IsDel = 1
  12514. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12515. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12516. {
  12517. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12518. DeleteUserId = dto.uesrId,
  12519. IsDel = 1
  12520. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12521. _sqlSugar.CommitTran();
  12522. jw = JsonView(true, "删除成功");
  12523. }
  12524. catch (Exception ex)
  12525. {
  12526. jw = JsonView(false, ex.Message);
  12527. }
  12528. return Ok(jw);
  12529. }
  12530. /// <summary>
  12531. /// 报批行程保存
  12532. /// </summary>
  12533. /// <param name="dto"></param>
  12534. /// <returns></returns>
  12535. [HttpPost]
  12536. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12537. {
  12538. var jw = JsonView(false);
  12539. var Find = dto.Arr.Find(x => x.id == 0);
  12540. if (Find != null)
  12541. {
  12542. jw.Msg = "生成的ID为0!";
  12543. return Ok(jw);
  12544. }
  12545. foreach (var item in dto.Arr)
  12546. {
  12547. foreach (var chi in item.chiList)
  12548. {
  12549. if (chi.parentId == 0)
  12550. {
  12551. chi.parentId = item.id;
  12552. }
  12553. }
  12554. }
  12555. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12556. _sqlSugar.BeginTran();
  12557. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12558. {
  12559. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12560. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12561. {
  12562. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12563. DeleteUserId = dto.UserId,
  12564. IsDel = 1
  12565. }).ExecuteCommand();
  12566. }
  12567. try
  12568. {
  12569. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12570. {
  12571. CreateTime = DateTime.Now,
  12572. CreateUserId = dto.UserId,
  12573. Details = x.details,
  12574. ParentId = x.parentId,
  12575. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12576. Remark = "",
  12577. IsDel = 0
  12578. }).ToList()).ExecuteCommand();
  12579. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12580. {
  12581. Id = x.id,
  12582. Details = x.details,
  12583. ParentId = x.parentId,
  12584. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12585. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12586. {
  12587. Details = x.Details,
  12588. ParentId = x.ParentId,
  12589. Time = x.Time
  12590. }).ExecuteCommand();
  12591. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12592. {
  12593. Id = x.id,
  12594. Date = x.date,
  12595. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12596. {
  12597. Date = x.Date
  12598. }).ExecuteCommand();
  12599. _sqlSugar.CommitTran();
  12600. jw = JsonView(true, "保存成功!");
  12601. }
  12602. catch (Exception ex)
  12603. {
  12604. _sqlSugar.RollbackTran();
  12605. jw = JsonView(false, "保存失败!" + ex.Message);
  12606. }
  12607. return Ok(jw);
  12608. }
  12609. /// <summary>
  12610. /// 报批行程生成
  12611. /// </summary>
  12612. /// <param name="dto"></param>
  12613. /// <returns></returns>
  12614. [HttpPost]
  12615. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12616. {
  12617. var jw = JsonView(false);
  12618. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12619. if (group == null)
  12620. {
  12621. jw.Msg = "暂无该团组!";
  12622. return Ok(jw);
  12623. }
  12624. //黑屏代码数据
  12625. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12626. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12627. {
  12628. jw.Msg = "黑屏代码有误!";
  12629. return Ok(jw);
  12630. }
  12631. foreach (DataRow row in dtBlack.Rows)
  12632. {
  12633. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12634. {
  12635. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12636. return Ok(jw);
  12637. }
  12638. }
  12639. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12640. var resultArr = new ArrayList();
  12641. if (officialActivitiesArr.Count == 0)
  12642. {
  12643. jw.Msg = "暂无公务出访信息!";
  12644. return Ok(jw);
  12645. }
  12646. try
  12647. {
  12648. _sqlSugar.BeginTran();
  12649. DeleteApprovalJourney(new
  12650. Domain.Dtos.Groups.DeleteApprovalJourney
  12651. {
  12652. Diid = dto.Diid,
  12653. uesrId = dto.Userid
  12654. });
  12655. var stay = "-";
  12656. var cityPath = "-";
  12657. //添加城市路径以及住宿地
  12658. //黑屏代码获取时间区间
  12659. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12660. var empty = "【未收入该三字码!请机票同事录入】";
  12661. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12662. for (int i = 0; i < timeArr.Count; i++)
  12663. {
  12664. stay = "-";
  12665. cityPath = "-";
  12666. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12667. DateTime NewData = DateTime.Parse(timeArr[i]);
  12668. 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();
  12669. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12670. if (tbSelect.Length > 0)
  12671. {
  12672. List<string> threeCodeStr = new List<string>();
  12673. bool isTrade = false;
  12674. string trip = string.Empty;
  12675. var rowLast = tbSelect.Last();
  12676. var rowFirst = tbSelect.First();
  12677. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12678. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12679. var takeOffTime = DateTime.Parse(timeArr[i]);
  12680. var fallToTime = DateTime.Parse(timeArr[i]);
  12681. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12682. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12683. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12684. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12685. foreach (var item in tbSelect)
  12686. {
  12687. var start = string.Empty;
  12688. var end = string.Empty;
  12689. var threeCode = item["Three"].ToString() ?? "";
  12690. if (threeCode.Length == 6)
  12691. {
  12692. start = threeCode.Substring(0, 3);
  12693. end = threeCode.Substring(3, 3);
  12694. if (threeCodeStr.Count == 0)
  12695. {
  12696. threeCodeStr.Add(start);
  12697. threeCodeStr.Add(end);
  12698. }
  12699. else
  12700. {
  12701. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12702. {
  12703. threeCodeStr.Add(end);
  12704. }
  12705. else
  12706. {
  12707. threeCodeStr.Add(start);
  12708. threeCodeStr.Add(end);
  12709. }
  12710. }
  12711. }
  12712. //处理机票信息
  12713. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12714. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12715. if (start_Object == null)
  12716. {
  12717. start_Object = new Res_ThreeCode()
  12718. {
  12719. AirPort = empty,
  12720. AirPort_En = empty,
  12721. City = empty,
  12722. Country = empty,
  12723. Four = empty,
  12724. Three = empty,
  12725. };
  12726. }
  12727. if (end_Object == null)
  12728. {
  12729. end_Object = new Res_ThreeCode()
  12730. {
  12731. AirPort = empty,
  12732. AirPort_En = empty,
  12733. City = empty,
  12734. Country = empty,
  12735. Four = empty,
  12736. Three = empty,
  12737. };
  12738. }
  12739. //机型判断
  12740. string airModel = item["AirModel"].ToString();
  12741. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12742. string flightTime = item["FlightTime"].ToString();
  12743. if (flightTime!.Contains(":"))
  12744. {
  12745. flightTime = flightTime.Replace(":", "小时");
  12746. flightTime += "分钟";
  12747. }
  12748. if (flightTime.Contains("H"))
  12749. {
  12750. flightTime = flightTime.Replace("H", "小时");
  12751. }
  12752. if (flightTime.Contains("M"))
  12753. {
  12754. flightTime = flightTime.Replace("M", "分钟");
  12755. }
  12756. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12757. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12758. {
  12759. flightTime = flightDataTime.Hour > 0
  12760. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12761. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12762. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12763. }
  12764. //航班号
  12765. string flightcode = item["Fliagtcode"].ToString();
  12766. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12767. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12768. if (aircompany == null)
  12769. {
  12770. aircompany = new Res_AirCompany
  12771. {
  12772. CnName = hsEmpty,
  12773. EnName = hsEmpty,
  12774. ShortCode = hsEmpty,
  12775. };
  12776. }
  12777. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12778. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12779. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12780. if (isTrade)
  12781. {
  12782. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12783. }
  12784. else
  12785. {
  12786. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12787. }
  12788. }
  12789. chiarr.Add(new Grp_ApprovalTravelDetails
  12790. {
  12791. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12792. CreateTime = DateTime.Now,
  12793. CreateUserId = dto.Userid,
  12794. ParentId = 0,
  12795. Details = trip
  12796. });
  12797. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12798. var last = threeCodeStr.Last();
  12799. foreach (var item in threeCodeStr)
  12800. {
  12801. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12802. if (item.Equals(last))
  12803. {
  12804. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12805. }
  12806. }
  12807. cityPath = cityPath.Trim('-');
  12808. }
  12809. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12810. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12811. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12812. appro.Diid = dto.Diid;
  12813. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12814. appro.Id = thisId;
  12815. appro.CreateUserId = dto.Userid;
  12816. appro.CreateTime = DateTime.Now;
  12817. foreach (var item in gwinfo)
  12818. {
  12819. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12820. chi.Details = "拜访" + item.Client;
  12821. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12822. {
  12823. chi.Details += "," + item.ReqSample;
  12824. }
  12825. chi.ParentId = thisId;
  12826. chi.Time = item.Time;
  12827. chiarr.Add(chi);
  12828. }
  12829. if (chiarr.Count < 5)
  12830. {
  12831. for (int j = chiarr.Count; j < 5; j++)
  12832. {
  12833. chiarr.Add(new
  12834. Grp_ApprovalTravelDetails());
  12835. }
  12836. }
  12837. resultArr.Add(new
  12838. {
  12839. appro.Id,
  12840. appro.Date,
  12841. appro.Diid,
  12842. chiList = chiarr.Select(x1 => new
  12843. {
  12844. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12845. x1.Details,
  12846. x1.ParentId,
  12847. x1.Id
  12848. })
  12849. });
  12850. }
  12851. _sqlSugar.CommitTran();
  12852. jw = JsonView(true, "生成成功!", resultArr);
  12853. }
  12854. catch (Exception ex)
  12855. {
  12856. jw.Code = 400;
  12857. jw.Msg = "生成失败!" + ex.Message;
  12858. }
  12859. return Ok(jw);
  12860. }
  12861. /// <summary>
  12862. /// 报批行程word导出
  12863. /// </summary>
  12864. /// <param name="dto"></param>
  12865. /// <returns></returns>
  12866. [HttpPost]
  12867. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12868. {
  12869. var jw = JsonView(false);
  12870. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12871. if (group == null)
  12872. {
  12873. jw.Msg = "暂无该团组!";
  12874. return Ok(jw);
  12875. }
  12876. //模板路径
  12877. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12878. //载入模板
  12879. Document doc = new Document(tempPath);
  12880. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12881. //获取所填表格的序数
  12882. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12883. Aspose.Words.Tables.Row titleRowClone = null;
  12884. Aspose.Words.Tables.Row CenterRowClone = null;
  12885. int index = 0;
  12886. int indexChi = 0;
  12887. int SetIndex = 0;
  12888. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12889. //获取数据,放到datatable
  12890. foreach (var item in ApprovalTravelArr)
  12891. {
  12892. if (index > 0)
  12893. {
  12894. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12895. tableOne.AppendChild(titleRowClone);
  12896. }
  12897. var textTime = item.Date;
  12898. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12899. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12900. SetIndex++;
  12901. if (ChiRep.Count > 0)
  12902. {
  12903. foreach (var itemChi in ChiRep)
  12904. {
  12905. var txtTime = itemChi.Time;
  12906. var txtDetail = itemChi.Details;
  12907. if (indexChi > 0)
  12908. {
  12909. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12910. tableOne.AppendChild(CenterRowClone);
  12911. }
  12912. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12913. {
  12914. SetCells(tableOne, doc, SetIndex, 0, "");
  12915. SetCells(tableOne, doc, SetIndex, 1, "");
  12916. indexChi++;
  12917. SetIndex++;
  12918. break;
  12919. }
  12920. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12921. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12922. indexChi++;
  12923. SetIndex++;
  12924. }
  12925. }
  12926. else
  12927. {
  12928. if (indexChi > 0)
  12929. {
  12930. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12931. tableOne.AppendChild(CenterRowClone);
  12932. }
  12933. SetCells(tableOne, doc, SetIndex, 0, "");
  12934. SetCells(tableOne, doc, SetIndex, 1, "");
  12935. indexChi++;
  12936. SetIndex++;
  12937. }
  12938. index++;
  12939. }
  12940. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12941. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12942. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12943. jw.Code = 200;
  12944. jw.Msg = "";
  12945. return Ok(jw);
  12946. }
  12947. private string intToString(int numberVal)
  12948. {
  12949. string numberval = numberVal.ToString();
  12950. Dictionary<char, string> Number = new Dictionary<char, string>();
  12951. Number.Add('1', "一");
  12952. Number.Add('2', "二");
  12953. Number.Add('3', "三");
  12954. Number.Add('4', "四");
  12955. Number.Add('5', "五");
  12956. Number.Add('6', "六");
  12957. Number.Add('7', "七");
  12958. Number.Add('8', "八");
  12959. Number.Add('9', "九");
  12960. string stringNumberVal = string.Empty;
  12961. for (int i = 0; i < numberval.Length; i++)
  12962. {
  12963. if (i == 0)
  12964. {
  12965. stringNumberVal += Number[numberval[i]];
  12966. }
  12967. else if (i >= 1)
  12968. {
  12969. if (numberval[i] == '0')
  12970. {
  12971. stringNumberVal = "十";
  12972. }
  12973. else
  12974. {
  12975. stringNumberVal += "十" + Number[numberval[i]];
  12976. }
  12977. }
  12978. }
  12979. return stringNumberVal;
  12980. }
  12981. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12982. {
  12983. //获取table中的某个单元格,从0开始
  12984. Cell lshCell = table.Rows[rows].Cells[cells];
  12985. //将单元格中段落移除
  12986. foreach (Node item in lshCell.Paragraphs)
  12987. {
  12988. lshCell.Paragraphs.Remove(item);
  12989. }
  12990. if (val.Contains("\r\n"))
  12991. {
  12992. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12993. foreach (var item in spArr)
  12994. {
  12995. //新建一个段落
  12996. Paragraph p = new Paragraph(doc);
  12997. var r = new Run(doc, item);
  12998. //把设置的值赋给之前新建的段落
  12999. p.AppendChild(r);
  13000. //将此段落加到单元格内
  13001. lshCell.AppendChild(p);
  13002. }
  13003. }
  13004. else
  13005. {
  13006. //新建一个段落
  13007. Paragraph p = new Paragraph(doc);
  13008. var r = new Run(doc, val);
  13009. //把设置的值赋给之前新建的段落
  13010. p.AppendChild(r);
  13011. //将此段落加到单元格内
  13012. lshCell.AppendChild(p);
  13013. }
  13014. }
  13015. [HttpPost]
  13016. public async Task<IActionResult> ServerHttp(string paramStr)
  13017. {
  13018. paramStr = paramStr.TrimEnd('\'');
  13019. paramStr = paramStr.TrimStart('\'');
  13020. JsonView jw = JsonView(false);
  13021. JObject param = JObject.Parse(paramStr);
  13022. if (!param.ContainsKey("url"))
  13023. {
  13024. jw.Msg = "url null";
  13025. return Ok(jw);
  13026. }
  13027. string url = param["url"]!.ToString();
  13028. var methon = "get";
  13029. Dictionary<string, string> bodyValues = null;
  13030. Dictionary<string, string> headValues = null;
  13031. if (param.ContainsKey("methon"))
  13032. {
  13033. methon = param["methon"]!.ToString();
  13034. }
  13035. if (param.ContainsKey("header"))
  13036. {
  13037. var header = param["header"]!.ToString();
  13038. JObject headerJobject = JObject.Parse(header);
  13039. headValues = new Dictionary<string, string>();
  13040. foreach (JProperty item in headerJobject.Properties())
  13041. {
  13042. var value = item.Value.ToString();
  13043. var head = item.Path;
  13044. headValues.Add(head, value);
  13045. }
  13046. }
  13047. if (param.ContainsKey("body"))
  13048. {
  13049. var body = param["body"]!.ToString();
  13050. bodyValues = new Dictionary<string, string>();
  13051. JObject bodyJobject = JObject.Parse(body);
  13052. foreach (JProperty item in bodyJobject.Properties())
  13053. {
  13054. var value = item.Value.ToString();
  13055. var head = item.Path;
  13056. bodyValues.Add(head, value);
  13057. }
  13058. }
  13059. HttpClient client = new HttpClient();
  13060. string responseString = string.Empty;
  13061. if (param.ContainsKey("isJson"))
  13062. {
  13063. }
  13064. if (headValues != null)
  13065. {
  13066. foreach (var item in headValues.Keys)
  13067. {
  13068. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13069. }
  13070. }
  13071. try
  13072. {
  13073. if (methon == "get")
  13074. {
  13075. responseString = await client.GetStringAsync(url);
  13076. }
  13077. else if (methon == "post")
  13078. {
  13079. if (bodyValues == null)
  13080. {
  13081. jw.Msg = "methon post body null";
  13082. return Ok(jw);
  13083. }
  13084. // 数据转化为 key=val 格式
  13085. var content = new FormUrlEncodedContent(bodyValues);
  13086. var response = await client.PostAsync(url, content);
  13087. // 获取数据
  13088. responseString = await response.Content.ReadAsStringAsync();
  13089. }
  13090. else
  13091. {
  13092. jw.Msg = "methon error";
  13093. }
  13094. jw = JsonView(true, "success", responseString);
  13095. }
  13096. catch (Exception ex)
  13097. {
  13098. jw.Msg = "error " + ex.Message;
  13099. jw.Data = ex.StackTrace;
  13100. }
  13101. finally
  13102. {
  13103. client.Dispose();
  13104. }
  13105. return Ok(jw);
  13106. }
  13107. #endregion
  13108. // /// <summary>
  13109. // ///
  13110. // /// </summary>
  13111. // /// <param name="_dto"></param>
  13112. // /// <returns></returns>
  13113. // [HttpPost]
  13114. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13115. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13116. // {
  13117. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13118. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13119. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13120. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13121. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13122. // dic_psg.Add("客人", 974);
  13123. // dic_psg.Add("司机", 975);
  13124. // dic_psg.Add("导游", 976);
  13125. // dic_psg.Add("公司内部人员", 977);
  13126. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13127. // foreach (var item in list_visa)
  13128. // {
  13129. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13130. // temp.Id = item.Id;
  13131. // temp.DIId = item.DIId;
  13132. // temp.VisaClient = item.VisaClient;
  13133. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13134. // temp.VisaCurrency = item.VisaCurrency;
  13135. // temp.IsThird = item.IsThird;
  13136. // if (dic_psg.ContainsKey(item.PassengerType))
  13137. // {
  13138. // temp.PassengerType = dic_psg[item.PassengerType];
  13139. // }
  13140. // else {
  13141. // temp.PassengerType = -1;
  13142. // }
  13143. // temp.VisaNumber = item.VisaNumber;
  13144. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13145. // temp.CreateUserId = item.Operators;
  13146. // DateTime dt_ct;
  13147. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13148. // if (b_ct)
  13149. // {
  13150. // temp.CreateTime = dt_ct;
  13151. // }
  13152. // else
  13153. // {
  13154. // temp.CreateTime = DateTime.Now;
  13155. // }
  13156. // temp.DeleteTime = "";
  13157. // temp.DeleteUserId = 0;
  13158. // temp.Remark = item.Remark;
  13159. // if (string.IsNullOrEmpty(temp.Remark)) {
  13160. // temp.Remark = "";
  13161. // }
  13162. // temp.IsDel = item.IsDel;
  13163. // temp.VisaDescription = item.VisaAttachment;
  13164. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13165. //([Id]
  13166. // ,[DIId]
  13167. // ,[VisaClient]
  13168. // ,[VisaPrice]
  13169. // ,[VisaCurrency]
  13170. // ,[IsThird]
  13171. // ,[PassengerType]
  13172. // ,[VisaNumber]
  13173. // ,[VisaFreeNumber]
  13174. // ,[CreateUserId]
  13175. // ,[CreateTime]
  13176. // ,[DeleteTime]
  13177. // ,[DeleteUserId]
  13178. // ,[Remark]
  13179. // ,[IsDel]
  13180. // ,[visaDescription])
  13181. // VALUES
  13182. // ({0},{1},'{2}',{3},{4}
  13183. //,{5},{6},{7},{8},{9}
  13184. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13185. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13186. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13187. //);
  13188. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13189. // }
  13190. // return Ok(JsonView(true, "操作成功!"));
  13191. // }
  13192. /// <summary>
  13193. /// 123132123
  13194. /// </summary>
  13195. /// <param name="_dto"></param>
  13196. /// <returns></returns>
  13197. [HttpPost]
  13198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13199. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13200. {
  13201. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13202. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13203. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13204. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13205. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13206. dicDetail.Add(789, 1034);
  13207. dicDetail.Add(790, 1035);
  13208. dicDetail.Add(791, 1036);
  13209. dicDetail.Add(792, 1037);
  13210. dicDetail.Add(793, 1038);
  13211. dicDetail.Add(794, 1039);
  13212. dicDetail.Add(795, 1040);
  13213. dicDetail.Add(796, 1041);
  13214. dicDetail.Add(797, 1042);
  13215. dicDetail.Add(798, 1043);
  13216. dicDetail.Add(801, 1044);
  13217. dicDetail.Add(802, 1045);
  13218. dicDetail.Add(803, 1046);
  13219. Dictionary<int, int> dic = new Dictionary<int, int>();
  13220. dic.Add(806, 1027);
  13221. dic.Add(807, 1028);
  13222. dic.Add(808, 1029);
  13223. dic.Add(809, 1030);
  13224. dic.Add(810, 1031);
  13225. dic.Add(811, 1032);
  13226. dic.Add(812, 1033);
  13227. foreach (var item in list_visa)
  13228. {
  13229. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13230. temp.Coefficient = item.coefficient;
  13231. DateTime dtCrt;
  13232. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13233. if (b1)
  13234. {
  13235. temp.CreateTime = dtCrt;
  13236. }
  13237. else
  13238. {
  13239. temp.CreateTime = DateTime.Now;
  13240. }
  13241. temp.CreateUserId = item.Operators;
  13242. temp.DeleteTime = "";
  13243. temp.DeleteUserId = 0;
  13244. temp.DiId = int.Parse(item.DIID);
  13245. temp.FilePath = item.FilePath;
  13246. temp.IsDel = item.IsDel;
  13247. temp.Price = item.Price;
  13248. temp.PriceCount = 1;
  13249. temp.PriceCurrency = item.Currency;
  13250. int detailId = 0;
  13251. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13252. {
  13253. detailId = dicDetail[item.PriceTypeDetail];
  13254. }
  13255. temp.PriceDetailType = detailId;
  13256. temp.PriceDt = DateTime.Now;
  13257. temp.PriceName = item.PriceName;
  13258. temp.PriceSum = item.Price;
  13259. int tid = 0;
  13260. if (dic.ContainsKey(item.PriceType))
  13261. {
  13262. tid = dic[item.PriceType];
  13263. }
  13264. temp.PriceType = tid;
  13265. temp.Remark = item.Remark;
  13266. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13267. }
  13268. return Ok(JsonView(true, "操作成功!"));
  13269. }
  13270. }
  13271. }