GroupsController.cs 708 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234
  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.Extensions;
  30. using System.Collections;
  31. using System.Data;
  32. using System.Diagnostics;
  33. using System.Globalization;
  34. using System.IO;
  35. using System.Reflection.PortableExecutable;
  36. using Ubiety.Dns.Core;
  37. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  38. using Bookmark = Aspose.Words.Bookmark;
  39. using Cell = Aspose.Words.Tables.Cell;
  40. using Table = Aspose.Words.Tables.Table;
  41. namespace OASystem.API.Controllers
  42. {
  43. /// <summary>
  44. /// 团组相关
  45. /// </summary>
  46. //[Authorize]
  47. [Route("api/[controller]/[action]")]
  48. public class GroupsController : ControllerBase
  49. {
  50. private readonly ILogger<GroupsController> _logger;
  51. private readonly GrpScheduleRepository _grpScheduleRep;
  52. private readonly IMapper _mapper;
  53. private readonly DelegationInfoRepository _groupRepository;
  54. private readonly TaskAssignmentRepository _taskAssignmentRep;
  55. private readonly AirTicketResRepository _airTicketResRep;
  56. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  57. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  58. private readonly DelegationEnDataRepository _delegationEnDataRep;
  59. private readonly DelegationVisaRepository _delegationVisaRep;
  60. private readonly VisaPriceRepository _visaPriceRep;
  61. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  62. private readonly HotelPriceRepository _hotelPriceRep;
  63. private readonly CustomersRepository _customersRep;
  64. private readonly MessageRepository _message;
  65. private readonly SqlSugarClient _sqlSugar;
  66. private readonly TourClientListRepository _tourClientListRep;
  67. private readonly TeamRateRepository _teamRateRep;
  68. #region 成本相关
  69. private readonly CheckBoxsRepository _checkBoxs;
  70. private readonly GroupCostRepository _GroupCostRepository;
  71. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  72. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  73. #endregion
  74. private readonly SetDataRepository _setDataRep;
  75. private string url;
  76. private string path;
  77. private readonly EnterExitCostRepository _enterExitCostRep;
  78. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  79. private readonly UsersRepository _usersRep;
  80. private readonly IJuHeApiService _juHeApi;
  81. private readonly InvertedListRepository _invertedListRep;
  82. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  83. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  84. private readonly ThreeCodeRepository _threeCodeRepository;
  85. private readonly HotelInquiryRepository _hotelInquiryRep;
  86. private readonly FeeAuditRepository _feeAuditRep;
  87. private readonly VisaCommissionRepository _visaCommissionRep;
  88. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  89. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  90. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  91. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  92. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  93. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  94. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  95. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  96. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  97. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep)
  98. {
  99. _logger = logger;
  100. _mapper = mapper;
  101. _grpScheduleRep = grpScheduleRep;
  102. _groupRepository = groupRepository;
  103. _taskAssignmentRep = taskAssignmentRep;
  104. _airTicketResRep = airTicketResRep;
  105. _sqlSugar = sqlSugar;
  106. url = AppSettingsHelper.Get("ExcelBaseUrl");
  107. path = AppSettingsHelper.Get("ExcelBasePath");
  108. if (!System.IO.Directory.Exists(path))
  109. {
  110. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  111. }
  112. _decreasePaymentsRep = decreasePaymentsRep;
  113. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  114. _delegationEnDataRep = delegationEnDataRep;
  115. _enterExitCostRep = enterExitCostRep;
  116. _delegationVisaRep = delegationVisaRep;
  117. _message = message;
  118. _visaPriceRep = visaPriceRep;
  119. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  120. _checkBoxs = checkBoxs;
  121. _GroupCostRepository = GroupCostRepository;
  122. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  123. _GroupCostParameterRepository = GroupCostParameterRepository;
  124. _hotelPriceRep = hotelPriceRep;
  125. _customersRep = customersRep;
  126. _setDataRep = setDataRep;
  127. _tourClientListRep = tourClientListRep;
  128. _teamRateRep = teamRateRep;
  129. _hubContext = hubContext;
  130. _usersRep = usersRep;
  131. _juHeApi = juHeApi;
  132. _invertedListRep = invertedListRep;
  133. _visaFeeInfoRep = visaFeeInfoRep;
  134. _ticketBlackCodeRep = ticketBlackCodeRep;
  135. _hotelInquiryRep = hotelInquiryRep;
  136. _threeCodeRepository = threeCodeRepository;
  137. _feeAuditRep = feeAuditRep;
  138. _visaCommissionRep = visaCommissionRep;
  139. _ffrRep = ffrRep;
  140. }
  141. #region 流程管控
  142. /// <summary>
  143. /// 获取团组流程管控信息
  144. /// </summary>
  145. /// <param name="paras">参数Json字符串</param>
  146. /// <returns></returns>
  147. [HttpPost]
  148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  149. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  150. {
  151. if (string.IsNullOrEmpty(_jsonDto.Paras))
  152. {
  153. return Ok(JsonView(false, "参数为空"));
  154. }
  155. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  156. if (_ScheduleDto != null)
  157. {
  158. if (_ScheduleDto.SearchType == 2)//获取列表
  159. {
  160. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  161. return Ok(JsonView(_grpScheduleViewList));
  162. }
  163. else//获取对象
  164. {
  165. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  166. if (_grpScheduleView != null)
  167. {
  168. return Ok(JsonView(_grpScheduleView));
  169. }
  170. }
  171. }
  172. else
  173. {
  174. return Ok(JsonView(false, "参数反序列化失败"));
  175. }
  176. return Ok(JsonView(false, "暂无数据!"));
  177. }
  178. /// <summary>
  179. /// 修改团组流程管控详细表数据
  180. /// </summary>
  181. /// <param name="paras"></param>
  182. /// <returns></returns>
  183. [HttpPost]
  184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  185. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  186. {
  187. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  188. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  189. .SetColumns(it => it.Duty == _detail.Duty)
  190. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  191. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  192. .SetColumns(it => it.JobContent == _detail.JobContent)
  193. .SetColumns(it => it.Remark == _detail.Remark)
  194. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  195. .Where(s => s.Id == dto.Id)
  196. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  197. .ExecuteCommandAsync();
  198. if (result > 0)
  199. {
  200. return Ok(JsonView(true, "保存成功!"));
  201. }
  202. return Ok(JsonView(false, "保存失败!"));
  203. }
  204. /// <summary>
  205. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  206. /// </summary>
  207. /// <param name="dto"></param>
  208. /// <returns></returns>
  209. [HttpPost]
  210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  211. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  212. {
  213. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  214. _detail.IsDel = 1;
  215. _detail.DeleteUserId = dto.Duty;
  216. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  217. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  218. .SetColumns(it => it.IsDel == _detail.IsDel)
  219. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  220. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  221. .Where(it => it.Id == dto.Id)
  222. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  223. //.WhereColumns(s => s.Id == dto.Id)
  224. .ExecuteCommandAsync();
  225. if (result > 0)
  226. {
  227. return Ok(JsonView(true, "删除成功!"));
  228. }
  229. return Ok(JsonView(false, "删除失败!"));
  230. }
  231. /// <summary>
  232. /// 增加团组流程管控详细表数据
  233. /// </summary>
  234. /// <param name="dto"></param>
  235. /// <returns></returns>
  236. [HttpPost]
  237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  238. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  239. {
  240. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  241. if (DateTime.Now < _detail.ExpectBeginDt)
  242. {
  243. _detail.StepStatus = 0;
  244. }
  245. else
  246. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  247. _detail.StepStatus = 1;
  248. }
  249. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  250. if (result > 0)
  251. {
  252. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  253. return Ok(JsonView(true, "添加成功!", _result));
  254. }
  255. return Ok(JsonView(false, "添加失败!"));
  256. }
  257. #endregion
  258. #region 团组基本信息
  259. /// <summary>
  260. /// 接团信息列表
  261. /// </summary>
  262. /// <param name="dto">团组列表请求dto</param>
  263. /// <returns></returns>
  264. [HttpPost]
  265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  266. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  267. {
  268. var groupData = await _groupRepository.GetGroupList(dto);
  269. if (groupData.Code != 0)
  270. {
  271. return Ok(JsonView(false, groupData.Msg));
  272. }
  273. return Ok(JsonView(groupData.Data));
  274. }
  275. /// <summary>
  276. /// 分页查询团组列表
  277. /// </summary>
  278. /// <param name="dto"></param>
  279. /// <returns></returns>
  280. [HttpPost]
  281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  282. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  283. {
  284. var watch = new Stopwatch();
  285. watch.Start();
  286. RefAsync<int> total = 0;
  287. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  288. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  289. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  290. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  291. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  292. .Distinct()
  293. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  294. watch.Stop();
  295. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  296. }
  297. /// <summary>
  298. /// 接团信息列表 Page
  299. /// </summary>
  300. /// <param name="dto">团组列表请求dto</param>
  301. /// <returns></returns>
  302. [HttpPost]
  303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  304. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  305. {
  306. #region 参数验证
  307. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  308. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  309. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  310. #region 页面操作权限验证
  311. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  312. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  313. #endregion
  314. #endregion
  315. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  316. {
  317. string sqlWhere = string.Empty;
  318. if (dto.IsSure == 0) //未完成
  319. {
  320. sqlWhere += string.Format(@" And IsSure = 0");
  321. }
  322. else if (dto.IsSure == 1) //已完成
  323. {
  324. sqlWhere += string.Format(@" And IsSure = 1");
  325. }
  326. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  327. {
  328. string tj = dto.SearchCriteria;
  329. 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}%')",
  330. tj, tj, tj, tj, tj);
  331. }
  332. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  333. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  334. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  335. JietuanOperator,IsSure,CreateTime,IsBid
  336. From (
  337. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  338. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  339. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  340. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  341. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  342. From Grp_DelegationInfo gdi
  343. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  344. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  345. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  346. Where gdi.IsDel = 0 {0}
  347. ) temp", sqlWhere);
  348. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  349. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  350. #region 处理所属部门
  351. /*
  352. * 1.sq 和 gyy 等显示 市场部
  353. * 2.王鸽和主管及张总还有管理员号统一国交部
  354. * 2-1. 4 管理员 ,21 张海麟
  355. */
  356. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  357. List<int> userIds1 = new List<int>() { 4, 21 };
  358. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  359. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  360. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  361. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  362. .ToList();
  363. foreach (var item in _DelegationList)
  364. {
  365. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  366. }
  367. #endregion
  368. var _view = new
  369. {
  370. PageFuncAuth = pageFunAuthView,
  371. Data = _DelegationList
  372. };
  373. return Ok(JsonView(true, "查询成功!", _view, total));
  374. }
  375. else
  376. {
  377. return Ok(JsonView(false, "查询失败"));
  378. }
  379. }
  380. /// <summary>
  381. /// 团组列表
  382. /// </summary>
  383. /// <returns></returns>
  384. [HttpPost]
  385. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  386. {
  387. #region 参数验证
  388. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  389. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  390. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  391. #region 页面操作权限验证
  392. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  393. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  394. #endregion
  395. #endregion
  396. if (dto.PortType != 1 && dto.PortType != 2)
  397. {
  398. return Ok(JsonView(false, "查询失败!"));
  399. }
  400. string orderbyStr = "order by gdi.CreateTime Desc";
  401. string sqlWhere = string.Empty;
  402. if (dto.IsSure == 0) //未完成
  403. {
  404. sqlWhere += string.Format(@" And IsSure = 0");
  405. }
  406. else if (dto.IsSure == 1) //已完成
  407. {
  408. sqlWhere += string.Format(@" And IsSure = 1");
  409. }
  410. //团组类型
  411. if (dto.TeamDid > 0)
  412. {
  413. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  414. }
  415. //团组名称
  416. if (!string.IsNullOrEmpty(dto.TeamName))
  417. {
  418. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  419. }
  420. //客户名称
  421. if (!string.IsNullOrEmpty(dto.ClientName))
  422. {
  423. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  424. }
  425. //客户单位
  426. if (!string.IsNullOrEmpty(dto.ClientUnit))
  427. {
  428. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  429. }
  430. //出访时间
  431. if (!string.IsNullOrEmpty(dto.visitDataTime))
  432. {
  433. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  434. orderbyStr = "order by gdi.VisitDate";
  435. }
  436. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  437. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  438. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  439. JietuanOperator,IsSure,CreateTime
  440. From (
  441. Select row_number() over({0}) as Row_Number,
  442. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  443. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  444. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  445. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  446. From Grp_DelegationInfo gdi
  447. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  448. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  449. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  450. Where gdi.IsDel = 0 {1}
  451. ) temp ", orderbyStr, sqlWhere);
  452. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  453. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  454. #region 处理所属部门
  455. /*
  456. * 1.sq 和 gyy 等显示 市场部
  457. * 2.王鸽和主管及张总还有管理员号统一国交部
  458. * 2-1. 4 管理员 ,21 张海麟
  459. */
  460. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  461. List<int> userIds1 = new List<int>() { 4, 21 };
  462. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  463. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  464. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  465. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  466. .ToList();
  467. foreach (var item in _DelegationList)
  468. {
  469. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  470. }
  471. #endregion
  472. var _view = new
  473. {
  474. PageFuncAuth = pageFunAuthView,
  475. Data = _DelegationList
  476. };
  477. return Ok(JsonView(true, "查询成功!", _view, total));
  478. }
  479. /// <summary>
  480. /// 接团信息详情
  481. /// </summary>
  482. /// <param name="dto">团组info请求dto</param>
  483. /// <returns></returns>
  484. [HttpPost]
  485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  486. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  487. {
  488. var groupData = await _groupRepository.GetGroupInfo(dto);
  489. if (groupData.Code != 0)
  490. {
  491. return Ok(JsonView(false, groupData.Msg));
  492. }
  493. return Ok(JsonView(groupData.Data));
  494. }
  495. /// <summary>
  496. /// 接团信息 编辑添加
  497. /// 基础信息数据源
  498. /// </summary>
  499. /// <param name="dto"></param>
  500. /// <returns></returns>
  501. [HttpPost]
  502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  503. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  504. {
  505. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  506. if (groupData.Code != 0)
  507. {
  508. return Ok(JsonView(false, groupData.Msg));
  509. }
  510. return Ok(JsonView(groupData.Data));
  511. }
  512. /// <summary>
  513. /// 接团信息 操作(增改)
  514. /// </summary>
  515. /// <param name="dto"></param>
  516. /// <returns></returns>
  517. [HttpPost]
  518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  519. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  520. {
  521. try
  522. {
  523. decimal ffrPrice = 0.00M;
  524. DateTime? visitDt = null;
  525. if (dto.Status == 2)
  526. {
  527. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  528. if (groupInfo != null)
  529. {
  530. ffrPrice = groupInfo.PaymentMoney;
  531. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  532. }
  533. }
  534. var groupData = await _groupRepository.GroupOperation(dto);
  535. if (groupData.Code != 0)
  536. {
  537. return Ok(JsonView(false, groupData.Msg));
  538. }
  539. int diId = 0;
  540. //添加时 默认加入团组汇率
  541. if (dto.Status == 1) //添加
  542. {
  543. diId = groupData.Data;
  544. //添加默认币种
  545. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  546. //默认分配权限
  547. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  548. //消息提示 王鸽 主管号
  549. List<int> _managerIds = new List<int>() { 22, 32 };
  550. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  551. if (userIds.Count > 0)
  552. {
  553. userIds.Add(208);
  554. //创建团组管控
  555. GroupStepForDelegation.CreateWorkStep(diId);
  556. //发送消息
  557. string groupName = dto.TeamName;
  558. string createGroupUser = string.Empty;
  559. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  560. if (userInfo != null) createGroupUser = userInfo.CnName;
  561. string title = $"系统通知";
  562. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  563. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  564. }
  565. //默认创建倒推表
  566. await _invertedListRep._Create(dto.UserId, diId);
  567. }
  568. else if (dto.Status == 2)
  569. {
  570. diId = dto.Id;
  571. }
  572. #region 团组操作默认添加/修改收款账单
  573. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  574. {
  575. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  576. .Where(x => x.IsDel == 0 &&
  577. x.Diid == diId &&
  578. x.Remark.Equals("预付款")
  579. )
  580. .WhereIF(ffrPrice > 0 , x => x.ItemSumPrice == ffrPrice)
  581. .WhereIF(visitDt != null, x=> x.CreateTime == visitDt)
  582. .FirstAsync();
  583. ffrInfo.Diid = diId;
  584. ffrInfo.PriceName = dto.ClientUnit;
  585. ffrInfo.Price = dto.PaymentMoney;
  586. ffrInfo.Count = 1;
  587. ffrInfo.Unit = $"元";
  588. ffrInfo.ItemSumPrice = dto.PaymentMoney;
  589. ffrInfo.Rate = 1.0000M;
  590. ffrInfo.Currency = 836;
  591. ffrInfo.AddingWay = 0;
  592. ffrInfo.CreateUserId = dto.UserId;
  593. ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
  594. ffrInfo.Remark = $"预付款";
  595. if (ffrInfo == null) //Add
  596. {
  597. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  598. }
  599. else //修改
  600. {
  601. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  602. .UpdateColumns(x => new
  603. {
  604. x.PriceName,
  605. x.Price,
  606. x.ItemSumPrice,
  607. x.CreateTime,
  608. x.CreateUserId
  609. })
  610. .WhereColumns(x => x.Id)
  611. .ExecuteCommandAsync();
  612. }
  613. }
  614. #endregion
  615. return Ok(JsonView(true, "操作成功!", diId));
  616. }
  617. catch (Exception ex)
  618. {
  619. Logs("[response]" + JsonConvert.SerializeObject(dto));
  620. Logs(ex.Message);
  621. return Ok(JsonView(false, ex.Message));
  622. }
  623. }
  624. /// <summary>
  625. /// 接团流程操作(增改)
  626. /// 安卓端使用 建团时添加客户名单
  627. /// </summary>
  628. /// <param name="dto"></param>
  629. /// <returns></returns>
  630. [HttpPost]
  631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  632. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  633. {
  634. try
  635. {
  636. #region 参数验证
  637. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  638. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  639. #region 页面操作权限验证
  640. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  641. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  642. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  643. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  644. #endregion
  645. #endregion
  646. _sqlSugar.BeginTran();
  647. decimal ffrPrice = 0.00M;
  648. DateTime? visitDt = null;
  649. if (dto.Status == 2)
  650. {
  651. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  652. if (groupInfo != null)
  653. {
  654. ffrPrice = groupInfo.PaymentMoney;
  655. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  656. }
  657. }
  658. var _dto = new GroupOperationDto();
  659. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  660. var groupData = await _groupRepository.GroupOperation(_dto);
  661. if (groupData.Code != 0)
  662. {
  663. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  664. }
  665. int diId = 0;
  666. //添加时 默认加入团组汇率
  667. if (dto.Status == 1) //添加
  668. {
  669. diId = groupData.Data;
  670. //添加默认币种
  671. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  672. //默认分配权限
  673. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  674. //消息提示 王鸽 主管号
  675. List<int> _managerIds = new List<int>() { 22, 32 };
  676. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  677. if (userIds.Count > 0)
  678. {
  679. userIds.Add(208);
  680. //创建团组管控
  681. GroupStepForDelegation.CreateWorkStep(diId);
  682. //发送消息
  683. string groupName = dto.TeamName;
  684. string createGroupUser = string.Empty;
  685. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  686. if (userInfo != null) createGroupUser = userInfo.CnName;
  687. string title = $"系统通知";
  688. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  689. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  690. }
  691. //默认创建倒推表
  692. await _invertedListRep._Create(dto.UserId, diId);
  693. }
  694. if (dto.Status == 2)
  695. {
  696. diId = dto.Id;
  697. if (diId == 0)
  698. {
  699. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  700. }
  701. }
  702. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  703. if (viewData.Code != 0)
  704. {
  705. _sqlSugar.RollbackTran();
  706. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  707. }
  708. #region 团组操作默认添加/修改收款账单
  709. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  710. {
  711. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  712. .Where(x => x.IsDel == 0 &&
  713. x.Diid == diId &&
  714. x.Remark.Equals("预付款")
  715. )
  716. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  717. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  718. .FirstAsync();
  719. ffrInfo.Diid = diId;
  720. ffrInfo.PriceName = dto.ClientUnit;
  721. ffrInfo.Price = dto.PaymentMoney;
  722. ffrInfo.Count = 1;
  723. ffrInfo.Unit = $"元";
  724. ffrInfo.ItemSumPrice = dto.PaymentMoney;
  725. ffrInfo.Rate = 1.0000M;
  726. ffrInfo.Currency = 836;
  727. ffrInfo.AddingWay = 0;
  728. ffrInfo.CreateUserId = dto.UserId;
  729. ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
  730. ffrInfo.Remark = $"预付款";
  731. if (ffrInfo == null) //Add
  732. {
  733. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  734. }
  735. else //修改
  736. {
  737. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  738. .UpdateColumns(x => new
  739. {
  740. x.PriceName,
  741. x.Price,
  742. x.ItemSumPrice,
  743. x.CreateTime,
  744. x.CreateUserId
  745. })
  746. .WhereColumns(x => x.Id)
  747. .ExecuteCommandAsync();
  748. }
  749. }
  750. #endregion
  751. _sqlSugar.CommitTran();
  752. return Ok(JsonView(true, "添加成功"));
  753. }
  754. catch (Exception ex)
  755. {
  756. _sqlSugar.RollbackTran();
  757. return Ok(JsonView(false, ex.Message));
  758. }
  759. }
  760. /// <summary>
  761. /// 接团信息 操作(删除)
  762. /// </summary>
  763. /// <param name="dto"></param>
  764. /// <returns></returns>
  765. [HttpPost]
  766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  767. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  768. {
  769. try
  770. {
  771. var groupData = await _groupRepository.GroupDel(dto);
  772. if (groupData.Code != 0)
  773. {
  774. return Ok(JsonView(false, groupData.Msg));
  775. }
  776. return Ok(JsonView(true));
  777. }
  778. catch (Exception ex)
  779. {
  780. Logs("[response]" + JsonConvert.SerializeObject(dto));
  781. Logs(ex.Message);
  782. return Ok(JsonView(false, ex.Message));
  783. }
  784. }
  785. /// <summary>
  786. /// 获取团组销售报价号
  787. /// 团组添加时 使用
  788. /// </summary>
  789. /// <returns></returns>
  790. [HttpPost]
  791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  792. public async Task<IActionResult> GetGroupSalesQuoteNo()
  793. {
  794. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  795. if (groupData.Code != 0)
  796. {
  797. return Ok(JsonView(false, groupData.Msg));
  798. }
  799. object salesQuoteNo = new
  800. {
  801. SalesQuoteNo = groupData.Data
  802. };
  803. return Ok(JsonView(salesQuoteNo));
  804. }
  805. /// <summary>
  806. /// 设置确认出团
  807. /// </summary>
  808. /// <param name="dto"></param>
  809. /// <returns></returns>
  810. [HttpPost]
  811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  812. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  813. {
  814. var groupData = await _groupRepository.ConfirmationGroup(dto);
  815. if (groupData.Code != 0)
  816. {
  817. return Ok(JsonView(false, groupData.Msg));
  818. }
  819. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  820. #region OA消息推送
  821. try
  822. {
  823. string groupName = groupInfo.TeamName;
  824. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  825. List<int> userIds = new List<int>();
  826. listUser.ForEach(s => userIds.Add(s.Id));
  827. string title = $"系统通知";
  828. string content = $"团组[{groupName}]已确认出团!";
  829. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  830. }
  831. catch (Exception ex)
  832. {
  833. }
  834. #endregion
  835. #region 应用推送
  836. try
  837. {
  838. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  839. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  840. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  841. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  842. {
  843. List<string> userList = new List<string>() { users.QiyeChatUserId };
  844. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  845. }
  846. }
  847. catch (Exception ex)
  848. {
  849. }
  850. #endregion
  851. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  852. return Ok(JsonView(true, "操作成功!", groupData.Data));
  853. }
  854. /// <summary>
  855. /// 获取团组名称data And 签证国别Data
  856. /// </summary>
  857. /// <param name="dto"></param>
  858. /// <returns></returns>
  859. [HttpPost]
  860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  861. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  862. {
  863. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  864. if (groupData.Code != 0)
  865. {
  866. return Ok(JsonView(false, groupData.Msg));
  867. }
  868. return Ok(JsonView(groupData.Data));
  869. }
  870. /// <summary>
  871. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  872. /// </summary>
  873. /// <returns></returns>
  874. [HttpPost]
  875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  876. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  877. {
  878. try
  879. {
  880. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  881. if (groupData.Code != 0)
  882. {
  883. return Ok(JsonView(false, groupData.Msg));
  884. }
  885. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  886. }
  887. catch (Exception ex)
  888. {
  889. return Ok(JsonView(false, "程序错误!"));
  890. throw;
  891. }
  892. }
  893. #endregion
  894. #region 团组&签证
  895. /// <summary>
  896. /// 根据团组Id获取签证客户信息List
  897. /// </summary>
  898. /// <param name="dto">请求dto</param>
  899. /// <returns></returns>
  900. [HttpPost]
  901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  902. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  903. {
  904. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  905. if (groupData.Code != 0)
  906. {
  907. return Ok(JsonView(false, groupData.Msg));
  908. }
  909. return Ok(JsonView(groupData.Data));
  910. }
  911. /// <summary>
  912. /// IOS获取团组签证拍照上传进度01(团组列表)
  913. /// </summary>
  914. /// <param name="dto">请求dto</param>
  915. /// <returns></returns>
  916. [HttpPost]
  917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  918. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  919. {
  920. if (dto == null)
  921. {
  922. return Ok(JsonView(false, "参数为空"));
  923. }
  924. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  925. return Ok(JsonView(visaList));
  926. }
  927. /// <summary>
  928. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  929. /// </summary>
  930. /// <returns></returns>
  931. [HttpPost]
  932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  933. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  934. {
  935. if (dto == null)
  936. {
  937. return Ok(JsonView(false, "请求错误:"));
  938. }
  939. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  940. return Ok(JsonView(list));
  941. }
  942. /// <summary>
  943. /// IOS获取团组签证拍照上传进度03(相册)
  944. /// </summary>
  945. /// <returns></returns>
  946. [HttpPost]
  947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  948. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  949. {
  950. if (dto == null)
  951. {
  952. return Ok(JsonView(false, "请求错误:"));
  953. }
  954. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  955. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  956. list.ForEach(s => s.url = url);
  957. return Ok(JsonView(list));
  958. }
  959. /// <summary>
  960. /// IOS获取团组签证拍照上传进度04(图片上传)
  961. /// </summary>
  962. /// <param name="dto"></param>
  963. /// <returns></returns>
  964. [HttpPost]
  965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  966. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  967. {
  968. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  969. //if (!string.IsNullOrEmpty(result))
  970. //{
  971. //}
  972. //else {
  973. // return Ok(JsonView(false, "上传失败"));
  974. //}
  975. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  976. int sucNum = 0;
  977. try
  978. {
  979. foreach (var item in dto.base64DataList)
  980. {
  981. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  982. string result = decodeBase64ToImage(item, imageName);
  983. if (!string.IsNullOrEmpty(result))
  984. {
  985. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  986. pic.CreateUserId = dto.CreateUserId;
  987. pic.PicName = imageName;
  988. pic.PicPath = result;
  989. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  990. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  991. if (insertResult > 0)
  992. {
  993. sucNum++;
  994. }
  995. }
  996. }
  997. }
  998. catch (Exception ex)
  999. {
  1000. return Ok(JsonView(false, ex.Message));
  1001. }
  1002. string msg = string.Format(@"成功上传{0}张", sucNum);
  1003. return Ok(JsonView(true, msg));
  1004. }
  1005. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1006. {
  1007. string filename = "";//声明一个string类型的相对路径
  1008. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1009. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1010. try//会有异常抛出,try,catch一下
  1011. {
  1012. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1013. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1014. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1015. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1016. //文件名称
  1017. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1018. //上传的文件的路径
  1019. string filePath = "";
  1020. if (!Directory.Exists(fileDir))
  1021. {
  1022. Directory.CreateDirectory(fileDir);
  1023. }
  1024. //上传的文件的路径
  1025. filePath = fileDir + filename;
  1026. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1027. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1028. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1029. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1030. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1031. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1032. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1033. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1034. bitmap.Dispose();
  1035. }
  1036. catch (Exception e)
  1037. {
  1038. string massage = e.Message;
  1039. Logs("IOS图片上传Error:" + massage);
  1040. //filename = e.Message;
  1041. }
  1042. return filename;//返回相对路径
  1043. }
  1044. /// <summary>
  1045. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1046. /// </summary>
  1047. /// <param name="dto"></param>
  1048. /// <returns></returns>
  1049. [HttpPost]
  1050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1051. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1052. {
  1053. if (dto == null)
  1054. {
  1055. return Ok(JsonView(false, "请求错误:"));
  1056. }
  1057. string msg = "参数错误";
  1058. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1059. {
  1060. try
  1061. {
  1062. //_delegationVisaRep.BeginTran();
  1063. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1064. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1065. .Where(s => s.Id == dto.visaProgressCustomerId)
  1066. .ExecuteCommandAsync();
  1067. if (updCount > 0 && dto.publishCode == 1)
  1068. {
  1069. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1070. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1071. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1072. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1073. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1074. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1075. if (groupData == null)
  1076. {
  1077. _delegationVisaRep.RollbackTran();
  1078. }
  1079. string title = string.Format(@"[签证进度更新]");
  1080. string content = string.Format(@"测试文本");
  1081. bool rst = await _message.AddMsg(new MessageDto()
  1082. {
  1083. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1084. IssuerId = dto.publisher,
  1085. Title = title,
  1086. Content = content,
  1087. ReleaseTime = DateTime.Now,
  1088. UIdList = new List<int> {
  1089. 234
  1090. }
  1091. });
  1092. if (rst)
  1093. {
  1094. return Ok(JsonView(true, "发送通知成功"));
  1095. }
  1096. }
  1097. //_delegationVisaRep.CommitTran();
  1098. }
  1099. catch (Exception)
  1100. {
  1101. //_delegationVisaRep.RollbackTran();
  1102. }
  1103. }
  1104. return Ok(JsonView(true, msg));
  1105. }
  1106. #endregion
  1107. #region 团组任务分配
  1108. /// <summary>
  1109. /// 团组任务分配初始化
  1110. /// </summary>
  1111. /// <param name="dto"></param>
  1112. /// <returns></returns>
  1113. [HttpPost]
  1114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1115. public async Task<IActionResult> GetTaskAssignmen()
  1116. {
  1117. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1118. if (groupData.Code != 0)
  1119. {
  1120. return Ok(JsonView(false, groupData.Msg));
  1121. }
  1122. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1123. }
  1124. /// <summary>
  1125. /// 团组任务分配查询
  1126. /// </summary>
  1127. /// <param name="dto"></param>
  1128. /// <returns></returns>
  1129. [HttpPost]
  1130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1131. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1132. {
  1133. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1134. if (groupData.Code != 0)
  1135. {
  1136. return Ok(JsonView(false, groupData.Msg));
  1137. }
  1138. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1139. }
  1140. /// <summary>
  1141. /// 团组任务分配操作
  1142. /// </summary>
  1143. /// <param name="dto"></param>
  1144. /// <returns></returns>
  1145. [HttpPost]
  1146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1147. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1148. {
  1149. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1150. if (groupData.Code != 0)
  1151. {
  1152. return Ok(JsonView(false, groupData.Msg));
  1153. }
  1154. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1155. }
  1156. /// <summary>
  1157. /// 团组任务分配
  1158. /// 批量分配
  1159. /// 查询团组
  1160. /// </summary>
  1161. /// <param name="dto"></param>
  1162. /// <returns></returns>
  1163. [HttpPost]
  1164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1165. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1166. {
  1167. //参数验证
  1168. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1169. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1170. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1171. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1172. }
  1173. /// <summary>
  1174. /// 团组任务分配
  1175. /// 批量分配
  1176. /// </summary>
  1177. /// <param name="dto"></param>
  1178. /// <returns></returns>
  1179. [HttpPost]
  1180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1181. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1182. {
  1183. //参数验证
  1184. if (dto.UserIds.Length < 1 ) return Ok(JsonView(false, $"请选择分配人员!"));
  1185. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1186. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1187. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1188. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1189. }
  1190. #endregion
  1191. #region 团组费用审核
  1192. /// <summary>
  1193. /// 费用审核
  1194. /// 团组列表 Page
  1195. /// </summary>
  1196. /// <param name="_dto">团组列表请求dto</param>
  1197. /// <returns></returns>
  1198. [HttpPost]
  1199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1200. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1201. {
  1202. #region 参数验证
  1203. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1204. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1205. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1206. #region 页面操作权限验证
  1207. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1208. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1209. #endregion
  1210. #endregion
  1211. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1212. {
  1213. string sqlWhere = string.Empty;
  1214. if (_dto.IsSure == 0) //未完成
  1215. {
  1216. sqlWhere += string.Format(@" And IsSure = 0");
  1217. }
  1218. else if (_dto.IsSure == 1) //已完成
  1219. {
  1220. sqlWhere += string.Format(@" And IsSure = 1");
  1221. }
  1222. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1223. {
  1224. string tj = _dto.SearchCriteria;
  1225. 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}%')",
  1226. tj, tj, tj, tj, tj);
  1227. }
  1228. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1229. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1230. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1231. From (
  1232. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1233. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1234. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1235. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1236. From Grp_DelegationInfo gdi
  1237. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1238. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1239. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1240. Where gdi.IsDel = 0 {0}
  1241. ) temp ", sqlWhere);
  1242. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1243. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1244. var _view = new
  1245. {
  1246. PageFuncAuth = pageFunAuthView,
  1247. Data = _DelegationList
  1248. };
  1249. return Ok(JsonView(true, "查询成功!", _view, total));
  1250. }
  1251. else
  1252. {
  1253. return Ok(JsonView(false, "查询失败"));
  1254. }
  1255. }
  1256. /// <summary>
  1257. /// 获取团组费用审核
  1258. /// </summary>
  1259. /// <param name="paras">参数Json字符串</param>
  1260. /// <returns></returns>
  1261. [HttpPost]
  1262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1263. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1264. {
  1265. try
  1266. {
  1267. #region 参数验证
  1268. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1269. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1270. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1271. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1272. #region 页面操作权限验证
  1273. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1274. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1275. #endregion
  1276. #endregion
  1277. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1278. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1279. #region 费用清单
  1280. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1281. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1282. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1283. List<Grp_CreditCardPayment> entityList = _groupRepository
  1284. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1285. .Where(exp.ToExpression())
  1286. .ToList();
  1287. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1288. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1289. /*
  1290. * 76://酒店预订
  1291. */
  1292. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1293. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1294. .ToListAsync();
  1295. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1296. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1297. .ToListAsync();
  1298. /*
  1299. * 79://车/导游地接
  1300. */
  1301. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1302. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1303. .ToListAsync();
  1304. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1305. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1306. .ToListAsync();
  1307. /*
  1308. * 80: //签证
  1309. */
  1310. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1311. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1312. .ToListAsync();
  1313. /*
  1314. *81: //邀请/公务活动
  1315. */
  1316. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1317. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1318. .ToListAsync();
  1319. /*
  1320. * 82: //团组客户保险
  1321. */
  1322. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1323. /*
  1324. * Lable = 85 机票预订
  1325. */
  1326. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1327. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1328. .ToListAsync();
  1329. /*
  1330. * 85 机票预定
  1331. */
  1332. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1333. /*
  1334. * 98 其他款项
  1335. */
  1336. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1337. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1338. .ToListAsync();
  1339. /*
  1340. * 285:收款退还
  1341. */
  1342. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1343. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1344. .ToListAsync();
  1345. /*
  1346. * 1015: //超支费用
  1347. */
  1348. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1349. /*
  1350. * 币种信息
  1351. */
  1352. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1353. /*
  1354. * 车/导游地接 费用类型
  1355. */
  1356. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1357. /*
  1358. * 车/导游地接 费用类型
  1359. */
  1360. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1361. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1362. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1363. /*
  1364. * 用户信息
  1365. */
  1366. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1367. /*
  1368. * 费用模块
  1369. */
  1370. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1371. string priceModule = string.Empty;
  1372. if (sdPriceName != null)
  1373. {
  1374. priceModule = sdPriceName.Name;
  1375. }
  1376. /*
  1377. * 成本信息
  1378. */
  1379. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1380. decimal _groupRate = 0.0000M;
  1381. string _groupCurrencyCode = "-";
  1382. if (groupCost != null)
  1383. {
  1384. _groupRate = groupCost.Rate;
  1385. if (int.TryParse(groupCost.Currency, out int _currency))
  1386. {
  1387. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1388. }
  1389. else _groupCurrencyCode = groupCost.Currency;
  1390. }
  1391. string costContentSql = $"Select * From Grp_GroupCost";
  1392. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1393. //处理日期为空的天数
  1394. for (int i = 0; i < groupCostDetails.Count; i++)
  1395. if (i != 0)
  1396. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1397. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1398. /*
  1399. * 处理详情数据
  1400. */
  1401. foreach (var entity in entityList)
  1402. {
  1403. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1404. _detail.Id = entity.Id;
  1405. _detail.PriceName = priceModule;
  1406. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1407. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1408. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1409. /*
  1410. * 应付款金额
  1411. */
  1412. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1413. string PaymentCurrency_WaitPay = "Unknown";
  1414. string hotelCurrncyCode = "Unknown";
  1415. string hotelCurrncyName = "Unknown";
  1416. if (sdPaymentCurrency_WaitPay != null)
  1417. {
  1418. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1419. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1420. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1421. if (hotelCurrncyCode.Equals("CNY"))
  1422. {
  1423. entity.DayRate = 1.0000M;
  1424. }
  1425. }
  1426. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1427. /*
  1428. * 此次付款金额
  1429. */
  1430. decimal CurrPayStr = 0.00M,
  1431. OriginalCurrPay = 0.00M;
  1432. if (entity.PayPercentage == 0)
  1433. {
  1434. if (entity.PayThenMoney != 0)
  1435. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1436. }
  1437. else
  1438. {
  1439. if (entity.PayMoney != 0)
  1440. {
  1441. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1442. }
  1443. }
  1444. if (_dto.Label == 79)
  1445. {
  1446. string original = string.Empty;
  1447. if (hotelCurrncyCode.Equals("CNY"))
  1448. {
  1449. OriginalCurrPay = CurrPayStr;
  1450. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1451. }
  1452. else
  1453. {
  1454. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1455. //760 EUR(7600.00 CNY)
  1456. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1457. }
  1458. }
  1459. else
  1460. {
  1461. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1462. }
  1463. /*
  1464. * 剩余尾款
  1465. */
  1466. decimal BalanceStr = 0;
  1467. if (CurrPayStr != 0)
  1468. {
  1469. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1470. BalanceStr = 0;
  1471. else
  1472. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1473. }
  1474. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1475. /*
  1476. * Bus名称
  1477. */
  1478. _detail.BusName = "待增加";
  1479. /*
  1480. *费用所属
  1481. */
  1482. switch (entity.CTable)
  1483. {
  1484. case 76://酒店预订
  1485. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1486. if (hotelReservations != null)
  1487. {
  1488. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1489. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1490. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1491. string roomFeeStr = "", roomFeestr1 = "";
  1492. //是否比较房型价格
  1493. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1494. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1495. roomFeeStr += $"<br/>";
  1496. if (hotelReservations.SingleRoomPrice > 0)
  1497. {
  1498. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1499. __isSingle = true;
  1500. }
  1501. if (hotelReservations.DoubleRoomPrice > 0)
  1502. {
  1503. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1504. __isDouble = true;
  1505. }
  1506. if (hotelReservations.SuiteRoomPrice > 0)
  1507. {
  1508. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1509. __isSuite = true;
  1510. }
  1511. if (hotelReservations.OtherRoomPrice > 0)
  1512. {
  1513. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1514. __isOther = true;
  1515. }
  1516. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1517. else roomFeeStr += " 0.00 * 0";
  1518. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1519. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1520. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1521. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1522. /*
  1523. * 费用类型
  1524. * 1:房费
  1525. * 2:早餐
  1526. * 3:地税
  1527. * 4:城市税
  1528. * </summary>
  1529. */
  1530. //地税
  1531. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1532. if (governmentRentData != null)
  1533. {
  1534. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1535. governmentRentFee = governmentRentData.Price;
  1536. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1537. if (governmentRentCurrData != null)
  1538. {
  1539. governmentRentCode = governmentRentCurrData.Name;
  1540. governmentRentName = $"({governmentRentCurrData.Remark})";
  1541. }
  1542. }
  1543. //城市税
  1544. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1545. if (cityTaxData != null)
  1546. {
  1547. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1548. cityTaxFee = cityTaxData.Price;
  1549. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1550. if (cityTaxCurrData != null)
  1551. {
  1552. cityTaxCode = cityTaxCurrData.Name;
  1553. cityTaxName = $"({cityTaxCurrData.Remark})";
  1554. }
  1555. }
  1556. //酒店早餐
  1557. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1558. if (breakfastData != null)
  1559. {
  1560. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1561. breakfastFee = breakfastData.Price;
  1562. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1563. if (breakfastCurrData != null)
  1564. {
  1565. breakfastCode = breakfastCurrData.Name;
  1566. breakfastName = $"({breakfastCurrData.Remark})";
  1567. }
  1568. }
  1569. //房间费用
  1570. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1571. if (roomData != null)
  1572. {
  1573. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1574. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1575. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1576. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1577. roomFee = roomData.Price;
  1578. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1579. if (roomCurrData != null)
  1580. {
  1581. roomCode = roomCurrData.Name;
  1582. roomName = $"({roomCurrData.Remark})";
  1583. }
  1584. }
  1585. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1586. string hotelCostStr = "";
  1587. decimal hotelCsotTotal = 0.00M;
  1588. if (groupCost != null)
  1589. {
  1590. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1591. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1592. }
  1593. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1594. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1595. string hotelCost_day = "";
  1596. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1597. foreach (var item in hotelCostDetails1)
  1598. {
  1599. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1600. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1601. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1602. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1603. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1604. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1605. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1606. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1607. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1608. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1609. hotelCost_day += @$"</br>";
  1610. }
  1611. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1612. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1613. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1614. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1615. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1616. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1617. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1618. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1619. $"房间说明: {hotelReservations.Remark} <br/>" +
  1620. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1621. $"{hotelBreakfastStr}" +
  1622. $"{hotelGovernmentRentStr}" +
  1623. $"{hotelCityTaxStr}";
  1624. _detail.PriceNameContent = hotelReservations.HotelName;
  1625. }
  1626. break;
  1627. case 79://车/导游地接
  1628. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1629. if (touristGuideGroundReservations != null)
  1630. {
  1631. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1632. {
  1633. _detail.BusName = touristGuideGroundReservations.BusName;
  1634. }
  1635. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1636. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1637. //if (isInt)
  1638. //{
  1639. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1640. // if (cityInfo != null)
  1641. // {
  1642. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1643. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1644. // if (carFeeItem != null)
  1645. // {
  1646. // nameContent += $@"({carFeeItem.Name})";
  1647. // }
  1648. // _detail.PriceNameContent = nameContent;
  1649. // }
  1650. //}
  1651. //else
  1652. //{
  1653. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1654. //}
  1655. var touristGuideGroundReservationsContents =
  1656. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1657. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1658. foreach (var item in touristGuideGroundReservationsContents)
  1659. {
  1660. string typeName = "Unknown";
  1661. string carCurrencyCode = "Unknown";
  1662. string carCurrencyName = "Unknown";
  1663. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1664. if (carTypeData != null) typeName = carTypeData.Name;
  1665. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1666. if (currencyData != null)
  1667. {
  1668. carCurrencyCode = currencyData.Name;
  1669. carCurrencyName = currencyData.Remark;
  1670. }
  1671. //op、成本 币种是否一致
  1672. bool IsCurrencyAgreement = false;
  1673. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1674. string opCostStr = string.Empty;
  1675. decimal opCostTypePrice = 0.00M;
  1676. #region 处理成本各项费用
  1677. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1678. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1679. if (opCost.Count > 0)
  1680. {
  1681. switch (item.SId)
  1682. {
  1683. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1684. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1685. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1686. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1687. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1688. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1689. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1690. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1691. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1692. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1693. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1694. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1695. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1696. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1697. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1698. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1699. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1700. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1701. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1702. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1703. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1704. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1705. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1706. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1707. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1708. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1709. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1710. }
  1711. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1712. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1713. }
  1714. #endregion
  1715. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1716. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1717. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1718. $"{opTypeStr} {opCostStr}<br/>" +
  1719. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1720. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1721. }
  1722. _detail.PriceMsgContent = priceMsg;
  1723. }
  1724. break;
  1725. case 80: //签证
  1726. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1727. if (visaInfo != null)
  1728. {
  1729. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1730. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1731. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1732. }
  1733. break;
  1734. case 81: //邀请/公务活动
  1735. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1736. if (_ioa != null)
  1737. {
  1738. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1739. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1740. sendCurrName = "Unknown", //快递费用币种 Name
  1741. sendCurrCode = "Unknown", //快递费用币种 Code
  1742. eventsCurrName = "Unknown", //公务活动费币种 Name
  1743. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1744. translateCurrName = "Unknown", //公务翻译费 Name
  1745. translateCurrCode = "Unknown"; //公务翻译费 Code
  1746. #region 处理费用币种
  1747. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1748. if (inviteCurrData != null)
  1749. {
  1750. inviteCurrName = inviteCurrData.Remark;
  1751. inviteCurrCode = inviteCurrData.Name;
  1752. }
  1753. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1754. if (sendCurrData != null)
  1755. {
  1756. sendCurrName = sendCurrData.Remark;
  1757. sendCurrCode = sendCurrData.Name;
  1758. }
  1759. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1760. if (eventsCurrData != null)
  1761. {
  1762. eventsCurrName = eventsCurrData.Remark;
  1763. eventsCurrCode = eventsCurrData.Name;
  1764. }
  1765. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1766. if (translateCurrData != null)
  1767. {
  1768. translateCurrName = translateCurrData.Remark;
  1769. translateCurrCode = translateCurrData.Name;
  1770. }
  1771. #endregion
  1772. _detail.PriceNameContent = _ioa.InviterArea;
  1773. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1774. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1775. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1776. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1777. $@"备注:" + _ioa.Remark + "<br/>";
  1778. }
  1779. break;
  1780. case 82: //团组客户保险
  1781. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1782. if (customers != null)
  1783. {
  1784. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1785. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1786. }
  1787. break;
  1788. case 85: //机票预订
  1789. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1790. if (jpRes != null)
  1791. {
  1792. string FlightsDescription = jpRes.FlightsDescription;
  1793. string PriceDescription = jpRes.PriceDescription;
  1794. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1795. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1796. }
  1797. break;
  1798. case 98://其他款项
  1799. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1800. if (gdpRes != null)
  1801. {
  1802. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1803. _detail.PriceNameContent = gdpRes.PriceName;
  1804. }
  1805. break;
  1806. case 285://收款退还
  1807. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1808. if (refundAndOtherMoney != null)
  1809. {
  1810. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1811. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1812. }
  1813. break;
  1814. case 751://酒店早餐
  1815. break;
  1816. case 1015://超支费用
  1817. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1818. if (groupExtraCost != null)
  1819. {
  1820. _detail.PriceNameContent = groupExtraCost.PriceName;
  1821. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1822. }
  1823. break;
  1824. default:
  1825. break;
  1826. }
  1827. /*
  1828. * 申请人
  1829. */
  1830. string operatorName = " - ";
  1831. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1832. if (_opUser != null)
  1833. {
  1834. operatorName = _opUser.CnName;
  1835. }
  1836. _detail.OperatorName = operatorName;
  1837. /*
  1838. * 审核人
  1839. */
  1840. string auditOperatorName = "Unknown";
  1841. if (entity.AuditGMOperate == 0)
  1842. auditOperatorName = " - ";
  1843. else if (entity.AuditGMOperate == 4)
  1844. auditOperatorName = "自动审核";
  1845. else
  1846. {
  1847. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1848. if (_adUser != null)
  1849. {
  1850. auditOperatorName = _adUser.CnName;
  1851. }
  1852. }
  1853. _detail.AuditOperatorName = auditOperatorName;
  1854. /*
  1855. * 超预算比例
  1856. */
  1857. string overBudgetStr = "";
  1858. if (entity.ExceedBudget == -1)
  1859. overBudgetStr = sdPriceName.Name + "尚无预算";
  1860. else if (entity.ExceedBudget == 0)
  1861. {
  1862. if (entity.CTable == 76 || entity.CTable == 79)
  1863. {
  1864. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1865. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1866. }
  1867. else
  1868. {
  1869. overBudgetStr = "未超预算";
  1870. }
  1871. }
  1872. else
  1873. overBudgetStr = entity.ExceedBudget.ToString("P");
  1874. _detail.OverBudget = overBudgetStr;
  1875. /*
  1876. * 已审核金额
  1877. */
  1878. decimal auditFee = 0.00M;
  1879. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  1880. /*
  1881. * 费用总计
  1882. */
  1883. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1884. {
  1885. CurrencyId = entity.PaymentCurrency,
  1886. CurrencyName = PaymentCurrency_WaitPay,
  1887. AmountPayable = entity.PayMoney,
  1888. ThisPayment = OriginalCurrPay,
  1889. BalancePayment = BalanceStr,
  1890. AuditedFunds = auditFee
  1891. });
  1892. _detail.IsAuditGM = entity.IsAuditGM;
  1893. detailList.Add(_detail);
  1894. }
  1895. #endregion
  1896. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1897. /*
  1898. * 下方描述处理
  1899. */
  1900. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1901. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1902. if (ccpCurrencyPrice != null)
  1903. {
  1904. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1905. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1906. }
  1907. else
  1908. {
  1909. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1910. }
  1911. string amountPayableStr = string.Format(@"应付款总金额: ");
  1912. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1913. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1914. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1915. foreach (var item in nonDuplicat)
  1916. {
  1917. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1918. if (strs.Count > 0)
  1919. {
  1920. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1921. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1922. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1923. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  1924. //单独处理此次付款金额
  1925. if (item.CurrencyId == 836) //人民币
  1926. {
  1927. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  1928. }
  1929. else
  1930. {
  1931. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  1932. }
  1933. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  1934. //单独处理已审核费用
  1935. if (item.CurrencyId == 836) //人民币
  1936. {
  1937. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1938. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1939. }
  1940. else
  1941. {
  1942. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1943. }
  1944. }
  1945. }
  1946. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1947. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1948. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1949. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1950. var _view1 = new
  1951. {
  1952. PageFuncAuth = pageFunAuthView,
  1953. Data = _view
  1954. };
  1955. return Ok(JsonView(_view1));
  1956. }
  1957. catch (Exception ex)
  1958. {
  1959. return Ok(JsonView(false, ex.Message));
  1960. }
  1961. }
  1962. /// <summary>
  1963. /// 费用审核
  1964. /// 修改团组费用审核状态
  1965. /// </summary>
  1966. /// <param name="_dto">参数Json字符串</param>
  1967. /// <returns></returns>
  1968. [HttpPost]
  1969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1970. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1971. {
  1972. #region 参数验证
  1973. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1974. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1975. #endregion
  1976. #region 页面操作权限验证
  1977. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1978. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1979. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1980. #endregion
  1981. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1982. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1983. DateTime dtNow = DateTime.Now;
  1984. _groupRepository.BeginTran();
  1985. int rst = 0;
  1986. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1987. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1988. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1989. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1990. List<dynamic> msgDatas = new List<dynamic>();
  1991. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1992. foreach (var item in idList)
  1993. {
  1994. int CreditId = int.Parse(item);
  1995. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1996. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1997. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1998. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1999. .Where(s => s.Id == CreditId)
  2000. .ExecuteCommandAsync();
  2001. if (result < 1)
  2002. {
  2003. rst = -1;
  2004. _groupRepository.RollbackTran();
  2005. return Ok(JsonView(false, "操作失败并回滚!"));
  2006. }
  2007. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2008. if (creditData != null)
  2009. {
  2010. #region 应用通知配置
  2011. try
  2012. {
  2013. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2014. }
  2015. catch (Exception ex)
  2016. {
  2017. }
  2018. #endregion
  2019. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2020. string groupNameStr = string.Empty;
  2021. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2022. if (groupData != null) groupNameStr = groupData.TeamName;
  2023. string creditTypeStr = string.Empty;
  2024. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2025. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2026. string creditCurrency = string.Empty;
  2027. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2028. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2029. if (creditCurrency.Equals("CNY"))
  2030. {
  2031. creditData.DayRate = 1.0000M;
  2032. }
  2033. if (creditData.PayPercentage == 0.00M)
  2034. {
  2035. creditData.PayPercentage = 100M;
  2036. }
  2037. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2038. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2039. string msgContent = "";
  2040. if (creditCurrency.Equals("CNY"))
  2041. {
  2042. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2043. }
  2044. else
  2045. {
  2046. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2047. }
  2048. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2049. }
  2050. }
  2051. if (rst == 0)
  2052. {
  2053. _groupRepository.CommitTran();
  2054. foreach (var item in msgDatas)
  2055. {
  2056. //发送消息
  2057. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2058. }
  2059. #region 应用推送
  2060. try
  2061. {
  2062. foreach (var ccpId in dic_ccp_user.Keys)
  2063. {
  2064. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2065. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2066. }
  2067. }
  2068. catch (Exception)
  2069. {
  2070. }
  2071. #endregion
  2072. return Ok(JsonView(true, "操作成功!"));
  2073. }
  2074. return Ok(JsonView(false, "操作失败!"));
  2075. }
  2076. #endregion
  2077. #region 机票费用录入
  2078. /// <summary>
  2079. /// 机票录入当前登录人可操作团组
  2080. /// </summary>
  2081. /// <param name="dto"></param>
  2082. /// <returns></returns>
  2083. [HttpPost]
  2084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2085. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2086. {
  2087. try
  2088. {
  2089. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2090. if (groupData.Code != 0)
  2091. {
  2092. return Ok(JsonView(false, groupData.Msg));
  2093. }
  2094. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2095. }
  2096. catch (Exception ex)
  2097. {
  2098. return Ok(JsonView(false, "程序错误!"));
  2099. throw;
  2100. }
  2101. }
  2102. /// <summary>
  2103. /// 机票费用录入列表
  2104. /// </summary>
  2105. /// <param name="dto"></param>
  2106. /// <returns></returns>
  2107. [HttpPost]
  2108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2109. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2110. {
  2111. try
  2112. {
  2113. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2114. if (groupData.Code != 0)
  2115. {
  2116. return Ok(JsonView(false, groupData.Msg));
  2117. }
  2118. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2119. }
  2120. catch (Exception ex)
  2121. {
  2122. return Ok(JsonView(false, ex.Message));
  2123. throw;
  2124. }
  2125. }
  2126. /// <summary>
  2127. /// 根据id查询费用录入信息
  2128. /// </summary>
  2129. /// <param name="dto"></param>
  2130. /// <returns></returns>
  2131. [HttpPost]
  2132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2133. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2134. {
  2135. try
  2136. {
  2137. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2138. if (groupData.Code != 0)
  2139. {
  2140. return Ok(JsonView(false, groupData.Msg));
  2141. }
  2142. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2143. }
  2144. catch (Exception ex)
  2145. {
  2146. return Ok(JsonView(false, "程序错误!"));
  2147. throw;
  2148. }
  2149. }
  2150. /// <summary>
  2151. /// 机票费用录入操作(Status:1.新增,2.修改)
  2152. /// </summary>
  2153. /// <param name="dto"></param>
  2154. /// <returns></returns>
  2155. [HttpPost]
  2156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2157. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2158. {
  2159. try
  2160. {
  2161. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2162. if (groupData.Code != 0)
  2163. {
  2164. return Ok(JsonView(false, groupData.Msg));
  2165. }
  2166. #region 应用推送
  2167. try
  2168. {
  2169. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2170. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2171. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2172. }
  2173. catch (Exception ex)
  2174. {
  2175. }
  2176. #endregion
  2177. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2178. }
  2179. catch (Exception ex)
  2180. {
  2181. return Ok(JsonView(false, "程序错误!"));
  2182. throw;
  2183. }
  2184. }
  2185. /// <summary>
  2186. /// 根据舱位类型查询接团客户名单信息
  2187. /// </summary>
  2188. /// <param name="dto"></param>
  2189. /// <returns></returns>
  2190. [HttpPost]
  2191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2192. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2193. {
  2194. try
  2195. {
  2196. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2197. if (crm_Groups.Count != 0)
  2198. {
  2199. List<dynamic> Customer = new List<dynamic>();
  2200. foreach (var item in crm_Groups)
  2201. {
  2202. var data = new
  2203. {
  2204. Id = item.Id,
  2205. Pinyin = item.Pinyin,
  2206. Name = item.LastName + item.FirstName
  2207. };
  2208. Customer.Add(data);
  2209. }
  2210. return Ok(JsonView(true, "查询成功!", Customer));
  2211. }
  2212. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2213. }
  2214. catch (Exception ex)
  2215. {
  2216. return Ok(JsonView(false, "程序错误!"));
  2217. throw;
  2218. }
  2219. }
  2220. /// <summary>
  2221. /// 根据团号获取客户信息
  2222. /// </summary>
  2223. /// <param name="dto"></param>
  2224. /// <returns></returns>
  2225. [HttpPost]
  2226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2227. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2228. {
  2229. var jw = JsonView(false);
  2230. if (dto.DIID < 1)
  2231. {
  2232. jw.Msg += "请输入正确的diid";
  2233. return Ok(jw);
  2234. }
  2235. var arr = getSimplClientList(dto.DIID);
  2236. jw = JsonView(true, "获取成功!", arr);
  2237. return Ok(jw);
  2238. }
  2239. private List<SimplClientInfo> getSimplClientList(int diId)
  2240. {
  2241. 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);
  2242. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2243. return arr;
  2244. }
  2245. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2246. {
  2247. string result = origin;
  2248. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2249. {
  2250. string[] temparr = origin.Split(',');
  2251. string fistrStr = temparr[0];
  2252. int count = temparr.Count();
  2253. int tempId;
  2254. bool success = int.TryParse(fistrStr, out tempId);
  2255. if (success)
  2256. {
  2257. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2258. if (tempInfo != null)
  2259. {
  2260. if (count > 1)
  2261. {
  2262. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2263. }
  2264. else
  2265. {
  2266. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2267. }
  2268. }
  2269. }
  2270. }
  2271. return result;
  2272. }
  2273. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2274. {
  2275. string result = origin;
  2276. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2277. {
  2278. string[] temparr = origin.Split(',');
  2279. result = "";
  2280. foreach (var item in temparr)
  2281. {
  2282. int tempId;
  2283. bool success = int.TryParse(item, out tempId);
  2284. if (success)
  2285. {
  2286. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2287. if (tempInfo != null)
  2288. {
  2289. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2290. }
  2291. }
  2292. }
  2293. }
  2294. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2295. return result;
  2296. }
  2297. /// <summary>
  2298. /// 机票费用录入,删除
  2299. /// </summary>
  2300. /// <param name="dto"></param>
  2301. /// <returns></returns>
  2302. [HttpPost]
  2303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2304. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2305. {
  2306. try
  2307. {
  2308. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2309. if (res)
  2310. {
  2311. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2312. {
  2313. IsDel = 1,
  2314. DeleteUserId = dto.DeleteUserId,
  2315. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2316. }).ExecuteCommandAsync();
  2317. return Ok(JsonView(true, "删除成功!"));
  2318. }
  2319. return Ok(JsonView(false, "删除失败!"));
  2320. }
  2321. catch (Exception ex)
  2322. {
  2323. return Ok(JsonView(false, "程序错误!"));
  2324. throw;
  2325. }
  2326. }
  2327. /// <summary>
  2328. /// 导出机票录入报表
  2329. /// </summary>
  2330. /// <param name="dto"></param>
  2331. /// <returns></returns>
  2332. [HttpPost]
  2333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2334. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2335. {
  2336. try
  2337. {
  2338. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2339. if (groupData.Code != 0)
  2340. {
  2341. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2342. }
  2343. else
  2344. {
  2345. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2346. if (AirTicketReservations.Count != 0)
  2347. {
  2348. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2349. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2350. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2351. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2352. WorkbookDesigner designer = new WorkbookDesigner();
  2353. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2354. decimal countCost = 0;
  2355. foreach (var item in AirTicketReservations)
  2356. {
  2357. #region 处理客人姓名
  2358. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2359. item.ClientName = clientNames;
  2360. #endregion
  2361. if (item.BankType == "其他")
  2362. {
  2363. item.BankNo = "--";
  2364. }
  2365. else
  2366. {
  2367. if (!string.IsNullOrEmpty(item.BankType))
  2368. {
  2369. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2370. }
  2371. }
  2372. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2373. item.Price = System.Decimal.Round(item.Price, 2);
  2374. countCost += Convert.ToDecimal(item.Price);
  2375. }
  2376. designer.SetDataSource("Export", AirTicketReservations);
  2377. designer.SetDataSource("ExportDiCode", diCode);
  2378. designer.SetDataSource("ExportDiName", diName);
  2379. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2380. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2381. designer.Process();
  2382. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2383. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2384. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2385. return Ok(JsonView(true, "成功", url = rst));
  2386. }
  2387. else
  2388. {
  2389. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2390. }
  2391. }
  2392. }
  2393. catch (Exception ex)
  2394. {
  2395. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2396. throw;
  2397. }
  2398. }
  2399. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2400. /// <summary>
  2401. /// 行程单导出
  2402. /// </summary>
  2403. /// <param name="dto"></param>
  2404. /// <returns></returns>
  2405. [HttpPost]
  2406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2407. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2408. {
  2409. try
  2410. {
  2411. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2412. if (groupData.Code != 0)
  2413. {
  2414. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2415. }
  2416. else
  2417. {
  2418. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2419. if (dto.Language == "CN")
  2420. {
  2421. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2422. DocumentBuilder builder = new DocumentBuilder(doc);
  2423. int tableIndex = 0;//表格索引
  2424. //得到文档中的第一个表格
  2425. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2426. foreach (var item in _AirTicketReservations)
  2427. {
  2428. #region 处理固定数据
  2429. string[] FlightsCode = item.FlightsCode.Split('/');
  2430. if (FlightsCode.Length != 0)
  2431. {
  2432. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2433. if (_AirCompany != null)
  2434. {
  2435. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2436. }
  2437. else
  2438. {
  2439. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2440. }
  2441. }
  2442. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2443. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2444. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2445. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2446. string name = "";
  2447. foreach (string clientName in nameArray)
  2448. {
  2449. if (!name.Contains(clientName))
  2450. {
  2451. name += clientName + ",";
  2452. }
  2453. }
  2454. if (!string.IsNullOrWhiteSpace(name))
  2455. {
  2456. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2457. }
  2458. else
  2459. {
  2460. table.Range.Bookmarks["ClientName"].Text = "--";
  2461. }
  2462. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2463. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2464. table.Range.Bookmarks["JointTicket"].Text = "--";
  2465. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2466. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2467. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2468. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2469. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2470. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2471. #endregion
  2472. #region 循环数据处理
  2473. List<AirInfo> airs = new List<AirInfo>();
  2474. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2475. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2476. for (int i = 0; i < FlightsCode.Length; i++)
  2477. {
  2478. AirInfo air = new AirInfo();
  2479. string[] tempstr = DayArray[i]
  2480. .Replace("\r\n", string.Empty)
  2481. .Replace("\\r\\n", string.Empty)
  2482. .TrimStart().TrimEnd()
  2483. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2484. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2485. string starCity = "";
  2486. if (star_Three != null)
  2487. {
  2488. starCity = star_Three.AirPort;
  2489. }
  2490. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2491. string EndCity = "";
  2492. if (End_Three != null)
  2493. {
  2494. EndCity = End_Three.AirPort;
  2495. }
  2496. air.Destination = starCity + "/" + EndCity;
  2497. air.Flight = FlightsCode[i];
  2498. air.SeatingClass = item.CTypeName;
  2499. string dateTime = tempstr[2];
  2500. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2501. air.FlightDate = DateTemp;
  2502. air.DepartureTime = tempstr[5];
  2503. air.LandingTime = tempstr[6];
  2504. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2505. air.TicketStatus = "--";
  2506. air.Luggage = "--";
  2507. air.DepartureTerminal = "--";
  2508. air.LandingTerminal = "--";
  2509. airs.Add(air);
  2510. }
  2511. int row = 13;
  2512. for (int i = 0; i < airs.Count; i++)
  2513. {
  2514. if (airs.Count > 2)
  2515. {
  2516. for (int j = 0; j < airs.Count - 2; j++)
  2517. {
  2518. var CopyRow = table.Rows[12].Clone(true);
  2519. table.Rows.Add(CopyRow);
  2520. }
  2521. }
  2522. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2523. int index = 0;
  2524. foreach (PropertyInfo property in properties)
  2525. {
  2526. string value = property.GetValue(airs[i]).ToString();
  2527. Cell ishcel0 = table.Rows[row].Cells[index];
  2528. Paragraph p = new Paragraph(doc);
  2529. string s = value;
  2530. p.AppendChild(new Run(doc, s));
  2531. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2532. ishcel0.AppendChild(p);
  2533. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2534. index++;
  2535. }
  2536. row++;
  2537. }
  2538. #endregion
  2539. Paragraph lastParagraph = new Paragraph(doc);
  2540. //第一个表格末尾加段落
  2541. table.ParentNode.InsertAfter(lastParagraph, table);
  2542. //复制第一个表格
  2543. Table cloneTable = (Table)table.Clone(true);
  2544. //在文档末尾段落后面加入复制的表格
  2545. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2546. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2547. {
  2548. int rownewsIndex = 13;
  2549. for (int i = 0; i < 2; i++)
  2550. {
  2551. var CopyRow = table.Rows[12].Clone(true);
  2552. table.Rows.RemoveAt(13);
  2553. table.Rows.Add(CopyRow);
  2554. rownewsIndex++;
  2555. }
  2556. }
  2557. else
  2558. {
  2559. table.Rows.RemoveAt(12);
  2560. }
  2561. cloneTable.Rows.RemoveAt(12);
  2562. }
  2563. if (_AirTicketReservations.Count != 0)
  2564. {
  2565. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2566. if (FlightsCode.Length != 0)
  2567. {
  2568. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2569. if (_AirCompany != null)
  2570. {
  2571. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2572. }
  2573. else
  2574. {
  2575. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2576. }
  2577. }
  2578. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2579. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2580. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2581. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2582. string name = "";
  2583. foreach (string clientName in nameArray)
  2584. {
  2585. if (!name.Contains(clientName))
  2586. {
  2587. name += clientName + ",";
  2588. }
  2589. }
  2590. if (!string.IsNullOrWhiteSpace(name))
  2591. {
  2592. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2593. }
  2594. else
  2595. {
  2596. table.Range.Bookmarks["ClientName"].Text = "--";
  2597. }
  2598. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2599. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2600. table.Range.Bookmarks["JointTicket"].Text = "--";
  2601. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2602. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2603. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2604. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2605. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2606. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2607. }
  2608. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2609. //保存合并后的文档
  2610. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2611. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2612. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2613. return Ok(JsonView(true, "成功!", rst));
  2614. }
  2615. else
  2616. {
  2617. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2618. DocumentBuilder builder = new DocumentBuilder(doc);
  2619. int tableIndex = 0;//表格索引
  2620. //得到文档中的第一个表格
  2621. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2622. List<string> texts = new List<string>();
  2623. foreach (var item in _AirTicketReservations)
  2624. {
  2625. string[] FlightsCode = item.FlightsCode.Split('/');
  2626. if (FlightsCode.Length != 0)
  2627. {
  2628. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2629. if (_AirCompany != null)
  2630. {
  2631. if (!transDic.ContainsKey(_AirCompany.CnName))
  2632. {
  2633. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2634. }
  2635. }
  2636. else
  2637. {
  2638. if (!transDic.ContainsKey("--"))
  2639. {
  2640. transDic.Add("--", "--");
  2641. }
  2642. }
  2643. }
  2644. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2645. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2646. string name = "";
  2647. foreach (string clientName in nameArray)
  2648. {
  2649. name += clientName + ",";
  2650. }
  2651. if (!texts.Contains(name))
  2652. {
  2653. texts.Add(name);
  2654. }
  2655. List<AirInfo> airs = new List<AirInfo>();
  2656. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2657. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2658. for (int i = 0; i < FlightsCode.Length; i++)
  2659. {
  2660. AirInfo air = new AirInfo();
  2661. string[] tempstr = DayArray[i]
  2662. .Replace("\r\n", string.Empty)
  2663. .Replace("\\r\\n", string.Empty)
  2664. .TrimStart().TrimEnd()
  2665. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2666. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2667. if (star_Three != null)
  2668. {
  2669. if (!transDic.ContainsKey(star_Three.AirPort))
  2670. {
  2671. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2672. }
  2673. }
  2674. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2675. if (End_Three != null)
  2676. {
  2677. if (!transDic.ContainsKey(End_Three.AirPort))
  2678. {
  2679. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2680. }
  2681. }
  2682. if (!texts.Contains(item.CTypeName))
  2683. {
  2684. texts.Add(item.CTypeName);
  2685. }
  2686. }
  2687. }
  2688. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2689. if (transData.Count > 0)
  2690. {
  2691. foreach (TranslateResult item in transData)
  2692. {
  2693. if (!transDic.ContainsKey(item.Query))
  2694. {
  2695. transDic.Add(item.Query, item.Translation);
  2696. }
  2697. }
  2698. }
  2699. foreach (var item in _AirTicketReservations)
  2700. {
  2701. #region 处理固定数据
  2702. string[] FlightsCode = item.FlightsCode.Split('/');
  2703. if (FlightsCode.Length != 0)
  2704. {
  2705. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2706. if (_AirCompany != null)
  2707. {
  2708. string str = "--";
  2709. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2710. if (!string.IsNullOrEmpty(translateResult))
  2711. {
  2712. str = translateResult;
  2713. str = _airTicketResRep.Processing(str);
  2714. }
  2715. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2716. }
  2717. else
  2718. {
  2719. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2720. }
  2721. }
  2722. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2723. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2724. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2725. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2726. string names = "";
  2727. foreach (string clientName in nameArray)
  2728. {
  2729. names += clientName + ",";
  2730. }
  2731. if (!string.IsNullOrWhiteSpace(names))
  2732. {
  2733. string str = "--";
  2734. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2735. if (!string.IsNullOrEmpty(translateResult))
  2736. {
  2737. str = translateResult;
  2738. str = _airTicketResRep.Processing(str);
  2739. }
  2740. table.Range.Bookmarks["ClientName"].Text = str;
  2741. }
  2742. else
  2743. {
  2744. table.Range.Bookmarks["ClientName"].Text = "--";
  2745. }
  2746. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2747. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2748. table.Range.Bookmarks["JointTicket"].Text = "--";
  2749. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2750. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2751. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2752. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2753. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2754. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2755. #endregion
  2756. #region 循环数据处理
  2757. List<AirInfo> airs = new List<AirInfo>();
  2758. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2759. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2760. for (int i = 0; i < FlightsCode.Length; i++)
  2761. {
  2762. AirInfo air = new AirInfo();
  2763. string[] tempstr = DayArray[i]
  2764. .Replace("\r\n", string.Empty)
  2765. .Replace("\\r\\n", string.Empty)
  2766. .TrimStart().TrimEnd()
  2767. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2768. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2769. string starCity = "";
  2770. if (star_Three != null)
  2771. {
  2772. string str2 = "--";
  2773. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2774. if (!string.IsNullOrEmpty(translateResult2))
  2775. {
  2776. str2 = translateResult2;
  2777. str2 = _airTicketResRep.Processing(str2);
  2778. }
  2779. starCity = str2;
  2780. }
  2781. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2782. string EndCity = "";
  2783. if (End_Three != null)
  2784. {
  2785. string str1 = "--";
  2786. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2787. if (!string.IsNullOrEmpty(translateResult1))
  2788. {
  2789. str1 = translateResult1;
  2790. str1 = _airTicketResRep.Processing(str1);
  2791. }
  2792. EndCity = str1;
  2793. }
  2794. air.Destination = starCity + "/" + EndCity;
  2795. air.Flight = FlightsCode[i];
  2796. string str = "--";
  2797. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2798. if (!string.IsNullOrEmpty(translateResult))
  2799. {
  2800. str = translateResult;
  2801. str = _airTicketResRep.Processing(str);
  2802. }
  2803. air.SeatingClass = str;
  2804. string dateTime = tempstr[2];
  2805. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2806. air.FlightDate = DateTemp;
  2807. air.DepartureTime = tempstr[5];
  2808. air.LandingTime = tempstr[6];
  2809. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2810. air.TicketStatus = "--";
  2811. air.Luggage = "--";
  2812. air.DepartureTerminal = "--";
  2813. air.LandingTerminal = "--";
  2814. airs.Add(air);
  2815. }
  2816. int row = 13;
  2817. for (int i = 0; i < airs.Count; i++)
  2818. {
  2819. if (airs.Count > 2)
  2820. {
  2821. for (int j = 0; j < airs.Count - 2; j++)
  2822. {
  2823. var CopyRow = table.Rows[12].Clone(true);
  2824. table.Rows.Add(CopyRow);
  2825. }
  2826. }
  2827. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2828. int index = 0;
  2829. foreach (PropertyInfo property in properties)
  2830. {
  2831. string value = property.GetValue(airs[i]).ToString();
  2832. Cell ishcel0 = table.Rows[row].Cells[index];
  2833. Paragraph p = new Paragraph(doc);
  2834. string s = value;
  2835. p.AppendChild(new Run(doc, s));
  2836. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2837. ishcel0.AppendChild(p);
  2838. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2839. //ishcel0.CellFormat.VerticalAlignment=
  2840. index++;
  2841. }
  2842. row++;
  2843. }
  2844. #endregion
  2845. Paragraph lastParagraph = new Paragraph(doc);
  2846. //第一个表格末尾加段落
  2847. table.ParentNode.InsertAfter(lastParagraph, table);
  2848. //复制第一个表格
  2849. Table cloneTable = (Table)table.Clone(true);
  2850. //在文档末尾段落后面加入复制的表格
  2851. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2852. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2853. {
  2854. int rownewsIndex = 13;
  2855. for (int i = 0; i < 2; i++)
  2856. {
  2857. var CopyRow = table.Rows[12].Clone(true);
  2858. table.Rows.RemoveAt(13);
  2859. table.Rows.Add(CopyRow);
  2860. rownewsIndex++;
  2861. }
  2862. }
  2863. else
  2864. {
  2865. table.Rows.RemoveAt(12);
  2866. }
  2867. cloneTable.Rows.RemoveAt(12);
  2868. }
  2869. if (_AirTicketReservations.Count != 0)
  2870. {
  2871. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2872. if (FlightsCode.Length != 0)
  2873. {
  2874. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2875. if (_AirCompany != null)
  2876. {
  2877. string str = "--";
  2878. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2879. if (!string.IsNullOrEmpty(translateResult))
  2880. {
  2881. str = translateResult;
  2882. str = _airTicketResRep.Processing(str);
  2883. }
  2884. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2885. }
  2886. else
  2887. {
  2888. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2889. }
  2890. }
  2891. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2892. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2893. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2894. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2895. string names = "";
  2896. foreach (string clientName in nameArray)
  2897. {
  2898. names += clientName + ",";
  2899. }
  2900. if (!string.IsNullOrWhiteSpace(names))
  2901. {
  2902. string str = "--";
  2903. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2904. if (!string.IsNullOrEmpty(translateResult))
  2905. {
  2906. str = translateResult;
  2907. str = _airTicketResRep.Processing(str);
  2908. }
  2909. table.Range.Bookmarks["ClientName"].Text = str;
  2910. }
  2911. else
  2912. {
  2913. table.Range.Bookmarks["ClientName"].Text = "--";
  2914. }
  2915. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2916. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2917. table.Range.Bookmarks["JointTicket"].Text = "--";
  2918. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2919. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2920. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2921. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2922. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2923. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2924. }
  2925. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2926. //保存合并后的文档
  2927. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2928. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2929. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2930. return Ok(JsonView(true, "成功!", rst));
  2931. }
  2932. }
  2933. }
  2934. catch (Exception ex)
  2935. {
  2936. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2937. throw;
  2938. }
  2939. }
  2940. #endregion
  2941. #region 团组增减款项 --> 其他款项
  2942. /// <summary>
  2943. /// 团组增减款项下拉框绑定
  2944. /// </summary>
  2945. /// <param name="dto"></param>
  2946. /// <returns></returns>
  2947. [HttpPost]
  2948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2949. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2950. {
  2951. #region 参数验证
  2952. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2953. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2954. #endregion
  2955. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2956. }
  2957. /// <summary>
  2958. /// 根据团组Id查询团组增减款项
  2959. /// </summary>
  2960. /// <param name="dto"></param>
  2961. /// <returns></returns>
  2962. [HttpPost]
  2963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2964. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2965. {
  2966. #region 参数验证
  2967. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2968. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2969. #endregion
  2970. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2971. }
  2972. /// <summary>
  2973. /// 团组增减款项操作(Status:1.新增,2.修改)
  2974. /// </summary>
  2975. /// <param name="dto"></param>
  2976. /// <returns></returns>
  2977. [HttpPost]
  2978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2979. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2980. {
  2981. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2982. if (groupData.Code != 200)
  2983. {
  2984. return Ok(JsonView(false, groupData.Msg));
  2985. }
  2986. #region 应用推送
  2987. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2988. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2989. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2990. #endregion
  2991. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2992. }
  2993. /// <summary>
  2994. /// 团组增减款项操作 删除
  2995. /// </summary>
  2996. /// <param name="dto"></param>
  2997. /// <returns></returns>
  2998. [HttpPost]
  2999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3000. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3001. {
  3002. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3003. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3004. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3005. if (res.Code == 0)
  3006. {
  3007. return Ok(JsonView(true, "删除成功!"));
  3008. }
  3009. return Ok(JsonView(false, "删除失败!"));
  3010. }
  3011. /// <summary>
  3012. /// 根据团组增减款项Id查询
  3013. /// </summary>
  3014. /// <param name="dto"></param>
  3015. /// <returns></returns>
  3016. [HttpPost]
  3017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3018. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3019. {
  3020. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3021. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3022. }
  3023. /// <summary>
  3024. /// 查询供应商名称
  3025. /// </summary>
  3026. /// <param name="dto"></param>
  3027. /// <returns></returns>
  3028. [HttpPost]
  3029. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3030. {
  3031. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3032. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3033. ?? new List<Grp_DecreasePayments>();
  3034. dbResult = dbResult.Distinct(new
  3035. ProductComparer()).ToList();
  3036. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3037. {
  3038. x.Id,
  3039. x.SupplierAddress,
  3040. x.SupplierArea,
  3041. x.SupplierContact,
  3042. x.SupplierContactNumber,
  3043. x.SupplierEmail,
  3044. x.SupplierName,
  3045. x.SupplierSocialAccount,
  3046. x.SupplierTypeId,
  3047. }).ToList());
  3048. return Ok(jw);
  3049. }
  3050. #endregion
  3051. #region 文件上传、删除
  3052. /// <summary>
  3053. /// region 文件上传 可以带参数
  3054. /// </summary>
  3055. /// <param name="file"></param>
  3056. /// <returns></returns>
  3057. [HttpPost]
  3058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3059. public async Task<IActionResult> UploadProject(IFormFile file)
  3060. {
  3061. //var TypeName = Request.Headers["TypeName"].ToString();
  3062. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3063. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3064. ////文件名称
  3065. //string projectFileName = file.FileName;
  3066. ////上传的文件的路径
  3067. //string filePath = $"{fileDir}/{projectFileName}";
  3068. //if (TypeName == "A")//A代表团组增减款项
  3069. //{
  3070. // filePath = fileDir + $@"\团组增减款项相关文件";
  3071. // if (!Directory.Exists(filePath))
  3072. // {
  3073. // Directory.CreateDirectory(filePath);
  3074. // }
  3075. // //上传的文件的路径
  3076. // filePath += $@"\{projectFileName}";
  3077. //}
  3078. //else if (TypeName == "B")//B代表商邀相关文件
  3079. //{
  3080. // //上传的文件的路径
  3081. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3082. // if (!Directory.Exists(filePath))
  3083. // {
  3084. // Directory.CreateDirectory(filePath);
  3085. // }
  3086. // //上传的文件的路径
  3087. // filePath = $@"\{projectFileName}";
  3088. //}
  3089. //try
  3090. //{
  3091. // using (FileStream fs = System.IO.File.Create(filePath))
  3092. // {
  3093. // file.CopyTo(fs);
  3094. // fs.Flush();
  3095. // }
  3096. //}
  3097. //catch (Exception ex)
  3098. //{
  3099. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3100. //}
  3101. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3102. try
  3103. {
  3104. var TypeName = Request.Headers["TypeName"].ToString();
  3105. if (file != null)
  3106. {
  3107. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3108. //文件名称
  3109. string projectFileName = file.FileName;
  3110. //上传的文件的路径
  3111. string filePath = $"{fileDir}/{projectFileName}";
  3112. if (TypeName == "A")//A代表团组增减款项
  3113. {
  3114. if (!Directory.Exists(fileDir))
  3115. {
  3116. Directory.CreateDirectory(fileDir);
  3117. }
  3118. //上传的文件的路径
  3119. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3120. }
  3121. else if (TypeName == "B")//B代表商邀相关文件
  3122. {
  3123. if (!Directory.Exists(fileDir))
  3124. {
  3125. Directory.CreateDirectory(fileDir);
  3126. }
  3127. //上传的文件的路径
  3128. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3129. }
  3130. using (FileStream fs = System.IO.File.Create(filePath))
  3131. {
  3132. file.CopyTo(fs);
  3133. fs.Flush();
  3134. }
  3135. return Ok(JsonView(true, "上传成功!", projectFileName));
  3136. }
  3137. else
  3138. {
  3139. return Ok(JsonView(false, "上传失败!"));
  3140. }
  3141. }
  3142. catch (Exception ex)
  3143. {
  3144. return Ok(JsonView(false, "程序错误!"));
  3145. }
  3146. }
  3147. /// <summary>
  3148. /// 删除指定文件
  3149. /// </summary>
  3150. /// <param name="dto"></param>
  3151. /// <returns></returns>
  3152. [HttpPost]
  3153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3154. public async Task<IActionResult> DelFile(DelFileDto dto)
  3155. {
  3156. try
  3157. {
  3158. var TypeName = Request.Headers["TypeName"].ToString();
  3159. string filePath = "";
  3160. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3161. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3162. int id = 0;
  3163. if (TypeName == "A")
  3164. {
  3165. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3166. // 删除该文件
  3167. System.IO.File.Delete(filePath);
  3168. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  3169. }
  3170. else if (TypeName == "B")
  3171. {
  3172. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3173. // 删除该文件
  3174. System.IO.File.Delete(filePath);
  3175. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  3176. }
  3177. if (id != 0)
  3178. {
  3179. return Ok(JsonView(true, "成功!"));
  3180. }
  3181. else
  3182. {
  3183. return Ok(JsonView(false, "失败!"));
  3184. }
  3185. }
  3186. catch (Exception ex)
  3187. {
  3188. return Ok(JsonView(false, "程序错误!"));
  3189. throw;
  3190. }
  3191. }
  3192. #endregion
  3193. #region 商邀费用录入
  3194. /// <summary>
  3195. /// 根据团组Id查询商邀费用列表
  3196. /// </summary>
  3197. /// <param name="dto"></param>
  3198. /// <returns></returns>
  3199. [HttpPost]
  3200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3201. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3202. {
  3203. try
  3204. {
  3205. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3206. if (groupData.Code != 0)
  3207. {
  3208. return Ok(JsonView(false, groupData.Msg));
  3209. }
  3210. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3211. }
  3212. catch (Exception ex)
  3213. {
  3214. return Ok(JsonView(false, "程序错误!"));
  3215. throw;
  3216. }
  3217. }
  3218. //
  3219. /// <summary>
  3220. /// 商邀费用 Info Page 基础数据源
  3221. /// </summary>
  3222. /// <param name="dto"></param>
  3223. /// <returns></returns>
  3224. [HttpPost]
  3225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3226. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3227. {
  3228. try
  3229. {
  3230. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3231. if (groupData.Code != 0)
  3232. {
  3233. return Ok(JsonView(false, groupData.Msg));
  3234. }
  3235. return Ok(JsonView(true, "操作成功", groupData.Data));
  3236. }
  3237. catch (Exception ex)
  3238. {
  3239. return Ok(JsonView(false, ex.Message));
  3240. throw;
  3241. }
  3242. }
  3243. /// <summary>
  3244. /// 根据商邀费用ID查询C表和商邀费用数据
  3245. /// </summary>
  3246. /// <param name="dto"></param>
  3247. /// <returns></returns>
  3248. [HttpPost]
  3249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3250. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3251. {
  3252. try
  3253. {
  3254. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3255. if (groupData.Code != 0)
  3256. {
  3257. return Ok(JsonView(false, groupData.Msg));
  3258. }
  3259. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3260. }
  3261. catch (Exception ex)
  3262. {
  3263. return Ok(JsonView(false, ex.Message));
  3264. throw;
  3265. }
  3266. }
  3267. /// <summary>
  3268. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3269. /// </summary>
  3270. /// <param name="dto"></param>
  3271. /// <returns></returns>
  3272. [HttpPost]
  3273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3274. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3275. {
  3276. try
  3277. {
  3278. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3279. if (groupData.Code != 0)
  3280. {
  3281. return Ok(JsonView(false, groupData.Msg));
  3282. }
  3283. #region 应用推送
  3284. try
  3285. {
  3286. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3287. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3288. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3289. }
  3290. catch (Exception ex)
  3291. {
  3292. }
  3293. #endregion
  3294. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3295. }
  3296. catch (Exception ex)
  3297. {
  3298. return Ok(JsonView(false, "程序错误!"));
  3299. throw;
  3300. }
  3301. }
  3302. /// <summary>
  3303. /// 商邀删除
  3304. /// </summary>
  3305. /// <param name="dto"></param>
  3306. /// <returns></returns>
  3307. [HttpPost]
  3308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3309. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3310. {
  3311. try
  3312. {
  3313. _sqlSugar.BeginTran();
  3314. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3315. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3316. {
  3317. IsDel = 1,
  3318. DeleteUserId = dto.DeleteUserId,
  3319. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3320. })
  3321. .Where(it => it.Id == dto.Id)
  3322. .ExecuteCommand();
  3323. if (res1 > 0)
  3324. {
  3325. int _diId = 0;
  3326. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3327. if (_ioaInfo != null)
  3328. {
  3329. _diId = _ioaInfo.DiId;
  3330. }
  3331. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3332. .SetColumns(a => new Grp_CreditCardPayment()
  3333. {
  3334. IsDel = 1,
  3335. DeleteUserId = dto.DeleteUserId,
  3336. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3337. })
  3338. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3339. .ExecuteCommand();
  3340. if (res2 > 0)
  3341. {
  3342. _sqlSugar.CommitTran();
  3343. return Ok(JsonView(true, "删除成功!"));
  3344. }
  3345. }
  3346. _sqlSugar.RollbackTran();
  3347. return Ok(JsonView(false, "删除失败"));
  3348. }
  3349. catch (Exception ex)
  3350. {
  3351. _sqlSugar.RollbackTran();
  3352. return Ok(JsonView(false, ex.Message));
  3353. }
  3354. }
  3355. /// <summary>
  3356. /// 团组模块文件上传
  3357. /// </summary>
  3358. /// <param name="dto"></param>
  3359. /// <returns></returns>
  3360. [HttpPost]
  3361. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3362. {
  3363. var jw = JsonView(false);
  3364. long M = 1024 * 1024;
  3365. if (dto.Files == null || dto.Files.Count == 0)
  3366. {
  3367. jw.Msg = "无文件信息!";
  3368. return Ok(jw);
  3369. }
  3370. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3371. {
  3372. jw.Msg = "文件大小超过20M!";
  3373. return Ok(jw);
  3374. }
  3375. //var nameSp = dto.File.FileName.Split(".");
  3376. //if (nameSp.Length < 2)
  3377. //{
  3378. // jw.Msg = "拓展名称有误!";
  3379. // return Ok(jw);
  3380. //}
  3381. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3382. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3383. //{
  3384. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3385. // return Ok(jw);
  3386. //}
  3387. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3388. if (Ctable == null)
  3389. {
  3390. jw.Msg = "Ctable指向有误!";
  3391. return Ok(jw);
  3392. }
  3393. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3394. if (groupInfo == null)
  3395. {
  3396. jw.Msg = "团组信息不存在!";
  3397. return Ok(jw);
  3398. }
  3399. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3400. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3401. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3402. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3403. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3404. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3405. try
  3406. {
  3407. if (!Directory.Exists(fileBase))
  3408. {
  3409. Directory.CreateDirectory(fileBase);
  3410. }
  3411. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3412. foreach (var fileStream in dto.Files)
  3413. {
  3414. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3415. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3416. {
  3417. Cid = dto.Cid,
  3418. CreateTime = DateTime.Now,
  3419. CreateUserId = dto.Userid,
  3420. Ctable = dto.Ctable,
  3421. Diid = dto.Diid,
  3422. IsDel = 0,
  3423. FilePath = saveFilePath,
  3424. FileName = fileStream.FileName
  3425. };
  3426. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3427. {
  3428. fileStream.CopyTo(fs);
  3429. fs.Flush();
  3430. }
  3431. saveArr.Add(file);
  3432. }
  3433. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3434. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3435. jw = JsonView(true, "保存成功!", new
  3436. {
  3437. count = addResult,
  3438. filesName = saveArr.Select(x => x.FileName)
  3439. }) ;
  3440. }
  3441. catch (Exception ex)
  3442. {
  3443. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3444. {
  3445. count = 0,
  3446. filesName = new string[0],
  3447. }) ;
  3448. }
  3449. return Ok(jw);
  3450. }
  3451. /// <summary>
  3452. /// 查询各模块已保存文件
  3453. /// </summary>
  3454. /// <param name="dto"></param>
  3455. /// <returns></returns>
  3456. [HttpPost]
  3457. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3458. {
  3459. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3460. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3461. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3462. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3463. {
  3464. expression = Expressionable.Create<Grp_GroupModelFile>()
  3465. .And(x=>visaIds.Contains(x.CreateUserId));
  3466. }
  3467. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3468. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3469. .Where(expression.ToExpression())
  3470. .ToList();
  3471. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3472. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3473. {
  3474. x.FileName,
  3475. x.Id,
  3476. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3477. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3478. })));
  3479. }
  3480. /// <summary>
  3481. /// 下载该团组下的所有文件
  3482. /// </summary>
  3483. /// <param name="dto"></param>
  3484. /// <returns></returns>
  3485. [HttpPost]
  3486. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3487. {
  3488. var jw = JsonView(false);
  3489. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3490. if (groupInfo == null)
  3491. {
  3492. jw.Msg = "团组信息不存在!";
  3493. return Ok(jw);
  3494. }
  3495. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3496. var isModule = Convert.ToBoolean(dto.isModule);
  3497. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3498. IOOperatorHelper io = new IOOperatorHelper();
  3499. if (isModule)
  3500. {
  3501. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3502. foreach (var moduleArr in moduleGroup)
  3503. {
  3504. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3505. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3506. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3507. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3508. foreach (var item in moduleArr)
  3509. {
  3510. if (System.IO.File.Exists(item.FilePath))
  3511. {
  3512. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3513. {
  3514. byte[] bytes = new byte[fileStream.Length];
  3515. fileStream.Read(bytes, 0, bytes.Length);
  3516. fileStream.Close();
  3517. Stream stream = new MemoryStream(bytes);
  3518. chiZips.Add(item.FileName, stream);
  3519. }
  3520. }
  3521. }
  3522. if (chiZips.Count > 0)
  3523. {
  3524. var byts = io.ConvertZipStream(chiZips);
  3525. Stream stream = new MemoryStream(byts);
  3526. Zips.Add(key.Name+"_.zip", stream);
  3527. }
  3528. }
  3529. }
  3530. else
  3531. {
  3532. foreach (var item in dbQuery)
  3533. {
  3534. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3535. {
  3536. byte[] bytes = new byte[fileStream.Length];
  3537. fileStream.Read(bytes, 0, bytes.Length);
  3538. fileStream.Close();
  3539. Stream stream = new MemoryStream(bytes);
  3540. while (Zips.Keys.Contains(item.FileName))
  3541. {
  3542. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3543. }
  3544. Zips.Add(item.FileName, stream);
  3545. }
  3546. }
  3547. }
  3548. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3549. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3550. if (Zips.Count > 0)
  3551. {
  3552. var byts = io.ConvertZipStream(Zips);
  3553. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3554. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3555. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3556. }
  3557. else
  3558. {
  3559. jw.Msg = "暂无生成文件!";
  3560. }
  3561. return Ok(jw);
  3562. }
  3563. /// <summary>
  3564. /// 下载该团组下此模块的所有文件
  3565. /// </summary>
  3566. /// <param name="dto"></param>
  3567. /// <returns></returns>
  3568. [HttpPost]
  3569. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3570. {
  3571. var jw = JsonView(false);
  3572. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3573. if (groupInfo == null)
  3574. {
  3575. jw.Msg = "团组信息不存在!";
  3576. return Ok(jw);
  3577. }
  3578. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3579. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3580. && x.IsDel == 0);
  3581. if (key == null)
  3582. {
  3583. jw.Msg = "Ctable指向错误!";
  3584. return Ok(jw);
  3585. }
  3586. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3587. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3588. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3589. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3590. IOOperatorHelper io = new IOOperatorHelper();
  3591. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3592. foreach (var item in dbQuery)
  3593. {
  3594. if (System.IO.File.Exists(item.FilePath))
  3595. {
  3596. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3597. {
  3598. byte[] bytes = new byte[fileStream.Length];
  3599. fileStream.Read(bytes, 0, bytes.Length);
  3600. fileStream.Close();
  3601. Stream stream = new MemoryStream(bytes);
  3602. while (Zips.Keys.Contains(item.FileName))
  3603. {
  3604. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3605. }
  3606. Zips.Add(item.FileName, stream);
  3607. }
  3608. }
  3609. }
  3610. if (Zips.Count > 0)
  3611. {
  3612. var byts = io.ConvertZipStream(Zips);
  3613. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3614. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3615. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3616. }
  3617. else
  3618. {
  3619. jw.Msg = "暂无生成文件!";
  3620. }
  3621. return Ok(jw);
  3622. }
  3623. /// <summary>
  3624. /// 删除该团组下的指定文件
  3625. /// </summary>
  3626. /// <param name="dto"></param>
  3627. /// <returns></returns>
  3628. [HttpPost]
  3629. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3630. {
  3631. var jw = JsonView(false);
  3632. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3633. if (sing == null)
  3634. {
  3635. jw.Msg = "暂无";
  3636. return Ok(jw);
  3637. }
  3638. if (System.IO.File.Exists(sing.FilePath))
  3639. {
  3640. try
  3641. {
  3642. System.IO.File.Delete(sing.FilePath);
  3643. }
  3644. catch (Exception ex)
  3645. {
  3646. jw.Msg = "删除失败!" + ex.Message;
  3647. return Ok(jw);
  3648. }
  3649. }
  3650. sing.IsDel = 1;
  3651. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3652. sing.DeleteUserId = dto.UserId;
  3653. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3654. jw = JsonView(true, "删除成功!");
  3655. return Ok(jw);
  3656. }
  3657. #endregion
  3658. #region 团组英文资料
  3659. /// <summary>
  3660. /// 查询团组英文所有资料
  3661. /// </summary>
  3662. /// <param name="dto"></param>
  3663. /// <returns></returns>
  3664. [HttpPost]
  3665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3666. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3667. {
  3668. try
  3669. {
  3670. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3671. if (groupData.Code != 0)
  3672. {
  3673. return Ok(JsonView(false, groupData.Msg));
  3674. }
  3675. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3676. }
  3677. catch (Exception ex)
  3678. {
  3679. return Ok(JsonView(false, "程序错误!"));
  3680. throw;
  3681. }
  3682. }
  3683. /// <summary>
  3684. /// 团组英文资料操作(Status:1.新增,2.修改)
  3685. /// </summary>
  3686. /// <param name="dto"></param>
  3687. /// <returns></returns>
  3688. [HttpPost]
  3689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3690. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3691. {
  3692. try
  3693. {
  3694. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3695. if (groupData.Code != 0)
  3696. {
  3697. return Ok(JsonView(false, groupData.Msg));
  3698. }
  3699. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3700. }
  3701. catch (Exception ex)
  3702. {
  3703. return Ok(JsonView(false, "程序错误!"));
  3704. throw;
  3705. }
  3706. }
  3707. /// <summary>
  3708. /// 团组英文资料Id查询数据
  3709. /// </summary>
  3710. /// <param name="dto"></param>
  3711. /// <returns></returns>
  3712. [HttpPost]
  3713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3714. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3715. {
  3716. try
  3717. {
  3718. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3719. if (_DelegationEnData != null)
  3720. {
  3721. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3722. }
  3723. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3724. }
  3725. catch (Exception ex)
  3726. {
  3727. return Ok(JsonView(false, "程序错误!"));
  3728. throw;
  3729. }
  3730. }
  3731. /// <summary>
  3732. /// 团组英文资料删除
  3733. /// </summary>
  3734. /// <param name="dto"></param>
  3735. /// <returns></returns>
  3736. [HttpPost]
  3737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3738. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3739. {
  3740. try
  3741. {
  3742. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3743. if (!res)
  3744. {
  3745. return Ok(JsonView(false, "删除失败"));
  3746. }
  3747. return Ok(JsonView(true, "删除成功!"));
  3748. }
  3749. catch (Exception ex)
  3750. {
  3751. return Ok(JsonView(false, "程序错误!"));
  3752. throw;
  3753. }
  3754. }
  3755. #endregion
  3756. #region 导出邀请函
  3757. /// <summary>
  3758. /// 导出邀请函页面初始化
  3759. /// </summary>
  3760. /// <param name="dto"></param>
  3761. /// <returns></returns>
  3762. [HttpPost]
  3763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3764. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3765. {
  3766. try
  3767. {
  3768. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3769. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3770. if (dto.DiId == 0)
  3771. {
  3772. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3773. }
  3774. else
  3775. {
  3776. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3777. }
  3778. return Ok(JsonView(true, "查询成功!", new
  3779. {
  3780. deleClient = crm_Deles,
  3781. delegations = grp_Delegations
  3782. }));
  3783. }
  3784. catch (Exception ex)
  3785. {
  3786. return Ok(JsonView(false, "程序错误!"));
  3787. throw;
  3788. }
  3789. }
  3790. /// <summary>
  3791. /// 导出邀请函
  3792. /// </summary>
  3793. /// <param name="dto"></param>
  3794. /// <returns></returns>
  3795. [HttpPost]
  3796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3797. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3798. {
  3799. #region 参数验证
  3800. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3801. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3802. #endregion
  3803. try
  3804. {
  3805. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3806. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3807. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3808. From Grp_TourClientList tcl
  3809. Left Join
  3810. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3811. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3812. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3813. From Crm_DeleClient dc
  3814. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3815. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3816. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3817. Where dc.IsDel = 0) temp
  3818. On temp.DcId =tcl.ClientId
  3819. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3820. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3821. List<string> texts = new List<string>();
  3822. if (datas.Count != 0)
  3823. {
  3824. foreach (TourClientListDetailsView item in datas)
  3825. {
  3826. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3827. {
  3828. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3829. }
  3830. else
  3831. {
  3832. string name = item.LastName + item.FirstName;
  3833. texts.Add(name);
  3834. }
  3835. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3836. {
  3837. if (!transDic.ContainsKey(item.Job))
  3838. {
  3839. texts.Add(item.Job);
  3840. }
  3841. }
  3842. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3843. {
  3844. texts.Add(item.CompanyFullName);
  3845. }
  3846. }
  3847. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3848. if (transData.Count > 0)
  3849. {
  3850. foreach (TranslateResult item in transData)
  3851. {
  3852. if (!transDic.ContainsKey(item.Query))
  3853. {
  3854. transDic.Add(item.Query, item.Translation);
  3855. }
  3856. }
  3857. }
  3858. List<GuestList> list = new List<GuestList>();
  3859. foreach (TourClientListDetailsView dele in datas)
  3860. {
  3861. GuestList guestList = new GuestList();
  3862. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3863. {
  3864. guestList.Name = dele.Pinyin;
  3865. }
  3866. else
  3867. {
  3868. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3869. guestList.Name = Name;
  3870. }
  3871. if (dele.Sex == 0)
  3872. {
  3873. guestList.Sex = "Male";
  3874. }
  3875. else if (dele.Sex == 1)
  3876. {
  3877. guestList.Sex = "Female";
  3878. }
  3879. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3880. if (!string.IsNullOrEmpty(dele.Job))
  3881. {
  3882. guestList.Job = dele.Job;
  3883. }
  3884. list.Add(guestList);
  3885. }
  3886. //载入模板
  3887. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3888. DocumentBuilder builder = new DocumentBuilder(doc);
  3889. //获取word里所有表格
  3890. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3891. //获取所填表格的序数
  3892. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3893. var rowStart = tableOne.Rows[0]; //获取第1行
  3894. //循环赋值
  3895. for (int i = 0; i < list.Count; i++)
  3896. {
  3897. builder.MoveToCell(0, i + 1, 0, 0);
  3898. builder.Write(list[i].Name.ToString());
  3899. builder.MoveToCell(0, i + 1, 1, 0);
  3900. builder.Write(list[i].Sex.ToString());
  3901. builder.MoveToCell(0, i + 1, 2, 0);
  3902. builder.Write(list[i].DOB.ToString());
  3903. builder.MoveToCell(0, i + 1, 3, 0);
  3904. builder.Write(list[i].Job.ToString());
  3905. }
  3906. //删除多余行
  3907. while (tableOne.Rows.Count > list.Count + 1)
  3908. {
  3909. tableOne.Rows.RemoveAt(list.Count + 1);
  3910. }
  3911. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3912. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3913. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3914. doc.Save(filePath);
  3915. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3916. return Ok(JsonView(true, "操作成功!", Url));
  3917. }
  3918. else
  3919. {
  3920. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3921. }
  3922. }
  3923. catch (Exception ex)
  3924. {
  3925. return Ok(JsonView(false, ex.Message));
  3926. throw;
  3927. }
  3928. }
  3929. #endregion
  3930. #region 团组经理模块 出入境费用
  3931. ///// <summary>
  3932. ///// 团组模块 - 出入境费用
  3933. ///// </summary>
  3934. ///// <returns></returns>
  3935. //[HttpPost]
  3936. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3937. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3938. //{
  3939. // try
  3940. // {
  3941. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3942. // if (data.Code != 0)
  3943. // {
  3944. // return Ok(JsonView(false, data.Msg));
  3945. // }
  3946. // return Ok(JsonView(true, "查询成功!"));
  3947. // }
  3948. // catch (Exception ex)
  3949. // {
  3950. // return Ok(JsonView(false, ex.Message));
  3951. // throw;
  3952. // }
  3953. //}
  3954. /// <summary>
  3955. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3956. /// </summary>
  3957. /// <returns></returns>
  3958. [HttpPost]
  3959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3960. public async Task<IActionResult> SetDayAndCostAreaChange()
  3961. {
  3962. try
  3963. {
  3964. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3965. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3966. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3967. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3968. foreach (var item in unite) //处理交集数据
  3969. {
  3970. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3971. }
  3972. foreach (var item in merge) //处理差集数据
  3973. {
  3974. int nationalTravelFeeId = 0;
  3975. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3976. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3977. else
  3978. {
  3979. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3980. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3981. }
  3982. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3983. }
  3984. //只更新dayAndCost 的 nationalTravelFeeId;
  3985. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3986. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3987. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3988. }
  3989. catch (Exception ex)
  3990. {
  3991. return Ok(JsonView(false, ex.Message));
  3992. throw;
  3993. }
  3994. }
  3995. /// <summary>
  3996. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3997. /// </summary>
  3998. /// <returns></returns>
  3999. [HttpPost]
  4000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4001. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4002. {
  4003. try
  4004. {
  4005. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4006. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4007. //SetDataInfoView
  4008. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4009. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4010. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4011. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4012. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4013. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4014. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4015. //默认币种显示
  4016. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4017. {
  4018. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4019. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4020. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4021. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4022. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4023. };
  4024. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4025. if (_currencyRate.Count > 0)
  4026. {
  4027. foreach (var item in _currencyInfos)
  4028. {
  4029. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4030. if (rateInfo != null)
  4031. {
  4032. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4033. rate1 *= 1.035M;
  4034. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4035. }
  4036. }
  4037. }
  4038. return Ok(JsonView(true, "查询成功!", new
  4039. {
  4040. GroupNameData = groupNameData.Data,
  4041. CurrencyData = _CurrencyData,
  4042. WordTypeData = _WordTypeData,
  4043. ExcelTypeData = _ExcelTypeData,
  4044. CurrencyInit = _currencyInfos
  4045. }));
  4046. }
  4047. catch (Exception ex)
  4048. {
  4049. return Ok(JsonView(false, ex.Message));
  4050. throw;
  4051. }
  4052. }
  4053. /// <summary>
  4054. /// 团组模块 - 出入境费用
  4055. /// 实时汇率 tips
  4056. /// 签证费用 tips
  4057. /// </summary>
  4058. /// <returns></returns>
  4059. [HttpPost]
  4060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4061. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4062. {
  4063. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4064. //默认币种显示
  4065. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4066. {
  4067. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4068. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4069. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4070. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4071. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4072. };
  4073. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4074. List<dynamic> reteInfos = new List<dynamic>();
  4075. if (_currencyRate.Count > 0)
  4076. {
  4077. foreach (var item in _currencyInfos)
  4078. {
  4079. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4080. if (rateInfo != null)
  4081. {
  4082. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4083. decimal rate1 = item.Rate;
  4084. rate1 *= 1.03M;
  4085. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4086. reteInfos.Add(new
  4087. {
  4088. currCode = item.CurrencyCode,
  4089. currName = item.CurrencyName,
  4090. rate = rate2,
  4091. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4092. });
  4093. }
  4094. }
  4095. }
  4096. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4097. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4098. return Ok(JsonView(true, "查询成功!", new
  4099. {
  4100. //GroupNameData = groupNameData.Data,
  4101. visaData = visaData.Data,
  4102. airData = airData.Data,
  4103. reteInfos = reteInfos
  4104. }));
  4105. }
  4106. /// <summary>
  4107. /// 团组模块 - 出入境费用 - Info
  4108. /// </summary>
  4109. /// <returns></returns>
  4110. [HttpPost]
  4111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4112. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4113. {
  4114. try
  4115. {
  4116. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4117. if (data.Code != 0)
  4118. {
  4119. return Ok(JsonView(false, data.Msg));
  4120. }
  4121. return Ok(JsonView(true, "查询成功!", data.Data));
  4122. }
  4123. catch (Exception ex)
  4124. {
  4125. return Ok(JsonView(false, ex.Message));
  4126. }
  4127. }
  4128. /// <summary>
  4129. /// 团组模块 - 出入境费用 - Add And Update
  4130. /// </summary>
  4131. /// <returns></returns>
  4132. [HttpPost]
  4133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4134. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4135. {
  4136. try
  4137. {
  4138. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4139. if (data.Code != 0)
  4140. {
  4141. return Ok(JsonView(false, data.Msg));
  4142. }
  4143. //生成默认文件pdf并且通知人员
  4144. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4145. {
  4146. DiId = dto.DiId,
  4147. ExportType = 1,
  4148. SubTypeId = 1005
  4149. }, "pdf");
  4150. //发送通知
  4151. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4152. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4153. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4154. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  4155. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  4156. return Ok(JsonView(true, data.Msg, data.Data));
  4157. }
  4158. catch (Exception ex)
  4159. {
  4160. return Ok(JsonView(false, ex.Message));
  4161. }
  4162. }
  4163. /// <summary>
  4164. /// 团组模块 - 出入境费用 - Confirm 费用
  4165. /// </summary>
  4166. /// <returns></returns>
  4167. [HttpPost]
  4168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4169. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4170. {
  4171. //TODO:测试完毕需把对应的用户ID更改
  4172. //1、数据表添加字段
  4173. //2、更改字段接口()
  4174. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4175. //3、确认成功 给财务发送消息
  4176. if (_view.Code == 200)
  4177. {
  4178. if (dto.Type == 1)
  4179. {
  4180. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4181. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4182. }
  4183. }
  4184. return Ok(_view);
  4185. }
  4186. /// <summary>
  4187. /// 团组模块 - 出入境费用 - File downlaod
  4188. /// </summary>
  4189. /// <param name="dto"></param>
  4190. /// <returns></returns>
  4191. [HttpPost]
  4192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4193. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4194. {
  4195. try
  4196. {
  4197. if (dto.DiId < 1)
  4198. {
  4199. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4200. }
  4201. if (dto.ExportType < 1)
  4202. {
  4203. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4204. }
  4205. if (dto.SubTypeId < 1)
  4206. {
  4207. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4208. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4209. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4210. 3 团组成员名单 1 团组成员名单"));
  4211. }
  4212. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4213. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4214. if (_EnterExitCosts == null)
  4215. {
  4216. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4217. }
  4218. //数据源
  4219. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4220. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4221. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4222. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4223. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4224. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4225. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4226. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4227. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4228. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4229. .Select((tcl, dc, cc) => new
  4230. {
  4231. Name = dc.LastName + dc.FirstName,
  4232. Sex = dc.Sex,
  4233. Birthday = dc.BirthDay,
  4234. Company = cc.CompanyFullName,
  4235. Job = dc.Job
  4236. })
  4237. .ToList();
  4238. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4239. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4240. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4241. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4242. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4243. if (dto.ExportType == 1) //明细表
  4244. {
  4245. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4246. {
  4247. //获取模板
  4248. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4249. //载入模板
  4250. Document doc = new Document(tempPath);
  4251. DocumentBuilder builder = new DocumentBuilder(doc);
  4252. //利用键值对存放数据
  4253. Dictionary<string, string> dic = new Dictionary<string, string>();
  4254. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4255. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4256. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4257. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4258. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4259. //境内费用(其他费用)
  4260. if (_EnterExitCosts.ChoiceOne == 1)
  4261. {
  4262. string row1_1 = "";
  4263. if (_EnterExitCosts.Visa > 0)
  4264. {
  4265. //insidePayTotal += _EnterExitCosts.Visa;
  4266. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4267. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4268. {
  4269. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4270. }
  4271. }
  4272. string row1_2 = "";
  4273. if (_EnterExitCosts.YiMiao > 0)
  4274. {
  4275. //insidePayTotal += _EnterExitCosts.YiMiao;
  4276. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4277. }
  4278. if (_EnterExitCosts.HeSuan > 0)
  4279. {
  4280. //insidePayTotal += _EnterExitCosts.HeSuan;
  4281. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4282. }
  4283. if (_EnterExitCosts.Service > 0)
  4284. {
  4285. //insidePayTotal += _EnterExitCosts.Service;
  4286. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4287. }
  4288. string row1_3 = "";
  4289. if (_EnterExitCosts.Safe > 0)
  4290. {
  4291. //insidePayTotal += _EnterExitCosts.Safe;
  4292. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4293. }
  4294. if (_EnterExitCosts.Ticket > 0)
  4295. {
  4296. //insidePayTotal += _EnterExitCosts.Ticket;
  4297. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4298. }
  4299. string row1 = "";
  4300. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4301. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4302. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4303. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4304. dic.Add("Row1Str", row1);
  4305. }
  4306. string airTotalStr = string.Empty,
  4307. airPriceStr = string.Empty;
  4308. //经济舱
  4309. if (_EnterExitCosts.SumJJC == 1)
  4310. {
  4311. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4312. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4313. }
  4314. //公务舱
  4315. if (_EnterExitCosts.SumGWC == 1)
  4316. {
  4317. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4318. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4319. }
  4320. //头等舱
  4321. if (_EnterExitCosts.SumTDC == 1)
  4322. {
  4323. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4324. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4325. }
  4326. dic.Add("AirTotalStr", airTotalStr);
  4327. dic.Add("AirPriceStr", airPriceStr);
  4328. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4329. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4330. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4331. int table1Row = 0,
  4332. table2Row = 0,
  4333. table3Row = 0,
  4334. table4Row = 0;
  4335. //住宿费
  4336. if (_EnterExitCosts.ChoiceThree == 1)
  4337. {
  4338. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4339. table1Row = dac1.Count;
  4340. #region 填充word表格内容
  4341. for (int i = 0; i < dac1.Count; i++)
  4342. {
  4343. Grp_DayAndCost dac = dac1[i];
  4344. if (dac == null) continue;
  4345. builder.MoveToCell(0, i, 0, 0);
  4346. builder.Write("第" + dac.Days.ToString() + "晚:");
  4347. builder.MoveToCell(0, i, 1, 0);
  4348. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4349. //builder.Write(dac.Place == null ? "" : dac.Place);
  4350. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4351. builder.MoveToCell(0, i, 2, 0);
  4352. builder.Write("费用标准:");
  4353. string curr = "";
  4354. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4355. if (currData != null)
  4356. {
  4357. curr = currData.Name;
  4358. }
  4359. builder.MoveToCell(0, i, 3, 0);
  4360. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4361. builder.MoveToCell(0, i, 4, 0);
  4362. builder.Write("费用小计:");
  4363. builder.MoveToCell(0, i, 5, 0);
  4364. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4365. }
  4366. #endregion
  4367. }else dic.Add("SubZS","0.00");
  4368. //删除多余行
  4369. while (table1.Rows.Count > table1Row)
  4370. {
  4371. table1.Rows.RemoveAt(table1Row);
  4372. }
  4373. //伙食费
  4374. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4375. if (_EnterExitCosts.ChoiceFour == 1)
  4376. {
  4377. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4378. table2Row = dac2.Count;
  4379. #region 填充word表格内容
  4380. for (int i = 0; i < dac2.Count; i++)
  4381. {
  4382. Grp_DayAndCost dac = dac2[i];
  4383. if (dac == null) continue;
  4384. builder.MoveToCell(1, i, 0, 0);
  4385. builder.Write("第" + dac.Days.ToString() + "天:");
  4386. builder.MoveToCell(1, i, 1, 0);
  4387. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4388. builder.MoveToCell(1, i, 2, 0);
  4389. builder.Write("费用标准:");
  4390. string curr = "";
  4391. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4392. if (currData != null)
  4393. {
  4394. curr = currData.Name;
  4395. }
  4396. builder.MoveToCell(1, i, 3, 0);
  4397. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4398. builder.MoveToCell(1, i, 4, 0);
  4399. builder.Write("费用小计:");
  4400. builder.MoveToCell(1, i, 5, 0);
  4401. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4402. }
  4403. #endregion
  4404. }else dic.Add("SubHS","0.00");
  4405. //删除多余行
  4406. while (table2.Rows.Count > table2Row)
  4407. {
  4408. table2.Rows.RemoveAt(table2Row);
  4409. }
  4410. //公杂费
  4411. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4412. if (_EnterExitCosts.ChoiceFive == 1)
  4413. {
  4414. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4415. table3Row = dac3.Count;
  4416. #region 填充word表格内容
  4417. for (int i = 0; i < dac3.Count; i++)
  4418. {
  4419. Grp_DayAndCost dac = dac3[i];
  4420. if (dac == null) continue;
  4421. builder.MoveToCell(2, i, 0, 0);
  4422. builder.Write("第" + dac.Days.ToString() + "天:");
  4423. builder.MoveToCell(2, i, 1, 0);
  4424. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4425. builder.MoveToCell(2, i, 2, 0);
  4426. builder.Write("费用标准:");
  4427. string curr = "";
  4428. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4429. if (currData != null)
  4430. {
  4431. curr = currData.Name;
  4432. }
  4433. builder.MoveToCell(2, i, 3, 0);
  4434. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4435. builder.MoveToCell(2, i, 4, 0);
  4436. builder.Write("费用小计:");
  4437. builder.MoveToCell(2, i, 5, 0);
  4438. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4439. }
  4440. //删除多余行
  4441. while (table3.Rows.Count > table3Row)
  4442. {
  4443. table3.Rows.RemoveAt(table3Row);
  4444. }
  4445. #endregion
  4446. }else dic.Add("SubGZF", "0.00");
  4447. //删除多余行
  4448. while (table3.Rows.Count > table3Row)
  4449. {
  4450. table3.Rows.RemoveAt(table3Row);
  4451. }
  4452. //培训费
  4453. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4454. if (_EnterExitCosts.ChoiceSix == 1)
  4455. {
  4456. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4457. dic.Add("SubPX", pxStr);
  4458. table4Row = dac4.Count;
  4459. #region 填充word表格内容
  4460. for (int i = 0; i < dac4.Count; i++)
  4461. {
  4462. Grp_DayAndCost dac = dac4[i];
  4463. if (dac == null) continue;
  4464. builder.MoveToCell(3, i, 0, 0);
  4465. builder.Write("第" + dac.Days.ToString() + "天:");
  4466. builder.MoveToCell(3, i, 1, 0);
  4467. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4468. builder.MoveToCell(3, i, 2, 0);
  4469. builder.Write("费用标准:");
  4470. string curr = "";
  4471. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4472. if (currData != null)
  4473. {
  4474. curr = currData.Name;
  4475. }
  4476. builder.MoveToCell(3, i, 3, 0);
  4477. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4478. builder.MoveToCell(3, i, 4, 0);
  4479. builder.Write("费用小计:");
  4480. builder.MoveToCell(3, i, 5, 0);
  4481. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4482. }
  4483. #endregion
  4484. }
  4485. //else dic.Add("SubPX","0.00");
  4486. //删除多余行
  4487. while (table4.Rows.Count > table4Row)
  4488. {
  4489. table4.Rows.RemoveAt(table4Row);
  4490. }
  4491. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4492. decimal subJJC = 0.00M,
  4493. subGWC = 0.00M,
  4494. subTDC = 0.00M;
  4495. //经济舱
  4496. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4497. //公务舱
  4498. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4499. //头等舱
  4500. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4501. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4502. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4503. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4504. #region 填充word模板书签内容
  4505. foreach (var key in dic.Keys)
  4506. {
  4507. builder.MoveToBookmark(key);
  4508. builder.Write(dic[key]);
  4509. }
  4510. #endregion
  4511. //文件名
  4512. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4513. AsposeHelper.removewatermark_v2180();
  4514. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4515. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4516. return Ok(JsonView(true, "成功", new { Url = url }));
  4517. }
  4518. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4519. {
  4520. //获取模板
  4521. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4522. //载入模板
  4523. Document doc = new Document(tempPath);
  4524. DocumentBuilder builder = new DocumentBuilder(doc);
  4525. Dictionary<string, string> dic = new Dictionary<string, string>();
  4526. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4527. {
  4528. List<string> list = new List<string>();
  4529. try
  4530. {
  4531. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4532. foreach (var item in spilitArr)
  4533. {
  4534. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4535. var depCode = spDotandEmpty[2].Substring(0, 3);
  4536. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4537. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4538. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4539. list.Add(depName);
  4540. list.Add(arrName);
  4541. }
  4542. list = list.Distinct().ToList();
  4543. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4544. }
  4545. catch (Exception)
  4546. {
  4547. dic.Add("ReturnCode", "行程录入不正确!");
  4548. }
  4549. }
  4550. else
  4551. {
  4552. dic.Add("ReturnCode", "未录入行程!");
  4553. }
  4554. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4555. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4556. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4557. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4558. {
  4559. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4560. dic.Add("Day", sp.Days.ToString());
  4561. }
  4562. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4563. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4564. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4565. //dic.Add("Names", Names);
  4566. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4567. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4568. decimal dac1totalPrice = 0.00M;
  4569. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4570. foreach (var dac in dac1)
  4571. {
  4572. if (dac.SubTotal == 0.00M)
  4573. {
  4574. continue;
  4575. }
  4576. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4577. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4578. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4579. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4580. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4581. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4582. builder.Write(currency);//币种
  4583. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4584. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4585. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4586. builder.Write("");//人数
  4587. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4588. builder.Write("");//天数
  4589. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4590. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4591. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4592. decimal rate = 0.00M;
  4593. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4594. builder.Write(rate.ToString("#0.0000"));//汇率
  4595. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4596. decimal rbmPrice = dac.SubTotal;
  4597. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4598. accommodationStartIndex++;
  4599. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4600. }
  4601. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4602. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4603. {
  4604. table1.Rows.RemoveAt(i - 1);
  4605. foodandotherStartIndex--;
  4606. }
  4607. if (dac2.Count == dac3.Count)//国家 币种 金额
  4608. {
  4609. for (int i = 0; i < dac2.Count; i++)
  4610. {
  4611. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4612. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4613. }
  4614. }
  4615. decimal dac2totalPrice = 0.00M;
  4616. foreach (var dac in dac2)
  4617. {
  4618. if (dac.SubTotal == 0)
  4619. {
  4620. continue;
  4621. }
  4622. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4623. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4624. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4625. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4626. builder.Write(currency);//币种
  4627. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4628. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4629. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4630. builder.Write("");//人数
  4631. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4632. builder.Write("");//天数
  4633. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4634. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4635. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4636. decimal rate = 0.00M;
  4637. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4638. builder.Write(rate.ToString("#0.0000"));//汇率
  4639. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4640. decimal rbmPrice = dac.SubTotal;
  4641. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4642. foodandotherStartIndex++;
  4643. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4644. }
  4645. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4646. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4647. {
  4648. table1.Rows.RemoveAt(i - 1);
  4649. }
  4650. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4651. string otherFeeStr = "";
  4652. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4653. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4654. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4655. if (otherFeeStr.Length > 0)
  4656. {
  4657. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4658. otherFeeStr = $"({otherFeeStr})";
  4659. dic.Add("OtherFeeStr", otherFeeStr);
  4660. }
  4661. //总计
  4662. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4663. //国际旅费
  4664. string outsideAir = string.Empty;
  4665. string allPriceAir = string.Empty;
  4666. if (_EnterExitCosts.SumJJC == 1)
  4667. {
  4668. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4669. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4670. }
  4671. if (_EnterExitCosts.SumGWC == 1)
  4672. {
  4673. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4674. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4675. }
  4676. if (_EnterExitCosts.SumTDC == 1)
  4677. {
  4678. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4679. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4680. }
  4681. dic.Add("InTravelPrice", $"({outsideAir})");
  4682. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4683. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4684. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4685. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4686. foreach (var key in dic.Keys)
  4687. {
  4688. builder.MoveToBookmark(key);
  4689. builder.Write(dic[key]);
  4690. }
  4691. //模板文件名
  4692. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4693. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4694. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4695. return Ok(JsonView(true, "成功", new { Url = url }));
  4696. }
  4697. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4698. {
  4699. //获取模板
  4700. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4701. //载入模板
  4702. WorkbookDesigner designer = new WorkbookDesigner();
  4703. designer.Workbook = new Workbook(tempPath);
  4704. Dictionary<string, string> dic = new Dictionary<string, string>();
  4705. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4706. {
  4707. List<string> list = new List<string>();
  4708. try
  4709. {
  4710. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4711. foreach (var item in spilitArr)
  4712. {
  4713. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4714. var depCode = spDotandEmpty[2].Substring(0, 3);
  4715. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4716. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4717. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4718. list.Add(depName);
  4719. list.Add(arrName);
  4720. }
  4721. list = list.Distinct().ToList();
  4722. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4723. }
  4724. catch (Exception)
  4725. {
  4726. dic.Add("ReturnCode", "行程录入不正确!");
  4727. }
  4728. }
  4729. else
  4730. {
  4731. dic.Add("ReturnCode", "未录入行程!");
  4732. }
  4733. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4734. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4735. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4736. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4737. {
  4738. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4739. dic.Add("Day", sp.Days.ToString());
  4740. }
  4741. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4742. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4743. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4744. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4745. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4746. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4747. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4748. designer.SetDataSource("Name", Names);
  4749. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4750. designer.SetDataSource("Day", dic["Day"] + "天");
  4751. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4752. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4753. int startIndex = 10;
  4754. const int startIndexcopy = 10;
  4755. if (dac2.Count == dac3.Count)//国家 币种 金额
  4756. {
  4757. for (int i = 0; i < dac2.Count; i++)
  4758. {
  4759. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4760. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4761. }
  4762. }
  4763. DataTable dtdac1 = new DataTable();
  4764. List<string> place = new List<string>();
  4765. dtdac1.Columns.AddRange(new DataColumn[] {
  4766. new DataColumn(){ ColumnName = "city"},
  4767. new DataColumn(){ ColumnName = "curr"},
  4768. new DataColumn(){ ColumnName = "criterion"},
  4769. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4770. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4771. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4772. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4773. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4774. });
  4775. DataTable dtdac2 = new DataTable();
  4776. dtdac2.Columns.AddRange(new DataColumn[] {
  4777. new DataColumn(){ ColumnName = "city"},
  4778. new DataColumn(){ ColumnName = "curr"},
  4779. new DataColumn(){ ColumnName = "criterion"},
  4780. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4781. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4782. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4783. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4784. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4785. });
  4786. dtdac1.TableName = "tb1";
  4787. dtdac2.TableName = "tb2";
  4788. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4789. foreach (var item in dac1)
  4790. {
  4791. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4792. if (place.Contains(item.Place))
  4793. {
  4794. continue;
  4795. }
  4796. DataRow row = dtdac1.NewRow();
  4797. row["city"] = item.Place;
  4798. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4799. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4800. row["curr"] = currency;
  4801. row["rate"] = rate.ToString("#0.0000");
  4802. row["criterion"] = item.Cost.ToString("#0.00");
  4803. row["number"] = 1;
  4804. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4805. //row["costRMB"] = rbmPrice;
  4806. dtdac1.Rows.Add(row);
  4807. place.Add(item.Place);
  4808. }
  4809. place = new List<string>();
  4810. foreach (var item in dac2)
  4811. {
  4812. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4813. if (place.Contains(item.Place))
  4814. {
  4815. continue;
  4816. }
  4817. DataRow row = dtdac2.NewRow();
  4818. row["city"] = item.Place;
  4819. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4820. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4821. row["curr"] = currency;
  4822. row["rate"] = rate.ToString("#0.0000");
  4823. row["criterion"] = item.Cost.ToString("#0.00");
  4824. row["number"] = 1;
  4825. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4826. //row["cost"] = item.SubTotal;
  4827. //row["costRMB"] = rbmPrice;
  4828. dtdac2.Rows.Add(row);
  4829. place.Add(item.Place);
  4830. //dac2totalPrice += rbmPrice;
  4831. }
  4832. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4833. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4834. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4835. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4836. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4837. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4838. string cell4Str1 = string.Empty;
  4839. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4840. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4841. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4842. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4843. string cellStr = $" 5.其他费用(";
  4844. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4845. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4846. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4847. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4848. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4849. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4850. if (cellStr.Length > 8)
  4851. {
  4852. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4853. }
  4854. cellStr += ")";
  4855. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4856. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4857. decimal pxFee = dac4.Sum(it => it.Cost);
  4858. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4859. string celllastStr1 = "";
  4860. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4861. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4862. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4863. celllastStr1 += $",国际旅费 元";
  4864. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4865. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4866. designer.SetDataSource("cell4Str", cell4Str);
  4867. designer.SetDataSource("cellStr", cellStr);
  4868. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4869. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4870. designer.SetDataSource("celllastStr", celllastStr);
  4871. Workbook wb = designer.Workbook;
  4872. var sheet = wb.Worksheets[0];
  4873. //绑定datatable数据集
  4874. designer.SetDataSource(dtdac1);
  4875. designer.SetDataSource(dtdac2);
  4876. designer.Process();
  4877. var rowStart = dtdac1.Rows.Count;
  4878. while (rowStart > 0)
  4879. {
  4880. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4881. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4882. startIndex++;
  4883. rowStart--;
  4884. }
  4885. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4886. startIndex += 1; //总计行
  4887. rowStart = dtdac2.Rows.Count;
  4888. while (rowStart > 0)
  4889. {
  4890. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4891. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4892. startIndex++;
  4893. rowStart--;
  4894. }
  4895. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4896. wb.CalculateFormula(true);
  4897. //模板文件名
  4898. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4899. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4900. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4901. return Ok(JsonView(true, "成功", new { Url = url }));
  4902. }
  4903. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4904. {
  4905. //获取模板
  4906. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4907. //载入模板
  4908. Document doc = new Document(tempPath);
  4909. DocumentBuilder builder = new DocumentBuilder(doc);
  4910. Dictionary<string, string> dic = new Dictionary<string, string>();
  4911. dic.Add("GroupName", _DelegationInfo.TeamName);
  4912. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4913. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4914. string missionLeaderJob = "";//负责人job
  4915. int groupNumber = 0; //团人数
  4916. if (DeleClientList.Count > 0)
  4917. {
  4918. missionLeader = DeleClientList[0]?.Name ?? "";
  4919. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4920. }
  4921. dic.Add("MissionLeader", missionLeader); //团负责人
  4922. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4923. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4924. #region MyRegion
  4925. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4926. //{
  4927. // List<string> list = new List<string>();
  4928. // try
  4929. // {
  4930. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4931. // foreach (var item in spilitArr)
  4932. // {
  4933. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4934. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4935. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4936. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4937. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4938. // list.Add(depName);
  4939. // list.Add(arrName);
  4940. // }
  4941. // list = list.Distinct().ToList();
  4942. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4943. // }
  4944. // catch (Exception)
  4945. // {
  4946. // dic.Add("ReturnCode", "行程录入不正确!");
  4947. // }
  4948. //}
  4949. //else
  4950. //{
  4951. // dic.Add("ReturnCode", "未录入行程!");
  4952. //}
  4953. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4954. dic.Add("ReturnCode", string.Join("、", countrys));
  4955. #endregion
  4956. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4957. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4958. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4959. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4960. //{
  4961. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4962. // dic.Add("Day", sp.Days.ToString());
  4963. //}
  4964. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4965. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4966. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4967. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4968. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4969. //培训人员名单
  4970. int cultivateRowIndex = 7;
  4971. foreach (var item in DeleClientList)
  4972. {
  4973. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4974. builder.Write(item.Name);
  4975. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4976. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4977. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4978. string birthDay = "";
  4979. if (item.Birthday != null)
  4980. {
  4981. DateTime dt = Convert.ToDateTime(item.Birthday);
  4982. birthDay = $"{dt.Year}.{dt.Month}";
  4983. }
  4984. builder.Write(birthDay);
  4985. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4986. builder.Write(item.Company);
  4987. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4988. builder.Write(item.Job);
  4989. cultivateRowIndex++;
  4990. }
  4991. //删除多余行
  4992. //cultivateRowIndex -= 2;
  4993. int delRows = 10 + 7 - cultivateRowIndex;
  4994. if (delRows > 0)
  4995. {
  4996. for (int i = 0; i < delRows; i++)
  4997. {
  4998. table1.Rows.RemoveAt(cultivateRowIndex);
  4999. //cultivateRowIndex++;
  5000. }
  5001. }
  5002. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5003. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5004. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5005. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5006. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5007. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5008. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5009. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5010. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5011. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5012. //其他费用
  5013. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5014. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5015. //其他费用合计
  5016. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5017. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5018. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5019. //公务舱合计
  5020. //国际旅费
  5021. string outsideJJ = "";
  5022. string allPriceJJ = "";
  5023. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5024. {
  5025. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5026. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5027. }
  5028. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5029. {
  5030. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5031. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5032. }
  5033. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5034. {
  5035. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5036. dic.Add("AirFeeTotal", airFeeTotalStr);
  5037. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5038. dic.Add("FeeTotal", feeTotalStr);
  5039. }
  5040. foreach (var key in dic.Keys)
  5041. {
  5042. builder.MoveToBookmark(key);
  5043. builder.Write(dic[key]);
  5044. }
  5045. //模板文件名
  5046. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5047. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5048. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5049. return Ok(JsonView(true, "成功", new { Url = url }));
  5050. }
  5051. }
  5052. else if (dto.ExportType == 2) //表格
  5053. {
  5054. //利用键值对存放数据
  5055. Dictionary<string, string> dic = new Dictionary<string, string>();
  5056. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5057. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5058. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5059. dic.Add("Day", sp.Days.ToString());
  5060. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5061. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5062. {
  5063. //获取模板
  5064. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5065. //载入模板
  5066. Document doc = new Document(tempPath);
  5067. DocumentBuilder builder = new DocumentBuilder(doc);
  5068. dic.Add("TeamName", _DelegationInfo.TeamName);
  5069. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5070. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5071. string missionLeaderName = "",
  5072. missionLeaderJob = "";
  5073. if (DeleClientList.Count > 0)
  5074. {
  5075. missionLeaderName = DeleClientList[0].Name;
  5076. missionLeaderJob = DeleClientList[0].Job;
  5077. }
  5078. dic.Add("MissionLeaderName", missionLeaderName);
  5079. dic.Add("MissionLeaderJob", missionLeaderJob);
  5080. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5081. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5082. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5083. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5084. int rowCount = 10;//总人数行
  5085. int startRowIndex = 7; //起始行
  5086. for (int i = 0; i < DeleClientList.Count; i++)
  5087. {
  5088. builder.MoveToCell(0, startRowIndex, 0, 0);
  5089. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5090. builder.MoveToCell(0, startRowIndex, 1, 0);
  5091. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5092. builder.Write(sex);//性别
  5093. builder.MoveToCell(0, startRowIndex, 2, 0);
  5094. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5095. builder.MoveToCell(0, startRowIndex, 3, 0);
  5096. builder.Write(DeleClientList[i].Company);//工作单位
  5097. builder.MoveToCell(0, startRowIndex, 4, 0);
  5098. builder.Write(DeleClientList[i].Job);//职务及级别
  5099. builder.MoveToCell(0, startRowIndex, 5, 0);
  5100. builder.Write("");//人员属性
  5101. builder.MoveToCell(0, startRowIndex, 6, 0);
  5102. builder.Write("");//上次出国时间
  5103. startRowIndex++;
  5104. }
  5105. int nullRow = rowCount - DeleClientList.Count;//空行
  5106. for (int i = 0; i < nullRow; i++)
  5107. {
  5108. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5109. }
  5110. foreach (var key in dic.Keys)
  5111. {
  5112. builder.MoveToBookmark(key);
  5113. builder.Write(dic[key]);
  5114. }
  5115. //模板文件名
  5116. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5117. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5118. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5119. return Ok(JsonView(true, "成功", new { Url = url }));
  5120. }
  5121. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5122. {
  5123. //获取模板
  5124. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5125. //载入模板
  5126. Document doc = new Document(tempPath);
  5127. DocumentBuilder builder = new DocumentBuilder(doc);
  5128. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5129. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5130. dic.Add("Names", Names);
  5131. int accommodationRows = 12, foodandotherRows = 12;
  5132. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5133. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5134. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5135. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5136. int accommodationStartIndex = 6;
  5137. decimal dac1totalPrice = 0.00M;
  5138. foreach (var dac in dac1)
  5139. {
  5140. if (dac.SubTotal == 0)
  5141. {
  5142. continue;
  5143. }
  5144. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5145. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5146. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5147. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5148. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5149. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5150. builder.Write(currency);//币种
  5151. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5152. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5153. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5154. builder.Write("");//人数
  5155. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5156. builder.Write("");//天数
  5157. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5158. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5159. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5160. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5161. builder.Write(rate.ToString("#0.0000"));//汇率
  5162. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5163. decimal rbmPrice = rate * dac.SubTotal;
  5164. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5165. accommodationStartIndex++;
  5166. dac1totalPrice += rbmPrice;
  5167. }
  5168. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5169. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5170. builder.Write("小计");
  5171. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5172. builder.Write(dac1totalPrice.ToString("#0.00"));
  5173. accommodationStartIndex++;
  5174. int nullRow = accommodationRows - dac1.Count;
  5175. //删除空行
  5176. //if (nullRow > 0)
  5177. //{
  5178. // int rowIndex = accommodationStartIndex;
  5179. // for (int i = 0; i < nullRow; i++)
  5180. // {
  5181. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5182. // row.Remove();
  5183. // rowIndex++;
  5184. // }
  5185. //}
  5186. if (dac2.Count == dac3.Count)//国家 币种 金额
  5187. {
  5188. for (int i = 0; i < dac2.Count; i++)
  5189. {
  5190. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5191. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5192. }
  5193. }
  5194. int foodandotherStartIndex = 19;//
  5195. decimal dac2totalPrice = 0.00M;
  5196. foreach (var dac in dac2)
  5197. {
  5198. if (dac.SubTotal == 0)
  5199. {
  5200. continue;
  5201. }
  5202. //foodandotherStartIndex = 12;
  5203. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5204. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5205. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5206. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5207. builder.Write(currency);//币种
  5208. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5209. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5210. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5211. builder.Write("");//人数
  5212. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5213. builder.Write("");//天数
  5214. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5215. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5216. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5217. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5218. builder.Write(rate.ToString("#0.0000"));//汇率
  5219. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5220. decimal rbmPrice = rate * dac.SubTotal;
  5221. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5222. foodandotherStartIndex++;
  5223. dac2totalPrice += rbmPrice;
  5224. }
  5225. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5226. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5227. //删除空行
  5228. //if (dac2.Count < foodandotherRows)
  5229. //{
  5230. // while (table2.Rows.Count > dac2.Count)
  5231. // {
  5232. // table2.Rows.RemoveAt(dac2.Count);
  5233. // }
  5234. //}
  5235. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5236. string otherFeeStr = "";
  5237. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5238. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5239. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5240. if (otherFeeStr.Length > 0)
  5241. {
  5242. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5243. otherFeeStr = $"({otherFeeStr})";
  5244. dic.Add("OtherFeeStr", otherFeeStr);
  5245. }
  5246. foreach (var key in dic.Keys)
  5247. {
  5248. builder.MoveToBookmark(key);
  5249. builder.Write(dic[key]);
  5250. }
  5251. //模板文件名
  5252. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5253. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5254. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5255. return Ok(JsonView(true, "成功", new { Url = url }));
  5256. }
  5257. }
  5258. else if (dto.ExportType == 3)
  5259. {
  5260. if (dto.SubTypeId == 1) //团组成员名单
  5261. {
  5262. if (DeleClientList.Count < 1)
  5263. {
  5264. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5265. }
  5266. //获取模板
  5267. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5268. //载入模板
  5269. Document doc = new Document(tempPath);
  5270. DocumentBuilder builder = new DocumentBuilder(doc);
  5271. //获取word里所有表格
  5272. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5273. //获取所填表格的序数
  5274. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5275. var rowStart = tableOne.Rows[0]; //获取第1行
  5276. //循环赋值
  5277. for (int i = 0; i < DeleClientList.Count; i++)
  5278. {
  5279. builder.MoveToCell(0, i + 1, 0, 0);
  5280. builder.Write(DeleClientList[i].Name);
  5281. builder.MoveToCell(0, i + 1, 1, 0);
  5282. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5283. builder.Write(sex);
  5284. builder.MoveToCell(0, i + 1, 2, 0);
  5285. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5286. builder.MoveToCell(0, i + 1, 3, 0);
  5287. builder.Write(DeleClientList[i].Company);
  5288. builder.MoveToCell(0, i + 1, 4, 0);
  5289. builder.Write(DeleClientList[i].Job);
  5290. }
  5291. //删除多余行
  5292. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5293. {
  5294. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5295. }
  5296. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5297. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5298. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5299. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5300. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5301. return Ok(JsonView(true, "成功", new { Url = url }));
  5302. }
  5303. }
  5304. return Ok(JsonView(false, "操作失败!"));
  5305. }
  5306. catch (Exception ex)
  5307. {
  5308. return Ok(JsonView(false, ex.Message));
  5309. }
  5310. }
  5311. /// <summary>
  5312. /// 获取三公费用标准city
  5313. /// </summary>
  5314. /// <param name="placeData"></param>
  5315. /// <param name="nationalTravelFeeId"></param>
  5316. /// <returns></returns>
  5317. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5318. {
  5319. string _city = string.Empty;
  5320. if (placeData.Count < 1) return _city;
  5321. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5322. if (data == null) return _city;
  5323. string country = data.Country;
  5324. string city = data.City;
  5325. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5326. else _city = city;
  5327. return _city;
  5328. }
  5329. /// <summary>
  5330. /// 团组模块 - 出入境费用 - 明细表导出
  5331. /// </summary>
  5332. /// <returns></returns>
  5333. [HttpPost]
  5334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5335. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5336. {
  5337. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5338. if (data.Code != 0)
  5339. {
  5340. return Ok(JsonView(false, data.Msg));
  5341. }
  5342. return Ok(JsonView(true, data.Msg, data.Data));
  5343. }
  5344. /// <summary>
  5345. /// 团组模块 - 出入境费用 - 一键清空
  5346. /// </summary>
  5347. /// <returns></returns>
  5348. [HttpPost]
  5349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5350. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5351. {
  5352. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5353. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5354. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5355. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5356. if (_view.Code == 0)
  5357. {
  5358. return Ok(JsonView(true, "操作成功"));
  5359. }
  5360. return Ok(JsonView(false, "操作失败"));
  5361. }
  5362. /// <summary>
  5363. /// 团组模块 - 出入境费用 - 子项删除
  5364. /// </summary>
  5365. /// <returns></returns>
  5366. [HttpPost]
  5367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5368. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5369. {
  5370. try
  5371. {
  5372. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5373. if (data.Code != 0)
  5374. {
  5375. return Ok(JsonView(false, data.Msg));
  5376. }
  5377. return Ok(JsonView(true, "操作成功!", data.Data));
  5378. }
  5379. catch (Exception ex)
  5380. {
  5381. return Ok(JsonView(false, ex.Message));
  5382. }
  5383. }
  5384. /// <summary>
  5385. /// 团组模块 - 出入境国家费用标准 List
  5386. /// </summary>
  5387. /// <returns></returns>
  5388. [HttpPost]
  5389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5390. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5391. {
  5392. try
  5393. {
  5394. Stopwatch sw = new Stopwatch();
  5395. sw.Start();
  5396. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5397. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5398. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5399. Where gntf.Isdel = 0");
  5400. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5401. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5402. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5403. //foreach (var item in nationalTravel)
  5404. //{
  5405. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5406. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5407. // if (otherData != null)
  5408. // {
  5409. // cityData.Remove(otherData);
  5410. // cityData.Add(otherData);
  5411. // }
  5412. // nationalTravelFeeData1.Add(new
  5413. // {
  5414. // Country = item.Country,
  5415. // CityData = cityData
  5416. // });
  5417. //}
  5418. sw.Stop();
  5419. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5420. }
  5421. catch (Exception ex)
  5422. {
  5423. return Ok(JsonView(false, ex.Message));
  5424. throw;
  5425. }
  5426. }
  5427. /// <summary>
  5428. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5429. /// </summary>
  5430. /// <returns></returns>
  5431. [HttpPost]
  5432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5433. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5434. {
  5435. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5436. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5437. List<string> countryData = new List<string>();
  5438. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5439. countryData = countryData.Distinct().ToList();
  5440. List<dynamic> dataSource = new List<dynamic>();
  5441. foreach (var item in countryData)
  5442. {
  5443. List<string> cityData1 = new List<string>();
  5444. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5445. var countryData2 = new
  5446. {
  5447. CountryName = item,
  5448. CityData = cityData1
  5449. };
  5450. dataSource.Add(countryData2);
  5451. }
  5452. return Ok(JsonView(true, "查询成功!", dataSource));
  5453. }
  5454. /// <summary>
  5455. /// 团组模块 - 出入境国家费用标准 Page List
  5456. /// </summary>
  5457. /// <returns></returns>
  5458. [HttpPost]
  5459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5460. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5461. {
  5462. int portId = dto.PortType;
  5463. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5464. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5465. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5466. string whereSql = string.Empty;
  5467. if (!string.IsNullOrEmpty(dto.Country))
  5468. {
  5469. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5470. }
  5471. if (!string.IsNullOrEmpty(dto.City))
  5472. {
  5473. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5474. }
  5475. string pageSql = string.Format(@"Select * From (
  5476. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5477. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5478. From Grp_NationalTravelFee gntf
  5479. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5480. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5481. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5482. RefAsync<int> total = 0;
  5483. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5484. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5485. }
  5486. /// <summary>
  5487. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5488. /// </summary>
  5489. /// <returns></returns>
  5490. [HttpPost]
  5491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5492. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5493. {
  5494. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5495. int portId = dto.PortType;
  5496. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5497. string whereSql = string.Empty;
  5498. if (!string.IsNullOrEmpty(dto.Country))
  5499. {
  5500. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5501. }
  5502. if (!string.IsNullOrEmpty(dto.City))
  5503. {
  5504. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5505. }
  5506. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5507. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5508. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5509. From Grp_NationalTravelFee gntf
  5510. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5511. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5512. Where gntf.Isdel = 0 {0} ", whereSql);
  5513. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5514. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5515. }
  5516. /// <summary>
  5517. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5518. /// </summary>
  5519. /// <returns></returns>
  5520. [HttpPost]
  5521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5522. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5523. {
  5524. try
  5525. {
  5526. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5527. if (data.Code != 0)
  5528. {
  5529. return Ok(JsonView(false, data.Msg));
  5530. }
  5531. return Ok(JsonView(true, "操作成功!", data.Data));
  5532. }
  5533. catch (Exception ex)
  5534. {
  5535. return Ok(JsonView(false, ex.Message));
  5536. }
  5537. }
  5538. /// <summary>
  5539. /// 团组模块 - 出入境国家费用标准 - Del
  5540. /// </summary>
  5541. /// <returns></returns>
  5542. [HttpPost]
  5543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5544. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5545. {
  5546. try
  5547. {
  5548. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5549. {
  5550. Id = dto.Id,
  5551. DeleteUserId = dto.DeleteUserId,
  5552. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5553. IsDel = 1
  5554. };
  5555. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5556. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5557. .WhereColumns(it => new { it.Id })
  5558. .ExecuteCommandAsync();
  5559. if (delStatus <= 0)
  5560. {
  5561. return Ok(JsonView(false, "删除失败!"));
  5562. }
  5563. return Ok(JsonView(true, "操作成功!"));
  5564. }
  5565. catch (Exception ex)
  5566. {
  5567. return Ok(JsonView(false, ex.Message));
  5568. }
  5569. }
  5570. #endregion
  5571. #region 签证费用录入
  5572. /// <summary>
  5573. /// 根据diid查询签证费用列表
  5574. /// </summary>
  5575. /// <param name="dto"></param>
  5576. /// <returns></returns>
  5577. [HttpPost]
  5578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5579. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5580. {
  5581. try
  5582. {
  5583. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5584. if (groupData.Code != 0)
  5585. {
  5586. return Ok(JsonView(false, groupData.Msg));
  5587. }
  5588. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5589. }
  5590. catch (Exception ex)
  5591. {
  5592. return Ok(JsonView(false, ex.Message));
  5593. }
  5594. }
  5595. /// <summary>
  5596. /// 根据签证费用Id查询单条数据及c表数据
  5597. /// </summary>
  5598. /// <param name="dto"></param>
  5599. /// <returns></returns>
  5600. [HttpPost]
  5601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5602. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5603. {
  5604. try
  5605. {
  5606. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5607. if (groupData.Code != 0)
  5608. {
  5609. return Ok(JsonView(false, groupData.Msg));
  5610. }
  5611. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5612. }
  5613. catch (Exception ex)
  5614. {
  5615. return Ok(JsonView(false, ex.Message));
  5616. }
  5617. }
  5618. /// <summary>
  5619. /// 签证费用删除
  5620. /// </summary>
  5621. /// <param name="dto"></param>
  5622. /// <returns></returns>
  5623. [HttpPost]
  5624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5625. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5626. {
  5627. _sqlSugar.BeginTran();
  5628. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5629. if (!res)
  5630. {
  5631. _sqlSugar.RollbackTran();
  5632. return Ok(JsonView(false, "删除失败"));
  5633. }
  5634. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5635. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5636. .SetColumns(a => new Grp_CreditCardPayment()
  5637. {
  5638. IsDel = 1,
  5639. DeleteUserId = dto.DeleteUserId,
  5640. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5641. }).ExecuteCommand();
  5642. if (resSub < 1)
  5643. {
  5644. _sqlSugar.RollbackTran();
  5645. return Ok(JsonView(false, "删除失败"));
  5646. }
  5647. _sqlSugar.CommitTran();
  5648. return Ok(JsonView(true, "删除成功!"));
  5649. }
  5650. /// <summary>
  5651. /// 签证费用录入下拉框初始化
  5652. /// </summary>
  5653. /// <returns></returns>
  5654. [HttpPost]
  5655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5656. public async Task<IActionResult> VisaPriceAddSelect()
  5657. {
  5658. try
  5659. {
  5660. //支付方式
  5661. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5662. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5663. //币种
  5664. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5665. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5666. //乘客类型
  5667. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5668. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5669. //卡类型
  5670. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5671. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5672. var data = new
  5673. {
  5674. Payment = _Payment,
  5675. CurrencyList = _CurrencyList,
  5676. PassengerType = _PassengerType,
  5677. BankCard = _BankCard
  5678. };
  5679. return Ok(JsonView(true, "查询成功!", data));
  5680. }
  5681. catch (Exception ex)
  5682. {
  5683. return Ok(JsonView(false, "程序错误!"));
  5684. throw;
  5685. }
  5686. }
  5687. /// <summary>
  5688. /// 签证费用录入操作(Status:1.新增,2.修改)
  5689. /// </summary>
  5690. /// <param name="dto"></param>
  5691. /// <returns></returns>
  5692. [HttpPost]
  5693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5694. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5695. {
  5696. try
  5697. {
  5698. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5699. if (groupData.Code != 0)
  5700. {
  5701. return Ok(JsonView(false, groupData.Msg));
  5702. }
  5703. #region 应用推送
  5704. try
  5705. {
  5706. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5707. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5708. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5709. }
  5710. catch (Exception ex)
  5711. {
  5712. }
  5713. #endregion
  5714. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5715. }
  5716. catch (Exception ex)
  5717. {
  5718. return Ok(JsonView(false, ex.Message));
  5719. }
  5720. }
  5721. #endregion
  5722. #region 签证提成录入
  5723. /// <summary>
  5724. /// 签证提成录入
  5725. /// 基础数据
  5726. /// </summary>
  5727. /// <param name="_dto"></param>
  5728. /// <returns></returns>
  5729. [HttpGet]
  5730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5731. public async Task<IActionResult> VisaCommissionInit()
  5732. {
  5733. return Ok(await _visaCommissionRep.Init());
  5734. }
  5735. /// <summary>
  5736. /// 签证提成录入
  5737. /// Item
  5738. /// </summary>
  5739. /// <param name="_dto"></param>
  5740. /// <returns></returns>
  5741. [HttpPost]
  5742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5743. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5744. {
  5745. var validator = new VisaCommissionItemDtoValidator();
  5746. var validatorRes = await validator.ValidateAsync(_dto);
  5747. if (!validatorRes.IsValid)
  5748. {
  5749. StringBuilder sb = new StringBuilder();
  5750. foreach (var item in validatorRes.Errors)
  5751. {
  5752. sb.AppendLine(item.ErrorMessage);
  5753. }
  5754. return Ok(JsonView(false, sb.ToString()));
  5755. }
  5756. return Ok(await _visaCommissionRep.Item(_dto));
  5757. }
  5758. /// <summary>
  5759. /// 签证提成录入
  5760. /// Save
  5761. /// </summary>
  5762. /// <param name="_dto"></param>
  5763. /// <returns></returns>
  5764. [HttpPost]
  5765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5766. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  5767. {
  5768. //参数验证
  5769. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  5770. foreach (var item in _dto.Items)
  5771. {
  5772. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  5773. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  5774. if (string.IsNullOrEmpty( item.Country) ) return Ok(JsonView(false, "国家为空!"));
  5775. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  5776. }
  5777. return Ok(await _visaCommissionRep.Save(_dto));
  5778. }
  5779. /// <summary>
  5780. /// 签证提成录入
  5781. /// Create
  5782. /// </summary>
  5783. /// <param name="_dto"></param>
  5784. /// <returns></returns>
  5785. [HttpPost]
  5786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5787. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  5788. {
  5789. var validator = new VisaCommissionCreateDtoValidator();
  5790. var validatorRes = await validator.ValidateAsync(_dto);
  5791. if (!validatorRes.IsValid)
  5792. {
  5793. StringBuilder sb = new StringBuilder();
  5794. foreach (var item in validatorRes.Errors)
  5795. {
  5796. sb.AppendLine(item.ErrorMessage);
  5797. }
  5798. return Ok(JsonView(false, sb.ToString()));
  5799. }
  5800. return Ok(await _visaCommissionRep.Create(_dto));
  5801. }
  5802. /// <summary>
  5803. /// 签证提成录入
  5804. /// Put(编辑)
  5805. /// </summary>
  5806. /// <param name="id"></param>
  5807. /// <param name="_dto"></param>
  5808. /// <returns></returns>
  5809. [HttpPut]
  5810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5811. public async Task<IActionResult> VisaCommissionEdit(int id,VisaCommissionCreateDto _dto)
  5812. {
  5813. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5814. var validator = new VisaCommissionCreateDtoValidator();
  5815. var validatorRes = await validator.ValidateAsync(_dto);
  5816. if (!validatorRes.IsValid)
  5817. {
  5818. StringBuilder sb = new StringBuilder();
  5819. foreach (var item in validatorRes.Errors)
  5820. {
  5821. sb.AppendLine(item.ErrorMessage);
  5822. }
  5823. return Ok(JsonView(false, sb.ToString()));
  5824. }
  5825. return Ok(await _visaCommissionRep.Edit(id,_dto));
  5826. }
  5827. /// <summary>
  5828. /// 签证提成录入
  5829. /// Del
  5830. /// </summary>
  5831. /// <param name="id"></param>
  5832. /// <param name="currUserId"></param>
  5833. /// <returns></returns>
  5834. [HttpPost]
  5835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5836. public async Task<IActionResult> VisaCommissionDel(int id,int currUserId)
  5837. {
  5838. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5839. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  5840. return Ok(await _visaCommissionRep.Del(id, currUserId));
  5841. }
  5842. #endregion
  5843. #region op费用录入
  5844. /// <summary>
  5845. /// 根据diid查询op费用列表
  5846. /// </summary>
  5847. /// <param name="dto"></param>
  5848. /// <returns></returns>
  5849. [HttpPost]
  5850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5851. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5852. {
  5853. try
  5854. {
  5855. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5856. if (groupData.Code != 0)
  5857. {
  5858. return Ok(JsonView(false, groupData.Msg));
  5859. }
  5860. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5861. }
  5862. catch (Exception ex)
  5863. {
  5864. return Ok(JsonView(false, ex.Message));
  5865. }
  5866. }
  5867. /// <summary>
  5868. /// 根据op费用Id查询单条数据及c表数据
  5869. /// </summary>
  5870. /// <param name="dto"></param>
  5871. /// <returns></returns>
  5872. [HttpPost]
  5873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5874. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5875. {
  5876. try
  5877. {
  5878. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5879. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5880. var data = new
  5881. {
  5882. CarTouristGuideGround = _groupData,
  5883. CreditCardPayment = _creditCardPayment
  5884. };
  5885. return Ok(JsonView(true, "查询成功!", data));
  5886. }
  5887. catch (Exception ex)
  5888. {
  5889. return Ok(JsonView(false, "程序错误!"));
  5890. }
  5891. }
  5892. /// <summary>
  5893. /// op费用删除
  5894. /// </summary>
  5895. /// <param name="dto"></param>
  5896. /// <returns></returns>
  5897. [HttpPost]
  5898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5899. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5900. {
  5901. try
  5902. {
  5903. _sqlSugar.BeginTran();
  5904. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5905. if (!res)
  5906. {
  5907. return Ok(JsonView(false, "删除失败"));
  5908. }
  5909. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5910. {
  5911. IsDel = 1,
  5912. DeleteUserId = dto.DeleteUserId,
  5913. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5914. }).ExecuteCommandAsync();
  5915. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5916. {
  5917. IsDel = 1,
  5918. DeleteUserId = dto.DeleteUserId,
  5919. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5920. }).ExecuteCommandAsync();
  5921. #region 删除超支相关数据
  5922. //删除导入的超支数据
  5923. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5924. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5925. {
  5926. IsDel = 1,
  5927. DeleteUserId = dto.DeleteUserId,
  5928. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5929. }).ExecuteCommand();
  5930. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5931. {
  5932. IsDel = 1,
  5933. DeleteUserId = dto.DeleteUserId,
  5934. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5935. }).ExecuteCommand() ;
  5936. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5937. {
  5938. IsDel = 1,
  5939. DeleteUserId = dto.DeleteUserId,
  5940. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5941. }).ExecuteCommand();
  5942. #endregion
  5943. _sqlSugar.CommitTran();
  5944. return Ok(JsonView(true, "删除成功!"));
  5945. }
  5946. catch (Exception ex)
  5947. {
  5948. _sqlSugar.RollbackTran();
  5949. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5950. }
  5951. }
  5952. /// <summary>
  5953. /// op费用录入操作(Status:1.新增,2.修改)
  5954. /// </summary>
  5955. /// <param name="dto"></param>
  5956. /// <returns></returns>
  5957. [HttpPost]
  5958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5959. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5960. {
  5961. try
  5962. {
  5963. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5964. if (groupData.Code != 0)
  5965. {
  5966. return Ok(JsonView(false, groupData.Msg));
  5967. }
  5968. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5969. }
  5970. catch (Exception ex)
  5971. {
  5972. return Ok(JsonView(false, ex.Message));
  5973. }
  5974. }
  5975. /// <summary>
  5976. /// 填写费用详细页面初始化绑定
  5977. /// </summary>
  5978. /// <param name="dto"></param>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5982. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5983. {
  5984. try
  5985. {
  5986. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5987. if (groupData.Code != 0)
  5988. {
  5989. return Ok(JsonView(false, groupData.Msg));
  5990. }
  5991. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5992. }
  5993. catch (Exception ex)
  5994. {
  5995. return Ok(JsonView(false, ex.Message));
  5996. }
  5997. }
  5998. /// <summary>
  5999. /// 根据op费用Id查询详细数据
  6000. /// </summary>
  6001. /// <param name="dto"></param>
  6002. /// <returns></returns>
  6003. [HttpPost]
  6004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6005. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6006. {
  6007. try
  6008. {
  6009. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6010. if (groupData.Code != 0)
  6011. {
  6012. return Ok(JsonView(false, groupData.Msg));
  6013. }
  6014. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6015. }
  6016. catch (Exception ex)
  6017. {
  6018. return Ok(JsonView(false, ex.Message));
  6019. }
  6020. }
  6021. /// <summary>
  6022. /// OP费用录入填写详情
  6023. /// </summary>
  6024. /// <param name="dto"></param>
  6025. /// <returns></returns>
  6026. [HttpPost]
  6027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6028. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6029. {
  6030. try
  6031. {
  6032. #region 参数校验
  6033. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6034. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6035. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6036. #endregion
  6037. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6038. if (groupData.Code != 0)
  6039. {
  6040. return Ok(JsonView(false, groupData.Msg));
  6041. }
  6042. //自动审核
  6043. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6044. #region 应用推送
  6045. try
  6046. {
  6047. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6048. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6049. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6050. }
  6051. catch (Exception ex)
  6052. {
  6053. }
  6054. #endregion
  6055. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6056. }
  6057. catch (Exception ex)
  6058. {
  6059. return Ok(JsonView(false, ex.Message));
  6060. }
  6061. }
  6062. /// <summary>
  6063. /// 获取三公详细所有城市
  6064. /// </summary>
  6065. /// <returns></returns>
  6066. [HttpGet]
  6067. public IActionResult OpCarCityResult()
  6068. {
  6069. var jw = JsonView(false);
  6070. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6071. {
  6072. x.Id,
  6073. x.Country,
  6074. x.City,
  6075. }).ToList();
  6076. if (data.Count > 0)
  6077. {
  6078. jw = JsonView(true, "获取成功!", data);
  6079. }
  6080. else
  6081. {
  6082. jw.Msg = "城市数据为空!";
  6083. jw.Data = new string[0];
  6084. }
  6085. return Ok(jw);
  6086. }
  6087. /// <summary>
  6088. /// 导出地接费用明细
  6089. /// </summary>
  6090. /// <param name="dto"></param>
  6091. /// <returns></returns>
  6092. [HttpPost]
  6093. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6094. {
  6095. var jw = JsonView(false);
  6096. if (dto.Diid < 1)
  6097. {
  6098. jw.Msg = "请输入正确的diid!";
  6099. return Ok(jw);
  6100. }
  6101. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6102. if (group == null)
  6103. {
  6104. jw.Msg = "未找到团组信息!";
  6105. return Ok(jw);
  6106. }
  6107. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6108. if (localGuideArr.Count == 0)
  6109. {
  6110. jw.Msg = "该团组暂无地接信息!";
  6111. return Ok(jw);
  6112. }
  6113. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6114. var overspendSoure = new Dictionary<int, int>
  6115. {
  6116. { 91, 982 }, //车
  6117. { 92 , 1059} ,//导游
  6118. { 994 , 1073}, //翻译
  6119. { 988 , 1074 }, //早餐
  6120. { 93 , 1075 }, //午餐
  6121. { 989 , 1076 }, //晚餐
  6122. };
  6123. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6124. foreach (var groupArr in localGroup)
  6125. {
  6126. var keyValue = groupArr.Key;
  6127. if (int.TryParse(keyValue, out int cityid))
  6128. {
  6129. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6130. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6131. }
  6132. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6133. foreach (var item in groupArr)
  6134. {
  6135. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6136. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6137. new Grp_CarTouristGuideGroundReservationsContentExtend
  6138. {
  6139. Count = a.Count,
  6140. CreateTime = a.CreateTime,
  6141. CreateUserId = a.CreateUserId,
  6142. CTGGRId = a.CTGGRId,
  6143. Currency = a.Currency,
  6144. DatePrice = a.DatePrice,
  6145. DeleteTime = a.DeleteTime,
  6146. DeleteUserId = a.DeleteUserId,
  6147. DiId = a.DiId,
  6148. Id = a.Id,
  6149. IsDel = a.IsDel,
  6150. Price = a.Price,
  6151. PriceContent = a.PriceContent,
  6152. Remark = a.Remark,
  6153. SId = a.SId,
  6154. SidName = b.Name,
  6155. Units = a.Units,
  6156. }
  6157. ).ToList();
  6158. if (content.Count > 0)
  6159. {
  6160. contentArr.Add(content);
  6161. }
  6162. }
  6163. //open excel
  6164. //set excel
  6165. //save excel
  6166. try
  6167. {
  6168. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6169. IWorkbook workbook;
  6170. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6171. {
  6172. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6173. }
  6174. else
  6175. {
  6176. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6177. }
  6178. ISheet sheet = workbook.GetSheetAt(0);
  6179. var rowStartIndex = 2;
  6180. var clounmCount = 10;
  6181. var initStyleRow = sheet.GetRow(2);
  6182. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6183. //var overspendArrDetail =
  6184. var existsId = new List<CarCompare>();
  6185. var lastElem = arr.Last();
  6186. var thisSid = -1;
  6187. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6188. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6189. {
  6190. Name = "未知币种!",
  6191. Remark = "未知币种!",
  6192. };
  6193. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6194. Action cloneRowFn = () =>
  6195. {
  6196. rowStartIndex++;
  6197. var cloneRow = sheet.CreateRow(rowStartIndex);
  6198. // 复制样式
  6199. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6200. {
  6201. ICell sourceCell = initStyleRow.GetCell(i);
  6202. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6203. // 确保单元格存在样式
  6204. if (sourceCell.CellStyle != null)
  6205. {
  6206. targetCell.CellStyle = sourceCell.CellStyle;
  6207. }
  6208. }
  6209. };
  6210. var mergeRow = () =>
  6211. {
  6212. for (int i = 2; i < sheet.LastRowNum; i++)
  6213. {
  6214. var row = sheet.GetRow(i);
  6215. var cellFirst = row.GetCell(0);
  6216. var thisIndex = i + 1;
  6217. while (thisIndex < sheet.LastRowNum)
  6218. {
  6219. var nextRow = sheet.GetRow(thisIndex);
  6220. var nextCellFirst = nextRow.GetCell(0);
  6221. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6222. {
  6223. thisIndex++;
  6224. }
  6225. else
  6226. {
  6227. break;
  6228. }
  6229. }
  6230. thisIndex--;
  6231. if (thisIndex != i)
  6232. {
  6233. //合并row
  6234. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6235. i, // 起始行索引(0-based)
  6236. thisIndex, // 结束行索引(0-based)
  6237. 0, // 起始列索引(0-based)
  6238. 0 // 结束列索引(0-based)
  6239. );
  6240. sheet.AddMergedRegion(cellRangeAddress);
  6241. i = thisIndex;
  6242. }
  6243. }
  6244. };
  6245. var chaoshiNumber = 0;
  6246. var totalNumber = 0.00M;
  6247. string lastStr = "";
  6248. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6249. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6250. {
  6251. b.IsAuditGM,
  6252. x.Id,
  6253. x.Area,
  6254. b.PayPercentage,
  6255. b.PayMoney,
  6256. }).ToList();
  6257. string yesPayment = "", noPayment = "";
  6258. foreach (var item in queryCarArrByCityAndDiid)
  6259. {
  6260. if (item.IsAuditGM == 1)
  6261. {
  6262. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6263. }
  6264. else
  6265. {
  6266. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6267. }
  6268. }
  6269. lastStr = yesPayment + noPayment;
  6270. foreach (var item in arr)
  6271. {
  6272. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6273. {
  6274. if (thisSid != item.SId)
  6275. {
  6276. if (thisSid == -1)
  6277. {
  6278. thisSid = item.SId;
  6279. }
  6280. else
  6281. {
  6282. //合并小计行
  6283. //创建合并区域的实例
  6284. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6285. rowStartIndex, // 起始行索引(0-based)
  6286. rowStartIndex, // 结束行索引(0-based)
  6287. 0, // 起始列索引(0-based)
  6288. 3 // 结束列索引(0-based)
  6289. );
  6290. sheet.AddMergedRegion(cellRangeAddress);
  6291. var CellStyle = workbook.CreateCellStyle();
  6292. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6293. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6294. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6295. for (int i = 0; i <= clounmCount; i++)
  6296. {
  6297. if (i > 6)
  6298. {
  6299. var CellStyle1 = workbook.CreateCellStyle();
  6300. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6301. IFont Font = workbook.CreateFont(); // 创建字体
  6302. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6303. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6304. CellStyle1.SetFont(Font);
  6305. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6306. }
  6307. else
  6308. {
  6309. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6310. }
  6311. }
  6312. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6313. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6314. //超时合计
  6315. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6316. //超时数
  6317. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6318. //超时合计费用
  6319. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6320. thisSid = item.SId;
  6321. cloneRowFn();
  6322. chaoshiNumber = 0;
  6323. totalNumber = 0;
  6324. }
  6325. }
  6326. IRow row = sheet.GetRow(rowStartIndex);
  6327. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6328. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6329. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6330. if (isOpenOverspendSoure)
  6331. {
  6332. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6333. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6334. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6335. }
  6336. for (int i = 0; i <= clounmCount; i++)
  6337. {
  6338. var cell = row.GetCell(i);
  6339. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6340. if (cell == null)
  6341. {
  6342. cell = row.CreateCell(i);
  6343. }
  6344. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6345. fontRed.CloneStyleFrom(cell.CellStyle);
  6346. IFont Font = workbook.CreateFont(); // 创建字体
  6347. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6348. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6349. fontRed.SetFont(Font);
  6350. byte[] rgb = new byte[3] { 255, 242, 204 };
  6351. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6352. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6353. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6354. if (workbook is XSSFWorkbook)
  6355. {
  6356. BackgroundColor255_242_204.FillForegroundColor = 0;
  6357. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6358. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6359. }
  6360. else
  6361. {
  6362. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6363. }
  6364. if (i == 1 || i > 6)
  6365. {
  6366. if (i > 6)
  6367. {
  6368. fontRed.FillForegroundColor = 0;
  6369. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6370. fontRed.FillPattern = FillPattern.SolidForeground;
  6371. }
  6372. cell.CellStyle = fontRed;
  6373. }
  6374. if (i > 2 && i < 7)
  6375. {
  6376. cell.CellStyle = BackgroundColor255_242_204;
  6377. }
  6378. cell.SetCellValue(setCellValue); //写入单元格
  6379. }
  6380. if (overspendSoure.ContainsKey(thisSid))
  6381. {
  6382. var overspendId = overspendSoure[thisSid];
  6383. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6384. }
  6385. cloneRowFn();
  6386. existsId.Add(new CarCompare
  6387. {
  6388. DataPrice = item.DatePrice.ObjToDate(),
  6389. Sid = item.SId
  6390. });
  6391. }
  6392. if (item.Equals(lastElem))
  6393. {
  6394. //合并小计行
  6395. //创建合并区域的实例
  6396. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6397. rowStartIndex, // 起始行索引(0-based)
  6398. rowStartIndex, // 结束行索引(0-based)
  6399. 0, // 起始列索引(0-based)
  6400. 3 // 结束列索引(0-based)
  6401. );
  6402. sheet.AddMergedRegion(cellRangeAddress);
  6403. var CellStyle = workbook.CreateCellStyle();
  6404. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6405. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6406. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6407. for (int i = 0; i <= clounmCount; i++)
  6408. {
  6409. if (i > 6)
  6410. {
  6411. var CellStyle1 = workbook.CreateCellStyle();
  6412. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6413. IFont Font = workbook.CreateFont(); // 创建字体
  6414. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6415. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6416. CellStyle1.SetFont(Font);
  6417. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6418. }
  6419. else
  6420. {
  6421. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6422. }
  6423. }
  6424. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6425. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6426. //超时合计
  6427. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6428. //超时数
  6429. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6430. //超时合计费用
  6431. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6432. cloneRowFn();
  6433. // 创建合并区域的实例
  6434. cellRangeAddress = new CellRangeAddress(
  6435. rowStartIndex, // 起始行索引(0-based)
  6436. rowStartIndex, // 结束行索引(0-based)
  6437. 0, // 起始列索引(0-based)
  6438. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6439. );
  6440. // 添加合并区域
  6441. sheet.AddMergedRegion(cellRangeAddress);
  6442. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6443. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6444. }
  6445. }
  6446. mergeRow();
  6447. // 保存修改后的Excel文件到新文件
  6448. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6449. // new FileStream(newFilePath, FileMode.CreateNew)
  6450. using (var stream = new MemoryStream())
  6451. {
  6452. workbook.Write(stream, true);
  6453. stream.Flush();
  6454. stream.Seek(0, SeekOrigin.Begin);
  6455. MemoryStream memoryStream = new MemoryStream();
  6456. stream.CopyTo(memoryStream);
  6457. memoryStream.Seek(0, SeekOrigin.Begin);
  6458. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6459. }
  6460. workbook.Close();
  6461. workbook.Dispose();
  6462. }
  6463. catch (Exception ex)
  6464. {
  6465. jw.Msg = "出现异常!" + ex.Message;
  6466. return Ok(jw);
  6467. }
  6468. }
  6469. if (Zips.Count > 0)
  6470. {
  6471. IOOperatorHelper io = new IOOperatorHelper();
  6472. var byts = io.ConvertZipStream(Zips);
  6473. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6474. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6475. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6476. }
  6477. else
  6478. {
  6479. jw.Msg = "暂无生成文件!";
  6480. }
  6481. return Ok(jw);
  6482. }
  6483. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6484. {
  6485. string outStr = string.Empty;
  6486. switch (i)
  6487. {
  6488. case 0:
  6489. outStr = arr[0].SidName;
  6490. break;
  6491. case 1:
  6492. outStr = arr[0].DataPriceStr;
  6493. break;
  6494. case 2:
  6495. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6496. break;
  6497. case 4:
  6498. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6499. break;
  6500. case 7:
  6501. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6502. {
  6503. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6504. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6505. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6506. }
  6507. break;
  6508. case 8:
  6509. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6510. {
  6511. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6512. }
  6513. break;
  6514. case 9:
  6515. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6516. {
  6517. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6518. }
  6519. break;
  6520. case 10:
  6521. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6522. {
  6523. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6524. }
  6525. break;
  6526. }
  6527. return outStr;
  6528. }
  6529. #region OP行程单
  6530. /// <summary>
  6531. /// OP行程单初始化
  6532. /// </summary>
  6533. /// <param name="dto"></param>
  6534. /// <returns></returns>
  6535. [HttpPost]
  6536. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6537. {
  6538. var jw = JsonView(false);
  6539. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6540. var group = groupList.First();
  6541. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6542. if (group == null)
  6543. {
  6544. jw.Msg = "暂无团组!";
  6545. return Ok(jw);
  6546. }
  6547. group = groupList.Find(x => x.Id == diid);
  6548. if (group == null)
  6549. {
  6550. jw.Msg = "请输入正确的团组ID!";
  6551. return Ok(jw);
  6552. }
  6553. string city = string.Empty;
  6554. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6555. if (blackCode.Count > 0)
  6556. {
  6557. var black = blackCode.First();
  6558. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6559. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6560. if (blackSp.Length > 0)
  6561. {
  6562. try
  6563. {
  6564. var cityArrCode = new List<string>(20);
  6565. foreach (var item in blackSp)
  6566. {
  6567. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6568. var IndexSelect = itemSp[2];
  6569. var cityArrCodeLength = cityArrCode.Count - 1;
  6570. var startCity = IndexSelect.Substring(0, 3);
  6571. if (cityArrCodeLength > 0)
  6572. {
  6573. var arrEndCity = cityArrCode[cityArrCodeLength];
  6574. if (arrEndCity != startCity)
  6575. {
  6576. cityArrCode.Add(startCity.ToUpper());
  6577. }
  6578. }
  6579. else
  6580. {
  6581. cityArrCode.Add(startCity.ToUpper());
  6582. }
  6583. var endCity = IndexSelect.Substring(3, 3);
  6584. cityArrCode.Add(endCity.ToUpper());
  6585. }
  6586. var cityThree = string.Empty;
  6587. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6588. cityThree = cityThree.TrimEnd(',');
  6589. if (string.IsNullOrWhiteSpace(cityThree))
  6590. {
  6591. throw new
  6592. Exception("error");
  6593. }
  6594. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6595. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6596. foreach (var item in cityArrCode)
  6597. {
  6598. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6599. if (find != null)
  6600. {
  6601. city += find.City + "/";
  6602. }
  6603. else
  6604. {
  6605. city += item + "三字码未收入/";
  6606. }
  6607. }
  6608. city = city.TrimEnd('/');
  6609. }
  6610. catch (Exception e)
  6611. {
  6612. city = "黑屏代码格式不正确!";
  6613. }
  6614. }
  6615. }
  6616. else
  6617. {
  6618. city = "未录入黑屏代码";
  6619. }
  6620. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6621. {
  6622. Date = x.Date,
  6623. Days = x.Days,
  6624. Diffgroup = x.Diffgroup,
  6625. Diid = x.Diid,
  6626. Traffic_First = x.Traffic_First,
  6627. Traffic_Second = x.Traffic_Second,
  6628. Trip = x.Trip,
  6629. WeekDay = x.WeekDay,
  6630. Id = x.Id
  6631. }).ToList();
  6632. jw.Data = new
  6633. {
  6634. groupList = groupList.Select(x => new
  6635. {
  6636. x.Id,
  6637. x.TeamName,
  6638. x.TourCode
  6639. }).ToList(),
  6640. groupInfo = new
  6641. {
  6642. group.VisitDays,
  6643. group.TourCode,
  6644. group.VisitPNumber,
  6645. group.TeamName,
  6646. city
  6647. },
  6648. OpTravelList
  6649. };
  6650. jw.Code = 200;
  6651. jw.Msg = "操作成功!";
  6652. return Ok(jw);
  6653. }
  6654. /// <summary>
  6655. /// 删除团组行程单
  6656. /// </summary>
  6657. /// <returns></returns>
  6658. [HttpPost]
  6659. public IActionResult DelTravel(DelOpTravelDto dto)
  6660. {
  6661. var jw = JsonView(false);
  6662. if (dto.UserId <= 0 || dto.Diid <= 0)
  6663. {
  6664. jw.Msg = "请输入正确的参数!";
  6665. return Ok(jw);
  6666. }
  6667. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6668. .SetColumns(x => new Grp_TravelList
  6669. {
  6670. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6671. DeleteUserId = dto.UserId,
  6672. IsDel = 1,
  6673. }).ExecuteCommand();
  6674. jw = JsonView(true);
  6675. return Ok(jw);
  6676. }
  6677. /// <summary>
  6678. /// 行程单保存
  6679. /// </summary>
  6680. /// <returns></returns>
  6681. [HttpPost]
  6682. public IActionResult TravelSave(TravelSaveDto dto)
  6683. {
  6684. var jw = JsonView(false);
  6685. if (dto.Arr.Count > 0)
  6686. {
  6687. try
  6688. {
  6689. _sqlSugar.BeginTran();
  6690. foreach (var item in dto.Arr)
  6691. {
  6692. if (item.Id == 0)
  6693. {
  6694. throw new Exception("请传入正确的Id");
  6695. }
  6696. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6697. .SetColumns(x => new Grp_TravelList
  6698. {
  6699. Trip = item.Trip
  6700. }).ExecuteCommand();
  6701. }
  6702. _sqlSugar.CommitTran();
  6703. jw = JsonView(true);
  6704. }
  6705. catch (Exception ex)
  6706. {
  6707. _sqlSugar.RollbackTran();
  6708. jw.Msg = "程序异常!" + ex.Message;
  6709. }
  6710. }
  6711. else
  6712. {
  6713. jw.Msg = "请传入正确的参数!";
  6714. }
  6715. return Ok(jw);
  6716. }
  6717. /// <summary>
  6718. /// 导出行程单
  6719. /// </summary>
  6720. /// <param name="dto"></param>
  6721. /// <returns></returns>
  6722. [HttpPost]
  6723. public IActionResult ExportTravel(ExportTravelDto dto)
  6724. {
  6725. var jw = JsonView(false);
  6726. jw.Data = "";
  6727. int diid = 0;
  6728. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6729. if (Find == null)
  6730. {
  6731. jw.Msg = "请选择正确的团组!";
  6732. return Ok(jw);
  6733. }
  6734. else
  6735. {
  6736. diid = Find.Id;
  6737. }
  6738. //数据源
  6739. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6740. DataTable dtBlack = null;
  6741. try
  6742. {
  6743. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6744. }
  6745. catch (Exception)
  6746. {
  6747. jw.Msg = "机票黑屏代码有误!";
  6748. return Ok(jw);
  6749. }
  6750. string CityStr = string.Empty;
  6751. if (dtBlack.Rows.Count == 0)
  6752. {
  6753. jw.Msg = "机票黑屏代码有误!";
  6754. return Ok(jw);
  6755. }
  6756. else
  6757. {
  6758. foreach (DataRow row in dtBlack.Rows)
  6759. {
  6760. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6761. {
  6762. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6763. return Ok(jw);
  6764. }
  6765. }
  6766. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6767. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6768. }
  6769. //创建数据源Table
  6770. DataTable dtSource = new DataTable();
  6771. dtSource.Columns.Add("Days", typeof(string));
  6772. dtSource.Columns.Add("Date", typeof(string));
  6773. dtSource.Columns.Add("Week", typeof(string));
  6774. dtSource.Columns.Add("Traffic", typeof(string));
  6775. dtSource.Columns.Add("Trip", typeof(string));
  6776. //获取数据,放到datatable
  6777. foreach (var item in _travelList)
  6778. {
  6779. DataRow dr = dtSource.NewRow();
  6780. dr["Days"] = item.Days;
  6781. dr["Date"] = item.Date;
  6782. dr["Week"] = item.WeekDay;
  6783. dr["Traffic"] = item.Traffic_First
  6784. + "\r\n"
  6785. + item.Traffic_Second;
  6786. dr["Trip"] = item.Trip;
  6787. dtSource.Rows.Add(dr);
  6788. }
  6789. Dictionary<string, string> dic = new Dictionary<string, string>();
  6790. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6791. dic.Add("City", CityStr);
  6792. dic.Add("Days", Find.VisitDays.ToString());
  6793. dic.Add("DeleCode", Find.TourCode);
  6794. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6795. //模板路径
  6796. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6797. //载入模板
  6798. Document doc = null;
  6799. DocumentBuilder builder = null;
  6800. try
  6801. {
  6802. //载入模板
  6803. doc = new Document(tempPath);
  6804. builder = new DocumentBuilder(doc);
  6805. }
  6806. catch (Exception)
  6807. {
  6808. jw.Msg = "模板位置不存在!";
  6809. return Ok(jw);
  6810. }
  6811. foreach (var key in dic.Keys)
  6812. {
  6813. Bookmark bookmark = doc.Range.Bookmarks[key];
  6814. if (bookmark != null)
  6815. {
  6816. builder.MoveToBookmark(key);
  6817. builder.Write(dic[key]);
  6818. }
  6819. }
  6820. //获取word里所有表格
  6821. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6822. //获取所填表格的序数
  6823. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6824. try
  6825. {
  6826. //循环赋值
  6827. for (int i = 0; i < dtSource.Rows.Count; i++)
  6828. {
  6829. builder.MoveToCell(0, i + 1, 0, 0);
  6830. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6831. builder.MoveToCell(0, i + 1, 1, 0);
  6832. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6833. builder.MoveToCell(0, i + 1, 2, 0);
  6834. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6835. var trip = dtSource.Rows[i]["Trip"].ToString();
  6836. builder.MoveToCell(0, i + 1, 3, 0);
  6837. builder.Write(trip);
  6838. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6839. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6840. // 获取特定索引的段落
  6841. Paragraph paragraph = (Paragraph)paragraphs[0];
  6842. Run run = paragraph.Runs[0];
  6843. Aspose.Words.Font font = run.Font;
  6844. font.Name = "黑体";
  6845. //设置双休红色
  6846. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6847. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6848. paragraph = (Paragraph)paragraphs[1];
  6849. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6850. {
  6851. run = paragraph.Runs[0];
  6852. font = run.Font;
  6853. font.Color = Color.Red;
  6854. }
  6855. }
  6856. }
  6857. catch (Exception ex)
  6858. {
  6859. }
  6860. //删除多余行
  6861. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6862. {
  6863. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6864. }
  6865. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6866. if (!Directory.Exists(savePath))
  6867. {
  6868. try
  6869. {
  6870. Directory.CreateDirectory(savePath);
  6871. }
  6872. catch
  6873. {
  6874. }
  6875. }
  6876. string path = savePath + Find.TeamName + "出访日程";
  6877. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6878. try
  6879. {
  6880. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6881. string postfix = ".docx";
  6882. if (dto.IsPDF == 1)
  6883. {
  6884. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6885. postfix = ".pdf";
  6886. }
  6887. doc.Save(path + postfix, saveFormat);
  6888. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6889. }
  6890. catch (Exception)
  6891. {
  6892. jw = JsonView(false);
  6893. }
  6894. return Ok(jw);
  6895. }
  6896. /// <summary>
  6897. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6898. /// </summary>
  6899. /// <param name="num"></param>
  6900. /// <returns></returns>
  6901. string GetNum(string num)
  6902. {
  6903. string str = "";
  6904. switch (num)
  6905. {
  6906. case "1":
  6907. str = "一";
  6908. break;
  6909. case "2":
  6910. str = "二";
  6911. break;
  6912. case "3":
  6913. str = "三";
  6914. break;
  6915. case "4":
  6916. str = "四";
  6917. break;
  6918. case "5":
  6919. str = "五";
  6920. break;
  6921. case "6":
  6922. str = "六";
  6923. break;
  6924. case "7":
  6925. str = "七";
  6926. break;
  6927. case "8":
  6928. str = "八";
  6929. break;
  6930. case "9":
  6931. str = "九";
  6932. break;
  6933. case "10":
  6934. str = "十";
  6935. break;
  6936. case "11":
  6937. str = "十一";
  6938. break;
  6939. case "12":
  6940. str = "十二";
  6941. break;
  6942. case "一":
  6943. str = "1";
  6944. break;
  6945. case "二":
  6946. str = "2";
  6947. break;
  6948. case "三":
  6949. str = "3";
  6950. break;
  6951. case "四":
  6952. str = "4";
  6953. break;
  6954. case "五":
  6955. str = "5";
  6956. break;
  6957. case "六":
  6958. str = "6";
  6959. break;
  6960. case "七":
  6961. str = "7";
  6962. break;
  6963. case "八":
  6964. str = "8";
  6965. break;
  6966. case "九":
  6967. str = "9";
  6968. break;
  6969. case "十":
  6970. str = "10";
  6971. break;
  6972. case "十一":
  6973. str = "11";
  6974. break;
  6975. case "十二":
  6976. str = "12";
  6977. break;
  6978. }
  6979. return str;
  6980. }
  6981. #endregion
  6982. #endregion
  6983. #region 团组成本
  6984. /// <summary>
  6985. /// 团组成本数据初始化
  6986. /// </summary>
  6987. /// <param name="dto"></param>
  6988. /// <returns></returns>
  6989. [HttpPost]
  6990. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6991. {
  6992. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6993. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6994. WHEN COUNT(*) >= 0 THEN 'True'
  6995. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6996. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6997. ").ToList(); //团组列表
  6998. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6999. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7000. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7001. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7002. if (groupinfoValue != null)
  7003. {
  7004. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7005. var spArr = new string[1] { countryArr };
  7006. if (countryArr.Contains("|"))
  7007. {
  7008. spArr = countryArr.Split("|");
  7009. }
  7010. else if (countryArr.Contains("、"))
  7011. {
  7012. spArr = countryArr.Split("、");
  7013. }
  7014. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7015. {
  7016. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7017. if (dbQueryCountry != null)
  7018. {
  7019. visaCountryInfoArr.Add(dbQueryCountry);
  7020. }
  7021. }
  7022. }
  7023. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7024. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7025. var create = _GroupCostRepository.
  7026. CreateGroupCostByBlackCode(dto.Diid);
  7027. if (groupCost.Count == 0 && create.Code == 0)
  7028. {
  7029. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7030. }
  7031. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7032. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7033. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7034. groupCostMap = groupCostMap.Select(x =>
  7035. {
  7036. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7037. {
  7038. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7039. }
  7040. return x;
  7041. }).ToList();
  7042. //GroupCostParameter.Add(new
  7043. // Grp_GroupCostParameter());
  7044. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7045. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7046. return Ok(JsonView(new
  7047. {
  7048. groupList,
  7049. groupInfo,
  7050. groupChecks,
  7051. groupCost = groupCostMap,
  7052. hotelNumber,
  7053. GroupCostParameter = GroupCostParameterMap,
  7054. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7055. {
  7056. x.VisaCountry,
  7057. x.VisaPrice,
  7058. x.Id,
  7059. }).ToList(),
  7060. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7061. blackCodeIsTrue = create.Code == 0 ? true : false,
  7062. hotelIsTrue = hotelIsTrue,
  7063. }));
  7064. }
  7065. /// <summary>
  7066. /// 团组成本信息保存
  7067. /// </summary>
  7068. /// <param name="dto"></param>
  7069. /// <returns></returns>
  7070. [HttpPost]
  7071. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7072. {
  7073. if (dto.Diid <= 0 || dto.Userid <= 0)
  7074. {
  7075. return Ok(JsonView(false));
  7076. }
  7077. JsonView jw = null;
  7078. bool isTrue = false;
  7079. #region 复制团组成本
  7080. //if (dto.Diid == 2581)
  7081. //{
  7082. // dto.Diid = 2599;
  7083. // dto.CheckBoxs.ForEach(x =>
  7084. // {
  7085. // x.Diid = 2599;
  7086. // });
  7087. // dto.GroupCosts.ForEach(x =>
  7088. // {
  7089. // x.Diid = 2599;
  7090. // });
  7091. // dto.CostTypeHotelNumbers.ForEach(x =>
  7092. // {
  7093. // x.Diid = 2599;
  7094. // });
  7095. // dto.GroupCostParameters.ForEach(x =>
  7096. // {
  7097. // x.DiId = 2599;
  7098. // });
  7099. //}
  7100. #endregion
  7101. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7102. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7103. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7104. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7105. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7106. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7107. try
  7108. {
  7109. _sqlSugar.BeginTran();
  7110. isTrue = await _GroupCostRepository.
  7111. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7112. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7113. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7114. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7115. _sqlSugar.CommitTran();
  7116. jw = JsonView(true, "保存成功!", isTrue);
  7117. }
  7118. catch (Exception)
  7119. {
  7120. _sqlSugar.RollbackTran();
  7121. jw = JsonView(false);
  7122. }
  7123. return Ok(jw);
  7124. }
  7125. /// <summary>
  7126. /// 司兼导数据
  7127. /// </summary>
  7128. /// <param name="dto"></param>
  7129. /// <returns></returns>
  7130. [HttpPost]
  7131. public IActionResult GetCarGuides(CarGuidesDto dto)
  7132. {
  7133. JsonView jw = null;
  7134. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7135. jw = JsonView(true, "获取成功!", Data);
  7136. return Ok(jw);
  7137. }
  7138. /// <summary>
  7139. /// 导游数据
  7140. /// </summary>
  7141. /// <param name="dto"></param>
  7142. /// <returns></returns>
  7143. [HttpPost]
  7144. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7145. {
  7146. JsonView jw = null;
  7147. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7148. // 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
  7149. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7150. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7151. jw = JsonView(true, "获取成功!", Data);
  7152. return Ok(jw);
  7153. }
  7154. /// <summary>
  7155. /// 成本车数据
  7156. /// </summary>
  7157. /// <param name="dto"></param>
  7158. /// <returns></returns>
  7159. [HttpPost]
  7160. public IActionResult GetCarInfo(CarGuidesDto dto)
  7161. {
  7162. JsonView jw = null;
  7163. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7164. jw = JsonView(true, "获取成功!", Data);
  7165. return Ok(jw);
  7166. }
  7167. /// <summary>
  7168. /// 景点数据
  7169. /// </summary>
  7170. /// <param name="dto"></param>
  7171. /// <returns></returns>
  7172. [HttpPost]
  7173. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7174. {
  7175. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7176. return Ok(JsonView(true, "获取成功!", Data));
  7177. }
  7178. /// <summary>
  7179. /// 成本通知
  7180. /// </summary>
  7181. /// <param name="dto"></param>
  7182. /// <returns></returns>
  7183. [HttpPost]
  7184. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7185. {
  7186. if (dto.Diid < 0)
  7187. {
  7188. return Ok(JsonView(false));
  7189. }
  7190. JsonView jw = null;
  7191. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7192. if (GroupCostParameter != null)
  7193. {
  7194. int IsShare = 0;
  7195. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7196. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7197. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7198. string msg = string.Empty;
  7199. if (isTrue)
  7200. {
  7201. if (IsShare == 0)
  7202. {
  7203. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7204. }
  7205. else
  7206. {
  7207. #region 企微通知对应岗位用户
  7208. try
  7209. {
  7210. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7211. }
  7212. catch (Exception ex)
  7213. {
  7214. }
  7215. #endregion
  7216. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7217. }
  7218. jw = JsonView(isTrue, msg, new { IsShare });
  7219. }
  7220. else
  7221. {
  7222. msg = "修改失败!";
  7223. jw = JsonView(isTrue, msg);
  7224. }
  7225. }
  7226. else
  7227. {
  7228. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7229. }
  7230. return Ok(jw);
  7231. }
  7232. /// <summary>
  7233. /// 导出报价单
  7234. /// </summary>
  7235. /// <param name="dto"></param>
  7236. /// <returns></returns>
  7237. [HttpPost]
  7238. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7239. {
  7240. if (dto.Diid == 0)
  7241. {
  7242. return Ok(JsonView(false, "请传递团组id"));
  7243. }
  7244. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7245. if (deleInfo.Code != 0)
  7246. {
  7247. return Ok(JsonView(false, "团组信息查询失败!"));
  7248. }
  7249. var di = deleInfo.Data as DelegationInfoWebView;
  7250. if (di != null)
  7251. {
  7252. di.TeamName = di.TeamName.Replace("|","、");
  7253. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7254. //文件名
  7255. string strFileName = di.TeamName + "-收款账单.doc";
  7256. //获取模板
  7257. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7258. //载入模板
  7259. Document doc = new Document(tmppath);
  7260. decimal TotalPrice = 0.00M;
  7261. string itemStr = string.Empty;
  7262. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7263. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7264. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7265. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7266. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7267. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7268. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7269. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7270. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7271. foreach (var cost in groupCostType)
  7272. {
  7273. var List = cost.ToList();
  7274. if (cost.Key == "A")
  7275. {
  7276. foreach (var ListItem in List)
  7277. {
  7278. if (ListItem.number > 0)
  7279. {
  7280. if (ListItem.code.Contains("TBR"))
  7281. {
  7282. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7283. }
  7284. else
  7285. {
  7286. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7287. }
  7288. TotalPrice += (ListItem.number * ListItem.price);
  7289. }
  7290. }
  7291. }
  7292. else
  7293. {
  7294. itemStr = itemStr.Insert(0, "A段\r\n");
  7295. itemStr += "B段\r\n";
  7296. foreach (var ListItem in List)
  7297. {
  7298. if (ListItem.number > 0)
  7299. {
  7300. if (ListItem.code.Contains("TBR"))
  7301. {
  7302. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7303. }
  7304. else
  7305. {
  7306. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7307. }
  7308. TotalPrice += (ListItem.number * ListItem.price);
  7309. }
  7310. }
  7311. }
  7312. }
  7313. #region 替换Word模板书签内容
  7314. Dictionary<string, string> marks = new Dictionary<string, string>();
  7315. marks.Add("To", di.ClientUnit);//付款方
  7316. marks.Add("ToTel", di.TellPhone);//付款方电话
  7317. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7318. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7319. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7320. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7321. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7322. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7323. marks.Add("PayItemContent", itemStr);//详细信息
  7324. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7325. #endregion
  7326. ////注
  7327. //if (doc.Range.Bookmarks["Attention"] != null)
  7328. //{
  7329. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7330. // mark.Text = frList[0].Attention;
  7331. //}
  7332. foreach (var item in marks.Keys)
  7333. {
  7334. if (doc.Range.Bookmarks[item] != null)
  7335. {
  7336. Bookmark mark = doc.Range.Bookmarks[item];
  7337. mark.Text = marks[item];
  7338. }
  7339. }
  7340. byte[] bytes = null;
  7341. using (MemoryStream stream = new MemoryStream())
  7342. {
  7343. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7344. bytes = stream.ToArray();
  7345. }
  7346. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7347. return Ok(JsonView(true, "", new
  7348. {
  7349. Data = bytes,
  7350. strFileName,
  7351. }));
  7352. }
  7353. else
  7354. {
  7355. return Ok(JsonView(false, "团组信息不存在!"));
  7356. }
  7357. }
  7358. /// <summary>
  7359. /// 导出团组成本
  7360. /// </summary>
  7361. /// <param name="dto"></param>
  7362. /// <returns></returns>
  7363. [HttpPost]
  7364. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7365. {
  7366. var jw = JsonView(false);
  7367. if (dto.Diid == 0)
  7368. {
  7369. return Ok(JsonView(false, "请传递团组id"));
  7370. }
  7371. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7372. if (deleInfo.Code != 0)
  7373. {
  7374. return Ok(JsonView(false, "团组信息查询失败!"));
  7375. }
  7376. var di = deleInfo.Data as DelegationInfoWebView;
  7377. if (di == null)
  7378. {
  7379. return Ok(JsonView(false, "团组信息查询失败!"));
  7380. }
  7381. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7382. WorkbookDesigner designer = new WorkbookDesigner();
  7383. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7384. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7385. for (int i = 0; i < List_GC.Count; i++)
  7386. {
  7387. GroupCost_Excel gc = new GroupCost_Excel();
  7388. gc.Id = List_GC[i].Id;
  7389. gc.Diid = List_GC[i].Diid.ToString();
  7390. gc.DAY = List_GC[i].DAY;
  7391. string week = "";
  7392. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7393. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7394. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7395. gc.ITIN = List_GC[i].ITIN;
  7396. gc.CarType = List_GC[i].CarType;
  7397. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7398. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7399. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7400. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7401. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7402. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7403. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7404. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7405. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7406. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7407. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7408. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7409. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7410. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7411. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7412. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7413. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7414. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7415. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7416. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7417. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7418. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7419. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7420. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7421. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7422. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7423. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7424. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7425. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7426. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7427. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7428. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7429. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7430. List_GC1.Add(gc);
  7431. }
  7432. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7433. dt.TableName = "TB";
  7434. //报表标题等不用dt的值
  7435. designer.SetDataSource("TeamName", dto.title.TeamName);
  7436. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7437. designer.SetDataSource("Tax", dto.title.Tax);
  7438. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7439. designer.SetDataSource("Currency", dto.title.Currency);
  7440. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7441. designer.SetDataSource("Rate", dto.title.Rate);
  7442. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7443. var Aparams = hotels.Find(x => x.Type == "Default");
  7444. if (Aparams == null)
  7445. {
  7446. return Ok(jw);
  7447. }
  7448. //酒店数量
  7449. var txtSGRNumber = Aparams.SGR.ToString();
  7450. var txtTBRNumber = Aparams.TBR.ToString();
  7451. var txtJSESNumber = Aparams.JSES.ToString();
  7452. var txtSUITENumbe = Aparams.SUITE.ToString();
  7453. if (dto.costType == "B")
  7454. {
  7455. Aparams = hotels.Find(x => x.Type == "A");
  7456. var Bparams = hotels.Find(x => x.Type == "B");
  7457. if (Aparams == null || Bparams == null)
  7458. {
  7459. return Ok(jw);
  7460. }
  7461. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7462. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7463. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7464. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7465. }
  7466. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7467. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7468. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7469. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7470. var ws = designer.Workbook.Worksheets[0];
  7471. int Row = List_GC.Count;
  7472. int startIndex = 11;
  7473. int HideRows = 0;
  7474. List<int> hideRowsList = new List<int>();
  7475. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7476. #region A段left数据
  7477. var left = dto.leftInfo.Find(x => x.Type == "A");
  7478. if (left == null)
  7479. {
  7480. return Ok(jw);
  7481. }
  7482. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7483. if (leftBindData != null)
  7484. {
  7485. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7486. designer.SetDataSource("VisaRS", leftBindData.rs);
  7487. designer.SetDataSource("VisaXS", leftBindData.xs);
  7488. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7489. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7490. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7491. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7492. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7493. }
  7494. else
  7495. {
  7496. hideRowsList.Add(Row + startIndex + HideRows);
  7497. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7498. }
  7499. HideRows += 2;
  7500. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7501. if (leftBindData != null)
  7502. {
  7503. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7504. designer.SetDataSource("BXRS", leftBindData.rs);
  7505. designer.SetDataSource("BXXS", leftBindData.xs);
  7506. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7507. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7508. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7509. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7510. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7511. }
  7512. else
  7513. {
  7514. hideRowsList.Add(Row + startIndex + HideRows);
  7515. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7516. }
  7517. HideRows += 2;
  7518. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7519. if (leftBindData != null)
  7520. {
  7521. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7522. designer.SetDataSource("HSRS", leftBindData.rs);
  7523. designer.SetDataSource("HSXS", leftBindData.xs);
  7524. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7525. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7526. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7527. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7528. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7529. }
  7530. else
  7531. {
  7532. hideRowsList.Add(Row + startIndex + HideRows);
  7533. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7534. }
  7535. HideRows += 2;
  7536. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7537. if (leftBindData != null)
  7538. {
  7539. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7540. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7541. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7542. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7543. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7544. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7545. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7546. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7547. }
  7548. else
  7549. {
  7550. hideRowsList.Add(Row + startIndex + HideRows);
  7551. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7552. }
  7553. HideRows += 2;
  7554. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7555. if (leftBindData != null)
  7556. {
  7557. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7558. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7559. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7560. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7561. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7562. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7563. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7564. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7565. }
  7566. else
  7567. {
  7568. hideRowsList.Add(Row + startIndex + HideRows);
  7569. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7570. }
  7571. HideRows += 2;
  7572. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7573. if (leftBindData != null)
  7574. {
  7575. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7576. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7577. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7578. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7579. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7580. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7581. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7582. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7583. }
  7584. else
  7585. {
  7586. hideRowsList.Add(Row + startIndex + HideRows);
  7587. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7588. }
  7589. HideRows += 2;
  7590. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7591. if (leftBindData != null)
  7592. {
  7593. ////TBR
  7594. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7595. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7596. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7597. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7598. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7599. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7600. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7601. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7602. }
  7603. else
  7604. {
  7605. hideRowsList.Add(Row + startIndex + HideRows);
  7606. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7607. }
  7608. HideRows += 2;
  7609. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7610. if (leftBindData != null)
  7611. {
  7612. ////SGR
  7613. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7614. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7615. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7616. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7617. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7618. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7619. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7620. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7621. }
  7622. else
  7623. {
  7624. hideRowsList.Add(Row + startIndex + HideRows);
  7625. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7626. }
  7627. HideRows += 2;
  7628. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7629. if (leftBindData != null)
  7630. {
  7631. ////JS/ES
  7632. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7633. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7634. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7635. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7636. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7637. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7638. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7639. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7640. }
  7641. else
  7642. {
  7643. hideRowsList.Add(Row + startIndex + HideRows);
  7644. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7645. }
  7646. HideRows += 2;
  7647. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7648. if (leftBindData != null)
  7649. {
  7650. ////SUITE
  7651. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7652. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7653. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7654. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7655. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7656. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7657. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7658. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7659. }
  7660. else
  7661. {
  7662. hideRowsList.Add(Row + startIndex + HideRows);
  7663. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7664. }
  7665. HideRows += 2;
  7666. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7667. if (leftBindData != null)
  7668. {
  7669. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7670. designer.SetDataSource("DJRS", leftBindData.rs);
  7671. designer.SetDataSource("DJXS", leftBindData.xs);
  7672. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7673. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7674. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7675. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7676. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7677. }
  7678. else
  7679. {
  7680. hideRowsList.Add(Row + startIndex + HideRows);
  7681. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7682. }
  7683. HideRows += 2;
  7684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7685. if (leftBindData != null)
  7686. {
  7687. designer.SetDataSource("HCPCB", leftBindData.cb);
  7688. designer.SetDataSource("HCPRS", leftBindData.rs);
  7689. designer.SetDataSource("HCPXS", leftBindData.xs);
  7690. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7691. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7692. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7693. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7694. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7695. }
  7696. else
  7697. {
  7698. hideRowsList.Add(Row + startIndex + HideRows);
  7699. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7700. }
  7701. HideRows += 2;
  7702. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7703. if (leftBindData != null)
  7704. {
  7705. designer.SetDataSource("CPCB", leftBindData.cb);
  7706. designer.SetDataSource("CPRS", leftBindData.rs);
  7707. designer.SetDataSource("CPXS", leftBindData.xs);
  7708. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7709. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7710. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7711. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7712. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7713. }
  7714. else
  7715. {
  7716. hideRowsList.Add(Row + startIndex + HideRows);
  7717. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7718. }
  7719. HideRows += 2;
  7720. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7721. if (leftBindData != null)
  7722. {
  7723. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7724. designer.SetDataSource("GWRS", leftBindData.rs);
  7725. designer.SetDataSource("GWXS", leftBindData.xs);
  7726. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7727. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7728. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7729. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7730. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7731. }
  7732. else
  7733. {
  7734. hideRowsList.Add(Row + startIndex + HideRows);
  7735. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7736. }
  7737. HideRows += 2;
  7738. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7739. if (leftBindData != null)
  7740. {
  7741. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7742. designer.SetDataSource("LYJRS", leftBindData.rs);
  7743. designer.SetDataSource("LYJXS", leftBindData.xs);
  7744. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7745. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7746. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7747. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7748. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7749. }
  7750. else
  7751. {
  7752. hideRowsList.Add(Row + startIndex + HideRows);
  7753. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7754. }
  7755. #endregion
  7756. #region A段Right信息
  7757. var right = dto.rightInfo.Find(x => x.Type == "A");
  7758. if (right == null)
  7759. {
  7760. return Ok(jw);
  7761. }
  7762. HideRows += 4;
  7763. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7764. if (rightBindData != null)
  7765. {
  7766. //经济舱 + 双人间 TBR
  7767. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7768. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7769. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7770. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7771. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7772. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7773. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7774. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7775. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7776. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7777. }
  7778. else
  7779. {
  7780. hideRowsList.Add(Row + startIndex + HideRows);
  7781. }
  7782. HideRows += 2;
  7783. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7784. if (rightBindData != null)
  7785. {
  7786. //经济舱 + 单人间 SGR
  7787. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7788. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7789. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7790. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7791. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7792. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7793. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7794. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7795. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7796. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7797. }
  7798. else
  7799. {
  7800. hideRowsList.Add(Row + startIndex + HideRows);
  7801. }
  7802. HideRows += 2;
  7803. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7804. if (rightBindData != null)
  7805. {
  7806. //公务舱 + 单人间 SGR
  7807. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7808. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7809. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7810. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7811. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7812. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7813. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7814. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7815. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7816. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7817. }
  7818. else
  7819. {
  7820. hideRowsList.Add(Row + startIndex + HideRows);
  7821. }
  7822. HideRows += 2;
  7823. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7824. if (rightBindData != null)
  7825. {
  7826. //公务舱 + 小套房 JSES
  7827. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7828. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7829. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7830. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7831. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7832. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7833. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7834. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7835. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7836. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7837. }
  7838. else
  7839. {
  7840. hideRowsList.Add(Row + startIndex + HideRows);
  7841. }
  7842. HideRows += 2;
  7843. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7844. if (rightBindData != null)
  7845. {
  7846. //公务舱 + 小套房 JSES
  7847. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7848. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7849. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7850. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7851. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7852. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7853. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7854. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7855. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7856. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7857. }
  7858. else
  7859. {
  7860. hideRowsList.Add(Row + startIndex + HideRows);
  7861. }
  7862. HideRows += 2;
  7863. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7864. if (rightBindData != null)
  7865. {
  7866. //经济舱 + 大套房
  7867. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7868. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7869. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7870. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7871. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7872. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7873. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7874. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7875. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7876. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7877. }
  7878. else
  7879. {
  7880. hideRowsList.Add(Row + startIndex + HideRows);
  7881. }
  7882. HideRows += 2;
  7883. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7884. if (rightBindData != null)
  7885. {
  7886. //头等舱 + 小套房 JSES
  7887. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7888. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7889. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7890. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7891. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7892. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7893. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7894. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7895. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7896. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7897. }
  7898. else
  7899. {
  7900. hideRowsList.Add(Row + startIndex + HideRows);
  7901. }
  7902. HideRows += 2;
  7903. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7904. if (rightBindData != null)
  7905. {
  7906. //头等舱 + 大套房
  7907. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7908. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7909. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7910. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7911. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7912. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7913. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7914. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7915. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7916. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7917. }
  7918. else
  7919. {
  7920. hideRowsList.Add(Row + startIndex + HideRows);
  7921. }
  7922. #endregion
  7923. #region B段标题清空
  7924. designer.SetDataSource("CostBDRCB", "");
  7925. designer.SetDataSource("CostBRS", "");
  7926. designer.SetDataSource("CostBXS", "");
  7927. designer.SetDataSource("CostBZCB", "");
  7928. designer.SetDataSource("CostBDRBJ", "");
  7929. designer.SetDataSource("CostBZBJ", "");
  7930. designer.SetDataSource("CostBDRLR", "");
  7931. designer.SetDataSource("CostBZLR", "");
  7932. designer.SetDataSource("CostBDRCBOM", "");
  7933. designer.SetDataSource("CostBRSOM", "");
  7934. designer.SetDataSource("CostBZCBOM", "");
  7935. designer.SetDataSource("CostBDRBJOM", "");
  7936. designer.SetDataSource("CostBZBJOM", "");
  7937. designer.SetDataSource("CostBDRLROM", "");
  7938. designer.SetDataSource("CostBZLROM", "");
  7939. #endregion
  7940. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7941. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7942. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7943. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7944. designer.SetDataSource("DJName", "地接(CNY)");
  7945. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7946. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7947. designer.SetDataSource("GWName", "公务(CNY)");
  7948. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7949. designer.SetDataSource("LYJName", "零用金(CNY)");
  7950. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7951. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7952. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7953. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7954. designer.SetDataSource("BXName", "保险(CNY)");
  7955. designer.SetDataSource("VisaName", "签证(CNY)");
  7956. #region B段基本数据
  7957. if (dto.costType == "B")
  7958. {
  7959. left = dto.leftInfo.Find(x => x.Type == "B");
  7960. if (left == null)
  7961. {
  7962. return Ok(jw);
  7963. }
  7964. #region B段left数据
  7965. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7966. if (leftBindData != null)
  7967. {
  7968. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7969. designer.SetDataSource("BHSRS", leftBindData.rs);
  7970. designer.SetDataSource("BHSXS", leftBindData.xs);
  7971. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7972. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7973. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7974. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7975. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7976. }
  7977. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7978. if (leftBindData != null)
  7979. {
  7980. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7981. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7982. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7983. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7984. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7985. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7986. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7987. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7988. }
  7989. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7990. if (leftBindData != null)
  7991. {
  7992. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7993. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7994. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7995. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7996. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7997. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7998. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7999. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8000. }
  8001. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8002. if (leftBindData != null)
  8003. {
  8004. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8005. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8006. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8007. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8008. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8009. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8010. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8011. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8012. }
  8013. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8014. if (leftBindData != null)
  8015. {
  8016. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8017. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8018. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8019. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8020. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8021. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8022. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8023. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8024. }
  8025. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8026. if (leftBindData != null)
  8027. {
  8028. designer.SetDataSource("BCPCB", leftBindData.cb);
  8029. designer.SetDataSource("BCPRS", leftBindData.rs);
  8030. designer.SetDataSource("BCPXS", leftBindData.xs);
  8031. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8032. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8033. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8034. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8035. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8036. }
  8037. //TBR
  8038. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8039. if (leftBindData != null)
  8040. {
  8041. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8042. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8043. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8044. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8045. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8046. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8047. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8048. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8049. }
  8050. //SGR
  8051. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8052. if (leftBindData != null)
  8053. {
  8054. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8055. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8056. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8057. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8058. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8059. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8060. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8061. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8062. }
  8063. //JS/ES
  8064. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8065. if (leftBindData != null)
  8066. {
  8067. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8068. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8069. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8070. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8071. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8072. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8073. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8074. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8075. }
  8076. //SUITE
  8077. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8078. if (leftBindData != null)
  8079. {
  8080. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8081. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8082. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8083. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8084. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8085. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8086. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8087. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8088. }
  8089. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8090. if (leftBindData != null)
  8091. {
  8092. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8093. designer.SetDataSource("BDJRS", leftBindData.rs);
  8094. designer.SetDataSource("BDJXS", leftBindData.xs);
  8095. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8096. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8097. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8098. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8099. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8100. }
  8101. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8102. if (leftBindData != null)
  8103. {
  8104. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8105. designer.SetDataSource("BGWRS", leftBindData.rs);
  8106. designer.SetDataSource("BGWXS", leftBindData.xs);
  8107. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8108. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8109. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8110. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8111. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8112. }
  8113. #region 优化方案
  8114. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8115. //excelBind.Add("零用金", new {
  8116. //cb="",
  8117. //rs="",
  8118. //xs ="",
  8119. //zcb = "",
  8120. //});
  8121. #endregion
  8122. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8123. if (leftBindData != null)
  8124. {
  8125. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8126. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8127. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8128. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8129. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8130. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8131. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8132. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8133. }
  8134. #endregion
  8135. #region B段Right信息
  8136. right = dto.rightInfo.Find(x => x.Type == "B");
  8137. if (right == null)
  8138. {
  8139. return Ok(jw);
  8140. }
  8141. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8142. if (rightBindData != null)
  8143. {
  8144. //经济舱 + 双人间 TBR
  8145. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8146. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8147. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8148. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8149. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8150. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8151. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8152. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8153. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8154. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8155. }
  8156. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8157. if (rightBindData != null)
  8158. {
  8159. //经济舱 + 单人间 SGR
  8160. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8161. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8162. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8163. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8164. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8165. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8166. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8167. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8168. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8169. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8170. }
  8171. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8172. if (rightBindData != null)
  8173. {
  8174. //公务舱 + 单人间 SGR
  8175. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8176. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8177. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8178. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8179. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8180. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8181. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8182. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8183. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8184. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8185. }
  8186. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8187. if (rightBindData != null)
  8188. {
  8189. //公务舱 + 小套房 JSES
  8190. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8191. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8192. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8193. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8194. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8195. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8196. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8197. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8198. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8199. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8200. }
  8201. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8202. if (rightBindData != null)
  8203. {
  8204. //公务舱 + 小套房 JSES
  8205. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8206. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8207. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8208. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8209. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8210. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8211. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8212. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8213. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8214. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8215. }
  8216. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8217. if (rightBindData != null)
  8218. {
  8219. //经济舱 + 大套房
  8220. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8221. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8222. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8223. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8224. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8225. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8226. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8227. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8228. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8229. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8230. }
  8231. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8232. if (rightBindData != null)
  8233. {
  8234. //头等舱 + 小套房 JSES
  8235. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8236. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8237. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8238. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8239. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8240. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8241. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8242. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8243. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8244. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8245. }
  8246. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8247. if (rightBindData != null)
  8248. {
  8249. //头等舱 + 大套房
  8250. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8251. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8252. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8253. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8254. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8255. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8256. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8257. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8258. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8259. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8260. }
  8261. #endregion
  8262. #region 标题
  8263. designer.SetDataSource("CostBDRCB", "单人成本");
  8264. designer.SetDataSource("CostBRS", "人数");
  8265. designer.SetDataSource("CostBXS", "系数");
  8266. designer.SetDataSource("CostBZCB", "总成本");
  8267. designer.SetDataSource("CostBDRBJ", "单人报价");
  8268. designer.SetDataSource("CostBZBJ", "总报价");
  8269. designer.SetDataSource("CostBDRLR", "单人利润");
  8270. designer.SetDataSource("CostBZLR", "总利润");
  8271. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8272. designer.SetDataSource("CostBRSOM", "人数");
  8273. designer.SetDataSource("CostBZCBOM", "总成本");
  8274. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8275. designer.SetDataSource("CostBZBJOM", "总报价");
  8276. designer.SetDataSource("CostBDRLROM", "单人利润");
  8277. designer.SetDataSource("CostBZLROM", "总利润");
  8278. #endregion
  8279. }
  8280. #endregion
  8281. designer.SetDataSource("TzZCB2", TzZCB2);
  8282. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8283. designer.SetDataSource("TzZLR2", TzZLR2);
  8284. string[] dataSourceKeys = new string[]
  8285. {
  8286. "VF",
  8287. "TGS",
  8288. "TGOF",
  8289. "TGM",
  8290. "TGA",
  8291. "TGTF",
  8292. "TGEF",
  8293. "CFM",
  8294. "CFOF",
  8295. "B",
  8296. "L",
  8297. "D",
  8298. "TBR",
  8299. "SGR",
  8300. "JSES",
  8301. "Suite",
  8302. "TV",
  8303. "1L",
  8304. "IF",
  8305. "EF",
  8306. "BRF",
  8307. "TE",
  8308. "TGT",
  8309. "DRVT",
  8310. "PC",
  8311. "TLF",
  8312. "ECT"
  8313. };
  8314. foreach (var item in dataSourceKeys)
  8315. {
  8316. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8317. if (find != null)
  8318. {
  8319. designer.SetDataSource(item, find.text);
  8320. }
  8321. else
  8322. {
  8323. designer.SetDataSource(item, 0);
  8324. }
  8325. }
  8326. designer.SetDataSource(dt);
  8327. //根据数据源处理生成报表内容
  8328. designer.Process();
  8329. designer.Workbook.Worksheets[0].Name = "清单";
  8330. Worksheet sheet = designer.Workbook.Worksheets[0];
  8331. foreach (var Rowindex in hideRowsList)
  8332. {
  8333. ws.Cells.HideRows(Rowindex, 2);
  8334. }
  8335. byte[] bytes = null;
  8336. string strFileName = di.TeamName + "-团组-成本.xls";
  8337. using (MemoryStream stream = new MemoryStream())
  8338. {
  8339. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8340. bytes = stream.ToArray();
  8341. }
  8342. return Ok(JsonView(true, "", new
  8343. {
  8344. Data = bytes,
  8345. strFileName,
  8346. }));
  8347. }
  8348. /// <summary>
  8349. /// 导出客户报表
  8350. /// </summary>
  8351. /// <returns></returns>
  8352. [HttpPost]
  8353. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8354. {
  8355. var jw = JsonView(false);
  8356. if (dto.Diid == 0)
  8357. {
  8358. return Ok(JsonView(false, "请传递团组id"));
  8359. }
  8360. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8361. if (deleInfo.Code != 0)
  8362. {
  8363. return Ok(JsonView(false, "团组信息查询失败!"));
  8364. }
  8365. var di = deleInfo.Data as DelegationInfoWebView;
  8366. if (di == null)
  8367. {
  8368. return Ok(JsonView(false, "团组信息查询失败!"));
  8369. }
  8370. //文件名
  8371. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8372. //获取模板
  8373. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8374. //载入模板
  8375. Document doc = new Document(tmppath);
  8376. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8377. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8378. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8379. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8380. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8381. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8382. if (AParameter == null)
  8383. {
  8384. return Ok(JsonView(false, "系数不存在!"));
  8385. }
  8386. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8387. , TzAirDesc, TzZCost;
  8388. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8389. = TzAirDesc = TzZCost = string.Empty;
  8390. TzNumber = AParameter.CostTypenumber.ToString();
  8391. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8392. CarGuides1 = dto.CarGuides1;
  8393. Meal = dto.Meal;
  8394. SubsidizedMeals = dto.SubsidizedMeals;
  8395. NightRepair = dto.NightRepair;
  8396. AttractionsTickets = dto.AttractionsTickets;
  8397. MiscellaneousFees = dto.MiscellaneousFees;
  8398. ATip = dto.ATip;
  8399. TzHotelDesc = "";
  8400. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8401. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8402. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8403. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8404. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8405. TzAirDesc = "";
  8406. TzZCost = dto.TzZCost;
  8407. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8408. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8409. var index = 1;
  8410. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8411. foreach (var item in TzHotelDescArr)
  8412. {
  8413. if (AinfoArr != null)
  8414. {
  8415. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8416. if (Ainfo != null)
  8417. {
  8418. if (int.Parse(Ainfo.rs) <= 0)
  8419. {
  8420. continue;
  8421. }
  8422. var hotelText = string.Empty;
  8423. switch (item)
  8424. {
  8425. case "SGR":
  8426. hotelText = "单人间";
  8427. break;
  8428. case "JSES":
  8429. hotelText = "小套房";
  8430. break;
  8431. case "SUITE":
  8432. hotelText = "套房";
  8433. break;
  8434. case "TBR":
  8435. hotelText = "双人间";
  8436. break;
  8437. }
  8438. if (item != "TBR")
  8439. {
  8440. 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";
  8441. }
  8442. else
  8443. {
  8444. 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";
  8445. }
  8446. index++;
  8447. }
  8448. }
  8449. }
  8450. index = 1;
  8451. foreach (var item in TzAirDescArr)
  8452. {
  8453. if (AinfoArr != null)
  8454. {
  8455. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8456. if (Ainfo != null)
  8457. {
  8458. if (int.Parse(Ainfo.rs) <= 0)
  8459. {
  8460. continue;
  8461. }
  8462. 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";
  8463. index++;
  8464. }
  8465. }
  8466. }
  8467. if (dto.costType == "B")
  8468. {
  8469. if (BParameter == null)
  8470. {
  8471. return Ok(JsonView(false, "B段系数不存在!"));
  8472. }
  8473. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8474. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8475. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8476. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8477. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8478. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8479. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8480. foreach (var item in TzHotelDescArr)
  8481. {
  8482. if (AinfoArr != null)
  8483. {
  8484. TzHotelDesc += "B段信息 \r\n";
  8485. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8486. if (Ainfo != null)
  8487. {
  8488. if (int.Parse(Ainfo.rs) <= 0)
  8489. {
  8490. continue;
  8491. }
  8492. var hotelText = string.Empty;
  8493. switch (item)
  8494. {
  8495. case "SGR":
  8496. hotelText = "单人间";
  8497. break;
  8498. case "JSES":
  8499. hotelText = "小套房";
  8500. break;
  8501. case "SUITE":
  8502. hotelText = "套房";
  8503. break;
  8504. case "TBR":
  8505. hotelText = "双人间";
  8506. break;
  8507. }
  8508. if (item != "TBR")
  8509. {
  8510. 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";
  8511. }
  8512. else
  8513. {
  8514. 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";
  8515. }
  8516. index++;
  8517. }
  8518. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8519. }
  8520. }
  8521. index = 1;
  8522. foreach (var item in TzAirDescArr)
  8523. {
  8524. if (AinfoArr != null)
  8525. {
  8526. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8527. if (Ainfo != null)
  8528. {
  8529. if (int.Parse(Ainfo.rs) <= 0)
  8530. {
  8531. continue;
  8532. }
  8533. 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";
  8534. index++;
  8535. }
  8536. }
  8537. }
  8538. }
  8539. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8540. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8541. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8542. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8543. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8544. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8545. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8546. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8547. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8548. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8549. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8550. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8551. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8552. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8553. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8554. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8555. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8556. DickeyValue.Add("TzZCost", TzZCost);
  8557. foreach (var key in DickeyValue.Keys)
  8558. {
  8559. if (doc.Range.Bookmarks[key] != null)
  8560. {
  8561. Bookmark mark = doc.Range.Bookmarks[key];
  8562. mark.Text = DickeyValue[key];
  8563. }
  8564. }
  8565. byte[] bytes = null;
  8566. string strFileName = di.TeamName + "-客户报价.doc";
  8567. using (MemoryStream stream = new MemoryStream())
  8568. {
  8569. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8570. bytes = stream.ToArray();
  8571. }
  8572. return Ok(JsonView(true, "", new
  8573. {
  8574. Data = bytes,
  8575. strFileName,
  8576. }));
  8577. }
  8578. /// <summary>
  8579. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8580. /// </summary>
  8581. /// <param name="dto"></param>
  8582. /// <returns></returns>
  8583. [HttpPost]
  8584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8585. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8586. {
  8587. try
  8588. {
  8589. #region 参数验证
  8590. if (dto.DiId < 0)
  8591. {
  8592. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8593. }
  8594. List<int> cTableIds = new List<int>() {
  8595. 76 ,//酒店预订
  8596. 77 ,//行程
  8597. 79 ,//车/导游地接
  8598. 80 ,//签证
  8599. 81 ,//邀请/公务活
  8600. 82 ,//团组客户保险
  8601. 85 ,//机票预订
  8602. 98 ,//其他款项
  8603. 285 ,//收款退还
  8604. 751 ,//酒店早餐
  8605. 1015 // 超支费用
  8606. };
  8607. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8608. {
  8609. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8610. }
  8611. #endregion
  8612. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8613. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8614. if (_GroupCostParameters.Count <= 0)
  8615. {
  8616. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8617. }
  8618. if (_GroupCostParameters[0].IsShare == 0)
  8619. {
  8620. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8621. }
  8622. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8623. //处理date为空问题
  8624. if (_GroupCosts.Count > 0)
  8625. {
  8626. for (int i = 0; i < _GroupCosts.Count; i++)
  8627. {
  8628. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8629. {
  8630. if (i > 0)
  8631. {
  8632. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8633. }
  8634. }
  8635. }
  8636. }
  8637. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8638. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8639. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8640. string currCode = "";
  8641. #region currCode 验证
  8642. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8643. if (isInt)
  8644. {
  8645. var currData = currDatas.Find(it => it.Id == intCurrency);
  8646. if (currData != null)
  8647. {
  8648. currCode = currData.Name;
  8649. }
  8650. }
  8651. else
  8652. {
  8653. currCode = _GroupCostParameters[0].Currency.Trim();
  8654. }
  8655. #endregion
  8656. //op,酒店单段模式存储
  8657. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8658. {
  8659. CurrencyCode = currCode,
  8660. Rate = _GroupCostParameters[0].Rate,
  8661. CostType = _GroupCostParameters[0].CostType,
  8662. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8663. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8664. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8665. };
  8666. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8667. if (_GroupCostParameters.Count == 2)
  8668. {
  8669. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8670. }
  8671. foreach (var item in _GroupCostParameters)
  8672. {
  8673. decimal _rate = 1;
  8674. decimal _rate1 = item.Rate;
  8675. decimal _scale = 1;
  8676. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8677. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8678. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8679. //if (userInfo != null)
  8680. //{
  8681. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8682. // {
  8683. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8684. // {
  8685. // _scale = 1.00M;
  8686. // }
  8687. // }
  8688. //}
  8689. #endregion
  8690. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8691. {
  8692. CurrencyCode = currCode,
  8693. Rate = _rate1,
  8694. CostType = item.CostType,
  8695. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8696. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8697. CostTypeNumber = item.CostTypenumber
  8698. };
  8699. if (_GroupCostParameters.Count > 1)
  8700. {
  8701. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8702. }
  8703. else
  8704. {
  8705. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8706. }
  8707. if (dto.CTable == 79)//
  8708. {
  8709. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8710. modulePromptInfo.TotalCost = item.DJCB;
  8711. }
  8712. List<string> costTypes = new List<string>() { "A", "B" };
  8713. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8714. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8715. if (_GroupCostsDuplicates.Count() == 1)
  8716. {
  8717. _GroupCostsTypeData = _GroupCosts;
  8718. }
  8719. else
  8720. {
  8721. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8722. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8723. }
  8724. /*
  8725. * 76 酒店预订
  8726. * 77 行程
  8727. * 79 车/导游地接
  8728. * 80 签证
  8729. * 81 邀请/公务活动
  8730. * 82 团组客户保险
  8731. * 85 机票预订
  8732. * 98 其他款项
  8733. * 285 收款退还
  8734. * 751 酒店早餐
  8735. * 1015 超支费用
  8736. */
  8737. switch (dto.CTable)
  8738. {
  8739. case 76: // 酒店预订
  8740. _ModuleSubPromptInfo.AddRange(
  8741. _GroupCostsTypeData.Select(it => new
  8742. {
  8743. it.DAY,
  8744. it.Date,
  8745. it.ACCON,
  8746. it.ITIN,
  8747. it.SGR,
  8748. it.TBR,
  8749. it.JS_ES,
  8750. it.Suite
  8751. })
  8752. );
  8753. break;
  8754. case 79: // 车/导游地接
  8755. _ModuleSubPromptInfo.AddRange(
  8756. _GroupCostsTypeData.Select(it => new
  8757. {
  8758. Date = it.Date, //日期
  8759. CarFee = it.CarCost * _rate * _scale, //车费用
  8760. CarType = it.CarType, //车型
  8761. DriverFee = it.CFS * _rate * _scale, //司机工资
  8762. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8763. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8764. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8765. GuideFee = it.TGS * _rate * _scale, //导游费用
  8766. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8767. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8768. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8769. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8770. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8771. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8772. Breakfast = it.B * _rate * _scale, //早餐费
  8773. Lunch = it.L * _rate * _scale, //午餐费
  8774. Dinner = it.D * _rate * _scale, //晚餐费
  8775. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8776. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8777. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8778. TicketFee = it.EF * _rate * _scale, //门票费
  8779. TicketRemark = it.EFR, //门票费描述
  8780. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8781. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8782. SpentCash = it.PC * _rate * _scale, //零用金
  8783. LeadersFee = it.TLF * _rate * _scale, //领队费
  8784. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8785. })
  8786. );
  8787. break;
  8788. case 85: // 机票
  8789. List<dynamic> datas = new List<dynamic>();
  8790. datas.Add(
  8791. new
  8792. {
  8793. AirType = "经济舱",
  8794. AirNum = item.JJCRS,
  8795. AirDRCB = item.JJCCB,
  8796. AirZCB = (item.JJCRS * item.JJCCB)
  8797. }
  8798. );
  8799. datas.Add(
  8800. new
  8801. {
  8802. AirType = "公务舱",
  8803. AirNum = item.GWCRS,
  8804. AirDRCB = item.GWCCB,
  8805. AirZCB = (item.GWCRS * item.GWCCB)
  8806. }
  8807. );
  8808. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8809. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8810. modulePromptInfo.Data = new
  8811. {
  8812. airFeeData = datas,
  8813. airInitData = initDatas
  8814. };
  8815. _ModulePromptInfos.Add(modulePromptInfo);
  8816. break;
  8817. default:
  8818. break;
  8819. }
  8820. }
  8821. if (dto.CTable != 85)
  8822. {
  8823. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8824. _ModulePromptInfos.Add(_ModulePromptInfo);
  8825. }
  8826. _view.ModulePromptInfos = _ModulePromptInfos;
  8827. return Ok(JsonView(true, "操作成功!", _view));
  8828. }
  8829. catch (Exception ex)
  8830. {
  8831. return Ok(JsonView(false, ex.Message));
  8832. }
  8833. }
  8834. /// <summary>
  8835. /// 根据黑屏代码重新生成行程
  8836. /// </summary>
  8837. /// <param name="dto"></param>
  8838. /// <returns></returns>
  8839. [HttpPost]
  8840. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8841. {
  8842. var jw = JsonView(false);
  8843. var Create = _GroupCostRepository.
  8844. CreateGroupCostByBlackCode(dto.Diid);
  8845. jw.Msg = Create.Msg;
  8846. if (Create.Code == 0)
  8847. {
  8848. jw.Code = 200;
  8849. jw.Data = new
  8850. {
  8851. groupCost = Create.Data,
  8852. blackCodeIsTrue = true
  8853. };
  8854. }
  8855. else
  8856. {
  8857. jw.Code = 400;
  8858. jw.Data = new
  8859. {
  8860. groupCost = Create.Data,
  8861. blackCodeIsTrue = false,
  8862. };
  8863. }
  8864. return Ok(jw);
  8865. }
  8866. /// <summary>
  8867. /// 成本获取OP历史车费用
  8868. /// </summary>
  8869. /// <param name="dto"></param>
  8870. /// <returns></returns>
  8871. [HttpPost]
  8872. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8873. {
  8874. var jw = JsonView(false);
  8875. try
  8876. {
  8877. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8878. //获取现有所有车的数据
  8879. if (!dto.Param.IsNullOrWhiteSpace())
  8880. {
  8881. string sql = $@"
  8882. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8883. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8884. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8885. 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
  8886. AND gctggr.ServiceEndTime is not NULL
  8887. ORDER by gctggrc.id DESC
  8888. ";
  8889. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8890. var numeberResult = await Task.Run(() =>
  8891. {
  8892. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8893. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8894. return numberArr;
  8895. });
  8896. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8897. foreach (var item in numeberResult)
  8898. {
  8899. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8900. {
  8901. Country = "数据异常!",
  8902. City = string.Empty,
  8903. };
  8904. item.Area = find.Country + " " + find.City;
  8905. }
  8906. dbResult.AddRange(numeberResult);
  8907. if (dto.Param.Contains("、"))
  8908. {
  8909. var sp = dto.Param.Split("、");
  8910. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8911. .Where(x =>
  8912. {
  8913. return System.Array.Exists(sp, e =>
  8914. {
  8915. bool where = false;
  8916. if (x.Area != null)
  8917. {
  8918. where = x.Area.Contains(e);
  8919. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8920. {
  8921. return false;
  8922. }
  8923. }
  8924. if (x.PriceName != null && !where)
  8925. {
  8926. where = x.PriceName.Contains(e);
  8927. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8928. {
  8929. return false;
  8930. }
  8931. }
  8932. return where;
  8933. });
  8934. }).ToList();
  8935. }
  8936. else
  8937. {
  8938. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8939. .Where(x =>
  8940. {
  8941. bool where = false;
  8942. if (x.Area != null)
  8943. {
  8944. where = x.Area.Contains(dto.Param);
  8945. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8946. {
  8947. return false;
  8948. }
  8949. }
  8950. if (x.PriceName != null && !where)
  8951. {
  8952. where = x.PriceName.Contains(dto.Param);
  8953. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8954. {
  8955. return false;
  8956. }
  8957. }
  8958. return where;
  8959. }
  8960. )
  8961. .ToList();
  8962. }
  8963. }
  8964. var view = dbResult.Select(x =>
  8965. {
  8966. decimal dp = 0.00M;
  8967. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8968. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8969. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8970. {
  8971. if (startB && endB)
  8972. {
  8973. var timesp = endD.Subtract(startD);
  8974. if ((timesp.Days + 1) != 0)
  8975. {
  8976. dp = x.Price / (timesp.Days + 1);
  8977. }
  8978. }
  8979. }
  8980. else
  8981. {
  8982. dp = x.Price;
  8983. }
  8984. return new
  8985. {
  8986. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8987. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8988. x.Area,
  8989. x.id,
  8990. price = x.Price.ToString("F2"),
  8991. x.PriceName,
  8992. x.PriceContent,
  8993. x.TeamName,
  8994. x.DatePrice,
  8995. dayPrice = dp.ToString("F2"),
  8996. };
  8997. }).OrderByDescending(x => x.id).ToList();
  8998. jw = JsonView(true, "获取成功!", view);
  8999. }
  9000. catch (Exception e)
  9001. {
  9002. jw = JsonView(false, e.Message);
  9003. }
  9004. return Ok(jw);
  9005. }
  9006. #endregion
  9007. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9008. /// <summary>
  9009. /// 酒店预订
  9010. /// 酒店费用列表 根据团组Id查询
  9011. /// </summary>
  9012. /// <param name="_dto"></param>
  9013. /// <returns></returns>
  9014. [HttpPost]
  9015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9016. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9017. {
  9018. #region 参数验证
  9019. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9020. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9021. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9022. #region 团组操作权限验证 76 酒店预定模块
  9023. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9024. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9025. #endregion
  9026. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9027. #region 页面操作权限验证
  9028. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9029. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9030. #endregion
  9031. #endregion
  9032. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9033. }
  9034. /// <summary>
  9035. /// 酒店预订
  9036. /// 基础数据
  9037. /// </summary>
  9038. /// <param name="_dto"></param>
  9039. /// <returns></returns>
  9040. [HttpPost]
  9041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9042. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9043. {
  9044. #region 参数验证
  9045. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9046. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9047. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9048. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9049. #region 页面操作权限验证
  9050. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9051. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9052. #endregion
  9053. #region 团组操作权限验证 76 酒店预定模块
  9054. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9055. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9056. #endregion
  9057. #endregion
  9058. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9059. }
  9060. /// <summary>
  9061. /// 酒店预订
  9062. /// 创建 入住卷号码
  9063. /// </summary>
  9064. /// <param name="_dto"></param>
  9065. /// <returns></returns>
  9066. [HttpPost]
  9067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9068. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9069. {
  9070. try
  9071. {
  9072. #region 参数验证
  9073. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9074. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9075. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9076. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9077. #region 页面操作权限验证
  9078. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9079. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9080. #endregion
  9081. #region 团组操作权限验证 76 酒店预定模块
  9082. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9083. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9084. #endregion
  9085. #endregion
  9086. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9087. if (data.Code != 0)
  9088. {
  9089. return Ok(JsonView(false, data.Msg));
  9090. }
  9091. return Ok(JsonView(true, data.Msg, data.Data));
  9092. }
  9093. catch (Exception ex)
  9094. {
  9095. return Ok(JsonView(false, ex.Message));
  9096. }
  9097. }
  9098. /// <summary>
  9099. /// 酒店预订
  9100. /// 详情
  9101. /// </summary>
  9102. /// <param name="_dto"></param>
  9103. /// <returns></returns>
  9104. [HttpPost]
  9105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9106. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9107. {
  9108. #region 参数验证
  9109. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9110. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9111. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9112. #region 团组操作权限验证 76 酒店预定模块
  9113. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9114. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9115. #endregion
  9116. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9117. #region 页面操作权限验证
  9118. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9119. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9120. #endregion
  9121. #endregion
  9122. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9123. }
  9124. /// <summary>
  9125. /// 酒店预订
  9126. /// Add Or Edit
  9127. /// </summary>
  9128. /// <param name="_dto"></param>
  9129. /// <returns></returns>
  9130. [HttpPost]
  9131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9132. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9133. {
  9134. #region 参数验证
  9135. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9136. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9137. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9138. #region 团组操作权限验证 76 酒店预定模块
  9139. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9140. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9141. #endregion
  9142. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9143. #region 页面操作权限验证
  9144. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9145. if (_dto.Id == 0) // Add
  9146. {
  9147. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9148. }
  9149. else if (_dto.Id > 1) // Edit
  9150. {
  9151. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9152. }
  9153. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9154. #endregion
  9155. #endregion
  9156. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9157. if (_view.Code != 200)
  9158. {
  9159. return Ok(_view);
  9160. }
  9161. #region 应用推送
  9162. try
  9163. {
  9164. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9165. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9166. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9167. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9168. //自动审核
  9169. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9170. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9171. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9172. }
  9173. catch (Exception ex)
  9174. {
  9175. }
  9176. #endregion
  9177. return Ok(_view);
  9178. }
  9179. /// <summary>
  9180. /// 酒店自动审核测试
  9181. /// Add Or Edit
  9182. /// </summary>
  9183. /// <param name="_dto"></param>
  9184. /// <returns></returns>
  9185. [HttpPost]
  9186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9187. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  9188. {
  9189. #region 应用推送
  9190. try
  9191. {
  9192. //自动审核
  9193. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9194. }
  9195. catch (Exception ex)
  9196. {
  9197. return Ok(JsonView(false, "操作失败"));
  9198. }
  9199. #endregion
  9200. return Ok(JsonView(false,"操作成功"));
  9201. }
  9202. /// <summary>
  9203. /// 酒店预订
  9204. /// Del
  9205. /// </summary>
  9206. /// <param name="_dto"></param>
  9207. /// <returns></returns>
  9208. [HttpPost]
  9209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9210. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9211. {
  9212. #region 参数验证
  9213. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9214. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9215. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9216. #region 团组操作权限验证 76 酒店预定模块
  9217. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9218. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9219. #endregion
  9220. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9221. #region 页面操作权限验证
  9222. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9223. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9224. #endregion
  9225. #endregion
  9226. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9227. }
  9228. /// <summary>
  9229. /// 酒店预订
  9230. /// 生成VOUCHER
  9231. /// 2024.05.06 之前版本
  9232. /// </summary>
  9233. /// <param name="_dto"></param>
  9234. /// <returns></returns>
  9235. [HttpPost]
  9236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9237. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9238. {
  9239. try
  9240. {
  9241. #region 参数验证
  9242. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9243. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9244. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9245. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9246. #region 团组操作权限验证 76 酒店预定模块
  9247. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9248. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9249. #endregion
  9250. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9251. #region 页面操作权限验证
  9252. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9253. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9254. #endregion
  9255. #endregion
  9256. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9257. //判断数据是否完整
  9258. if (hr != null)
  9259. {
  9260. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9261. {
  9262. string strFileName = "HotelStatement/";
  9263. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9264. if (dele != null)
  9265. strFileName += dele.TourCode;
  9266. //载入模板
  9267. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9268. Document doc = new Document(sss);
  9269. DocumentBuilder builder = new DocumentBuilder(doc);
  9270. #region 替换Word模板书签内容
  9271. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9272. //入住卷预定号码
  9273. if (doc.Range.Bookmarks["VNO"] != null)
  9274. {
  9275. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9276. mark.Text = hr.CheckNumber;
  9277. }
  9278. //酒店时间
  9279. if (doc.Range.Bookmarks["Date"] != null)
  9280. {
  9281. Bookmark mark = doc.Range.Bookmarks["Date"];
  9282. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9283. }
  9284. //团号
  9285. if (doc.Range.Bookmarks["TNo"] != null)
  9286. {
  9287. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9288. mark.Text = dele.TourCode;
  9289. }
  9290. //预定号码
  9291. if (doc.Range.Bookmarks["BookingId"] != null)
  9292. {
  9293. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9294. mark.Text = hr.ReservationsNo;
  9295. }
  9296. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9297. {
  9298. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9299. mark.Text = hr.DetermineNo;
  9300. }
  9301. //酒店城市
  9302. if (doc.Range.Bookmarks["City"] != null)
  9303. {
  9304. Bookmark mark = doc.Range.Bookmarks["City"];
  9305. mark.Text = hr.City;
  9306. }
  9307. //酒店名称
  9308. if (doc.Range.Bookmarks["HName"] != null)
  9309. {
  9310. Bookmark mark = doc.Range.Bookmarks["HName"];
  9311. mark.Text = hr.HotelName;
  9312. }
  9313. //酒店地址
  9314. if (doc.Range.Bookmarks["Address"] != null)
  9315. {
  9316. Bookmark mark = doc.Range.Bookmarks["Address"];
  9317. mark.Text = hr.HotelAddress;
  9318. }
  9319. //酒店电话
  9320. if (doc.Range.Bookmarks["Tel"] != null)
  9321. {
  9322. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9323. mark.Text = hr.HotelTel;
  9324. }
  9325. //酒店传真
  9326. if (doc.Range.Bookmarks["Fax"] != null)
  9327. {
  9328. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9329. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9330. {
  9331. mark.Text = hr.HotelFax;
  9332. }
  9333. }
  9334. //入住时间
  9335. if (doc.Range.Bookmarks["CIn"] != null)
  9336. {
  9337. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9338. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9339. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9340. }
  9341. //退房时间
  9342. if (doc.Range.Bookmarks["COut"] != null)
  9343. {
  9344. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9345. Bookmark mark = doc.Range.Bookmarks["COut"];
  9346. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9347. }
  9348. //客户名称
  9349. if (doc.Range.Bookmarks["GName"] != null)
  9350. {
  9351. string guestName = "";
  9352. string[] clients = new string[] { };
  9353. if (hr.GuestName.Contains(","))
  9354. {
  9355. clients = hr.GuestName.Split(",");
  9356. }
  9357. else
  9358. {
  9359. clients = new string[] { hr.GuestName };
  9360. }
  9361. List<int> clientIds_int = new List<int>();
  9362. if (clients.Length > 0)
  9363. {
  9364. foreach (var item in clients)
  9365. {
  9366. if (item.IsNumeric())
  9367. {
  9368. clientIds_int.Add(int.Parse(item));
  9369. }
  9370. }
  9371. }
  9372. if (clientIds_int.Count > 0)
  9373. {
  9374. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9375. foreach (var client in _clientDatas)
  9376. {
  9377. //男
  9378. if (client.Sex == 0) guestName += $"Mr.";
  9379. //女
  9380. else if (client.Sex == 1) guestName += $"Ms.";
  9381. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9382. {
  9383. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9384. }
  9385. //guestName += $"{client.Pinyin},";
  9386. }
  9387. if (guestName.Length > 0)
  9388. {
  9389. guestName = guestName.Substring(0, guestName.Length - 1);
  9390. }
  9391. }
  9392. else
  9393. {
  9394. guestName = hr.GuestName;
  9395. }
  9396. Bookmark mark = doc.Range.Bookmarks["GName"];
  9397. mark.Text = guestName;
  9398. }
  9399. //房间介绍
  9400. if (doc.Range.Bookmarks["ROOM"] != null)
  9401. {
  9402. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9403. mark.Text = hr.RoomExplanation;
  9404. }
  9405. //报价描述
  9406. if (doc.Range.Bookmarks["NOTE"] != null)
  9407. {
  9408. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9409. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9410. if (ss != null)
  9411. mark.Text = ss.Name;
  9412. }
  9413. //入住时间
  9414. if (doc.Range.Bookmarks["CheckIn"] != null)
  9415. {
  9416. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9417. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9418. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9419. }
  9420. //退房时间
  9421. if (doc.Range.Bookmarks["CheckOut"] != null)
  9422. {
  9423. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9424. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9425. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9426. }
  9427. //日期
  9428. if (doc.Range.Bookmarks["DT"] != null)
  9429. {
  9430. Bookmark mark = doc.Range.Bookmarks["DT"];
  9431. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9432. }
  9433. //名称
  9434. if (doc.Range.Bookmarks["VName"] != null)
  9435. {
  9436. Bookmark mark = doc.Range.Bookmarks["VName"];
  9437. mark.Text = hr.HotelName;
  9438. }
  9439. //号码
  9440. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9441. {
  9442. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9443. mark.Text = hr.CheckNumber;
  9444. }
  9445. #endregion
  9446. strFileName += "VOUCHER.doc";
  9447. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9448. doc.Save(fileDir);
  9449. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9450. return Ok(JsonView(true, "操作成功!", Url));
  9451. }
  9452. else
  9453. {
  9454. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9455. }
  9456. }
  9457. else
  9458. {
  9459. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9460. }
  9461. }
  9462. catch (Exception ex)
  9463. {
  9464. return Ok(JsonView(false, ex.Message));
  9465. }
  9466. }
  9467. /// <summary>
  9468. /// 酒店预订
  9469. /// 生成VOUCHER
  9470. /// 2024.05.06 之后版本
  9471. /// </summary>
  9472. /// <param name="_dto"></param>
  9473. /// <returns></returns>
  9474. [HttpPost]
  9475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9476. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9477. {
  9478. #region 参数验证
  9479. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9480. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9481. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9482. #region 团组操作权限验证 76 酒店预定模块
  9483. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9484. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9485. #endregion
  9486. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9487. #region 页面操作权限验证
  9488. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9489. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9490. #endregion
  9491. #endregion
  9492. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9493. //判断数据是否完整
  9494. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9495. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9496. string strFileName = "HotelStatement/";
  9497. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9498. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9499. #region 数据处理
  9500. List<int> guestIds = new List<int>();
  9501. int index = 0;
  9502. foreach (var item in hrDtas)
  9503. {
  9504. if (item.GuestName.Contains(","))
  9505. {
  9506. string[] guestIdArr = item.GuestName.Split(',');
  9507. foreach (var guestIdStr in guestIdArr)
  9508. {
  9509. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9510. if (guestBool)
  9511. {
  9512. guestIds.Add(guestId);
  9513. }
  9514. }
  9515. }
  9516. else guestNames += item.GuestName;
  9517. var voucherInfo = new HotelVoucherInfoView()
  9518. {
  9519. HotelName = item.HotelName,
  9520. CheckInDate = item.CheckInDate,
  9521. CheckOutDate = item.CheckOutDate,
  9522. ConfirmationNumber = item.DetermineNo.Trim(),
  9523. RoomType = item.RoomExplanation
  9524. };
  9525. vouchers.Add(voucherInfo);
  9526. }
  9527. if (guestIds.Count > 0)
  9528. {
  9529. guestIds = guestIds.Distinct().ToList();
  9530. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9531. if (guestDatas.Count > 0)
  9532. {
  9533. guestNames = "";
  9534. foreach (var guest in guestDatas)
  9535. {
  9536. string guestName = "";
  9537. if (guest.Sex == 0) guestName += @"MR.";
  9538. else if (guest.Sex == 1) guestName += @"MS.";
  9539. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9540. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9541. guestNames += @$"{guestName.Trim()}、";
  9542. }
  9543. if (guestNames.Length > 0)
  9544. {
  9545. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9546. }
  9547. }
  9548. }
  9549. #endregion
  9550. //载入模板
  9551. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9552. Document doc = new Document(sss);
  9553. DocumentBuilder builder = new DocumentBuilder(doc);
  9554. if (doc.Range.Bookmarks["GuestName"] != null)
  9555. {
  9556. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9557. mark.Text = guestNames;
  9558. }
  9559. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9560. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9561. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9562. for (int i = 1; i <= vouchers.Count; i++)
  9563. {
  9564. HotelVoucherInfoView hviv = vouchers[i - 1];
  9565. builder.MoveToCell(0, i, 0, 0);
  9566. builder.Write(hviv.HotelName);
  9567. builder.MoveToCell(0, i, 1, 0);
  9568. builder.Write(hviv.CheckInDate);
  9569. builder.MoveToCell(0, i, 2, 0);
  9570. builder.Write(hviv.CheckOutDate);
  9571. builder.MoveToCell(0, i, 3, 0);
  9572. builder.Write(hviv.RoomType);
  9573. builder.MoveToCell(0, i, 4, 0);
  9574. builder.Write(hviv.ConfirmationNumber);
  9575. }
  9576. //删除多余行
  9577. int currRowIndex = vouchers.Count + 1;
  9578. int delRows = 21 - currRowIndex;
  9579. if (delRows > 0)
  9580. {
  9581. for (int i = 0; i < delRows; i++)
  9582. {
  9583. table.Rows.RemoveAt(currRowIndex);
  9584. //cultivateRowIndex++;
  9585. }
  9586. }
  9587. strFileName += "VOUCHER.docx";
  9588. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9589. doc.Save(fileDir);
  9590. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9591. return Ok(JsonView(true, "操作成功!", Url));
  9592. }
  9593. /// <summary>
  9594. /// 酒店预订
  9595. /// 生成VOUCHER 批量生成
  9596. /// New
  9597. /// </summary>
  9598. /// <param name="_dto"></param>
  9599. /// <returns></returns>
  9600. [HttpPost]
  9601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9602. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9603. {
  9604. #region 参数验证
  9605. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9606. if (_dto.PageId < 1) _dto.PageId = 28;
  9607. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9608. #region 团组操作权限验证 76 酒店预定模块
  9609. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9610. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9611. #endregion
  9612. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9613. #region 页面操作权限验证
  9614. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9615. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9616. #endregion
  9617. #endregion
  9618. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9619. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9620. .OrderBy(x => x.CreateTime)
  9621. .ToListAsync();
  9622. //判断数据是否完整
  9623. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9624. string strFileName = "HotelStatement/";
  9625. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9626. if (dele != null)
  9627. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9628. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9629. for (int i = 0; i < hrDtas.Count; i++)
  9630. {
  9631. string guestNames = string.Empty;
  9632. List<int> guestIds = new List<int>();
  9633. var item = hrDtas[i];
  9634. //处理客户姓名
  9635. if (item.GuestName.Contains(","))
  9636. {
  9637. string[] guestIdArr = item.GuestName.Split(',');
  9638. foreach (var guestIdStr in guestIdArr)
  9639. if (int.TryParse(guestIdStr, out int guestId))
  9640. guestIds.Add(guestId);
  9641. }
  9642. else {
  9643. //NaN
  9644. if (item.GuestName.Contains("NaN"))
  9645. {
  9646. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9647. }
  9648. }
  9649. if (guestIds.Count > 0)
  9650. {
  9651. guestIds = guestIds.Distinct().ToList();
  9652. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9653. if (guestDatas1.Count > 0)
  9654. {
  9655. guestNames = "";
  9656. foreach (var guest in guestDatas1)
  9657. {
  9658. string guestName = "";
  9659. if (guest.Sex == 0) guestName += @"MR.";
  9660. else if (guest.Sex == 1) guestName += @"MS.";
  9661. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9662. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9663. guestNames += @$"{guestName.Trim()}、";
  9664. }
  9665. if (guestNames.Length > 0)
  9666. {
  9667. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9668. }
  9669. }
  9670. }
  9671. //if (!string.IsNullOrEmpty(guestNames))
  9672. //{
  9673. hrDtas[i].GuestName = guestNames;
  9674. //}
  9675. }
  9676. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9677. Document doc = new Document();
  9678. DocumentBuilder builder = new DocumentBuilder(doc);
  9679. try
  9680. {
  9681. builder.MoveToDocumentStart();
  9682. foreach (var item in hrDtas)
  9683. {
  9684. //标题
  9685. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9686. builder.ParagraphFormat.LineSpacing = 1;
  9687. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9688. builder.ParagraphFormat.Style.Font.Size = 9;
  9689. builder.ParagraphFormat.Style.Font.Bold = true;
  9690. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9691. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9692. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9694. builder.ParagraphFormat.LineSpacing = 1;
  9695. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9696. builder.ParagraphFormat.Style.Font.Size = 9;
  9697. builder.ParagraphFormat.Style.Font.Bold = true;
  9698. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9699. builder.StartTable();
  9700. // 设置边框颜色
  9701. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9702. //设置边框样式
  9703. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9704. //表格
  9705. #region 第一行
  9706. builder.InsertCell();
  9707. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9708. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9709. //builder.CellFormat.AllowAutoFit = false;
  9710. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9711. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9712. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9713. builder.CellFormat.WrapText = true; //自动换行
  9714. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9715. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  9716. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9717. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9718. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9719. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9720. builder.Write("TOUR NO:");
  9721. builder.InsertCell();
  9722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9723. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9724. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9725. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9726. builder.ParagraphFormat.Style.Font.Bold = false;
  9727. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9728. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9729. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9730. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9731. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9732. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9733. builder.Write($"{dele?.TourCode ?? "-"}");
  9734. builder.InsertCell();
  9735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9736. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9737. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9738. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9739. builder.ParagraphFormat.Style.Font.Bold = false;
  9740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9742. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9743. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9744. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9745. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9746. builder.Write($"CITY:");
  9747. builder.InsertCell();
  9748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9749. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9750. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9751. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9752. builder.ParagraphFormat.Style.Font.Bold = false;
  9753. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9754. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9755. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9756. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9757. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9758. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9759. builder.Write($"{item.City}");
  9760. builder.EndRow();
  9761. #endregion
  9762. #region 第二行
  9763. builder.InsertCell();
  9764. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9765. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9766. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9767. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9768. builder.ParagraphFormat.Style.Font.Bold = false;
  9769. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9770. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9771. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9772. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9773. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9774. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9775. builder.Write("CONFIRMATION NO:");
  9776. builder.InsertCell();
  9777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9778. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9779. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9780. builder.ParagraphFormat.Style.Font.Bold = false;
  9781. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9782. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9783. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9784. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9785. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9786. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9787. builder.CellFormat.VerticalMerge = CellMerge.None;
  9788. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9789. builder.Write($"{item.DetermineNo}");
  9790. builder.InsertCell();
  9791. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9792. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9793. builder.InsertCell();
  9794. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9795. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9796. builder.EndRow();
  9797. #endregion
  9798. #region 第三行
  9799. builder.InsertCell();
  9800. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9801. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9802. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9803. builder.ParagraphFormat.Style.Font.Bold = false;
  9804. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9805. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9806. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9807. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9808. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9809. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9810. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9811. builder.Write($"HOTEL NAME:");
  9812. builder.InsertCell();
  9813. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9814. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9815. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9816. builder.ParagraphFormat.Style.Font.Bold = false;
  9817. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9818. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9819. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9820. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9821. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9822. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9823. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9824. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9825. builder.Write($"{item.HotelName}");
  9826. builder.InsertCell();
  9827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9828. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9829. builder.InsertCell();
  9830. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9831. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9832. builder.EndRow();
  9833. #endregion
  9834. #region 第四行
  9835. builder.InsertCell();
  9836. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9837. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9838. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9839. builder.ParagraphFormat.Style.Font.Bold = false;
  9840. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9841. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9842. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9843. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9844. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9845. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9846. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9847. builder.Write($"HOTEL ADDRESS:");
  9848. builder.InsertCell();
  9849. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9850. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9851. builder.ParagraphFormat.Style.Font.Size = 8;
  9852. builder.ParagraphFormat.Style.Font.Bold = false;
  9853. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9854. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9855. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9856. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9857. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9858. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9859. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9860. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9861. builder.Write($"{item.HotelAddress}");
  9862. builder.InsertCell();
  9863. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9864. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9865. builder.InsertCell();
  9866. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9867. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9868. builder.EndRow();
  9869. #endregion
  9870. #region 第五行
  9871. builder.InsertCell();
  9872. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9873. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9874. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9875. builder.ParagraphFormat.Style.Font.Bold = false;
  9876. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9877. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9878. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9879. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9880. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9881. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9882. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9883. builder.Write("TEL:");
  9884. builder.InsertCell();
  9885. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9886. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9887. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9888. builder.ParagraphFormat.Style.Font.Bold = false;
  9889. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9890. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9891. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9892. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9893. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9894. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9895. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9896. builder.Write($"{item.HotelTel}");
  9897. builder.InsertCell();
  9898. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9899. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9900. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9901. builder.ParagraphFormat.Style.Font.Bold = false;
  9902. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9903. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9904. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9905. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9906. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9907. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9908. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9909. builder.Write($"FAX:");
  9910. builder.InsertCell();
  9911. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9912. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9913. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9914. builder.ParagraphFormat.Style.Font.Bold = false;
  9915. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9916. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9917. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9918. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9919. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9920. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9921. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9922. builder.Write($"{item.HotelFax}");
  9923. builder.EndRow();
  9924. #endregion
  9925. #region 第六行
  9926. builder.InsertCell();
  9927. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9928. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9929. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9930. builder.ParagraphFormat.Style.Font.Bold = false;
  9931. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9932. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9933. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9934. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9935. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9936. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9937. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9938. builder.Write("CHECK IN:");
  9939. builder.InsertCell();
  9940. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9941. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9942. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9943. builder.ParagraphFormat.Style.Font.Bold = false;
  9944. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9945. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9946. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9947. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9948. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9949. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9950. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9951. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  9952. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9953. builder.Write($"{checkInStr}");
  9954. builder.InsertCell();
  9955. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9956. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9957. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9958. builder.ParagraphFormat.Style.Font.Bold = false;
  9959. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9960. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9961. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9962. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9963. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9964. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9965. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9966. builder.Write($"CHECK OUT:");
  9967. builder.InsertCell();
  9968. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9969. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9970. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9971. builder.ParagraphFormat.Style.Font.Bold = false;
  9972. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9973. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9974. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9975. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9976. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9977. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9978. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9979. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  9980. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  9981. builder.Write($"{checkOutStr}");
  9982. builder.EndRow();
  9983. #endregion
  9984. #region 第七行
  9985. builder.InsertCell();
  9986. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9987. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9988. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9989. builder.ParagraphFormat.Style.Font.Bold = false;
  9990. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9991. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9992. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9993. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9994. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9995. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9996. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9997. builder.Write($"GUEST NAME:");
  9998. builder.InsertCell();
  9999. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10000. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10001. builder.ParagraphFormat.Style.Font.Size = 8;
  10002. builder.ParagraphFormat.Style.Font.Bold = false;
  10003. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10004. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10005. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10006. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10007. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10008. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10009. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10010. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10011. builder.Write($"{item.GuestName}");
  10012. builder.InsertCell();
  10013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10014. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10015. builder.InsertCell();
  10016. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10017. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10018. builder.EndRow();
  10019. #endregion
  10020. #region 第八行
  10021. builder.InsertCell();
  10022. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10023. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10024. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10025. builder.ParagraphFormat.Style.Font.Bold = false;
  10026. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10027. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10028. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10029. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10030. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10031. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10032. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10033. builder.Write($"ROOM TYPE:");
  10034. builder.InsertCell();
  10035. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10036. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10037. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10038. builder.ParagraphFormat.Style.Font.Bold = false;
  10039. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10040. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10041. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10042. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10043. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10044. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10045. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10046. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10047. builder.Write($"{item.RoomExplanation}");
  10048. builder.InsertCell();
  10049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10050. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10051. builder.InsertCell();
  10052. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10053. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10054. builder.EndRow();
  10055. #endregion
  10056. #region 第九行
  10057. builder.InsertCell();
  10058. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10059. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10060. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10061. builder.ParagraphFormat.Style.Font.Bold = false;
  10062. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10063. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10064. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10065. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10066. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10067. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10068. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10069. builder.Write($"NOTE:");
  10070. builder.InsertCell();
  10071. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10072. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10073. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10074. builder.ParagraphFormat.Style.Font.Bold = false;
  10075. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10076. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10077. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10078. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10079. 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.");
  10080. builder.InsertCell();
  10081. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10082. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10083. builder.InsertCell();
  10084. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10085. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10086. builder.EndRow();
  10087. #endregion
  10088. builder.EndTable();
  10089. //换行
  10090. builder.Writeln("");
  10091. builder.Writeln("");
  10092. }
  10093. #region 获取文档中的所有表格 设置文字自适应
  10094. // 获取文档中的所有表格。
  10095. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10096. {
  10097. // 遍历表格中的所有行。
  10098. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10099. {
  10100. foreach (Cell cell in row.Cells)
  10101. {
  10102. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10103. cellFormat.Width = 0;
  10104. }
  10105. }
  10106. }
  10107. #endregion
  10108. #region 设置页眉
  10109. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10110. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10111. if (System.IO.File.Exists(voucherHeaderPath))
  10112. {
  10113. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10114. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10115. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10116. Shape shape = builder.InsertImage(imageBytes);
  10117. // 调整图片位置
  10118. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10119. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10120. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10121. shape.Left = 0; // 将图片距离页面左边缘的距离
  10122. shape.Width = 81; // 设置图片宽度
  10123. shape.Height = 36; // 设置图片高度
  10124. }
  10125. //靠右
  10126. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10127. //// 设置页脚上下边距
  10128. //builder.PageSetup.HeaderDistance = 42;
  10129. // 添加页眉线
  10130. Aspose.Words.Border borderHeader = null;
  10131. try
  10132. {
  10133. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10134. }
  10135. catch (Exception e)
  10136. {
  10137. // TODO Auto-generated catch block
  10138. //e.printStackTrace();
  10139. }
  10140. borderHeader.Shadow = true;
  10141. borderHeader.DistanceFromText = 2;
  10142. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10143. #endregion
  10144. }
  10145. catch (Exception ex)
  10146. {
  10147. }
  10148. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10149. doc.Save(fileDir);
  10150. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10151. return Ok(JsonView(true, "操作成功!", Url));
  10152. }
  10153. /// <summary>
  10154. /// 酒店预订
  10155. /// 生成 预定成本 Excel
  10156. /// </summary>
  10157. /// <param name="_dto"></param>
  10158. /// <returns></returns>
  10159. [HttpPost]
  10160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10161. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10162. {
  10163. #region 参数验证
  10164. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10165. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10166. if (!vadalitorRes.IsValid)
  10167. {
  10168. var errors = new StringBuilder();
  10169. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10170. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10171. }
  10172. #region 团组操作权限验证 76 酒店预定模块
  10173. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10174. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10175. #endregion
  10176. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10177. #region 页面操作权限验证
  10178. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10179. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10180. #endregion
  10181. #endregion
  10182. decimal _rate = 1.00M;
  10183. string _currency = "";
  10184. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10185. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10186. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10187. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10188. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10189. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10190. {
  10191. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10192. }
  10193. _currency = _GroupCostParameter.Currency;
  10194. bool isIntType = int.TryParse(_currency, out int currId);
  10195. if (isIntType)
  10196. {
  10197. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10198. }
  10199. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10200. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10201. if (currInfo == null)
  10202. {
  10203. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10204. }
  10205. if (!_currency.ToUpper().Equals("CNY"))
  10206. {
  10207. _rate = _GroupCostParameter.Rate;
  10208. }
  10209. _rate = currInfo.Rate;
  10210. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10211. string strFileName = "HotelStatement/";
  10212. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10213. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10214. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10215. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10216. #region 数据处理
  10217. foreach (var item in hrDtas)
  10218. {
  10219. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10220. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10221. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10222. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10223. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10224. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10225. string singleRoomFeeStr = string.Empty,
  10226. doubleRoomFeeStr = string.Empty,
  10227. suiteRoomFeeStr = string.Empty,
  10228. otherRoomFeeStr = string.Empty,
  10229. payMoneyStr = string.Empty,
  10230. cardPriceStr = string.Empty;
  10231. if (roomCurr.Equals(_currency))
  10232. {
  10233. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10234. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10235. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10236. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10237. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10238. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10239. }
  10240. else
  10241. {
  10242. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10243. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10244. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10245. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10246. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10247. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10248. }
  10249. string breakfastPriceStr = string.Empty,
  10250. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10251. governmentRentStr = string.Empty,
  10252. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10253. cityTaxStrStr = string.Empty,
  10254. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10255. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10256. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10257. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10258. int payDId = roomInfo?.PayDId ?? 0;
  10259. pcfds.Add(new HotelReservations_PCFD_View()
  10260. {
  10261. City = item.City,
  10262. HotelName = item.HotelName,
  10263. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10264. // SingleRoomCount = item.SingleRoomCount,
  10265. SingleRoomPrice = singleRoomFeeStr,
  10266. // DoubleRoomCount = item.DoubleRoomCount,
  10267. DoubleRoomPrice = doubleRoomFeeStr,
  10268. //SuiteRoomCount = item.SuiteRoomCount,
  10269. SuiteRoomPrice = suiteRoomFeeStr,
  10270. OtherRoomPrice = otherRoomFeeStr,
  10271. //OtherRoomCount = item.OtherRoomCount,
  10272. BreakfastPrice = breakfastPriceStr,
  10273. GovernmentRent = governmentRentStr,
  10274. CityTax = cityTaxStrStr,
  10275. RoomExplanation = item.RoomExplanation,
  10276. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10277. PayTime = roomInfo?.ConsumptionDate,
  10278. BankNo = roomInfo?.BankNo,
  10279. PayMoney = payMoneyStr,
  10280. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10281. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10282. CardPrice = cardPriceStr,
  10283. Remark = ccpInfo.Remark
  10284. });
  10285. }
  10286. #endregion
  10287. //载入模板
  10288. WorkbookDesigner designer = new WorkbookDesigner();
  10289. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10290. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10291. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10292. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10293. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10294. designer.SetDataSource("Opertor", userInfo.CnName);
  10295. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10296. dt.TableName = "ViewMyHotelReservations";
  10297. designer.SetDataSource(dt);
  10298. designer.Process();
  10299. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10300. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10301. designer.Workbook.Save(serverPath);
  10302. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10303. #region 删除指定行
  10304. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10305. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10306. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10307. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10308. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10309. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10310. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10311. cssIndex = dt.Columns["CityTax"].Ordinal,
  10312. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10313. remarkIndex = dt.Columns["Remark"].Ordinal;
  10314. //删除指定列
  10315. foreach (DataRow item in dt.Rows)
  10316. {
  10317. string singleStr = item["SingleRoomPrice"].ToString();
  10318. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10319. if (containsDigitButNotZero1) singleDel = false;
  10320. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10321. string doubleStr = item["DoubleRoomPrice"].ToString();
  10322. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10323. if (containsDigitButNotZero2) doubleDel = false;
  10324. string suiteStr = item["SuiteRoomPrice"].ToString();
  10325. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10326. if (containsDigitButNotZero3) suiteDel = false;
  10327. string otherStr = item["OtherRoomPrice"].ToString();
  10328. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10329. if (containsDigitButNotZero4) otherDel = false;
  10330. string zcStr = item["BreakfastPrice"].ToString();
  10331. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10332. if (containsDigitButNotZero5) zcDel = false;
  10333. string dsStr = item["GovernmentRent"].ToString();
  10334. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10335. if (containsDigitButNotZero6) dsDel = false;
  10336. string cssStr = item["CityTax"].ToString();
  10337. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10338. if (containsDigitButNotZero7) cssDel = false;
  10339. string cpStr = item["ConsumptionPatterns"].ToString();
  10340. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10341. string remarkStr = item["Remark"].ToString();
  10342. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10343. }
  10344. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10345. DeleteColumn(serverPath, cpIndex, cpDel);
  10346. DeleteColumn(serverPath, dsIndex, dsDel);
  10347. DeleteColumn(serverPath, cssIndex, cssDel);
  10348. DeleteColumn(serverPath, zcIndex, zcDel);
  10349. DeleteColumn(serverPath, otherIndex, otherDel);
  10350. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10351. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10352. DeleteColumn(serverPath, singleIndex, singleDel);
  10353. #endregion
  10354. //只保留第一个表格
  10355. DeleteSheet(serverPath);
  10356. return Ok(JsonView(true, "操作成功", url = rst));
  10357. }
  10358. /// <summary>
  10359. /// 删除指定列
  10360. /// </summary>
  10361. /// <param name="file"></param>
  10362. /// <param name="columnIndex"></param>
  10363. /// <param name="isDel"></param>
  10364. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10365. {
  10366. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10367. //wb.Save(file);
  10368. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10369. if (sheet1 != null)
  10370. {
  10371. if (isDel)
  10372. {
  10373. Cells cells = sheet1.Cells;
  10374. cells.DeleteColumn(columnIndex);
  10375. }
  10376. }
  10377. wb.Save(file);
  10378. }
  10379. /// <summary>
  10380. /// 删除sheet
  10381. /// </summary>
  10382. /// <param name="file"></param>
  10383. /// <param name="sheetName"></param>
  10384. private void DeleteSheet(string file, string sheetName = "")
  10385. {
  10386. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10387. //wb.Save(file);
  10388. List<string> sheets = new List<string>();
  10389. foreach (var item in wb.Worksheets)
  10390. {
  10391. sheets.Add(item.Name);
  10392. }
  10393. if (sheets.Count > 0)
  10394. {
  10395. sheets.RemoveAt(0);//不删除第一个sheet
  10396. foreach (var item in sheets)
  10397. {
  10398. wb.Worksheets.RemoveAt(item);
  10399. }
  10400. }
  10401. wb.Save(file);
  10402. }
  10403. /// <summary>
  10404. /// 酒店预订
  10405. /// 确认单
  10406. /// </summary>
  10407. /// <param name="_dto"></param>
  10408. /// <returns></returns>
  10409. [HttpPost]
  10410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10411. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10412. {
  10413. try
  10414. {
  10415. #region 参数验证
  10416. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10417. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10418. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10419. #region 团组操作权限验证 76 酒店预定模块
  10420. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10421. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10422. #endregion
  10423. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10424. #region 页面操作权限验证
  10425. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10426. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10427. #endregion
  10428. #endregion
  10429. //团组信息
  10430. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10431. //酒店数据
  10432. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10433. if (listhoteldata.Count < 0)
  10434. {
  10435. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10436. }
  10437. //利datatable存储
  10438. DataTable dt = new DataTable();
  10439. dt.Columns.Add("CheckInDate", typeof(string));
  10440. dt.Columns.Add("City", typeof(string));
  10441. dt.Columns.Add("Hotel", typeof(string));
  10442. dt.Columns.Add("Room", typeof(string));
  10443. for (int i = 0; i < listhoteldata.Count; i++)
  10444. {
  10445. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10446. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10447. while (dayStart < dayEnd)
  10448. {
  10449. string temp = "";
  10450. DataRow row = dt.NewRow();
  10451. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10452. row["City"] = listhoteldata[i].City;
  10453. row["Hotel"] = listhoteldata[i].HotelName;
  10454. if (listhoteldata[i].SingleRoomCount > 0)
  10455. {
  10456. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10457. }
  10458. if (listhoteldata[i].DoubleRoomCount > 0)
  10459. {
  10460. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10461. }
  10462. if (listhoteldata[i].SuiteRoomCount > 0)
  10463. {
  10464. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10465. }
  10466. if (listhoteldata[i].OtherRoomCount > 0)
  10467. {
  10468. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10469. }
  10470. row["Room"] = temp;
  10471. dt.Rows.Add(row);
  10472. dayStart = dayStart.AddDays(1);
  10473. }
  10474. }
  10475. Dictionary<string, string> dic = new Dictionary<string, string>();
  10476. dic.Add("Dele", di.TeamName);
  10477. dic.Add("City", di.VisitCountry);
  10478. //模板路径
  10479. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10480. //载入模板
  10481. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10482. DocumentBuilder builder = new DocumentBuilder(doc);
  10483. foreach (var key in dic.Keys)
  10484. {
  10485. builder.MoveToBookmark(key);
  10486. builder.Write(dic[key]);
  10487. }
  10488. //获取word里所有表格
  10489. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10490. //获取所填表格的序数
  10491. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10492. var rowStart = tableOne.Rows[0]; //获取第1行
  10493. //循环赋值
  10494. for (int i = 0; i < dt.Rows.Count; i++)
  10495. {
  10496. builder.MoveToCell(0, i + 1, 0, 0);
  10497. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10498. builder.MoveToCell(0, i + 1, 1, 0);
  10499. builder.Write(dt.Rows[i]["City"].ToString());
  10500. builder.MoveToCell(0, i + 1, 2, 0);
  10501. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10502. builder.MoveToCell(0, i + 1, 3, 0);
  10503. builder.Write(dt.Rows[i]["Room"].ToString());
  10504. }
  10505. //删除多余行
  10506. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10507. {
  10508. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10509. }
  10510. string strFileName = di.TeamName + "酒店确认单.doc";
  10511. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10512. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10513. return Ok(JsonView(true, "成功", url));
  10514. }
  10515. catch (Exception ex)
  10516. {
  10517. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10518. }
  10519. }
  10520. #endregion
  10521. #region 团组状态
  10522. /// <summary>
  10523. /// 团组状态列表 Page
  10524. /// </summary>
  10525. /// <param name="dto">团组列表请求dto</param>
  10526. /// <returns></returns>
  10527. [HttpPost]
  10528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10529. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10530. {
  10531. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10532. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10533. {
  10534. string sqlWhere = string.Empty;
  10535. if (dto.IsSure == 0) //未完成
  10536. {
  10537. sqlWhere += string.Format(@" And IsSure = 0");
  10538. }
  10539. else if (dto.IsSure == 1) //已完成
  10540. {
  10541. sqlWhere += string.Format(@" And IsSure = 1");
  10542. }
  10543. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10544. {
  10545. string tj = dto.SearchCriteria;
  10546. 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}%')",
  10547. tj, tj, tj, tj, tj);
  10548. }
  10549. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10550. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10551. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10552. From (
  10553. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10554. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10555. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10556. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10557. From Grp_DelegationInfo gdi
  10558. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10559. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10560. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10561. Where gdi.IsDel = 0 {0}
  10562. ) temp ", sqlWhere);
  10563. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10564. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10565. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10566. }
  10567. else
  10568. {
  10569. return Ok(JsonView(false, "查询失败"));
  10570. }
  10571. }
  10572. /// <summary>
  10573. /// 团组状态
  10574. /// 设置操作完成
  10575. /// </summary>
  10576. /// <param name="dto">团组列表请求dto</param>
  10577. /// <returns></returns>
  10578. [HttpPost]
  10579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10580. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10581. {
  10582. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10583. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10584. {
  10585. Id = dto.Id,
  10586. IsSure = 1
  10587. };
  10588. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10589. .UpdateColumns(it => new { it.IsSure })
  10590. .WhereColumns(it => new { it.Id })
  10591. .ExecuteCommandAsync();
  10592. if (result > 0)
  10593. {
  10594. return Ok(JsonView(true, "操作完成!"));
  10595. }
  10596. return Ok(JsonView(false, "操作失败!"));
  10597. }
  10598. #endregion
  10599. #region 保险费用录入
  10600. /// <summary>
  10601. /// 根据团组Id查询保险费用列表
  10602. /// </summary>
  10603. /// <param name="dto"></param>
  10604. /// <returns></returns>
  10605. [HttpPost]
  10606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10607. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10608. {
  10609. try
  10610. {
  10611. Result groupData = await _customersRep.CustomersByDiId(dto);
  10612. if (groupData.Code != 0)
  10613. {
  10614. return Ok(JsonView(false, groupData.Msg));
  10615. }
  10616. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10617. }
  10618. catch (Exception ex)
  10619. {
  10620. return Ok(JsonView(false, ex.Message));
  10621. }
  10622. }
  10623. /// <summary>
  10624. /// 根据保险费用Id查询保险费用详细
  10625. /// </summary>
  10626. /// <param name="dto"></param>
  10627. /// <returns></returns>
  10628. [HttpPost]
  10629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10630. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10631. {
  10632. try
  10633. {
  10634. Result groupData = await _customersRep.CustomersById(dto);
  10635. if (groupData.Code != 0)
  10636. {
  10637. return Ok(JsonView(false, groupData.Msg));
  10638. }
  10639. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10640. }
  10641. catch (Exception ex)
  10642. {
  10643. return Ok(JsonView(false, ex.Message));
  10644. }
  10645. }
  10646. /// <summary>
  10647. /// 保险费用录入页面初始化绑定
  10648. /// </summary>
  10649. /// <param name="dto"></param>
  10650. /// <returns></returns>
  10651. [HttpPost]
  10652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10653. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10654. {
  10655. try
  10656. {
  10657. Result groupData = await _customersRep.CustomersInitialize(dto);
  10658. if (groupData.Code != 0)
  10659. {
  10660. return Ok(JsonView(false, groupData.Msg));
  10661. }
  10662. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10663. }
  10664. catch (Exception ex)
  10665. {
  10666. return Ok(JsonView(false, ex.Message));
  10667. }
  10668. }
  10669. /// <summary>
  10670. /// 保险费用操作(Status:1.新增,2.修改)
  10671. /// </summary>
  10672. /// <param name="dto"></param>
  10673. /// <returns></returns>
  10674. [HttpPost]
  10675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10676. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10677. {
  10678. try
  10679. {
  10680. Result groupData = await _customersRep.OpCustomers(dto);
  10681. if (groupData.Code != 0)
  10682. {
  10683. return Ok(JsonView(false, groupData.Msg));
  10684. }
  10685. #region 应用推送
  10686. try
  10687. {
  10688. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10689. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10690. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10691. }
  10692. catch (Exception ex)
  10693. {
  10694. }
  10695. #endregion
  10696. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10697. }
  10698. catch (Exception ex)
  10699. {
  10700. return Ok(JsonView(false, ex.Message));
  10701. }
  10702. }
  10703. /// <summary>
  10704. /// 保险文件上传
  10705. /// </summary>
  10706. /// <param name="file"></param>
  10707. /// <returns></returns>
  10708. [HttpPost]
  10709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10710. public async Task<IActionResult> UploadCus(IFormFile file)
  10711. {
  10712. try
  10713. {
  10714. if (file != null)
  10715. {
  10716. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10717. //文件名称
  10718. string projectFileName = file.FileName;
  10719. //上传的文件的路径
  10720. string filePath = "";
  10721. if (!Directory.Exists(fileDir))
  10722. {
  10723. Directory.CreateDirectory(fileDir);
  10724. }
  10725. //上传的文件的路径
  10726. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10727. using (FileStream fs = System.IO.File.Create(filePath))
  10728. {
  10729. file.CopyTo(fs);
  10730. fs.Flush();
  10731. }
  10732. return Ok(JsonView(true, "上传成功!", projectFileName));
  10733. }
  10734. else
  10735. {
  10736. return Ok(JsonView(false, "上传失败!"));
  10737. }
  10738. }
  10739. catch (Exception ex)
  10740. {
  10741. return Ok(JsonView(false, "程序错误!"));
  10742. throw;
  10743. }
  10744. }
  10745. /// <summary>
  10746. /// 保险删除指定文件
  10747. /// </summary>
  10748. /// <param name="dto"></param>
  10749. /// <returns></returns>
  10750. [HttpPost]
  10751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10752. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10753. {
  10754. try
  10755. {
  10756. string filePath = "";
  10757. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10758. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10759. //int id = 0;
  10760. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10761. // 删除该文件
  10762. try
  10763. {
  10764. System.IO.File.Delete(filePath);
  10765. 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()
  10766. {
  10767. Attachment = "",
  10768. }).ExecuteCommandAsync();
  10769. if (result != 0)
  10770. {
  10771. return Ok(JsonView(true, "成功!"));
  10772. }
  10773. else
  10774. {
  10775. return Ok(JsonView(false, "失败!"));
  10776. }
  10777. }
  10778. catch (Exception)
  10779. {
  10780. 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()
  10781. {
  10782. Attachment = "",
  10783. }).ExecuteCommandAsync();
  10784. if (result != 0)
  10785. {
  10786. return Ok(JsonView(true, "成功!"));
  10787. }
  10788. else
  10789. {
  10790. return Ok(JsonView(false, "失败!"));
  10791. }
  10792. }
  10793. }
  10794. catch (Exception ex)
  10795. {
  10796. return Ok(JsonView(false, "程序错误!"));
  10797. throw;
  10798. }
  10799. }
  10800. /// <summary>
  10801. /// 保险费用操作(删除)
  10802. /// </summary>
  10803. /// <param name="dto"></param>
  10804. /// <returns></returns>
  10805. [HttpPost]
  10806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10807. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10808. {
  10809. try
  10810. {
  10811. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10812. if (!res)
  10813. {
  10814. return Ok(JsonView(false, "删除失败"));
  10815. }
  10816. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10817. {
  10818. IsDel = 1,
  10819. DeleteUserId = dto.DeleteUserId,
  10820. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10821. }).ExecuteCommandAsync();
  10822. return Ok(JsonView(true, "删除成功!"));
  10823. }
  10824. catch (Exception ex)
  10825. {
  10826. return Ok(JsonView(false, "程序错误!"));
  10827. throw;
  10828. }
  10829. }
  10830. #endregion
  10831. #region 接团客户名单 PageId 104
  10832. /// <summary>
  10833. /// 接团客户名单
  10834. /// 迁移数据(慎用!)
  10835. /// </summary>
  10836. /// <param name="dto"></param>
  10837. /// <returns></returns>
  10838. [HttpPost]
  10839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10840. public async Task<IActionResult> PostTourClientListChange()
  10841. {
  10842. try
  10843. {
  10844. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10845. //var groupClinetData1
  10846. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10847. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10848. int updateCount = 0;
  10849. if (oldOAClientList.Count > 0)
  10850. {
  10851. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10852. _sqlSugar.BeginTran();
  10853. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10854. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10855. foreach (var item in oldOAClientList)
  10856. {
  10857. int comId = 0;
  10858. string format = "yyyy-MM-dd HH:mm:ss";
  10859. string data11 = "1990-01-01 00:00";
  10860. var data1 = IsValidDate(item.OPdate, format);
  10861. if (data1) data11 = item.OPdate;
  10862. //客户公司验证
  10863. if (!string.IsNullOrEmpty(item.Company))
  10864. {
  10865. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10866. if (clientComInfo == null) // add
  10867. {
  10868. var addInfo = new Crm_CustomerCompany()
  10869. {
  10870. CompanyAbbreviation = "",
  10871. CompanyFullName = item.Company,
  10872. Address = "",
  10873. PostCodes = "",
  10874. LastedOpUserId = item.OPer,
  10875. LastedOpDt = Convert.ToDateTime(data11),
  10876. CreateUserId = item.OPer,
  10877. CreateTime = Convert.ToDateTime(data11),
  10878. IsDel = 0
  10879. };
  10880. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10881. if (comId1 > 0) comId = comId1;
  10882. }
  10883. else comId = clientComInfo.Id;
  10884. }
  10885. //客户人员验证
  10886. int clientId = 0;
  10887. string name = item.LastName + item.Name;
  10888. if (!string.IsNullOrEmpty(name))
  10889. {
  10890. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10891. if (clientInfo == null)
  10892. {
  10893. DateTime? dateTime = null;
  10894. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10895. if (isDt) dateTime = birthDayDt;
  10896. var addInfo1 = new Crm_DeleClient()
  10897. {
  10898. CrmCompanyId = comId,
  10899. DiId = -1,
  10900. LastName = item.LastName,
  10901. FirstName = item.Name,
  10902. OldName = "",
  10903. Pinyin = item.Pinyin,
  10904. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10905. Marriage = 0,
  10906. Phone = item.Phone,
  10907. Job = item.Job,
  10908. BirthDay = dateTime
  10909. };
  10910. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10911. if (clientId1 > 0) clientId = clientId1;
  10912. }
  10913. else clientId = clientInfo.Id;
  10914. }
  10915. if (clientId < 1)
  10916. {
  10917. continue;
  10918. }
  10919. int airType = 0;
  10920. if (item.AirType == "超经舱") airType = 459;
  10921. else if (item.AirType == "公务舱") airType = 458;
  10922. else if (item.AirType == "经济舱") airType = 460;
  10923. else if (item.AirType == "其他") airType = 565;
  10924. else if (item.AirType == "头等舱") airType = 457;
  10925. var _TourClientListEntity = new Grp_TourClientList()
  10926. {
  10927. DiId = item.Diid,
  10928. ClientId = clientId,
  10929. CreateUserId = item.OPer,
  10930. CreateTime = Convert.ToDateTime(data11),
  10931. Remark = item.Remark,
  10932. IsDel = item.Isdel,
  10933. ShippingSpaceTypeId = airType,
  10934. ShippingSpaceSpecialNeeds = item.AirRemark,
  10935. HotelSpecialNeeds = item.RoomType
  10936. };
  10937. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10938. if (_TourClientList > 0)
  10939. {
  10940. updateCount++;
  10941. }
  10942. }
  10943. _sqlSugar.CommitTran();
  10944. }
  10945. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10946. }
  10947. catch (Exception ex)
  10948. {
  10949. _sqlSugar.RollbackTran();
  10950. return Ok(JsonView(false, ex.Message));
  10951. }
  10952. return Ok(JsonView(true));
  10953. }
  10954. private bool IsValidDate(string dateString, string format)
  10955. {
  10956. DateTime dateValue;
  10957. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10958. return valid;
  10959. }
  10960. /// <summary>
  10961. /// 接团客户名单
  10962. /// 根据团组Id查询List
  10963. /// </summary>
  10964. /// <param name="dto"></param>
  10965. /// <returns></returns>
  10966. [HttpPost]
  10967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10968. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10969. {
  10970. #region 参数验证
  10971. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10972. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10973. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10974. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10975. #region 页面操作权限验证
  10976. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10977. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10978. #endregion
  10979. #endregion
  10980. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10981. if (viewData.Code != 0)
  10982. {
  10983. return Ok(JsonView(false, viewData.Msg));
  10984. }
  10985. return Ok(JsonView(viewData.Data));
  10986. }
  10987. /// <summary>
  10988. /// 接团客户名单
  10989. /// 基础数据 Init
  10990. /// </summary>
  10991. /// <param name="_dto"></param>
  10992. /// <returns></returns>
  10993. [HttpPost]
  10994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10995. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10996. {
  10997. #region 参数验证
  10998. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10999. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11000. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11001. #region 页面操作权限验证
  11002. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11003. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11004. #endregion
  11005. #endregion
  11006. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  11007. if (viewData.Code != 0)
  11008. {
  11009. return Ok(JsonView(false, viewData.Msg));
  11010. }
  11011. return Ok(JsonView(viewData.Data));
  11012. }
  11013. /// <summary>
  11014. /// 接团客户名单
  11015. /// 根据 Id查询 Details
  11016. /// </summary>
  11017. /// <param name="_dto"></param>
  11018. /// <returns></returns>
  11019. [HttpPost]
  11020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11021. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11022. {
  11023. #region 参数验证
  11024. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11025. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11026. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11027. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11028. #region 页面操作权限验证
  11029. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11030. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11031. #endregion
  11032. #endregion
  11033. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11034. if (viewData.Code != 0)
  11035. {
  11036. return Ok(JsonView(false, viewData.Msg));
  11037. }
  11038. return Ok(JsonView(viewData.Data));
  11039. }
  11040. /// <summary>
  11041. /// 接团客户名单
  11042. /// Add Or Edit
  11043. /// </summary>
  11044. /// <param name="_dto"></param>
  11045. /// <returns></returns>
  11046. [HttpPost]
  11047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11048. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11049. {
  11050. #region 参数验证
  11051. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11052. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11053. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11054. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11055. #region 页面操作权限验证
  11056. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11057. if (_dto.Id == 0) //添加
  11058. {
  11059. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11060. }
  11061. else if (_dto.Id >= 0) //修改
  11062. {
  11063. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11064. }
  11065. #endregion
  11066. #endregion
  11067. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11068. if (viewData.Code != 0)
  11069. {
  11070. return Ok(JsonView(false, viewData.Msg));
  11071. }
  11072. return Ok(JsonView(true));
  11073. }
  11074. /// <summary>
  11075. /// 接团客户名单
  11076. /// AddMultiple(添加多个)
  11077. /// </summary>
  11078. /// <param name="_dto"></param>
  11079. /// <returns></returns>
  11080. [HttpPost]
  11081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11082. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11083. {
  11084. #region 参数验证
  11085. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11086. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11087. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11088. #region 页面操作权限验证
  11089. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11090. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11091. #endregion
  11092. #endregion
  11093. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11094. if (viewData.Code != 0)
  11095. {
  11096. return Ok(JsonView(false, viewData.Msg));
  11097. }
  11098. return Ok(JsonView(true));
  11099. }
  11100. /// <summary>
  11101. /// 接团客户名单
  11102. /// Del
  11103. /// </summary>
  11104. /// <param name="_dto"></param>
  11105. /// <returns></returns>
  11106. [HttpPost]
  11107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11108. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11109. {
  11110. #region 参数验证
  11111. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11112. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11113. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11114. #region 页面操作权限验证
  11115. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11116. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11117. #endregion
  11118. #endregion
  11119. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11120. if (viewData.Code != 0)
  11121. {
  11122. return Ok(JsonView(false, viewData.Msg));
  11123. }
  11124. return Ok(JsonView(true));
  11125. }
  11126. /// <summary>
  11127. /// 接团客户名单
  11128. /// 文件下载 客户名单
  11129. /// </summary>
  11130. /// <param name="_dto"></param>
  11131. /// <returns></returns>
  11132. [HttpPost]
  11133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11134. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11135. {
  11136. #region 参数验证
  11137. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11138. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11139. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11140. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11141. #region 页面操作权限验证
  11142. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11143. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11144. #endregion
  11145. #endregion
  11146. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11147. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11148. From Grp_TourClientList tcl
  11149. Left Join
  11150. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11151. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11152. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11153. From Crm_DeleClient dc
  11154. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11155. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11156. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11157. Where dc.IsDel = 0) temp
  11158. On temp.DcId =tcl.ClientId
  11159. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11160. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11161. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11162. //载入模板
  11163. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11164. if (_dto.Language == 1)
  11165. {
  11166. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11167. }
  11168. //载入模板
  11169. var doc = new Document(tempPath);
  11170. DocumentBuilder builder = new DocumentBuilder(doc);
  11171. //获取word里所有表格
  11172. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11173. //获取所填表格的序数
  11174. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11175. var rowStart = tableOne.Rows[0]; //获取第1行
  11176. if (_dto.Language == 0)
  11177. {
  11178. //循环赋值
  11179. for (int i = 0; i < DcList.Count; i++)
  11180. {
  11181. builder.MoveToCell(0, i + 1, 0, 0);
  11182. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11183. builder.MoveToCell(0, i + 1, 1, 0);
  11184. int sex = DcList[i].Sex;
  11185. string sexStr = string.Empty;
  11186. if (sex == 0) sexStr = "男";
  11187. else if (sex == 1) sexStr = "女";
  11188. else sexStr = "未设置";
  11189. builder.Write(sexStr);
  11190. builder.MoveToCell(0, i + 1, 2, 0);
  11191. string birthDay = DcList[i].BirthDay;
  11192. string birthDayStr = string.Empty;
  11193. if (!string.IsNullOrEmpty(birthDay))
  11194. {
  11195. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11196. }
  11197. builder.Write(birthDayStr);
  11198. builder.MoveToCell(0, i + 1, 3, 0);
  11199. string company = "";
  11200. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11201. {
  11202. company = DcList[i].CompanyFullName.ToString();
  11203. }
  11204. builder.Write(company);
  11205. builder.MoveToCell(0, i + 1, 4, 0);
  11206. builder.Write(DcList[i].Job);
  11207. }
  11208. }
  11209. else if (_dto.Language == 1)
  11210. {
  11211. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11212. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11213. List<string> transArrayStr = new List<string>();
  11214. string transStrRes1 = "";
  11215. for (int i = 0; i < DcList.Count; i++)
  11216. {
  11217. var dc = DcList[i];
  11218. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11219. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11220. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11221. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11222. else transStrRes1 += $"{str1}|";
  11223. }
  11224. //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";
  11225. string transStrRes = "";
  11226. if (transStrRes1.Length > 0 )
  11227. {
  11228. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11229. }
  11230. //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
  11231. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11232. //List<string> transArray = new List<string> { };
  11233. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11234. if (transStrRes.Contains("|"))
  11235. {
  11236. string[] transArray1 = transStrRes.Split('|');
  11237. if (transArray1.Length > 0)
  11238. {
  11239. foreach (var item in transArray1)
  11240. {
  11241. if (item.Contains("&"))
  11242. {
  11243. string[] transArray2 = item.Split('&');
  11244. int index = 0;
  11245. string companyName = "", job = "";
  11246. if (transArray2.Length > 0)
  11247. {
  11248. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11249. if (1 < transArray2.Length) companyName = transArray2[1];
  11250. if (2 < transArray2.Length) job = transArray2[2];
  11251. }
  11252. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11253. }
  11254. }
  11255. }
  11256. }
  11257. //循环赋值
  11258. for (int i = 0; i < DcList.Count; i++)
  11259. {
  11260. string PYName = "";
  11261. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11262. {
  11263. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11264. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11265. PYName = PY_First + " " + PY_Last;
  11266. }
  11267. else
  11268. {
  11269. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11270. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11271. PYName = PY_First + " " + PY_Last;
  11272. }
  11273. builder.MoveToCell(0, i + 1, 0, 0);
  11274. builder.Write(PYName);
  11275. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11276. builder.MoveToCell(0, i + 1, 1, 0);
  11277. builder.Write(sex);
  11278. DateTime birthDt;
  11279. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11280. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11281. builder.MoveToCell(0, i + 1, 2, 0);
  11282. builder.Write(birthday);
  11283. string company = string.Empty,job = string.Empty;
  11284. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11285. if (dcTransInfo != null)
  11286. {
  11287. company = dcTransInfo.CompanyName;
  11288. job = dcTransInfo.Job;
  11289. }
  11290. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11291. {
  11292. //查询对照表
  11293. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11294. if (tempCec != null)
  11295. {
  11296. company = tempCec.enName;
  11297. }
  11298. //翻译
  11299. else
  11300. {
  11301. }
  11302. }
  11303. builder.MoveToCell(0, i + 1, 3, 0);
  11304. builder.Write(company);
  11305. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11306. {
  11307. //查询对照表
  11308. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11309. if (tempPec != null)
  11310. {
  11311. job = tempPec.enName;
  11312. }
  11313. //翻译
  11314. else
  11315. {
  11316. }
  11317. }
  11318. builder.MoveToCell(0, i + 1, 4, 0);
  11319. builder.Write(job);
  11320. }
  11321. }
  11322. //删除多余行
  11323. while (tableOne.Rows.Count > DcList.Count + 1)
  11324. {
  11325. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11326. }
  11327. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11328. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11329. doc.Save(fileDir);
  11330. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11331. return Ok(JsonView(true, "操作成功!", Url));
  11332. }
  11333. private class TranslateInfo
  11334. {
  11335. public int Index { get; set; }
  11336. public string CompanyName { get; set; }
  11337. public string Job { get; set; }
  11338. }
  11339. #endregion
  11340. #region 团组倒推表
  11341. /// <summary>
  11342. /// 倒推表基础数据
  11343. /// Init
  11344. /// </summary>
  11345. /// <param name="dto"></param>
  11346. /// <returns></returns>
  11347. [HttpPost]
  11348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11349. public async Task<IActionResult> PostInvertedListInit()
  11350. {
  11351. var viewData = await _invertedListRep._Init();
  11352. if (viewData.Code != 0)
  11353. {
  11354. return Ok(JsonView(false, viewData.Msg));
  11355. }
  11356. return Ok(JsonView(viewData.Data));
  11357. }
  11358. /// <summary>
  11359. /// 倒推表
  11360. /// Info
  11361. /// </summary>
  11362. /// <param name="dto"></param>
  11363. /// <returns></returns>
  11364. [HttpPost]
  11365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11366. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11367. {
  11368. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11369. if (viewData.Code != 0)
  11370. {
  11371. return Ok(JsonView(false, viewData.Msg));
  11372. }
  11373. return Ok(JsonView(viewData.Data));
  11374. }
  11375. /// <summary>
  11376. /// 倒推表
  11377. /// Create
  11378. /// </summary>
  11379. /// <param name="dto"></param>
  11380. /// <returns></returns>
  11381. [HttpPost]
  11382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11383. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11384. {
  11385. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11386. if (viewData.Code != 0)
  11387. {
  11388. return Ok(JsonView(false, viewData.Msg));
  11389. }
  11390. return Ok(JsonView(viewData.Data));
  11391. }
  11392. /// <summary>
  11393. /// 倒推表
  11394. /// Update
  11395. /// </summary>
  11396. /// <param name="dto"></param>
  11397. /// <returns></returns>
  11398. [HttpPost]
  11399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11400. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11401. {
  11402. var viewData = await _invertedListRep._Update(dto);
  11403. if (viewData.Code != 0)
  11404. {
  11405. return Ok(JsonView(false, viewData.Msg));
  11406. }
  11407. return Ok(JsonView(viewData.Data));
  11408. }
  11409. /// <summary>
  11410. /// 倒推表
  11411. /// File Download
  11412. /// </summary>
  11413. /// <param name="dto"></param>
  11414. /// <returns></returns>
  11415. [HttpPost]
  11416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11417. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11418. {
  11419. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11420. if (info2.Code != 0)
  11421. {
  11422. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11423. }
  11424. var info1 = info2.Data as InvertedListInfoView;
  11425. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11426. string teamName = "";
  11427. if (info != null) teamName = info.TeamName;
  11428. //载入模板
  11429. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11430. DocumentBuilder builder = new DocumentBuilder(doc);
  11431. //利用键值对存放数据
  11432. Dictionary<string, string> dic = new Dictionary<string, string>();
  11433. dic.Add("TeamName", teamName);
  11434. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11435. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11436. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11437. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11438. dic.Add("SQRemark", info1.ApprovalRemark);
  11439. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11440. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11441. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11442. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11443. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11444. dic.Add("QZRemark", info1.VisaInformationRemark);
  11445. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11446. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11447. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11448. dic.Add("CQRemark", info1.IssueVisaRemark);
  11449. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11450. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11451. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11452. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11453. #region 填充word模板书签内容
  11454. foreach (var key in dic.Keys)
  11455. {
  11456. builder.MoveToBookmark(key);
  11457. builder.Write(dic[key]);
  11458. }
  11459. #endregion
  11460. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11461. string fileName = $"{teamName}团出行准备流程表.doc";
  11462. string filePath = fileDir + $@"InvertedList/{fileName}";
  11463. doc.Save(filePath);
  11464. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11465. return Ok(JsonView(true, "操作成功!", Url));
  11466. }
  11467. #endregion
  11468. #region 三公签证费用(签证费、代办费)
  11469. /// <summary>
  11470. /// 三公签证费用(签证费、代办费)
  11471. /// List
  11472. /// </summary>
  11473. /// <returns></returns>
  11474. [HttpPost]
  11475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11476. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11477. {
  11478. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11479. if (_view.Code != 0)
  11480. {
  11481. return Ok(JsonView(false, _view.Msg));
  11482. }
  11483. return Ok(JsonView(true, "操作成功!", _view.Data));
  11484. }
  11485. /// <summary>
  11486. /// 三公签证费用(签证费、代办费)
  11487. /// Add Or Update
  11488. /// </summary>
  11489. /// <returns></returns>
  11490. [HttpPost]
  11491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11492. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11493. {
  11494. var _view = await _visaFeeInfoRep._Update(_dto);
  11495. if (_view.Code != 0)
  11496. {
  11497. return Ok(JsonView(false, _view.Msg));
  11498. }
  11499. return Ok(JsonView(true, _view.Msg));
  11500. }
  11501. #endregion
  11502. #region 酒店询价
  11503. /// <summary>
  11504. /// 酒店询价
  11505. /// Init
  11506. /// </summary>
  11507. /// <param name="dto"></param>
  11508. /// <returns></returns>
  11509. [HttpPost]
  11510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11511. public async Task<IActionResult> PostHotelInquiryInit()
  11512. {
  11513. var res = await _hotelInquiryRep._Init();
  11514. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11515. return Ok(JsonView(true, res.Msg, res.Data));
  11516. }
  11517. /// <summary>
  11518. /// 酒店询价
  11519. /// page Item
  11520. /// </summary>
  11521. /// <param name="_dto"></param>
  11522. /// <returns></returns>
  11523. [HttpPost]
  11524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11525. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11526. {
  11527. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11528. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11529. var view = res.Data as PageDataViewBase;
  11530. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11531. }
  11532. /// <summary>
  11533. /// 酒店询价
  11534. /// info
  11535. /// </summary>
  11536. /// <param name="_dto"></param>
  11537. /// <returns></returns>
  11538. [HttpPost]
  11539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11540. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11541. {
  11542. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11543. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11544. return Ok(JsonView(true, res.Msg, res.Data));
  11545. }
  11546. /// <summary>
  11547. /// 酒店询价
  11548. /// Add Or Edit
  11549. /// </summary>
  11550. /// <param name="_dto"></param>
  11551. /// <returns></returns>
  11552. [HttpPost]
  11553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11554. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11555. {
  11556. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11557. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11558. return Ok(JsonView(true, res.Msg, res.Data));
  11559. }
  11560. /// <summary>
  11561. /// 酒店询价
  11562. /// Del
  11563. /// </summary>
  11564. /// <param name="_dto"></param>
  11565. /// <returns></returns>
  11566. [HttpPost]
  11567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11568. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11569. {
  11570. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11571. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11572. return Ok(JsonView(true, res.Msg, res.Data));
  11573. }
  11574. #endregion
  11575. #region 下载匹配op行程单
  11576. /// <summary>
  11577. /// 匹配op行程单
  11578. /// Init
  11579. /// </summary>
  11580. /// <param name="dto">团组列表请求dto</param>
  11581. /// <returns></returns>
  11582. [HttpPost]
  11583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11584. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11585. {
  11586. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11587. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11588. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11589. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11590. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11591. .Where(it => it.IsDel == 0)
  11592. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11593. .OrderByDescending(it => it.CreateUserId)
  11594. .ToList();
  11595. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11596. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11597. var diids = groupInfos.Select(it => it.Id).ToList();
  11598. List<string> countrys = new List<string>();
  11599. foreach (var item in country)
  11600. {
  11601. var data = _groupRepository.FormartTeamName(item);
  11602. var dataArray = _groupRepository.GroupSplitCountry(data);
  11603. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11604. }
  11605. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11606. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11607. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11608. foreach (var item in areaItem)
  11609. {
  11610. string areaStr = item.Value;
  11611. if (!string.IsNullOrEmpty(areaStr))
  11612. {
  11613. string[] str1 = areaStr.Split("-");
  11614. if (str1.Length > 0)
  11615. {
  11616. areaArray.AddRange(str1);
  11617. }
  11618. }
  11619. }
  11620. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11621. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11622. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11623. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11624. .ToList();
  11625. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11626. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11627. .Where(it => countriesIds.Contains(it.Id))
  11628. .Select(it => new { it.Id, Name = it.Name_CN })
  11629. .ToList();
  11630. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11631. .Select(it => it.TeamName).ToList();
  11632. stopwatch.Stop();
  11633. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11634. }
  11635. ///// <summary>
  11636. ///// 匹配op行程单
  11637. ///// Init 查询区域数据
  11638. ///// </summary>
  11639. ///// <param name="dto">团组列表请求dto</param>
  11640. ///// <returns></returns>
  11641. //[HttpPost]
  11642. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11643. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11644. //{
  11645. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11646. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11647. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11648. // if (string.IsNullOrEmpty(countriesDataStr))
  11649. // {
  11650. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11651. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11652. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11653. // }
  11654. // else
  11655. // {
  11656. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11657. // }
  11658. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11659. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11660. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11661. // List<dynamic> childList = new List<dynamic>();
  11662. // int parentId = dto.CountriesId;
  11663. // if (provinceData.Count > 1)
  11664. // {
  11665. // foreach (var item1 in provinceData)
  11666. // {
  11667. // List<dynamic> childList1 = new List<dynamic>();
  11668. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11669. // foreach (var item2 in citiesData1)
  11670. // {
  11671. // List<dynamic> childList2 = new List<dynamic>();
  11672. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11673. // foreach (var item3 in countiesData1)
  11674. // {
  11675. // childList2.Add(new
  11676. // {
  11677. // id = item3.Id,
  11678. // parentId = item2.Id,
  11679. // level = "district",
  11680. // name = item3.Name_CN,
  11681. // });
  11682. // }
  11683. // childList1.Add(new
  11684. // {
  11685. // id = item2.Id,
  11686. // parentId = item1.Id,
  11687. // level = "city",
  11688. // name = item2.Name_CN,
  11689. // childList = childList2
  11690. // });
  11691. // }
  11692. // childList.Add(new
  11693. // {
  11694. // id = item1.Id,
  11695. // parentId = parentId,
  11696. // level = "province",
  11697. // name = item1.Name_CN,
  11698. // childList = childList1
  11699. // });
  11700. // }
  11701. // //城市
  11702. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11703. // foreach (var item2 in citiesData2)
  11704. // {
  11705. // List<dynamic> childList22 = new List<dynamic>();
  11706. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11707. // foreach (var item3 in countiesData1)
  11708. // {
  11709. // childList22.Add(new
  11710. // {
  11711. // id = item3.Id,
  11712. // parentId = item2.Id,
  11713. // level = "district",
  11714. // name = item3.Name_CN,
  11715. // });
  11716. // }
  11717. // childList.Add(new
  11718. // {
  11719. // id = item2.Id,
  11720. // parentId = parentId,
  11721. // level = "city",
  11722. // name = item2.Name_CN,
  11723. // childList = childList22
  11724. // });
  11725. // }
  11726. // }
  11727. // else
  11728. // {
  11729. // foreach (var item2 in citiesData)
  11730. // {
  11731. // string cname = item2.Name_CN;
  11732. // List<dynamic> childList1 = new List<dynamic>();
  11733. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11734. // foreach (var item3 in countiesData1)
  11735. // {
  11736. // childList1.Add(new
  11737. // {
  11738. // Id = item3.Id,
  11739. // parentId = item2.Id,
  11740. // level = "district",
  11741. // name = item3.Name_CN
  11742. // });
  11743. // }
  11744. // childList.Add(new
  11745. // {
  11746. // id = item2.Id,
  11747. // parentId = parentId,
  11748. // level = "city",
  11749. // name = item2.Name_CN,
  11750. // childList = childList1
  11751. // });
  11752. // }
  11753. // }
  11754. // stopwatch.Stop();
  11755. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11756. //}
  11757. /// <summary>
  11758. /// 匹配op行程单
  11759. /// 接团信息列表 Page
  11760. /// </summary>
  11761. /// <param name="dto">团组列表请求dto</param>
  11762. /// <returns></returns>
  11763. [HttpPost]
  11764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11765. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11766. {
  11767. var swatch = new Stopwatch();
  11768. swatch.Start();
  11769. #region 参数验证
  11770. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11771. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11772. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11773. #region 页面操作权限验证
  11774. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11775. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11776. #endregion
  11777. #endregion
  11778. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11779. {
  11780. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11781. string sqlWhere = "";
  11782. if (!string.IsNullOrEmpty(dto.Country))
  11783. {
  11784. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11785. }
  11786. if (!string.IsNullOrEmpty(dto.Area))
  11787. {
  11788. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11789. }
  11790. if (!string.IsNullOrEmpty(dto.TeamName))
  11791. {
  11792. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11793. }
  11794. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11795. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11796. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11797. swatch.Stop();
  11798. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11799. }
  11800. else
  11801. {
  11802. return Ok(JsonView(false, "查询失败"));
  11803. }
  11804. }
  11805. /// <summary>
  11806. /// 匹配op行程单
  11807. /// 行程单下载
  11808. /// </summary>
  11809. /// <param name="dto">团组列表请求dto</param>
  11810. /// <returns></returns>
  11811. [HttpPost]
  11812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11813. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11814. {
  11815. #region 参数验证
  11816. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11817. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11818. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11819. #region 页面操作权限验证
  11820. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11821. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11822. #endregion
  11823. #endregion
  11824. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11825. {
  11826. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11827. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11828. }
  11829. else
  11830. {
  11831. return Ok(JsonView(false, "下载失败!"));
  11832. }
  11833. }
  11834. #endregion
  11835. #region 国家信息 数据 注释
  11836. //[HttpPost]
  11837. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11838. //{
  11839. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11840. // foreach (var item in dto)
  11841. // {
  11842. // infos.Add(new Grp_GroupsTaskAssignment()
  11843. // {
  11844. // DIId = item,
  11845. // CTId = 82,
  11846. // UId = 248,
  11847. // IsEnable = 1,
  11848. // CreateUserId = 233,
  11849. // CreateTime = DateTime.Now,
  11850. // IsDel = 0
  11851. // });
  11852. // infos.Add(new Grp_GroupsTaskAssignment()
  11853. // {
  11854. // DIId = item,
  11855. // CTId = 82,
  11856. // UId = 286,
  11857. // IsEnable = 1,
  11858. // CreateUserId = 233,
  11859. // CreateTime = DateTime.Now,
  11860. // IsDel = 0
  11861. // });
  11862. // }
  11863. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11864. // return Ok("操作成功");
  11865. //}
  11866. //public class paramJsonDto
  11867. //{
  11868. // public List<CountriesInfo> str { get; set; }
  11869. //}
  11870. //[HttpPost]
  11871. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11872. //{
  11873. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11874. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11875. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11876. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11877. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11878. // _sqlSugar.BeginTran();
  11879. // int countitiesIndex = 0;
  11880. // foreach (var item in dto.str)
  11881. // {
  11882. // dynamic data = item.c;
  11883. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11884. // if (data != null)
  11885. // {
  11886. // countitiesIndex++;
  11887. // foreach (var item1 in data)
  11888. // {
  11889. // string cnname = item1.cn;
  11890. // string enname = item1.en;
  11891. // Sys_Cities provinceInfo = new Sys_Cities()
  11892. // {
  11893. // CountriesId = countriesId,
  11894. // Name_CN = cnname,
  11895. // Name_EN = enname,
  11896. // ParentId = 0,
  11897. // IsCapital = 1,
  11898. // CreateUserId = 208,
  11899. // CreateTime = DateTime.Now,
  11900. // IsDel = 0
  11901. // };
  11902. // if (item1.lv == "province") //省份
  11903. // {
  11904. // provinceInfo.Level = 1;
  11905. // int provinceId = 0;
  11906. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11907. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11908. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11909. // var data1 = item1.c;
  11910. // foreach (var item2 in data1)
  11911. // {
  11912. // if (item2.lv == "city")
  11913. // {
  11914. // string citycnname = item2.cn;
  11915. // string cityenname = item2.en;
  11916. // Sys_Cities cityInfo = new Sys_Cities()
  11917. // {
  11918. // CountriesId = countriesId,
  11919. // ParentId = provinceId,
  11920. // Level = 2,
  11921. // Name_CN = citycnname,
  11922. // Name_EN = cityenname,
  11923. // IsCapital = 1,
  11924. // CreateUserId = 208,
  11925. // CreateTime = DateTime.Now,
  11926. // IsDel = 0
  11927. // };
  11928. // if (item2.c != null)
  11929. // {
  11930. // int cityId = 0;
  11931. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11932. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11933. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11934. // foreach (var item3 in item2.c)
  11935. // {
  11936. // if (item3.lv == "district")
  11937. // {
  11938. // var districtInfo = new Sys_Cities()
  11939. // {
  11940. // CountriesId = countriesId,
  11941. // Name_CN = item3.cn,
  11942. // Name_EN = item3.en,
  11943. // Level = 3,
  11944. // ParentId = cityId,
  11945. // IsCapital = 1,
  11946. // CreateUserId = 208,
  11947. // CreateTime = DateTime.Now,
  11948. // IsDel = 0
  11949. // };
  11950. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11951. // //{
  11952. // districts.Add(districtInfo);
  11953. // //}
  11954. // }
  11955. // }
  11956. // }
  11957. // else
  11958. // {
  11959. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11960. // //{
  11961. // cities.Add(cityInfo);
  11962. // //}
  11963. // }
  11964. // }
  11965. // }
  11966. // }
  11967. // else if (item1.lv == "city")//城市
  11968. // {
  11969. // provinceInfo.Level = 2;
  11970. // if (item1.c != null)
  11971. // {
  11972. // int cityId = 0;
  11973. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11974. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11975. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11976. // foreach (var item3 in item1.c)
  11977. // {
  11978. // if (item3.lv == "district")
  11979. // {
  11980. // var districtInfo = new Sys_Cities()
  11981. // {
  11982. // CountriesId = countriesId,
  11983. // Name_CN = item3.cn,
  11984. // Name_EN = item3.en,
  11985. // Level = 3,
  11986. // ParentId = cityId,
  11987. // IsCapital = 1,
  11988. // CreateUserId = 208,
  11989. // CreateTime = DateTime.Now,
  11990. // IsDel = 0
  11991. // };
  11992. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11993. // //{
  11994. // districts.Add(districtInfo);
  11995. // //}
  11996. // }
  11997. // }
  11998. // }
  11999. // else
  12000. // {
  12001. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12002. // //{
  12003. // cities.Add(provinceInfo);
  12004. // //}
  12005. // }
  12006. // }
  12007. // }
  12008. // }
  12009. // }
  12010. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12011. // cities = cities.Distinct().ToList();
  12012. // districts = districts.Distinct().ToList();
  12013. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12014. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12015. // cities.AddRange(districts);
  12016. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12017. // //_sqlSugar.RollbackTran();
  12018. // _sqlSugar.CommitTran();
  12019. // return Ok(JsonView(false, "操作成功!"));
  12020. //}
  12021. //[HttpPost]
  12022. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12023. //{
  12024. // List<CountitiesInfo> infos = dto.MyProperty;
  12025. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12026. // _sqlSugar.BeginTran();
  12027. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12028. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12029. // foreach (var item in infos)
  12030. // {
  12031. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12032. // if (countryInfo != null)
  12033. // {
  12034. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12035. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12036. // if (cityInfo1 != null)
  12037. // {
  12038. // cityInfo1.IsCapital = 0;
  12039. // cityInfos.Add(cityInfo1);
  12040. // }
  12041. // }
  12042. // }
  12043. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12044. // .UpdateColumns(it => it.IsCapital)
  12045. // .WhereColumns(it => it.Id)
  12046. // .ExecuteCommand();
  12047. // //_sqlSugar.RollbackTran();
  12048. // _sqlSugar.CommitTran();
  12049. // return Ok(JsonView(false, "操作成功!"));
  12050. //}
  12051. //public class CounrtiesDto
  12052. //{
  12053. // public List<CountitiesInfo> MyProperty { get; set; }
  12054. //}
  12055. //public class CountitiesInfo
  12056. //{
  12057. // /// <summary>
  12058. // /// 圣约翰
  12059. // /// </summary>
  12060. // public string capital_name_chinese { get; set; }
  12061. // /// <summary>
  12062. // ///
  12063. // /// </summary>
  12064. // public string capital_name { get; set; }
  12065. // /// <summary>
  12066. // ///
  12067. // /// </summary>
  12068. // public string country_type { get; set; }
  12069. // /// <summary>
  12070. // /// 安提瓜和巴布达
  12071. // /// </summary>
  12072. // public string country_name_chinese { get; set; }
  12073. // /// <summary>
  12074. // /// 安提瓜和巴布达
  12075. // /// </summary>
  12076. // public string country_name_chinese_short { get; set; }
  12077. // /// <summary>
  12078. // /// 安提瓜和巴布达
  12079. // /// </summary>
  12080. // public string country_name_chinese_UN { get; set; }
  12081. // /// <summary>
  12082. // ///
  12083. // /// </summary>
  12084. // public string country_name_english_abbreviation { get; set; }
  12085. // /// <summary>
  12086. // ///
  12087. // /// </summary>
  12088. // public string country_name_english_formal { get; set; }
  12089. // /// <summary>
  12090. // ///
  12091. // /// </summary>
  12092. // public string country_name_english_UN { get; set; }
  12093. // /// <summary>
  12094. // ///
  12095. // /// </summary>
  12096. // public string continent_name { get; set; }
  12097. // /// <summary>
  12098. // ///
  12099. // /// </summary>
  12100. // public string subregion_name { get; set; }
  12101. // /// <summary>
  12102. // ///
  12103. // /// </summary>
  12104. // public string country_code2 { get; set; }
  12105. // /// <summary>
  12106. // ///
  12107. // /// </summary>
  12108. // public string country_code3 { get; set; }
  12109. // /// <summary>
  12110. // ///
  12111. // /// </summary>
  12112. // public string phone_code { get; set; }
  12113. //}
  12114. //public class CountriesInfo : BasicInfo
  12115. //{
  12116. // public List<CitiesInfo> c { get; set; }
  12117. //}
  12118. //public class CitiesInfo : BasicInfo
  12119. //{
  12120. // public List<AreaInfo> c { get; set; }
  12121. //}
  12122. //public class AreaInfo : BasicInfo
  12123. //{
  12124. // public List<AreaInfo> c { get; set; }
  12125. //}
  12126. //public class BasicInfo
  12127. //{
  12128. // public string code { get; set; }
  12129. // public string cn { get; set; }
  12130. // public string lv { get; set; }
  12131. // public string en { get; set; }
  12132. //}
  12133. #endregion
  12134. #region 查看邀请方
  12135. /// <summary>
  12136. /// 查看邀请方
  12137. /// 邀请方信息 Init
  12138. /// </summary>
  12139. /// <param name="dto"></param>
  12140. /// <returns></returns>
  12141. [HttpPost]
  12142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12143. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12144. {
  12145. string sqlWhere = string.Empty;
  12146. if (!string.IsNullOrEmpty(dto.Search))
  12147. {
  12148. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12149. }
  12150. string sql = string.Format($@"Select
  12151. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12152. Id,
  12153. UnitName
  12154. From Res_InvitationOfficialActivityData
  12155. Where IsDel = 0
  12156. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12157. RefAsync<int> total = 0;
  12158. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12159. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12160. }
  12161. /// <summary>
  12162. /// 查看邀请方
  12163. /// 国家信息 Init
  12164. /// </summary>
  12165. /// <param name="dto"></param>
  12166. /// <returns></returns>
  12167. [HttpPost]
  12168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12169. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12170. {
  12171. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12172. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12173. var diids = groupInfos.Select(it => it.Id).ToList();
  12174. List<string> countrys = new List<string>();
  12175. foreach (var item in country)
  12176. {
  12177. var data = _groupRepository.FormartTeamName(item);
  12178. var dataArray = _groupRepository.GroupSplitCountry(data);
  12179. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12180. }
  12181. countrys = countrys.Distinct().ToList();
  12182. for (int i = 0; i < countrys.Count; i++)
  12183. {
  12184. string item = countrys[i];
  12185. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12186. {
  12187. countrys.Remove(item);
  12188. i--;
  12189. }
  12190. }
  12191. RefAsync<int> total = 0;
  12192. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12193. .Where(it => countrys.Contains(it.Name_CN))
  12194. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12195. .Select(it => new { id = it.Id, name = it.Name_CN })
  12196. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12197. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12198. }
  12199. /// <summary>
  12200. /// 查看邀请方
  12201. /// 城市信息 Init
  12202. /// </summary>
  12203. /// <param name="dto"></param>
  12204. /// <returns></returns>
  12205. [HttpPost]
  12206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12207. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12208. {
  12209. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12210. RefAsync<int> total = 0;
  12211. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12212. .Where(it => it.CountriesId == dto.CountiesId)
  12213. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12214. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12215. .Select(it => new { id = it.Id, name = it.Name_CN })
  12216. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12217. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12218. }
  12219. /// <summary>
  12220. /// 查看邀请方
  12221. /// 团组名称 Init
  12222. /// </summary>
  12223. /// <param name="dto"></param>
  12224. /// <returns></returns>
  12225. [HttpPost]
  12226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12227. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12228. {
  12229. var watch = new Stopwatch();
  12230. watch.Start();
  12231. RefAsync<int> total = 0;
  12232. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12233. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12234. .Where((oa, di) => oa.IsDel == 0)
  12235. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12236. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12237. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12238. .Distinct()
  12239. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12240. watch.Stop();
  12241. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12242. }
  12243. /// <summary>
  12244. /// 查看邀请方
  12245. /// 团组 & 邀请方信息
  12246. /// </summary>
  12247. /// <param name="dto"></param>
  12248. /// <returns></returns>
  12249. [HttpPost]
  12250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12251. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12252. {
  12253. var watch = new Stopwatch();
  12254. watch.Start();
  12255. RefAsync<int> total = 0;
  12256. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12257. .AS("Grp_DelegationInfo")
  12258. .Includes(x => x.InvitingInfos)
  12259. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12260. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12261. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12262. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12263. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12264. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12265. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12266. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12267. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12268. infos.ForEach(x =>
  12269. {
  12270. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12271. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12272. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12273. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12274. });
  12275. watch.Stop();
  12276. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12277. }
  12278. #endregion
  12279. #region 报批行程
  12280. /// <summary>
  12281. /// 报批行程初始化
  12282. /// </summary>
  12283. /// <param name="dto"></param>
  12284. /// <returns></returns>
  12285. [HttpPost]
  12286. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12287. {
  12288. const int chiNumber = 5;
  12289. var jw = JsonView(false);
  12290. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12291. var group = groupList.First();
  12292. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12293. group = groupList.First(x => x.Id == diid);
  12294. if (group == null)
  12295. {
  12296. jw.Msg = "暂无团组!";
  12297. return Ok(jw);
  12298. }
  12299. var data = new
  12300. {
  12301. groupList = groupList.Select(x => new
  12302. {
  12303. x.TeamName,
  12304. x.Id
  12305. }),
  12306. content = new ArrayList(),
  12307. groupInfo = new
  12308. {
  12309. group.VisitDays,
  12310. group.TourCode,
  12311. group.VisitPNumber,
  12312. group.TeamName,
  12313. group.Id,
  12314. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12315. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12316. },
  12317. };
  12318. var resultArr = new ArrayList();
  12319. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12320. if (content.Count == 0)
  12321. {
  12322. var stay = "-";
  12323. var cityPath = "-";
  12324. //添加城市路径以及住宿地
  12325. //黑屏代码数据
  12326. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12327. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12328. {
  12329. jw = JsonView(true, "黑屏代码有误!", data);
  12330. return Ok(jw);
  12331. }
  12332. foreach (DataRow row in dtBlack.Rows)
  12333. {
  12334. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12335. {
  12336. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12337. return Ok(jw);
  12338. }
  12339. }
  12340. //黑屏代码获取时间区间
  12341. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12342. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12343. _sqlSugar.BeginTran();
  12344. for (int i = 0; i < timeArr.Count; i++)
  12345. {
  12346. stay = "-";
  12347. cityPath = "-";
  12348. DateTime NewData = DateTime.Parse(timeArr[i]);
  12349. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12350. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12351. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12352. if (tbSelect.Length > 0)
  12353. {
  12354. List<string> threeCodeStr = new List<string>();
  12355. foreach (var item in tbSelect)
  12356. {
  12357. var threeCode = item["Three"].ToString() ?? "";
  12358. if (threeCode.Length == 6)
  12359. {
  12360. var start = threeCode.Substring(0, 3);
  12361. var end = threeCode.Substring(3, 3);
  12362. if (threeCodeStr.Count == 0)
  12363. {
  12364. threeCodeStr.Add(start);
  12365. threeCodeStr.Add(end);
  12366. }
  12367. else
  12368. {
  12369. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12370. {
  12371. threeCodeStr.Add(end);
  12372. }
  12373. else
  12374. {
  12375. threeCodeStr.Add(start);
  12376. threeCodeStr.Add(end);
  12377. }
  12378. }
  12379. }
  12380. }
  12381. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12382. var last = threeCodeStr.Last();
  12383. foreach (var item in threeCodeStr)
  12384. {
  12385. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12386. if (item.Equals(last))
  12387. {
  12388. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12389. }
  12390. }
  12391. cityPath = cityPath.Trim('-');
  12392. }
  12393. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12394. appro.Diid = diid ?? -1;
  12395. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12396. appro.Id = thisId;
  12397. appro.CreateUserId = dto.UserId;
  12398. appro.CreateTime = DateTime.Now;
  12399. content.Add(appro);
  12400. }
  12401. _sqlSugar.CommitTran();
  12402. }
  12403. foreach (var x in content)
  12404. {
  12405. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12406. if (chiList.Count < chiNumber)
  12407. {
  12408. for (int i = chiList.Count; i < chiNumber; i++)
  12409. {
  12410. chiList.Add(new Grp_ApprovalTravelDetails());
  12411. }
  12412. }
  12413. resultArr.Add(new
  12414. {
  12415. x.Id,
  12416. x.Date,
  12417. x.Diid,
  12418. chiList = chiList.Select(x1 => new
  12419. {
  12420. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12421. x1.Details,
  12422. x1.ParentId,
  12423. x1.Id
  12424. })
  12425. });
  12426. }
  12427. data = data with
  12428. {
  12429. content = resultArr,
  12430. };
  12431. jw = JsonView(true, "获取成功!", data);
  12432. return Ok(jw);
  12433. }
  12434. /// <summary>
  12435. /// 报批行程删除
  12436. /// </summary>
  12437. /// <param name="dto"></param>
  12438. /// <returns></returns>
  12439. [HttpPost]
  12440. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12441. {
  12442. var jw = JsonView(false);
  12443. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12444. if (group == null)
  12445. {
  12446. jw.Msg = "团组参数有误!";
  12447. return Ok(jw);
  12448. }
  12449. try
  12450. {
  12451. _sqlSugar.BeginTran();
  12452. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12453. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12454. {
  12455. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12456. DeleteUserId = dto.uesrId,
  12457. IsDel = 1
  12458. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12459. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12460. {
  12461. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12462. DeleteUserId = dto.uesrId,
  12463. IsDel = 1
  12464. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12465. _sqlSugar.CommitTran();
  12466. jw = JsonView(true, "删除成功");
  12467. }
  12468. catch (Exception ex)
  12469. {
  12470. jw = JsonView(false, ex.Message);
  12471. }
  12472. return Ok(jw);
  12473. }
  12474. /// <summary>
  12475. /// 报批行程保存
  12476. /// </summary>
  12477. /// <param name="dto"></param>
  12478. /// <returns></returns>
  12479. [HttpPost]
  12480. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12481. {
  12482. var jw = JsonView(false);
  12483. var Find = dto.Arr.Find(x => x.id == 0);
  12484. if (Find != null)
  12485. {
  12486. jw.Msg = "生成的ID为0!";
  12487. return Ok(jw);
  12488. }
  12489. foreach (var item in dto.Arr)
  12490. {
  12491. foreach (var chi in item.chiList)
  12492. {
  12493. if (chi.parentId == 0)
  12494. {
  12495. chi.parentId = item.id;
  12496. }
  12497. }
  12498. }
  12499. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12500. _sqlSugar.BeginTran();
  12501. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12502. {
  12503. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12504. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12505. {
  12506. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12507. DeleteUserId = dto.UserId,
  12508. IsDel = 1
  12509. }).ExecuteCommand();
  12510. }
  12511. try
  12512. {
  12513. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12514. {
  12515. CreateTime = DateTime.Now,
  12516. CreateUserId = dto.UserId,
  12517. Details = x.details,
  12518. ParentId = x.parentId,
  12519. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12520. Remark = "",
  12521. IsDel = 0
  12522. }).ToList()).ExecuteCommand();
  12523. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12524. {
  12525. Id = x.id,
  12526. Details = x.details,
  12527. ParentId = x.parentId,
  12528. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12529. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12530. {
  12531. Details = x.Details,
  12532. ParentId = x.ParentId,
  12533. Time = x.Time
  12534. }).ExecuteCommand();
  12535. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12536. {
  12537. Id = x.id,
  12538. Date = x.date,
  12539. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12540. {
  12541. Date = x.Date
  12542. }).ExecuteCommand();
  12543. _sqlSugar.CommitTran();
  12544. jw = JsonView(true, "保存成功!");
  12545. }
  12546. catch (Exception ex)
  12547. {
  12548. _sqlSugar.RollbackTran();
  12549. jw = JsonView(false, "保存失败!" + ex.Message);
  12550. }
  12551. return Ok(jw);
  12552. }
  12553. /// <summary>
  12554. /// 报批行程生成
  12555. /// </summary>
  12556. /// <param name="dto"></param>
  12557. /// <returns></returns>
  12558. [HttpPost]
  12559. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12560. {
  12561. var jw = JsonView(false);
  12562. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12563. if (group == null)
  12564. {
  12565. jw.Msg = "暂无该团组!";
  12566. return Ok(jw);
  12567. }
  12568. //黑屏代码数据
  12569. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12570. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12571. {
  12572. jw.Msg = "黑屏代码有误!";
  12573. return Ok(jw);
  12574. }
  12575. foreach (DataRow row in dtBlack.Rows)
  12576. {
  12577. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12578. {
  12579. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12580. return Ok(jw);
  12581. }
  12582. }
  12583. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12584. var resultArr = new ArrayList();
  12585. if (officialActivitiesArr.Count == 0)
  12586. {
  12587. jw.Msg = "暂无公务出访信息!";
  12588. return Ok(jw);
  12589. }
  12590. try
  12591. {
  12592. _sqlSugar.BeginTran();
  12593. DeleteApprovalJourney(new
  12594. Domain.Dtos.Groups.DeleteApprovalJourney
  12595. {
  12596. Diid = dto.Diid,
  12597. uesrId = dto.Userid
  12598. });
  12599. var stay = "-";
  12600. var cityPath = "-";
  12601. //添加城市路径以及住宿地
  12602. //黑屏代码获取时间区间
  12603. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12604. var empty = "【未收入该三字码!请机票同事录入】";
  12605. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12606. for (int i = 0; i < timeArr.Count; i++)
  12607. {
  12608. stay = "-";
  12609. cityPath = "-";
  12610. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12611. DateTime NewData = DateTime.Parse(timeArr[i]);
  12612. 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();
  12613. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12614. if (tbSelect.Length > 0)
  12615. {
  12616. List<string> threeCodeStr = new List<string>();
  12617. bool isTrade = false;
  12618. string trip = string.Empty;
  12619. var rowLast = tbSelect.Last();
  12620. var rowFirst = tbSelect.First();
  12621. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12622. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12623. var takeOffTime = DateTime.Parse(timeArr[i]);
  12624. var fallToTime = DateTime.Parse(timeArr[i]);
  12625. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12626. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12627. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12628. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12629. foreach (var item in tbSelect)
  12630. {
  12631. var start = string.Empty;
  12632. var end = string.Empty;
  12633. var threeCode = item["Three"].ToString() ?? "";
  12634. if (threeCode.Length == 6)
  12635. {
  12636. start = threeCode.Substring(0, 3);
  12637. end = threeCode.Substring(3, 3);
  12638. if (threeCodeStr.Count == 0)
  12639. {
  12640. threeCodeStr.Add(start);
  12641. threeCodeStr.Add(end);
  12642. }
  12643. else
  12644. {
  12645. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12646. {
  12647. threeCodeStr.Add(end);
  12648. }
  12649. else
  12650. {
  12651. threeCodeStr.Add(start);
  12652. threeCodeStr.Add(end);
  12653. }
  12654. }
  12655. }
  12656. //处理机票信息
  12657. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12658. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12659. if (start_Object == null)
  12660. {
  12661. start_Object = new Res_ThreeCode()
  12662. {
  12663. AirPort = empty,
  12664. AirPort_En = empty,
  12665. City = empty,
  12666. Country = empty,
  12667. Four = empty,
  12668. Three = empty,
  12669. };
  12670. }
  12671. if (end_Object == null)
  12672. {
  12673. end_Object = new Res_ThreeCode()
  12674. {
  12675. AirPort = empty,
  12676. AirPort_En = empty,
  12677. City = empty,
  12678. Country = empty,
  12679. Four = empty,
  12680. Three = empty,
  12681. };
  12682. }
  12683. //机型判断
  12684. string airModel = item["AirModel"].ToString();
  12685. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12686. string flightTime = item["FlightTime"].ToString();
  12687. if (flightTime!.Contains(":"))
  12688. {
  12689. flightTime = flightTime.Replace(":", "小时");
  12690. flightTime += "分钟";
  12691. }
  12692. if (flightTime.Contains("H"))
  12693. {
  12694. flightTime = flightTime.Replace("H", "小时");
  12695. }
  12696. if (flightTime.Contains("M"))
  12697. {
  12698. flightTime = flightTime.Replace("M", "分钟");
  12699. }
  12700. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12701. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12702. {
  12703. flightTime = flightDataTime.Hour > 0
  12704. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12705. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12706. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12707. }
  12708. //航班号
  12709. string flightcode = item["Fliagtcode"].ToString();
  12710. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12711. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12712. if (aircompany == null)
  12713. {
  12714. aircompany = new Res_AirCompany
  12715. {
  12716. CnName = hsEmpty,
  12717. EnName = hsEmpty,
  12718. ShortCode = hsEmpty,
  12719. };
  12720. }
  12721. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12722. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12723. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12724. if (isTrade)
  12725. {
  12726. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12727. }
  12728. else
  12729. {
  12730. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12731. }
  12732. }
  12733. chiarr.Add(new Grp_ApprovalTravelDetails
  12734. {
  12735. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12736. CreateTime = DateTime.Now,
  12737. CreateUserId = dto.Userid,
  12738. ParentId = 0,
  12739. Details = trip
  12740. });
  12741. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12742. var last = threeCodeStr.Last();
  12743. foreach (var item in threeCodeStr)
  12744. {
  12745. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12746. if (item.Equals(last))
  12747. {
  12748. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12749. }
  12750. }
  12751. cityPath = cityPath.Trim('-');
  12752. }
  12753. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12754. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12755. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12756. appro.Diid = dto.Diid;
  12757. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12758. appro.Id = thisId;
  12759. appro.CreateUserId = dto.Userid;
  12760. appro.CreateTime = DateTime.Now;
  12761. foreach (var item in gwinfo)
  12762. {
  12763. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12764. chi.Details = "拜访" + item.Client;
  12765. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12766. {
  12767. chi.Details += "," + item.ReqSample;
  12768. }
  12769. chi.ParentId = thisId;
  12770. chi.Time = item.Time;
  12771. chiarr.Add(chi);
  12772. }
  12773. if (chiarr.Count < 5)
  12774. {
  12775. for (int j = chiarr.Count; j < 5; j++)
  12776. {
  12777. chiarr.Add(new
  12778. Grp_ApprovalTravelDetails());
  12779. }
  12780. }
  12781. resultArr.Add(new
  12782. {
  12783. appro.Id,
  12784. appro.Date,
  12785. appro.Diid,
  12786. chiList = chiarr.Select(x1 => new
  12787. {
  12788. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12789. x1.Details,
  12790. x1.ParentId,
  12791. x1.Id
  12792. })
  12793. });
  12794. }
  12795. _sqlSugar.CommitTran();
  12796. jw = JsonView(true, "生成成功!", resultArr);
  12797. }
  12798. catch (Exception ex)
  12799. {
  12800. jw.Code = 400;
  12801. jw.Msg = "生成失败!" + ex.Message;
  12802. }
  12803. return Ok(jw);
  12804. }
  12805. /// <summary>
  12806. /// 报批行程word导出
  12807. /// </summary>
  12808. /// <param name="dto"></param>
  12809. /// <returns></returns>
  12810. [HttpPost]
  12811. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12812. {
  12813. var jw = JsonView(false);
  12814. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12815. if (group == null)
  12816. {
  12817. jw.Msg = "暂无该团组!";
  12818. return Ok(jw);
  12819. }
  12820. //模板路径
  12821. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12822. //载入模板
  12823. Document doc = new Document(tempPath);
  12824. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12825. //获取所填表格的序数
  12826. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12827. Aspose.Words.Tables.Row titleRowClone = null;
  12828. Aspose.Words.Tables.Row CenterRowClone = null;
  12829. int index = 0;
  12830. int indexChi = 0;
  12831. int SetIndex = 0;
  12832. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12833. //获取数据,放到datatable
  12834. foreach (var item in ApprovalTravelArr)
  12835. {
  12836. if (index > 0)
  12837. {
  12838. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12839. tableOne.AppendChild(titleRowClone);
  12840. }
  12841. var textTime = item.Date;
  12842. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12843. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12844. SetIndex++;
  12845. if (ChiRep.Count > 0)
  12846. {
  12847. foreach (var itemChi in ChiRep)
  12848. {
  12849. var txtTime = itemChi.Time;
  12850. var txtDetail = itemChi.Details;
  12851. if (indexChi > 0)
  12852. {
  12853. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12854. tableOne.AppendChild(CenterRowClone);
  12855. }
  12856. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12857. {
  12858. SetCells(tableOne, doc, SetIndex, 0, "");
  12859. SetCells(tableOne, doc, SetIndex, 1, "");
  12860. indexChi++;
  12861. SetIndex++;
  12862. break;
  12863. }
  12864. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12865. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12866. indexChi++;
  12867. SetIndex++;
  12868. }
  12869. }
  12870. else
  12871. {
  12872. if (indexChi > 0)
  12873. {
  12874. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12875. tableOne.AppendChild(CenterRowClone);
  12876. }
  12877. SetCells(tableOne, doc, SetIndex, 0, "");
  12878. SetCells(tableOne, doc, SetIndex, 1, "");
  12879. indexChi++;
  12880. SetIndex++;
  12881. }
  12882. index++;
  12883. }
  12884. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12885. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12886. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12887. jw.Code = 200;
  12888. jw.Msg = "";
  12889. return Ok(jw);
  12890. }
  12891. private string intToString(int numberVal)
  12892. {
  12893. string numberval = numberVal.ToString();
  12894. Dictionary<char, string> Number = new Dictionary<char, string>();
  12895. Number.Add('1', "一");
  12896. Number.Add('2', "二");
  12897. Number.Add('3', "三");
  12898. Number.Add('4', "四");
  12899. Number.Add('5', "五");
  12900. Number.Add('6', "六");
  12901. Number.Add('7', "七");
  12902. Number.Add('8', "八");
  12903. Number.Add('9', "九");
  12904. string stringNumberVal = string.Empty;
  12905. for (int i = 0; i < numberval.Length; i++)
  12906. {
  12907. if (i == 0)
  12908. {
  12909. stringNumberVal += Number[numberval[i]];
  12910. }
  12911. else if (i >= 1)
  12912. {
  12913. if (numberval[i] == '0')
  12914. {
  12915. stringNumberVal = "十";
  12916. }
  12917. else
  12918. {
  12919. stringNumberVal += "十" + Number[numberval[i]];
  12920. }
  12921. }
  12922. }
  12923. return stringNumberVal;
  12924. }
  12925. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12926. {
  12927. //获取table中的某个单元格,从0开始
  12928. Cell lshCell = table.Rows[rows].Cells[cells];
  12929. //将单元格中段落移除
  12930. foreach (Node item in lshCell.Paragraphs)
  12931. {
  12932. lshCell.Paragraphs.Remove(item);
  12933. }
  12934. if (val.Contains("\r\n"))
  12935. {
  12936. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12937. foreach (var item in spArr)
  12938. {
  12939. //新建一个段落
  12940. Paragraph p = new Paragraph(doc);
  12941. var r = new Run(doc, item);
  12942. //把设置的值赋给之前新建的段落
  12943. p.AppendChild(r);
  12944. //将此段落加到单元格内
  12945. lshCell.AppendChild(p);
  12946. }
  12947. }
  12948. else
  12949. {
  12950. //新建一个段落
  12951. Paragraph p = new Paragraph(doc);
  12952. var r = new Run(doc, val);
  12953. //把设置的值赋给之前新建的段落
  12954. p.AppendChild(r);
  12955. //将此段落加到单元格内
  12956. lshCell.AppendChild(p);
  12957. }
  12958. }
  12959. [HttpPost]
  12960. public async Task<IActionResult> ServerHttp(string paramStr)
  12961. {
  12962. paramStr = paramStr.TrimEnd('\'');
  12963. paramStr = paramStr.TrimStart('\'');
  12964. JsonView jw = JsonView(false);
  12965. JObject param = JObject.Parse(paramStr);
  12966. if (!param.ContainsKey("url"))
  12967. {
  12968. jw.Msg = "url null";
  12969. return Ok(jw);
  12970. }
  12971. string url = param["url"]!.ToString();
  12972. var methon = "get";
  12973. Dictionary<string, string> bodyValues = null;
  12974. Dictionary<string, string> headValues = null;
  12975. if (param.ContainsKey("methon"))
  12976. {
  12977. methon = param["methon"]!.ToString();
  12978. }
  12979. if (param.ContainsKey("header"))
  12980. {
  12981. var header = param["header"]!.ToString();
  12982. JObject headerJobject = JObject.Parse(header);
  12983. headValues = new Dictionary<string, string>();
  12984. foreach (JProperty item in headerJobject.Properties())
  12985. {
  12986. var value = item.Value.ToString();
  12987. var head = item.Path;
  12988. headValues.Add(head, value);
  12989. }
  12990. }
  12991. if (param.ContainsKey("body"))
  12992. {
  12993. var body = param["body"]!.ToString();
  12994. bodyValues = new Dictionary<string, string>();
  12995. JObject bodyJobject = JObject.Parse(body);
  12996. foreach (JProperty item in bodyJobject.Properties())
  12997. {
  12998. var value = item.Value.ToString();
  12999. var head = item.Path;
  13000. bodyValues.Add(head, value);
  13001. }
  13002. }
  13003. HttpClient client = new HttpClient();
  13004. string responseString = string.Empty;
  13005. if (param.ContainsKey("isJson"))
  13006. {
  13007. }
  13008. if (headValues != null)
  13009. {
  13010. foreach (var item in headValues.Keys)
  13011. {
  13012. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13013. }
  13014. }
  13015. try
  13016. {
  13017. if (methon == "get")
  13018. {
  13019. responseString = await client.GetStringAsync(url);
  13020. }
  13021. else if (methon == "post")
  13022. {
  13023. if (bodyValues == null)
  13024. {
  13025. jw.Msg = "methon post body null";
  13026. return Ok(jw);
  13027. }
  13028. // 数据转化为 key=val 格式
  13029. var content = new FormUrlEncodedContent(bodyValues);
  13030. var response = await client.PostAsync(url, content);
  13031. // 获取数据
  13032. responseString = await response.Content.ReadAsStringAsync();
  13033. }
  13034. else
  13035. {
  13036. jw.Msg = "methon error";
  13037. }
  13038. jw = JsonView(true, "success", responseString);
  13039. }
  13040. catch (Exception ex)
  13041. {
  13042. jw.Msg = "error " + ex.Message;
  13043. jw.Data = ex.StackTrace;
  13044. }
  13045. finally
  13046. {
  13047. client.Dispose();
  13048. }
  13049. return Ok(jw);
  13050. }
  13051. #endregion
  13052. // /// <summary>
  13053. // ///
  13054. // /// </summary>
  13055. // /// <param name="_dto"></param>
  13056. // /// <returns></returns>
  13057. // [HttpPost]
  13058. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13059. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13060. // {
  13061. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13062. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13063. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13064. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13065. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13066. // dic_psg.Add("客人", 974);
  13067. // dic_psg.Add("司机", 975);
  13068. // dic_psg.Add("导游", 976);
  13069. // dic_psg.Add("公司内部人员", 977);
  13070. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13071. // foreach (var item in list_visa)
  13072. // {
  13073. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13074. // temp.Id = item.Id;
  13075. // temp.DIId = item.DIId;
  13076. // temp.VisaClient = item.VisaClient;
  13077. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13078. // temp.VisaCurrency = item.VisaCurrency;
  13079. // temp.IsThird = item.IsThird;
  13080. // if (dic_psg.ContainsKey(item.PassengerType))
  13081. // {
  13082. // temp.PassengerType = dic_psg[item.PassengerType];
  13083. // }
  13084. // else {
  13085. // temp.PassengerType = -1;
  13086. // }
  13087. // temp.VisaNumber = item.VisaNumber;
  13088. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13089. // temp.CreateUserId = item.Operators;
  13090. // DateTime dt_ct;
  13091. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13092. // if (b_ct)
  13093. // {
  13094. // temp.CreateTime = dt_ct;
  13095. // }
  13096. // else
  13097. // {
  13098. // temp.CreateTime = DateTime.Now;
  13099. // }
  13100. // temp.DeleteTime = "";
  13101. // temp.DeleteUserId = 0;
  13102. // temp.Remark = item.Remark;
  13103. // if (string.IsNullOrEmpty(temp.Remark)) {
  13104. // temp.Remark = "";
  13105. // }
  13106. // temp.IsDel = item.IsDel;
  13107. // temp.VisaDescription = item.VisaAttachment;
  13108. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13109. //([Id]
  13110. // ,[DIId]
  13111. // ,[VisaClient]
  13112. // ,[VisaPrice]
  13113. // ,[VisaCurrency]
  13114. // ,[IsThird]
  13115. // ,[PassengerType]
  13116. // ,[VisaNumber]
  13117. // ,[VisaFreeNumber]
  13118. // ,[CreateUserId]
  13119. // ,[CreateTime]
  13120. // ,[DeleteTime]
  13121. // ,[DeleteUserId]
  13122. // ,[Remark]
  13123. // ,[IsDel]
  13124. // ,[visaDescription])
  13125. // VALUES
  13126. // ({0},{1},'{2}',{3},{4}
  13127. //,{5},{6},{7},{8},{9}
  13128. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13129. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13130. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13131. //);
  13132. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13133. // }
  13134. // return Ok(JsonView(true, "操作成功!"));
  13135. // }
  13136. /// <summary>
  13137. /// 123132123
  13138. /// </summary>
  13139. /// <param name="_dto"></param>
  13140. /// <returns></returns>
  13141. [HttpPost]
  13142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13143. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13144. {
  13145. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13146. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13147. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13148. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13149. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13150. dicDetail.Add(789, 1034);
  13151. dicDetail.Add(790, 1035);
  13152. dicDetail.Add(791, 1036);
  13153. dicDetail.Add(792, 1037);
  13154. dicDetail.Add(793, 1038);
  13155. dicDetail.Add(794, 1039);
  13156. dicDetail.Add(795, 1040);
  13157. dicDetail.Add(796, 1041);
  13158. dicDetail.Add(797, 1042);
  13159. dicDetail.Add(798, 1043);
  13160. dicDetail.Add(801, 1044);
  13161. dicDetail.Add(802, 1045);
  13162. dicDetail.Add(803, 1046);
  13163. Dictionary<int, int> dic = new Dictionary<int, int>();
  13164. dic.Add(806, 1027);
  13165. dic.Add(807, 1028);
  13166. dic.Add(808, 1029);
  13167. dic.Add(809, 1030);
  13168. dic.Add(810, 1031);
  13169. dic.Add(811, 1032);
  13170. dic.Add(812, 1033);
  13171. foreach (var item in list_visa)
  13172. {
  13173. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13174. temp.Coefficient = item.coefficient;
  13175. DateTime dtCrt;
  13176. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13177. if (b1)
  13178. {
  13179. temp.CreateTime = dtCrt;
  13180. }
  13181. else
  13182. {
  13183. temp.CreateTime = DateTime.Now;
  13184. }
  13185. temp.CreateUserId = item.Operators;
  13186. temp.DeleteTime = "";
  13187. temp.DeleteUserId = 0;
  13188. temp.DiId = int.Parse(item.DIID);
  13189. temp.FilePath = item.FilePath;
  13190. temp.IsDel = item.IsDel;
  13191. temp.Price = item.Price;
  13192. temp.PriceCount = 1;
  13193. temp.PriceCurrency = item.Currency;
  13194. int detailId = 0;
  13195. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13196. {
  13197. detailId = dicDetail[item.PriceTypeDetail];
  13198. }
  13199. temp.PriceDetailType = detailId;
  13200. temp.PriceDt = DateTime.Now;
  13201. temp.PriceName = item.PriceName;
  13202. temp.PriceSum = item.Price;
  13203. int tid = 0;
  13204. if (dic.ContainsKey(item.PriceType))
  13205. {
  13206. tid = dic[item.PriceType];
  13207. }
  13208. temp.PriceType = tid;
  13209. temp.Remark = item.Remark;
  13210. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13211. }
  13212. return Ok(JsonView(true, "操作成功!"));
  13213. }
  13214. }
  13215. }