GroupsController.cs 706 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162
  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. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2136. if (groupData.Code != 0)
  2137. {
  2138. return Ok(JsonView(false, groupData.Msg));
  2139. }
  2140. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2141. }
  2142. /// <summary>
  2143. /// 机票费用录入操作(Status:1.新增,2.修改)
  2144. /// </summary>
  2145. /// <param name="dto"></param>
  2146. /// <returns></returns>
  2147. [HttpPost]
  2148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2149. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2150. {
  2151. try
  2152. {
  2153. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2154. if (groupData.Code != 0)
  2155. {
  2156. return Ok(JsonView(false, groupData.Msg));
  2157. }
  2158. #region 应用推送
  2159. try
  2160. {
  2161. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2162. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2163. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2164. }
  2165. catch (Exception ex)
  2166. {
  2167. }
  2168. #endregion
  2169. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2170. }
  2171. catch (Exception ex)
  2172. {
  2173. return Ok(JsonView(false, "程序错误!"));
  2174. throw;
  2175. }
  2176. }
  2177. /// <summary>
  2178. /// 根据舱位类型查询接团客户名单信息
  2179. /// </summary>
  2180. /// <param name="dto"></param>
  2181. /// <returns></returns>
  2182. [HttpPost]
  2183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2184. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2185. {
  2186. try
  2187. {
  2188. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2189. if (crm_Groups.Count != 0)
  2190. {
  2191. List<dynamic> Customer = new List<dynamic>();
  2192. foreach (var item in crm_Groups)
  2193. {
  2194. var data = new
  2195. {
  2196. Id = item.Id,
  2197. Pinyin = item.Pinyin,
  2198. Name = item.LastName + item.FirstName
  2199. };
  2200. Customer.Add(data);
  2201. }
  2202. return Ok(JsonView(true, "查询成功!", Customer));
  2203. }
  2204. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2205. }
  2206. catch (Exception ex)
  2207. {
  2208. return Ok(JsonView(false, "程序错误!"));
  2209. throw;
  2210. }
  2211. }
  2212. /// <summary>
  2213. /// 根据团号获取客户信息
  2214. /// </summary>
  2215. /// <param name="dto"></param>
  2216. /// <returns></returns>
  2217. [HttpPost]
  2218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2219. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2220. {
  2221. var jw = JsonView(false);
  2222. if (dto.DIID < 1)
  2223. {
  2224. jw.Msg += "请输入正确的diid";
  2225. return Ok(jw);
  2226. }
  2227. var arr = getSimplClientList(dto.DIID);
  2228. jw = JsonView(true, "获取成功!", arr);
  2229. return Ok(jw);
  2230. }
  2231. private List<SimplClientInfo> getSimplClientList(int diId)
  2232. {
  2233. 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);
  2234. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2235. return arr;
  2236. }
  2237. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2238. {
  2239. string result = origin;
  2240. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2241. {
  2242. string[] temparr = origin.Split(',');
  2243. string fistrStr = temparr[0];
  2244. int count = temparr.Count();
  2245. int tempId;
  2246. bool success = int.TryParse(fistrStr, out tempId);
  2247. if (success)
  2248. {
  2249. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2250. if (tempInfo != null)
  2251. {
  2252. if (count > 1)
  2253. {
  2254. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2255. }
  2256. else
  2257. {
  2258. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2259. }
  2260. }
  2261. }
  2262. }
  2263. return result;
  2264. }
  2265. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2266. {
  2267. string result = origin;
  2268. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2269. {
  2270. string[] temparr = origin.Split(',');
  2271. result = "";
  2272. foreach (var item in temparr)
  2273. {
  2274. int tempId;
  2275. bool success = int.TryParse(item, out tempId);
  2276. if (success)
  2277. {
  2278. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2279. if (tempInfo != null)
  2280. {
  2281. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2282. }
  2283. }
  2284. }
  2285. }
  2286. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2287. return result;
  2288. }
  2289. /// <summary>
  2290. /// 机票费用录入,删除
  2291. /// </summary>
  2292. /// <param name="dto"></param>
  2293. /// <returns></returns>
  2294. [HttpPost]
  2295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2296. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2297. {
  2298. try
  2299. {
  2300. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2301. if (res)
  2302. {
  2303. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2304. {
  2305. IsDel = 1,
  2306. DeleteUserId = dto.DeleteUserId,
  2307. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2308. }).ExecuteCommandAsync();
  2309. return Ok(JsonView(true, "删除成功!"));
  2310. }
  2311. return Ok(JsonView(false, "删除失败!"));
  2312. }
  2313. catch (Exception ex)
  2314. {
  2315. return Ok(JsonView(false, "程序错误!"));
  2316. throw;
  2317. }
  2318. }
  2319. /// <summary>
  2320. /// 导出机票录入报表
  2321. /// </summary>
  2322. /// <param name="dto"></param>
  2323. /// <returns></returns>
  2324. [HttpPost]
  2325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2326. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2327. {
  2328. try
  2329. {
  2330. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2331. if (groupData.Code != 0)
  2332. {
  2333. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2334. }
  2335. else
  2336. {
  2337. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2338. if (AirTicketReservations.Count != 0)
  2339. {
  2340. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2341. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2342. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2343. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2344. WorkbookDesigner designer = new WorkbookDesigner();
  2345. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2346. decimal countCost = 0;
  2347. foreach (var item in AirTicketReservations)
  2348. {
  2349. #region 处理客人姓名
  2350. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2351. item.ClientName = clientNames;
  2352. #endregion
  2353. if (item.BankType == "其他")
  2354. {
  2355. item.BankNo = "--";
  2356. }
  2357. else
  2358. {
  2359. if (!string.IsNullOrEmpty(item.BankType))
  2360. {
  2361. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2362. }
  2363. }
  2364. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2365. item.Price = System.Decimal.Round(item.Price, 2);
  2366. countCost += Convert.ToDecimal(item.Price);
  2367. }
  2368. designer.SetDataSource("Export", AirTicketReservations);
  2369. designer.SetDataSource("ExportDiCode", diCode);
  2370. designer.SetDataSource("ExportDiName", diName);
  2371. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2372. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2373. designer.Process();
  2374. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2375. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2376. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2377. return Ok(JsonView(true, "成功", url = rst));
  2378. }
  2379. else
  2380. {
  2381. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2382. }
  2383. }
  2384. }
  2385. catch (Exception ex)
  2386. {
  2387. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2388. throw;
  2389. }
  2390. }
  2391. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2392. /// <summary>
  2393. /// 行程单导出
  2394. /// </summary>
  2395. /// <param name="dto"></param>
  2396. /// <returns></returns>
  2397. [HttpPost]
  2398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2399. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2400. {
  2401. try
  2402. {
  2403. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2404. if (groupData.Code != 0)
  2405. {
  2406. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2407. }
  2408. else
  2409. {
  2410. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2411. if (dto.Language == "CN")
  2412. {
  2413. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2414. DocumentBuilder builder = new DocumentBuilder(doc);
  2415. int tableIndex = 0;//表格索引
  2416. //得到文档中的第一个表格
  2417. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2418. foreach (var item in _AirTicketReservations)
  2419. {
  2420. #region 处理固定数据
  2421. string[] FlightsCode = item.FlightsCode.Split('/');
  2422. if (FlightsCode.Length != 0)
  2423. {
  2424. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2425. if (_AirCompany != null)
  2426. {
  2427. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2428. }
  2429. else
  2430. {
  2431. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2432. }
  2433. }
  2434. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2435. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2436. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2437. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2438. string name = "";
  2439. foreach (string clientName in nameArray)
  2440. {
  2441. if (!name.Contains(clientName))
  2442. {
  2443. name += clientName + ",";
  2444. }
  2445. }
  2446. if (!string.IsNullOrWhiteSpace(name))
  2447. {
  2448. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2449. }
  2450. else
  2451. {
  2452. table.Range.Bookmarks["ClientName"].Text = "--";
  2453. }
  2454. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2455. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2456. table.Range.Bookmarks["JointTicket"].Text = "--";
  2457. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2458. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2459. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2460. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2461. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2462. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2463. #endregion
  2464. #region 循环数据处理
  2465. List<AirInfo> airs = new List<AirInfo>();
  2466. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2467. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2468. for (int i = 0; i < FlightsCode.Length; i++)
  2469. {
  2470. AirInfo air = new AirInfo();
  2471. string[] tempstr = DayArray[i]
  2472. .Replace("\r\n", string.Empty)
  2473. .Replace("\\r\\n", string.Empty)
  2474. .TrimStart().TrimEnd()
  2475. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2476. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2477. string starCity = "";
  2478. if (star_Three != null)
  2479. {
  2480. starCity = star_Three.AirPort;
  2481. }
  2482. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2483. string EndCity = "";
  2484. if (End_Three != null)
  2485. {
  2486. EndCity = End_Three.AirPort;
  2487. }
  2488. air.Destination = starCity + "/" + EndCity;
  2489. air.Flight = FlightsCode[i];
  2490. air.SeatingClass = item.CTypeName;
  2491. string dateTime = tempstr[2];
  2492. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2493. air.FlightDate = DateTemp;
  2494. air.DepartureTime = tempstr[5];
  2495. air.LandingTime = tempstr[6];
  2496. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2497. air.TicketStatus = "--";
  2498. air.Luggage = "--";
  2499. air.DepartureTerminal = "--";
  2500. air.LandingTerminal = "--";
  2501. airs.Add(air);
  2502. }
  2503. int row = 13;
  2504. for (int i = 0; i < airs.Count; i++)
  2505. {
  2506. if (airs.Count > 2)
  2507. {
  2508. for (int j = 0; j < airs.Count - 2; j++)
  2509. {
  2510. var CopyRow = table.Rows[12].Clone(true);
  2511. table.Rows.Add(CopyRow);
  2512. }
  2513. }
  2514. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2515. int index = 0;
  2516. foreach (PropertyInfo property in properties)
  2517. {
  2518. string value = property.GetValue(airs[i]).ToString();
  2519. Cell ishcel0 = table.Rows[row].Cells[index];
  2520. Paragraph p = new Paragraph(doc);
  2521. string s = value;
  2522. p.AppendChild(new Run(doc, s));
  2523. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2524. ishcel0.AppendChild(p);
  2525. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2526. index++;
  2527. }
  2528. row++;
  2529. }
  2530. #endregion
  2531. Paragraph lastParagraph = new Paragraph(doc);
  2532. //第一个表格末尾加段落
  2533. table.ParentNode.InsertAfter(lastParagraph, table);
  2534. //复制第一个表格
  2535. Table cloneTable = (Table)table.Clone(true);
  2536. //在文档末尾段落后面加入复制的表格
  2537. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2538. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2539. {
  2540. int rownewsIndex = 13;
  2541. for (int i = 0; i < 2; i++)
  2542. {
  2543. var CopyRow = table.Rows[12].Clone(true);
  2544. table.Rows.RemoveAt(13);
  2545. table.Rows.Add(CopyRow);
  2546. rownewsIndex++;
  2547. }
  2548. }
  2549. else
  2550. {
  2551. table.Rows.RemoveAt(12);
  2552. }
  2553. cloneTable.Rows.RemoveAt(12);
  2554. }
  2555. if (_AirTicketReservations.Count != 0)
  2556. {
  2557. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2558. if (FlightsCode.Length != 0)
  2559. {
  2560. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2561. if (_AirCompany != null)
  2562. {
  2563. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2564. }
  2565. else
  2566. {
  2567. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2568. }
  2569. }
  2570. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2571. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2572. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2573. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2574. string name = "";
  2575. foreach (string clientName in nameArray)
  2576. {
  2577. if (!name.Contains(clientName))
  2578. {
  2579. name += clientName + ",";
  2580. }
  2581. }
  2582. if (!string.IsNullOrWhiteSpace(name))
  2583. {
  2584. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2585. }
  2586. else
  2587. {
  2588. table.Range.Bookmarks["ClientName"].Text = "--";
  2589. }
  2590. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2591. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2592. table.Range.Bookmarks["JointTicket"].Text = "--";
  2593. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2594. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2595. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2596. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2597. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2598. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2599. }
  2600. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2601. //保存合并后的文档
  2602. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2603. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2604. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2605. return Ok(JsonView(true, "成功!", rst));
  2606. }
  2607. else
  2608. {
  2609. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2610. DocumentBuilder builder = new DocumentBuilder(doc);
  2611. int tableIndex = 0;//表格索引
  2612. //得到文档中的第一个表格
  2613. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2614. List<string> texts = new List<string>();
  2615. foreach (var item in _AirTicketReservations)
  2616. {
  2617. string[] FlightsCode = item.FlightsCode.Split('/');
  2618. if (FlightsCode.Length != 0)
  2619. {
  2620. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2621. if (_AirCompany != null)
  2622. {
  2623. if (!transDic.ContainsKey(_AirCompany.CnName))
  2624. {
  2625. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2626. }
  2627. }
  2628. else
  2629. {
  2630. if (!transDic.ContainsKey("--"))
  2631. {
  2632. transDic.Add("--", "--");
  2633. }
  2634. }
  2635. }
  2636. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2637. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2638. string name = "";
  2639. foreach (string clientName in nameArray)
  2640. {
  2641. name += clientName + ",";
  2642. }
  2643. if (!texts.Contains(name))
  2644. {
  2645. texts.Add(name);
  2646. }
  2647. List<AirInfo> airs = new List<AirInfo>();
  2648. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2649. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2650. for (int i = 0; i < FlightsCode.Length; i++)
  2651. {
  2652. AirInfo air = new AirInfo();
  2653. string[] tempstr = DayArray[i]
  2654. .Replace("\r\n", string.Empty)
  2655. .Replace("\\r\\n", string.Empty)
  2656. .TrimStart().TrimEnd()
  2657. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2658. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2659. if (star_Three != null)
  2660. {
  2661. if (!transDic.ContainsKey(star_Three.AirPort))
  2662. {
  2663. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2664. }
  2665. }
  2666. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2667. if (End_Three != null)
  2668. {
  2669. if (!transDic.ContainsKey(End_Three.AirPort))
  2670. {
  2671. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2672. }
  2673. }
  2674. if (!texts.Contains(item.CTypeName))
  2675. {
  2676. texts.Add(item.CTypeName);
  2677. }
  2678. }
  2679. }
  2680. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2681. if (transData.Count > 0)
  2682. {
  2683. foreach (TranslateResult item in transData)
  2684. {
  2685. if (!transDic.ContainsKey(item.Query))
  2686. {
  2687. transDic.Add(item.Query, item.Translation);
  2688. }
  2689. }
  2690. }
  2691. foreach (var item in _AirTicketReservations)
  2692. {
  2693. #region 处理固定数据
  2694. string[] FlightsCode = item.FlightsCode.Split('/');
  2695. if (FlightsCode.Length != 0)
  2696. {
  2697. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2698. if (_AirCompany != null)
  2699. {
  2700. string str = "--";
  2701. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2702. if (!string.IsNullOrEmpty(translateResult))
  2703. {
  2704. str = translateResult;
  2705. str = _airTicketResRep.Processing(str);
  2706. }
  2707. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2708. }
  2709. else
  2710. {
  2711. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2712. }
  2713. }
  2714. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2715. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2716. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2717. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2718. string names = "";
  2719. foreach (string clientName in nameArray)
  2720. {
  2721. names += clientName + ",";
  2722. }
  2723. if (!string.IsNullOrWhiteSpace(names))
  2724. {
  2725. string str = "--";
  2726. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2727. if (!string.IsNullOrEmpty(translateResult))
  2728. {
  2729. str = translateResult;
  2730. str = _airTicketResRep.Processing(str);
  2731. }
  2732. table.Range.Bookmarks["ClientName"].Text = str;
  2733. }
  2734. else
  2735. {
  2736. table.Range.Bookmarks["ClientName"].Text = "--";
  2737. }
  2738. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2739. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2740. table.Range.Bookmarks["JointTicket"].Text = "--";
  2741. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2742. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2743. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2744. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2745. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2746. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2747. #endregion
  2748. #region 循环数据处理
  2749. List<AirInfo> airs = new List<AirInfo>();
  2750. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2751. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2752. for (int i = 0; i < FlightsCode.Length; i++)
  2753. {
  2754. AirInfo air = new AirInfo();
  2755. string[] tempstr = DayArray[i]
  2756. .Replace("\r\n", string.Empty)
  2757. .Replace("\\r\\n", string.Empty)
  2758. .TrimStart().TrimEnd()
  2759. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2760. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2761. string starCity = "";
  2762. if (star_Three != null)
  2763. {
  2764. string str2 = "--";
  2765. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2766. if (!string.IsNullOrEmpty(translateResult2))
  2767. {
  2768. str2 = translateResult2;
  2769. str2 = _airTicketResRep.Processing(str2);
  2770. }
  2771. starCity = str2;
  2772. }
  2773. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2774. string EndCity = "";
  2775. if (End_Three != null)
  2776. {
  2777. string str1 = "--";
  2778. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2779. if (!string.IsNullOrEmpty(translateResult1))
  2780. {
  2781. str1 = translateResult1;
  2782. str1 = _airTicketResRep.Processing(str1);
  2783. }
  2784. EndCity = str1;
  2785. }
  2786. air.Destination = starCity + "/" + EndCity;
  2787. air.Flight = FlightsCode[i];
  2788. string str = "--";
  2789. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2790. if (!string.IsNullOrEmpty(translateResult))
  2791. {
  2792. str = translateResult;
  2793. str = _airTicketResRep.Processing(str);
  2794. }
  2795. air.SeatingClass = str;
  2796. string dateTime = tempstr[2];
  2797. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2798. air.FlightDate = DateTemp;
  2799. air.DepartureTime = tempstr[5];
  2800. air.LandingTime = tempstr[6];
  2801. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2802. air.TicketStatus = "--";
  2803. air.Luggage = "--";
  2804. air.DepartureTerminal = "--";
  2805. air.LandingTerminal = "--";
  2806. airs.Add(air);
  2807. }
  2808. int row = 13;
  2809. for (int i = 0; i < airs.Count; i++)
  2810. {
  2811. if (airs.Count > 2)
  2812. {
  2813. for (int j = 0; j < airs.Count - 2; j++)
  2814. {
  2815. var CopyRow = table.Rows[12].Clone(true);
  2816. table.Rows.Add(CopyRow);
  2817. }
  2818. }
  2819. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2820. int index = 0;
  2821. foreach (PropertyInfo property in properties)
  2822. {
  2823. string value = property.GetValue(airs[i]).ToString();
  2824. Cell ishcel0 = table.Rows[row].Cells[index];
  2825. Paragraph p = new Paragraph(doc);
  2826. string s = value;
  2827. p.AppendChild(new Run(doc, s));
  2828. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2829. ishcel0.AppendChild(p);
  2830. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2831. //ishcel0.CellFormat.VerticalAlignment=
  2832. index++;
  2833. }
  2834. row++;
  2835. }
  2836. #endregion
  2837. Paragraph lastParagraph = new Paragraph(doc);
  2838. //第一个表格末尾加段落
  2839. table.ParentNode.InsertAfter(lastParagraph, table);
  2840. //复制第一个表格
  2841. Table cloneTable = (Table)table.Clone(true);
  2842. //在文档末尾段落后面加入复制的表格
  2843. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2844. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2845. {
  2846. int rownewsIndex = 13;
  2847. for (int i = 0; i < 2; i++)
  2848. {
  2849. var CopyRow = table.Rows[12].Clone(true);
  2850. table.Rows.RemoveAt(13);
  2851. table.Rows.Add(CopyRow);
  2852. rownewsIndex++;
  2853. }
  2854. }
  2855. else
  2856. {
  2857. table.Rows.RemoveAt(12);
  2858. }
  2859. cloneTable.Rows.RemoveAt(12);
  2860. }
  2861. if (_AirTicketReservations.Count != 0)
  2862. {
  2863. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2864. if (FlightsCode.Length != 0)
  2865. {
  2866. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2867. if (_AirCompany != null)
  2868. {
  2869. string str = "--";
  2870. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2871. if (!string.IsNullOrEmpty(translateResult))
  2872. {
  2873. str = translateResult;
  2874. str = _airTicketResRep.Processing(str);
  2875. }
  2876. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2877. }
  2878. else
  2879. {
  2880. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2881. }
  2882. }
  2883. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2884. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2885. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2886. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2887. string names = "";
  2888. foreach (string clientName in nameArray)
  2889. {
  2890. names += clientName + ",";
  2891. }
  2892. if (!string.IsNullOrWhiteSpace(names))
  2893. {
  2894. string str = "--";
  2895. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2896. if (!string.IsNullOrEmpty(translateResult))
  2897. {
  2898. str = translateResult;
  2899. str = _airTicketResRep.Processing(str);
  2900. }
  2901. table.Range.Bookmarks["ClientName"].Text = str;
  2902. }
  2903. else
  2904. {
  2905. table.Range.Bookmarks["ClientName"].Text = "--";
  2906. }
  2907. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2908. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2909. table.Range.Bookmarks["JointTicket"].Text = "--";
  2910. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2911. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2912. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2913. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2914. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2915. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2916. }
  2917. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2918. //保存合并后的文档
  2919. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2920. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2921. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2922. return Ok(JsonView(true, "成功!", rst));
  2923. }
  2924. }
  2925. }
  2926. catch (Exception ex)
  2927. {
  2928. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2929. throw;
  2930. }
  2931. }
  2932. #endregion
  2933. #region 团组增减款项 --> 其他款项
  2934. /// <summary>
  2935. /// 团组增减款项下拉框绑定
  2936. /// </summary>
  2937. /// <param name="dto"></param>
  2938. /// <returns></returns>
  2939. [HttpPost]
  2940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2941. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2942. {
  2943. #region 参数验证
  2944. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2945. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2946. #endregion
  2947. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2948. }
  2949. /// <summary>
  2950. /// 根据团组Id查询团组增减款项
  2951. /// </summary>
  2952. /// <param name="dto"></param>
  2953. /// <returns></returns>
  2954. [HttpPost]
  2955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2956. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2957. {
  2958. #region 参数验证
  2959. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2960. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2961. #endregion
  2962. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2963. }
  2964. /// <summary>
  2965. /// 团组增减款项操作(Status:1.新增,2.修改)
  2966. /// </summary>
  2967. /// <param name="dto"></param>
  2968. /// <returns></returns>
  2969. [HttpPost]
  2970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2971. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2972. {
  2973. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2974. if (groupData.Code != 200)
  2975. {
  2976. return Ok(JsonView(false, groupData.Msg));
  2977. }
  2978. #region 应用推送
  2979. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2980. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2981. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2982. #endregion
  2983. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2984. }
  2985. /// <summary>
  2986. /// 团组增减款项操作 删除
  2987. /// </summary>
  2988. /// <param name="dto"></param>
  2989. /// <returns></returns>
  2990. [HttpPost]
  2991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2992. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2993. {
  2994. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2995. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2996. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2997. if (res.Code == 0)
  2998. {
  2999. return Ok(JsonView(true, "删除成功!"));
  3000. }
  3001. return Ok(JsonView(false, "删除失败!"));
  3002. }
  3003. /// <summary>
  3004. /// 根据团组增减款项Id查询
  3005. /// </summary>
  3006. /// <param name="dto"></param>
  3007. /// <returns></returns>
  3008. [HttpPost]
  3009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3010. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3011. {
  3012. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3013. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3014. }
  3015. /// <summary>
  3016. /// 查询供应商名称
  3017. /// </summary>
  3018. /// <param name="dto"></param>
  3019. /// <returns></returns>
  3020. [HttpPost]
  3021. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3022. {
  3023. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3024. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3025. ?? new List<Grp_DecreasePayments>();
  3026. dbResult = dbResult.Distinct(new
  3027. ProductComparer()).ToList();
  3028. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3029. {
  3030. x.Id,
  3031. x.SupplierAddress,
  3032. x.SupplierArea,
  3033. x.SupplierContact,
  3034. x.SupplierContactNumber,
  3035. x.SupplierEmail,
  3036. x.SupplierName,
  3037. x.SupplierSocialAccount,
  3038. x.SupplierTypeId,
  3039. }).ToList());
  3040. return Ok(jw);
  3041. }
  3042. #endregion
  3043. #region 文件上传、删除
  3044. /// <summary>
  3045. /// region 文件上传 可以带参数
  3046. /// </summary>
  3047. /// <param name="file"></param>
  3048. /// <returns></returns>
  3049. [HttpPost]
  3050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3051. public async Task<IActionResult> UploadProject(IFormFile file)
  3052. {
  3053. //var TypeName = Request.Headers["TypeName"].ToString();
  3054. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3055. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3056. ////文件名称
  3057. //string projectFileName = file.FileName;
  3058. ////上传的文件的路径
  3059. //string filePath = $"{fileDir}/{projectFileName}";
  3060. //if (TypeName == "A")//A代表团组增减款项
  3061. //{
  3062. // filePath = fileDir + $@"\团组增减款项相关文件";
  3063. // if (!Directory.Exists(filePath))
  3064. // {
  3065. // Directory.CreateDirectory(filePath);
  3066. // }
  3067. // //上传的文件的路径
  3068. // filePath += $@"\{projectFileName}";
  3069. //}
  3070. //else if (TypeName == "B")//B代表商邀相关文件
  3071. //{
  3072. // //上传的文件的路径
  3073. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3074. // if (!Directory.Exists(filePath))
  3075. // {
  3076. // Directory.CreateDirectory(filePath);
  3077. // }
  3078. // //上传的文件的路径
  3079. // filePath = $@"\{projectFileName}";
  3080. //}
  3081. //try
  3082. //{
  3083. // using (FileStream fs = System.IO.File.Create(filePath))
  3084. // {
  3085. // file.CopyTo(fs);
  3086. // fs.Flush();
  3087. // }
  3088. //}
  3089. //catch (Exception ex)
  3090. //{
  3091. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3092. //}
  3093. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3094. try
  3095. {
  3096. var TypeName = Request.Headers["TypeName"].ToString();
  3097. if (file != null)
  3098. {
  3099. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3100. //文件名称
  3101. string projectFileName = file.FileName;
  3102. //上传的文件的路径
  3103. string filePath = $"{fileDir}/{projectFileName}";
  3104. if (TypeName == "A")//A代表团组增减款项
  3105. {
  3106. if (!Directory.Exists(fileDir))
  3107. {
  3108. Directory.CreateDirectory(fileDir);
  3109. }
  3110. //上传的文件的路径
  3111. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3112. }
  3113. else if (TypeName == "B")//B代表商邀相关文件
  3114. {
  3115. if (!Directory.Exists(fileDir))
  3116. {
  3117. Directory.CreateDirectory(fileDir);
  3118. }
  3119. //上传的文件的路径
  3120. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3121. }
  3122. using (FileStream fs = System.IO.File.Create(filePath))
  3123. {
  3124. file.CopyTo(fs);
  3125. fs.Flush();
  3126. }
  3127. return Ok(JsonView(true, "上传成功!", projectFileName));
  3128. }
  3129. else
  3130. {
  3131. return Ok(JsonView(false, "上传失败!"));
  3132. }
  3133. }
  3134. catch (Exception ex)
  3135. {
  3136. return Ok(JsonView(false, "程序错误!"));
  3137. }
  3138. }
  3139. /// <summary>
  3140. /// 删除指定文件
  3141. /// </summary>
  3142. /// <param name="dto"></param>
  3143. /// <returns></returns>
  3144. [HttpPost]
  3145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3146. public async Task<IActionResult> DelFile(DelFileDto dto)
  3147. {
  3148. try
  3149. {
  3150. var TypeName = Request.Headers["TypeName"].ToString();
  3151. string filePath = "";
  3152. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3153. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3154. int id = 0;
  3155. if (TypeName == "A")
  3156. {
  3157. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3158. // 删除该文件
  3159. System.IO.File.Delete(filePath);
  3160. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  3161. }
  3162. else if (TypeName == "B")
  3163. {
  3164. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3165. // 删除该文件
  3166. System.IO.File.Delete(filePath);
  3167. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  3168. }
  3169. if (id != 0)
  3170. {
  3171. return Ok(JsonView(true, "成功!"));
  3172. }
  3173. else
  3174. {
  3175. return Ok(JsonView(false, "失败!"));
  3176. }
  3177. }
  3178. catch (Exception ex)
  3179. {
  3180. return Ok(JsonView(false, "程序错误!"));
  3181. throw;
  3182. }
  3183. }
  3184. #endregion
  3185. #region 商邀费用录入
  3186. /// <summary>
  3187. /// 根据团组Id查询商邀费用列表
  3188. /// </summary>
  3189. /// <param name="dto"></param>
  3190. /// <returns></returns>
  3191. [HttpPost]
  3192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3193. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3194. {
  3195. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3196. if (groupData.Code != 0)
  3197. {
  3198. return Ok(JsonView(false, groupData.Msg));
  3199. }
  3200. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3201. }
  3202. //
  3203. /// <summary>
  3204. /// 商邀费用 Info Page 基础数据源
  3205. /// </summary>
  3206. /// <param name="dto"></param>
  3207. /// <returns></returns>
  3208. [HttpPost]
  3209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3210. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3211. {
  3212. try
  3213. {
  3214. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3215. if (groupData.Code != 0)
  3216. {
  3217. return Ok(JsonView(false, groupData.Msg));
  3218. }
  3219. return Ok(JsonView(true, "操作成功", groupData.Data));
  3220. }
  3221. catch (Exception ex)
  3222. {
  3223. return Ok(JsonView(false, ex.Message));
  3224. throw;
  3225. }
  3226. }
  3227. /// <summary>
  3228. /// 根据商邀费用ID查询C表和商邀费用数据
  3229. /// </summary>
  3230. /// <param name="dto"></param>
  3231. /// <returns></returns>
  3232. [HttpPost]
  3233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3234. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3235. {
  3236. try
  3237. {
  3238. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3239. if (groupData.Code != 0)
  3240. {
  3241. return Ok(JsonView(false, groupData.Msg));
  3242. }
  3243. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3244. }
  3245. catch (Exception ex)
  3246. {
  3247. return Ok(JsonView(false, ex.Message));
  3248. throw;
  3249. }
  3250. }
  3251. /// <summary>
  3252. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3253. /// </summary>
  3254. /// <param name="dto"></param>
  3255. /// <returns></returns>
  3256. [HttpPost]
  3257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3258. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3259. {
  3260. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3261. if (groupData.Code != 0)
  3262. {
  3263. return Ok(JsonView(false, groupData.Msg));
  3264. }
  3265. #region 应用推送
  3266. try
  3267. {
  3268. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3269. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3270. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3271. }
  3272. catch (Exception ex)
  3273. {
  3274. }
  3275. #endregion
  3276. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3277. }
  3278. /// <summary>
  3279. /// 商邀删除
  3280. /// </summary>
  3281. /// <param name="dto"></param>
  3282. /// <returns></returns>
  3283. [HttpPost]
  3284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3285. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3286. {
  3287. try
  3288. {
  3289. _sqlSugar.BeginTran();
  3290. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3291. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3292. {
  3293. IsDel = 1,
  3294. DeleteUserId = dto.DeleteUserId,
  3295. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3296. })
  3297. .Where(it => it.Id == dto.Id)
  3298. .ExecuteCommand();
  3299. if (res1 > 0)
  3300. {
  3301. int _diId = 0;
  3302. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3303. if (_ioaInfo != null)
  3304. {
  3305. _diId = _ioaInfo.DiId;
  3306. }
  3307. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3308. .SetColumns(a => new Grp_CreditCardPayment()
  3309. {
  3310. IsDel = 1,
  3311. DeleteUserId = dto.DeleteUserId,
  3312. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3313. })
  3314. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3315. .ExecuteCommand();
  3316. if (res2 > 0)
  3317. {
  3318. _sqlSugar.CommitTran();
  3319. return Ok(JsonView(true, "删除成功!"));
  3320. }
  3321. }
  3322. _sqlSugar.RollbackTran();
  3323. return Ok(JsonView(false, "删除失败"));
  3324. }
  3325. catch (Exception ex)
  3326. {
  3327. _sqlSugar.RollbackTran();
  3328. return Ok(JsonView(false, ex.Message));
  3329. }
  3330. }
  3331. /// <summary>
  3332. /// 团组模块文件上传
  3333. /// </summary>
  3334. /// <param name="dto"></param>
  3335. /// <returns></returns>
  3336. [HttpPost]
  3337. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3338. {
  3339. var jw = JsonView(false);
  3340. long M = 1024 * 1024;
  3341. if (dto.Files == null || dto.Files.Count == 0)
  3342. {
  3343. jw.Msg = "无文件信息!";
  3344. return Ok(jw);
  3345. }
  3346. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3347. {
  3348. jw.Msg = "文件大小超过20M!";
  3349. return Ok(jw);
  3350. }
  3351. //var nameSp = dto.File.FileName.Split(".");
  3352. //if (nameSp.Length < 2)
  3353. //{
  3354. // jw.Msg = "拓展名称有误!";
  3355. // return Ok(jw);
  3356. //}
  3357. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3358. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3359. //{
  3360. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3361. // return Ok(jw);
  3362. //}
  3363. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3364. if (Ctable == null)
  3365. {
  3366. jw.Msg = "Ctable指向有误!";
  3367. return Ok(jw);
  3368. }
  3369. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3370. if (groupInfo == null)
  3371. {
  3372. jw.Msg = "团组信息不存在!";
  3373. return Ok(jw);
  3374. }
  3375. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3376. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3377. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3378. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3379. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3380. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3381. try
  3382. {
  3383. if (!Directory.Exists(fileBase))
  3384. {
  3385. Directory.CreateDirectory(fileBase);
  3386. }
  3387. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3388. foreach (var fileStream in dto.Files)
  3389. {
  3390. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3391. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3392. {
  3393. Cid = dto.Cid,
  3394. CreateTime = DateTime.Now,
  3395. CreateUserId = dto.Userid,
  3396. Ctable = dto.Ctable,
  3397. Diid = dto.Diid,
  3398. IsDel = 0,
  3399. FilePath = saveFilePath,
  3400. FileName = fileStream.FileName
  3401. };
  3402. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3403. {
  3404. fileStream.CopyTo(fs);
  3405. fs.Flush();
  3406. }
  3407. saveArr.Add(file);
  3408. }
  3409. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3410. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3411. jw = JsonView(true, "保存成功!", new
  3412. {
  3413. count = addResult,
  3414. filesName = saveArr.Select(x => x.FileName)
  3415. }) ;
  3416. }
  3417. catch (Exception ex)
  3418. {
  3419. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3420. {
  3421. count = 0,
  3422. filesName = new string[0],
  3423. }) ;
  3424. }
  3425. return Ok(jw);
  3426. }
  3427. /// <summary>
  3428. /// 查询各模块已保存文件
  3429. /// </summary>
  3430. /// <param name="dto"></param>
  3431. /// <returns></returns>
  3432. [HttpPost]
  3433. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3434. {
  3435. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3436. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3437. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3438. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3439. {
  3440. expression = Expressionable.Create<Grp_GroupModelFile>()
  3441. .And(x=>visaIds.Contains(x.CreateUserId));
  3442. }
  3443. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3444. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3445. .Where(expression.ToExpression())
  3446. .ToList();
  3447. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3448. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3449. {
  3450. x.FileName,
  3451. x.Id,
  3452. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3453. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3454. })));
  3455. }
  3456. /// <summary>
  3457. /// 下载该团组下的所有文件
  3458. /// </summary>
  3459. /// <param name="dto"></param>
  3460. /// <returns></returns>
  3461. [HttpPost]
  3462. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3463. {
  3464. var jw = JsonView(false);
  3465. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3466. if (groupInfo == null)
  3467. {
  3468. jw.Msg = "团组信息不存在!";
  3469. return Ok(jw);
  3470. }
  3471. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3472. var isModule = Convert.ToBoolean(dto.isModule);
  3473. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3474. IOOperatorHelper io = new IOOperatorHelper();
  3475. if (isModule)
  3476. {
  3477. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3478. foreach (var moduleArr in moduleGroup)
  3479. {
  3480. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3481. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3482. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3483. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3484. foreach (var item in moduleArr)
  3485. {
  3486. if (System.IO.File.Exists(item.FilePath))
  3487. {
  3488. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3489. {
  3490. byte[] bytes = new byte[fileStream.Length];
  3491. fileStream.Read(bytes, 0, bytes.Length);
  3492. fileStream.Close();
  3493. Stream stream = new MemoryStream(bytes);
  3494. chiZips.Add(item.FileName, stream);
  3495. }
  3496. }
  3497. }
  3498. if (chiZips.Count > 0)
  3499. {
  3500. var byts = io.ConvertZipStream(chiZips);
  3501. Stream stream = new MemoryStream(byts);
  3502. Zips.Add(key.Name+"_.zip", stream);
  3503. }
  3504. }
  3505. }
  3506. else
  3507. {
  3508. foreach (var item in dbQuery)
  3509. {
  3510. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3511. {
  3512. byte[] bytes = new byte[fileStream.Length];
  3513. fileStream.Read(bytes, 0, bytes.Length);
  3514. fileStream.Close();
  3515. Stream stream = new MemoryStream(bytes);
  3516. while (Zips.Keys.Contains(item.FileName))
  3517. {
  3518. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3519. }
  3520. Zips.Add(item.FileName, stream);
  3521. }
  3522. }
  3523. }
  3524. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3525. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3526. if (Zips.Count > 0)
  3527. {
  3528. var byts = io.ConvertZipStream(Zips);
  3529. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3530. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3531. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3532. }
  3533. else
  3534. {
  3535. jw.Msg = "暂无生成文件!";
  3536. }
  3537. return Ok(jw);
  3538. }
  3539. /// <summary>
  3540. /// 下载该团组下此模块的所有文件
  3541. /// </summary>
  3542. /// <param name="dto"></param>
  3543. /// <returns></returns>
  3544. [HttpPost]
  3545. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3546. {
  3547. var jw = JsonView(false);
  3548. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3549. if (groupInfo == null)
  3550. {
  3551. jw.Msg = "团组信息不存在!";
  3552. return Ok(jw);
  3553. }
  3554. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3555. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3556. && x.IsDel == 0);
  3557. if (key == null)
  3558. {
  3559. jw.Msg = "Ctable指向错误!";
  3560. return Ok(jw);
  3561. }
  3562. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3563. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3564. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3565. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3566. IOOperatorHelper io = new IOOperatorHelper();
  3567. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3568. foreach (var item in dbQuery)
  3569. {
  3570. if (System.IO.File.Exists(item.FilePath))
  3571. {
  3572. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3573. {
  3574. byte[] bytes = new byte[fileStream.Length];
  3575. fileStream.Read(bytes, 0, bytes.Length);
  3576. fileStream.Close();
  3577. Stream stream = new MemoryStream(bytes);
  3578. while (Zips.Keys.Contains(item.FileName))
  3579. {
  3580. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3581. }
  3582. Zips.Add(item.FileName, stream);
  3583. }
  3584. }
  3585. }
  3586. if (Zips.Count > 0)
  3587. {
  3588. var byts = io.ConvertZipStream(Zips);
  3589. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3590. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3591. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3592. }
  3593. else
  3594. {
  3595. jw.Msg = "暂无生成文件!";
  3596. }
  3597. return Ok(jw);
  3598. }
  3599. /// <summary>
  3600. /// 删除该团组下的指定文件
  3601. /// </summary>
  3602. /// <param name="dto"></param>
  3603. /// <returns></returns>
  3604. [HttpPost]
  3605. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3606. {
  3607. var jw = JsonView(false);
  3608. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3609. if (sing == null)
  3610. {
  3611. jw.Msg = "暂无";
  3612. return Ok(jw);
  3613. }
  3614. if (System.IO.File.Exists(sing.FilePath))
  3615. {
  3616. try
  3617. {
  3618. System.IO.File.Delete(sing.FilePath);
  3619. }
  3620. catch (Exception ex)
  3621. {
  3622. jw.Msg = "删除失败!" + ex.Message;
  3623. return Ok(jw);
  3624. }
  3625. }
  3626. sing.IsDel = 1;
  3627. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3628. sing.DeleteUserId = dto.UserId;
  3629. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3630. jw = JsonView(true, "删除成功!");
  3631. return Ok(jw);
  3632. }
  3633. #endregion
  3634. #region 团组英文资料
  3635. /// <summary>
  3636. /// 查询团组英文所有资料
  3637. /// </summary>
  3638. /// <param name="dto"></param>
  3639. /// <returns></returns>
  3640. [HttpPost]
  3641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3642. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3643. {
  3644. try
  3645. {
  3646. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3647. if (groupData.Code != 0)
  3648. {
  3649. return Ok(JsonView(false, groupData.Msg));
  3650. }
  3651. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3652. }
  3653. catch (Exception ex)
  3654. {
  3655. return Ok(JsonView(false, "程序错误!"));
  3656. throw;
  3657. }
  3658. }
  3659. /// <summary>
  3660. /// 团组英文资料操作(Status:1.新增,2.修改)
  3661. /// </summary>
  3662. /// <param name="dto"></param>
  3663. /// <returns></returns>
  3664. [HttpPost]
  3665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3666. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3667. {
  3668. try
  3669. {
  3670. Result groupData = await _delegationEnDataRep.OpDelegationEnData(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. /// 团组英文资料Id查询数据
  3685. /// </summary>
  3686. /// <param name="dto"></param>
  3687. /// <returns></returns>
  3688. [HttpPost]
  3689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3690. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3691. {
  3692. try
  3693. {
  3694. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3695. if (_DelegationEnData != null)
  3696. {
  3697. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3698. }
  3699. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3700. }
  3701. catch (Exception ex)
  3702. {
  3703. return Ok(JsonView(false, "程序错误!"));
  3704. throw;
  3705. }
  3706. }
  3707. /// <summary>
  3708. /// 团组英文资料删除
  3709. /// </summary>
  3710. /// <param name="dto"></param>
  3711. /// <returns></returns>
  3712. [HttpPost]
  3713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3714. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3715. {
  3716. try
  3717. {
  3718. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3719. if (!res)
  3720. {
  3721. return Ok(JsonView(false, "删除失败"));
  3722. }
  3723. return Ok(JsonView(true, "删除成功!"));
  3724. }
  3725. catch (Exception ex)
  3726. {
  3727. return Ok(JsonView(false, "程序错误!"));
  3728. throw;
  3729. }
  3730. }
  3731. #endregion
  3732. #region 导出邀请函
  3733. /// <summary>
  3734. /// 导出邀请函页面初始化
  3735. /// </summary>
  3736. /// <param name="dto"></param>
  3737. /// <returns></returns>
  3738. [HttpPost]
  3739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3740. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3741. {
  3742. try
  3743. {
  3744. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3745. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3746. if (dto.DiId == 0)
  3747. {
  3748. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3749. }
  3750. else
  3751. {
  3752. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3753. }
  3754. return Ok(JsonView(true, "查询成功!", new
  3755. {
  3756. deleClient = crm_Deles,
  3757. delegations = grp_Delegations
  3758. }));
  3759. }
  3760. catch (Exception ex)
  3761. {
  3762. return Ok(JsonView(false, "程序错误!"));
  3763. throw;
  3764. }
  3765. }
  3766. /// <summary>
  3767. /// 导出邀请函
  3768. /// </summary>
  3769. /// <param name="dto"></param>
  3770. /// <returns></returns>
  3771. [HttpPost]
  3772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3773. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3774. {
  3775. #region 参数验证
  3776. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3777. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3778. #endregion
  3779. try
  3780. {
  3781. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3782. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3783. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3784. From Grp_TourClientList tcl
  3785. Left Join
  3786. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3787. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3788. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3789. From Crm_DeleClient dc
  3790. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3791. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3792. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3793. Where dc.IsDel = 0) temp
  3794. On temp.DcId =tcl.ClientId
  3795. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3796. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3797. List<string> texts = new List<string>();
  3798. if (datas.Count != 0)
  3799. {
  3800. foreach (TourClientListDetailsView item in datas)
  3801. {
  3802. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3803. {
  3804. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3805. }
  3806. else
  3807. {
  3808. string name = item.LastName + item.FirstName;
  3809. texts.Add(name);
  3810. }
  3811. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3812. {
  3813. if (!transDic.ContainsKey(item.Job))
  3814. {
  3815. texts.Add(item.Job);
  3816. }
  3817. }
  3818. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3819. {
  3820. texts.Add(item.CompanyFullName);
  3821. }
  3822. }
  3823. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3824. if (transData.Count > 0)
  3825. {
  3826. foreach (TranslateResult item in transData)
  3827. {
  3828. if (!transDic.ContainsKey(item.Query))
  3829. {
  3830. transDic.Add(item.Query, item.Translation);
  3831. }
  3832. }
  3833. }
  3834. List<GuestList> list = new List<GuestList>();
  3835. foreach (TourClientListDetailsView dele in datas)
  3836. {
  3837. GuestList guestList = new GuestList();
  3838. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3839. {
  3840. guestList.Name = dele.Pinyin;
  3841. }
  3842. else
  3843. {
  3844. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3845. guestList.Name = Name;
  3846. }
  3847. if (dele.Sex == 0)
  3848. {
  3849. guestList.Sex = "Male";
  3850. }
  3851. else if (dele.Sex == 1)
  3852. {
  3853. guestList.Sex = "Female";
  3854. }
  3855. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3856. if (!string.IsNullOrEmpty(dele.Job))
  3857. {
  3858. guestList.Job = dele.Job;
  3859. }
  3860. list.Add(guestList);
  3861. }
  3862. //载入模板
  3863. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3864. DocumentBuilder builder = new DocumentBuilder(doc);
  3865. //获取word里所有表格
  3866. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3867. //获取所填表格的序数
  3868. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3869. var rowStart = tableOne.Rows[0]; //获取第1行
  3870. //循环赋值
  3871. for (int i = 0; i < list.Count; i++)
  3872. {
  3873. builder.MoveToCell(0, i + 1, 0, 0);
  3874. builder.Write(list[i].Name.ToString());
  3875. builder.MoveToCell(0, i + 1, 1, 0);
  3876. builder.Write(list[i].Sex.ToString());
  3877. builder.MoveToCell(0, i + 1, 2, 0);
  3878. builder.Write(list[i].DOB.ToString());
  3879. builder.MoveToCell(0, i + 1, 3, 0);
  3880. builder.Write(list[i].Job.ToString());
  3881. }
  3882. //删除多余行
  3883. while (tableOne.Rows.Count > list.Count + 1)
  3884. {
  3885. tableOne.Rows.RemoveAt(list.Count + 1);
  3886. }
  3887. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3888. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3889. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3890. doc.Save(filePath);
  3891. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3892. return Ok(JsonView(true, "操作成功!", Url));
  3893. }
  3894. else
  3895. {
  3896. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3897. }
  3898. }
  3899. catch (Exception ex)
  3900. {
  3901. return Ok(JsonView(false, ex.Message));
  3902. throw;
  3903. }
  3904. }
  3905. #endregion
  3906. #region 团组经理模块 出入境费用
  3907. ///// <summary>
  3908. ///// 团组模块 - 出入境费用
  3909. ///// </summary>
  3910. ///// <returns></returns>
  3911. //[HttpPost]
  3912. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3913. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3914. //{
  3915. // try
  3916. // {
  3917. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3918. // if (data.Code != 0)
  3919. // {
  3920. // return Ok(JsonView(false, data.Msg));
  3921. // }
  3922. // return Ok(JsonView(true, "查询成功!"));
  3923. // }
  3924. // catch (Exception ex)
  3925. // {
  3926. // return Ok(JsonView(false, ex.Message));
  3927. // throw;
  3928. // }
  3929. //}
  3930. /// <summary>
  3931. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3932. /// </summary>
  3933. /// <returns></returns>
  3934. [HttpPost]
  3935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3936. public async Task<IActionResult> SetDayAndCostAreaChange()
  3937. {
  3938. try
  3939. {
  3940. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3941. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3942. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3943. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3944. foreach (var item in unite) //处理交集数据
  3945. {
  3946. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3947. }
  3948. foreach (var item in merge) //处理差集数据
  3949. {
  3950. int nationalTravelFeeId = 0;
  3951. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3952. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3953. else
  3954. {
  3955. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3956. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3957. }
  3958. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3959. }
  3960. //只更新dayAndCost 的 nationalTravelFeeId;
  3961. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3962. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3963. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3964. }
  3965. catch (Exception ex)
  3966. {
  3967. return Ok(JsonView(false, ex.Message));
  3968. throw;
  3969. }
  3970. }
  3971. /// <summary>
  3972. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3973. /// </summary>
  3974. /// <returns></returns>
  3975. [HttpPost]
  3976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3977. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3978. {
  3979. try
  3980. {
  3981. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3982. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3983. //SetDataInfoView
  3984. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3985. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3986. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3987. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3988. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3989. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3990. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3991. //默认币种显示
  3992. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3993. {
  3994. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3995. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3996. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3997. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3998. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3999. };
  4000. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4001. if (_currencyRate.Count > 0)
  4002. {
  4003. foreach (var item in _currencyInfos)
  4004. {
  4005. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4006. if (rateInfo != null)
  4007. {
  4008. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4009. rate1 *= 1.035M;
  4010. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4011. }
  4012. }
  4013. }
  4014. return Ok(JsonView(true, "查询成功!", new
  4015. {
  4016. GroupNameData = groupNameData.Data,
  4017. CurrencyData = _CurrencyData,
  4018. WordTypeData = _WordTypeData,
  4019. ExcelTypeData = _ExcelTypeData,
  4020. CurrencyInit = _currencyInfos
  4021. }));
  4022. }
  4023. catch (Exception ex)
  4024. {
  4025. return Ok(JsonView(false, ex.Message));
  4026. throw;
  4027. }
  4028. }
  4029. /// <summary>
  4030. /// 团组模块 - 出入境费用
  4031. /// 实时汇率 tips
  4032. /// 签证费用 tips
  4033. /// </summary>
  4034. /// <returns></returns>
  4035. [HttpPost]
  4036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4037. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4038. {
  4039. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4040. //默认币种显示
  4041. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4042. {
  4043. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4044. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4045. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4046. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4047. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4048. };
  4049. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4050. List<dynamic> reteInfos = new List<dynamic>();
  4051. if (_currencyRate.Count > 0)
  4052. {
  4053. foreach (var item in _currencyInfos)
  4054. {
  4055. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4056. if (rateInfo != null)
  4057. {
  4058. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4059. decimal rate1 = item.Rate;
  4060. rate1 *= 1.03M;
  4061. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4062. reteInfos.Add(new
  4063. {
  4064. currCode = item.CurrencyCode,
  4065. currName = item.CurrencyName,
  4066. rate = rate2,
  4067. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4068. });
  4069. }
  4070. }
  4071. }
  4072. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4073. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4074. return Ok(JsonView(true, "查询成功!", new
  4075. {
  4076. //GroupNameData = groupNameData.Data,
  4077. visaData = visaData.Data,
  4078. airData = airData.Data,
  4079. reteInfos = reteInfos
  4080. }));
  4081. }
  4082. /// <summary>
  4083. /// 团组模块 - 出入境费用 - Info
  4084. /// </summary>
  4085. /// <returns></returns>
  4086. [HttpPost]
  4087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4088. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4089. {
  4090. try
  4091. {
  4092. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4093. if (data.Code != 0)
  4094. {
  4095. return Ok(JsonView(false, data.Msg));
  4096. }
  4097. return Ok(JsonView(true, "查询成功!", data.Data));
  4098. }
  4099. catch (Exception ex)
  4100. {
  4101. return Ok(JsonView(false, ex.Message));
  4102. }
  4103. }
  4104. /// <summary>
  4105. /// 团组模块 - 出入境费用 - Add And Update
  4106. /// </summary>
  4107. /// <returns></returns>
  4108. [HttpPost]
  4109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4110. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4111. {
  4112. try
  4113. {
  4114. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4115. if (data.Code != 0)
  4116. {
  4117. return Ok(JsonView(false, data.Msg));
  4118. }
  4119. //生成默认文件pdf并且通知人员
  4120. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4121. {
  4122. DiId = dto.DiId,
  4123. ExportType = 1,
  4124. SubTypeId = 1005
  4125. }, "pdf");
  4126. //发送通知
  4127. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4128. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4129. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4130. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  4131. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  4132. return Ok(JsonView(true, data.Msg, data.Data));
  4133. }
  4134. catch (Exception ex)
  4135. {
  4136. return Ok(JsonView(false, ex.Message));
  4137. }
  4138. }
  4139. /// <summary>
  4140. /// 团组模块 - 出入境费用 - Confirm 费用
  4141. /// </summary>
  4142. /// <returns></returns>
  4143. [HttpPost]
  4144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4145. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4146. {
  4147. //TODO:测试完毕需把对应的用户ID更改
  4148. //1、数据表添加字段
  4149. //2、更改字段接口()
  4150. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4151. //3、确认成功 给财务发送消息
  4152. if (_view.Code == 200)
  4153. {
  4154. if (dto.Type == 1)
  4155. {
  4156. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4157. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4158. }
  4159. }
  4160. return Ok(_view);
  4161. }
  4162. /// <summary>
  4163. /// 团组模块 - 出入境费用 - File downlaod
  4164. /// </summary>
  4165. /// <param name="dto"></param>
  4166. /// <returns></returns>
  4167. [HttpPost]
  4168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4169. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4170. {
  4171. try
  4172. {
  4173. if (dto.DiId < 1)
  4174. {
  4175. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4176. }
  4177. if (dto.ExportType < 1)
  4178. {
  4179. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4180. }
  4181. if (dto.SubTypeId < 1)
  4182. {
  4183. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4184. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4185. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4186. 3 团组成员名单 1 团组成员名单"));
  4187. }
  4188. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4189. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4190. if (_EnterExitCosts == null)
  4191. {
  4192. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4193. }
  4194. //数据源
  4195. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4196. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4197. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4198. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4199. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4200. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4201. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4202. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4203. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4204. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4205. .Select((tcl, dc, cc) => new
  4206. {
  4207. Name = dc.LastName + dc.FirstName,
  4208. Sex = dc.Sex,
  4209. Birthday = dc.BirthDay,
  4210. Company = cc.CompanyFullName,
  4211. Job = dc.Job
  4212. })
  4213. .ToList();
  4214. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4215. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4216. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4217. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4218. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4219. if (dto.ExportType == 1) //明细表
  4220. {
  4221. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4222. {
  4223. //获取模板
  4224. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4225. //载入模板
  4226. Document doc = new Document(tempPath);
  4227. DocumentBuilder builder = new DocumentBuilder(doc);
  4228. //利用键值对存放数据
  4229. Dictionary<string, string> dic = new Dictionary<string, string>();
  4230. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4231. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4232. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4233. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4234. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4235. //境内费用(其他费用)
  4236. if (_EnterExitCosts.ChoiceOne == 1)
  4237. {
  4238. string row1_1 = "";
  4239. if (_EnterExitCosts.Visa > 0)
  4240. {
  4241. //insidePayTotal += _EnterExitCosts.Visa;
  4242. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4243. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4244. {
  4245. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4246. }
  4247. }
  4248. string row1_2 = "";
  4249. if (_EnterExitCosts.YiMiao > 0)
  4250. {
  4251. //insidePayTotal += _EnterExitCosts.YiMiao;
  4252. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4253. }
  4254. if (_EnterExitCosts.HeSuan > 0)
  4255. {
  4256. //insidePayTotal += _EnterExitCosts.HeSuan;
  4257. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4258. }
  4259. if (_EnterExitCosts.Service > 0)
  4260. {
  4261. //insidePayTotal += _EnterExitCosts.Service;
  4262. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4263. }
  4264. string row1_3 = "";
  4265. if (_EnterExitCosts.Safe > 0)
  4266. {
  4267. //insidePayTotal += _EnterExitCosts.Safe;
  4268. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4269. }
  4270. if (_EnterExitCosts.Ticket > 0)
  4271. {
  4272. //insidePayTotal += _EnterExitCosts.Ticket;
  4273. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4274. }
  4275. string row1 = "";
  4276. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4277. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4278. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4279. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4280. dic.Add("Row1Str", row1);
  4281. }
  4282. string airTotalStr = string.Empty,
  4283. airPriceStr = string.Empty;
  4284. //经济舱
  4285. if (_EnterExitCosts.SumJJC == 1)
  4286. {
  4287. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4288. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4289. }
  4290. //公务舱
  4291. if (_EnterExitCosts.SumGWC == 1)
  4292. {
  4293. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4294. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4295. }
  4296. //头等舱
  4297. if (_EnterExitCosts.SumTDC == 1)
  4298. {
  4299. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4300. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4301. }
  4302. dic.Add("AirTotalStr", airTotalStr);
  4303. dic.Add("AirPriceStr", airPriceStr);
  4304. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4305. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4306. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4307. int table1Row = 0,
  4308. table2Row = 0,
  4309. table3Row = 0,
  4310. table4Row = 0;
  4311. //住宿费
  4312. if (_EnterExitCosts.ChoiceThree == 1)
  4313. {
  4314. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4315. table1Row = dac1.Count;
  4316. #region 填充word表格内容
  4317. for (int i = 0; i < dac1.Count; i++)
  4318. {
  4319. Grp_DayAndCost dac = dac1[i];
  4320. if (dac == null) continue;
  4321. builder.MoveToCell(0, i, 0, 0);
  4322. builder.Write("第" + dac.Days.ToString() + "晚:");
  4323. builder.MoveToCell(0, i, 1, 0);
  4324. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4325. //builder.Write(dac.Place == null ? "" : dac.Place);
  4326. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4327. builder.MoveToCell(0, i, 2, 0);
  4328. builder.Write("费用标准:");
  4329. string curr = "";
  4330. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4331. if (currData != null)
  4332. {
  4333. curr = currData.Name;
  4334. }
  4335. builder.MoveToCell(0, i, 3, 0);
  4336. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4337. builder.MoveToCell(0, i, 4, 0);
  4338. builder.Write("费用小计:");
  4339. builder.MoveToCell(0, i, 5, 0);
  4340. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4341. }
  4342. #endregion
  4343. }else dic.Add("SubZS","0.00");
  4344. //删除多余行
  4345. while (table1.Rows.Count > table1Row)
  4346. {
  4347. table1.Rows.RemoveAt(table1Row);
  4348. }
  4349. //伙食费
  4350. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4351. if (_EnterExitCosts.ChoiceFour == 1)
  4352. {
  4353. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4354. table2Row = dac2.Count;
  4355. #region 填充word表格内容
  4356. for (int i = 0; i < dac2.Count; i++)
  4357. {
  4358. Grp_DayAndCost dac = dac2[i];
  4359. if (dac == null) continue;
  4360. builder.MoveToCell(1, i, 0, 0);
  4361. builder.Write("第" + dac.Days.ToString() + "天:");
  4362. builder.MoveToCell(1, i, 1, 0);
  4363. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4364. builder.MoveToCell(1, i, 2, 0);
  4365. builder.Write("费用标准:");
  4366. string curr = "";
  4367. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4368. if (currData != null)
  4369. {
  4370. curr = currData.Name;
  4371. }
  4372. builder.MoveToCell(1, i, 3, 0);
  4373. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4374. builder.MoveToCell(1, i, 4, 0);
  4375. builder.Write("费用小计:");
  4376. builder.MoveToCell(1, i, 5, 0);
  4377. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4378. }
  4379. #endregion
  4380. }else dic.Add("SubHS","0.00");
  4381. //删除多余行
  4382. while (table2.Rows.Count > table2Row)
  4383. {
  4384. table2.Rows.RemoveAt(table2Row);
  4385. }
  4386. //公杂费
  4387. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4388. if (_EnterExitCosts.ChoiceFive == 1)
  4389. {
  4390. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4391. table3Row = dac3.Count;
  4392. #region 填充word表格内容
  4393. for (int i = 0; i < dac3.Count; i++)
  4394. {
  4395. Grp_DayAndCost dac = dac3[i];
  4396. if (dac == null) continue;
  4397. builder.MoveToCell(2, i, 0, 0);
  4398. builder.Write("第" + dac.Days.ToString() + "天:");
  4399. builder.MoveToCell(2, i, 1, 0);
  4400. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4401. builder.MoveToCell(2, i, 2, 0);
  4402. builder.Write("费用标准:");
  4403. string curr = "";
  4404. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4405. if (currData != null)
  4406. {
  4407. curr = currData.Name;
  4408. }
  4409. builder.MoveToCell(2, i, 3, 0);
  4410. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4411. builder.MoveToCell(2, i, 4, 0);
  4412. builder.Write("费用小计:");
  4413. builder.MoveToCell(2, i, 5, 0);
  4414. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4415. }
  4416. //删除多余行
  4417. while (table3.Rows.Count > table3Row)
  4418. {
  4419. table3.Rows.RemoveAt(table3Row);
  4420. }
  4421. #endregion
  4422. }else dic.Add("SubGZF", "0.00");
  4423. //删除多余行
  4424. while (table3.Rows.Count > table3Row)
  4425. {
  4426. table3.Rows.RemoveAt(table3Row);
  4427. }
  4428. //培训费
  4429. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4430. if (_EnterExitCosts.ChoiceSix == 1)
  4431. {
  4432. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4433. dic.Add("SubPX", pxStr);
  4434. table4Row = dac4.Count;
  4435. #region 填充word表格内容
  4436. for (int i = 0; i < dac4.Count; i++)
  4437. {
  4438. Grp_DayAndCost dac = dac4[i];
  4439. if (dac == null) continue;
  4440. builder.MoveToCell(3, i, 0, 0);
  4441. builder.Write("第" + dac.Days.ToString() + "天:");
  4442. builder.MoveToCell(3, i, 1, 0);
  4443. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4444. builder.MoveToCell(3, i, 2, 0);
  4445. builder.Write("费用标准:");
  4446. string curr = "";
  4447. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4448. if (currData != null)
  4449. {
  4450. curr = currData.Name;
  4451. }
  4452. builder.MoveToCell(3, i, 3, 0);
  4453. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4454. builder.MoveToCell(3, i, 4, 0);
  4455. builder.Write("费用小计:");
  4456. builder.MoveToCell(3, i, 5, 0);
  4457. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4458. }
  4459. #endregion
  4460. }
  4461. //else dic.Add("SubPX","0.00");
  4462. //删除多余行
  4463. while (table4.Rows.Count > table4Row)
  4464. {
  4465. table4.Rows.RemoveAt(table4Row);
  4466. }
  4467. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4468. decimal subJJC = 0.00M,
  4469. subGWC = 0.00M,
  4470. subTDC = 0.00M;
  4471. //经济舱
  4472. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4473. //公务舱
  4474. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4475. //头等舱
  4476. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4477. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4478. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4479. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4480. #region 填充word模板书签内容
  4481. foreach (var key in dic.Keys)
  4482. {
  4483. builder.MoveToBookmark(key);
  4484. builder.Write(dic[key]);
  4485. }
  4486. #endregion
  4487. //文件名
  4488. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4489. AsposeHelper.removewatermark_v2180();
  4490. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4491. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4492. return Ok(JsonView(true, "成功", new { Url = url }));
  4493. }
  4494. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4495. {
  4496. //获取模板
  4497. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4498. //载入模板
  4499. Document doc = new Document(tempPath);
  4500. DocumentBuilder builder = new DocumentBuilder(doc);
  4501. Dictionary<string, string> dic = new Dictionary<string, string>();
  4502. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4503. {
  4504. List<string> list = new List<string>();
  4505. try
  4506. {
  4507. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4508. foreach (var item in spilitArr)
  4509. {
  4510. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4511. var depCode = spDotandEmpty[2].Substring(0, 3);
  4512. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4513. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4514. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4515. list.Add(depName);
  4516. list.Add(arrName);
  4517. }
  4518. list = list.Distinct().ToList();
  4519. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4520. }
  4521. catch (Exception)
  4522. {
  4523. dic.Add("ReturnCode", "行程录入不正确!");
  4524. }
  4525. }
  4526. else
  4527. {
  4528. dic.Add("ReturnCode", "未录入行程!");
  4529. }
  4530. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4531. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4532. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4533. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4534. {
  4535. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4536. dic.Add("Day", sp.Days.ToString());
  4537. }
  4538. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4539. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4540. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4541. //dic.Add("Names", Names);
  4542. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4543. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4544. decimal dac1totalPrice = 0.00M;
  4545. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4546. foreach (var dac in dac1)
  4547. {
  4548. if (dac.SubTotal == 0.00M)
  4549. {
  4550. continue;
  4551. }
  4552. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4553. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4554. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4555. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4556. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4557. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4558. builder.Write(currency);//币种
  4559. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4560. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4561. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4562. builder.Write("");//人数
  4563. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4564. builder.Write("");//天数
  4565. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4566. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4567. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4568. decimal rate = 0.00M;
  4569. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4570. builder.Write(rate.ToString("#0.0000"));//汇率
  4571. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4572. decimal rbmPrice = dac.SubTotal;
  4573. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4574. accommodationStartIndex++;
  4575. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4576. }
  4577. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4578. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4579. {
  4580. table1.Rows.RemoveAt(i - 1);
  4581. foodandotherStartIndex--;
  4582. }
  4583. if (dac2.Count == dac3.Count)//国家 币种 金额
  4584. {
  4585. for (int i = 0; i < dac2.Count; i++)
  4586. {
  4587. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4588. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4589. }
  4590. }
  4591. decimal dac2totalPrice = 0.00M;
  4592. foreach (var dac in dac2)
  4593. {
  4594. if (dac.SubTotal == 0)
  4595. {
  4596. continue;
  4597. }
  4598. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4599. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4600. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4601. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4602. builder.Write(currency);//币种
  4603. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4604. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4605. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4606. builder.Write("");//人数
  4607. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4608. builder.Write("");//天数
  4609. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4610. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4611. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4612. decimal rate = 0.00M;
  4613. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4614. builder.Write(rate.ToString("#0.0000"));//汇率
  4615. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4616. decimal rbmPrice = dac.SubTotal;
  4617. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4618. foodandotherStartIndex++;
  4619. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4620. }
  4621. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4622. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4623. {
  4624. table1.Rows.RemoveAt(i - 1);
  4625. }
  4626. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4627. string otherFeeStr = "";
  4628. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4629. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4630. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4631. if (otherFeeStr.Length > 0)
  4632. {
  4633. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4634. otherFeeStr = $"({otherFeeStr})";
  4635. dic.Add("OtherFeeStr", otherFeeStr);
  4636. }
  4637. //总计
  4638. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4639. //国际旅费
  4640. string outsideAir = string.Empty;
  4641. string allPriceAir = string.Empty;
  4642. if (_EnterExitCosts.SumJJC == 1)
  4643. {
  4644. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4645. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4646. }
  4647. if (_EnterExitCosts.SumGWC == 1)
  4648. {
  4649. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4650. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4651. }
  4652. if (_EnterExitCosts.SumTDC == 1)
  4653. {
  4654. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4655. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4656. }
  4657. dic.Add("InTravelPrice", $"({outsideAir})");
  4658. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4659. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4660. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4661. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4662. foreach (var key in dic.Keys)
  4663. {
  4664. builder.MoveToBookmark(key);
  4665. builder.Write(dic[key]);
  4666. }
  4667. //模板文件名
  4668. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4669. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4670. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4671. return Ok(JsonView(true, "成功", new { Url = url }));
  4672. }
  4673. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4674. {
  4675. //获取模板
  4676. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4677. //载入模板
  4678. WorkbookDesigner designer = new WorkbookDesigner();
  4679. designer.Workbook = new Workbook(tempPath);
  4680. Dictionary<string, string> dic = new Dictionary<string, string>();
  4681. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4682. {
  4683. List<string> list = new List<string>();
  4684. try
  4685. {
  4686. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4687. foreach (var item in spilitArr)
  4688. {
  4689. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4690. var depCode = spDotandEmpty[2].Substring(0, 3);
  4691. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4692. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4693. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4694. list.Add(depName);
  4695. list.Add(arrName);
  4696. }
  4697. list = list.Distinct().ToList();
  4698. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4699. }
  4700. catch (Exception)
  4701. {
  4702. dic.Add("ReturnCode", "行程录入不正确!");
  4703. }
  4704. }
  4705. else
  4706. {
  4707. dic.Add("ReturnCode", "未录入行程!");
  4708. }
  4709. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4710. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4711. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4712. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4713. {
  4714. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4715. dic.Add("Day", sp.Days.ToString());
  4716. }
  4717. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4718. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4719. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4720. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4721. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4722. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4723. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4724. designer.SetDataSource("Name", Names);
  4725. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4726. designer.SetDataSource("Day", dic["Day"] + "天");
  4727. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4728. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4729. int startIndex = 10;
  4730. const int startIndexcopy = 10;
  4731. if (dac2.Count == dac3.Count)//国家 币种 金额
  4732. {
  4733. for (int i = 0; i < dac2.Count; i++)
  4734. {
  4735. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4736. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4737. }
  4738. }
  4739. DataTable dtdac1 = new DataTable();
  4740. List<string> place = new List<string>();
  4741. dtdac1.Columns.AddRange(new DataColumn[] {
  4742. new DataColumn(){ ColumnName = "city"},
  4743. new DataColumn(){ ColumnName = "curr"},
  4744. new DataColumn(){ ColumnName = "criterion"},
  4745. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4746. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4747. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4748. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4749. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4750. });
  4751. DataTable dtdac2 = new DataTable();
  4752. dtdac2.Columns.AddRange(new DataColumn[] {
  4753. new DataColumn(){ ColumnName = "city"},
  4754. new DataColumn(){ ColumnName = "curr"},
  4755. new DataColumn(){ ColumnName = "criterion"},
  4756. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4757. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4758. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4759. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4760. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4761. });
  4762. dtdac1.TableName = "tb1";
  4763. dtdac2.TableName = "tb2";
  4764. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4765. foreach (var item in dac1)
  4766. {
  4767. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4768. if (place.Contains(item.Place))
  4769. {
  4770. continue;
  4771. }
  4772. DataRow row = dtdac1.NewRow();
  4773. row["city"] = item.Place;
  4774. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4775. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4776. row["curr"] = currency;
  4777. row["rate"] = rate.ToString("#0.0000");
  4778. row["criterion"] = item.Cost.ToString("#0.00");
  4779. row["number"] = 1;
  4780. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4781. //row["costRMB"] = rbmPrice;
  4782. dtdac1.Rows.Add(row);
  4783. place.Add(item.Place);
  4784. }
  4785. place = new List<string>();
  4786. foreach (var item in dac2)
  4787. {
  4788. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4789. if (place.Contains(item.Place))
  4790. {
  4791. continue;
  4792. }
  4793. DataRow row = dtdac2.NewRow();
  4794. row["city"] = item.Place;
  4795. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4796. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4797. row["curr"] = currency;
  4798. row["rate"] = rate.ToString("#0.0000");
  4799. row["criterion"] = item.Cost.ToString("#0.00");
  4800. row["number"] = 1;
  4801. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4802. //row["cost"] = item.SubTotal;
  4803. //row["costRMB"] = rbmPrice;
  4804. dtdac2.Rows.Add(row);
  4805. place.Add(item.Place);
  4806. //dac2totalPrice += rbmPrice;
  4807. }
  4808. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4809. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4810. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4811. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4812. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4813. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4814. string cell4Str1 = string.Empty;
  4815. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4816. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4817. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4818. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4819. string cellStr = $" 5.其他费用(";
  4820. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4821. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4822. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4823. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4824. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4825. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4826. if (cellStr.Length > 8)
  4827. {
  4828. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4829. }
  4830. cellStr += ")";
  4831. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4832. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4833. decimal pxFee = dac4.Sum(it => it.Cost);
  4834. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4835. string celllastStr1 = "";
  4836. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4837. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4838. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4839. celllastStr1 += $",国际旅费 元";
  4840. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4841. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4842. designer.SetDataSource("cell4Str", cell4Str);
  4843. designer.SetDataSource("cellStr", cellStr);
  4844. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4845. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4846. designer.SetDataSource("celllastStr", celllastStr);
  4847. Workbook wb = designer.Workbook;
  4848. var sheet = wb.Worksheets[0];
  4849. //绑定datatable数据集
  4850. designer.SetDataSource(dtdac1);
  4851. designer.SetDataSource(dtdac2);
  4852. designer.Process();
  4853. var rowStart = dtdac1.Rows.Count;
  4854. while (rowStart > 0)
  4855. {
  4856. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4857. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4858. startIndex++;
  4859. rowStart--;
  4860. }
  4861. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4862. startIndex += 1; //总计行
  4863. rowStart = dtdac2.Rows.Count;
  4864. while (rowStart > 0)
  4865. {
  4866. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4867. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4868. startIndex++;
  4869. rowStart--;
  4870. }
  4871. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4872. wb.CalculateFormula(true);
  4873. //模板文件名
  4874. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4875. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4876. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4877. return Ok(JsonView(true, "成功", new { Url = url }));
  4878. }
  4879. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4880. {
  4881. //获取模板
  4882. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4883. //载入模板
  4884. Document doc = new Document(tempPath);
  4885. DocumentBuilder builder = new DocumentBuilder(doc);
  4886. Dictionary<string, string> dic = new Dictionary<string, string>();
  4887. dic.Add("GroupName", _DelegationInfo.TeamName);
  4888. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4889. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4890. string missionLeaderJob = "";//负责人job
  4891. int groupNumber = 0; //团人数
  4892. if (DeleClientList.Count > 0)
  4893. {
  4894. missionLeader = DeleClientList[0]?.Name ?? "";
  4895. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4896. }
  4897. dic.Add("MissionLeader", missionLeader); //团负责人
  4898. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4899. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4900. #region MyRegion
  4901. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4902. //{
  4903. // List<string> list = new List<string>();
  4904. // try
  4905. // {
  4906. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4907. // foreach (var item in spilitArr)
  4908. // {
  4909. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4910. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4911. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4912. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4913. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4914. // list.Add(depName);
  4915. // list.Add(arrName);
  4916. // }
  4917. // list = list.Distinct().ToList();
  4918. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4919. // }
  4920. // catch (Exception)
  4921. // {
  4922. // dic.Add("ReturnCode", "行程录入不正确!");
  4923. // }
  4924. //}
  4925. //else
  4926. //{
  4927. // dic.Add("ReturnCode", "未录入行程!");
  4928. //}
  4929. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4930. dic.Add("ReturnCode", string.Join("、", countrys));
  4931. #endregion
  4932. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4933. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4934. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4935. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4936. //{
  4937. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4938. // dic.Add("Day", sp.Days.ToString());
  4939. //}
  4940. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4941. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4942. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4943. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4944. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4945. //培训人员名单
  4946. int cultivateRowIndex = 7;
  4947. foreach (var item in DeleClientList)
  4948. {
  4949. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4950. builder.Write(item.Name);
  4951. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4952. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4953. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4954. string birthDay = "";
  4955. if (item.Birthday != null)
  4956. {
  4957. DateTime dt = Convert.ToDateTime(item.Birthday);
  4958. birthDay = $"{dt.Year}.{dt.Month}";
  4959. }
  4960. builder.Write(birthDay);
  4961. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4962. builder.Write(item.Company);
  4963. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4964. builder.Write(item.Job);
  4965. cultivateRowIndex++;
  4966. }
  4967. //删除多余行
  4968. //cultivateRowIndex -= 2;
  4969. int delRows = 10 + 7 - cultivateRowIndex;
  4970. if (delRows > 0)
  4971. {
  4972. for (int i = 0; i < delRows; i++)
  4973. {
  4974. table1.Rows.RemoveAt(cultivateRowIndex);
  4975. //cultivateRowIndex++;
  4976. }
  4977. }
  4978. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4979. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4980. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4981. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4982. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4983. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4984. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4985. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4986. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4987. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4988. //其他费用
  4989. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4990. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4991. //其他费用合计
  4992. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4993. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4994. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4995. //公务舱合计
  4996. //国际旅费
  4997. string outsideJJ = "";
  4998. string allPriceJJ = "";
  4999. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5000. {
  5001. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5002. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5003. }
  5004. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5005. {
  5006. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5007. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5008. }
  5009. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5010. {
  5011. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5012. dic.Add("AirFeeTotal", airFeeTotalStr);
  5013. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5014. dic.Add("FeeTotal", feeTotalStr);
  5015. }
  5016. foreach (var key in dic.Keys)
  5017. {
  5018. builder.MoveToBookmark(key);
  5019. builder.Write(dic[key]);
  5020. }
  5021. //模板文件名
  5022. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5023. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5024. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5025. return Ok(JsonView(true, "成功", new { Url = url }));
  5026. }
  5027. }
  5028. else if (dto.ExportType == 2) //表格
  5029. {
  5030. //利用键值对存放数据
  5031. Dictionary<string, string> dic = new Dictionary<string, string>();
  5032. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5033. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5034. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5035. dic.Add("Day", sp.Days.ToString());
  5036. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5037. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5038. {
  5039. //获取模板
  5040. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5041. //载入模板
  5042. Document doc = new Document(tempPath);
  5043. DocumentBuilder builder = new DocumentBuilder(doc);
  5044. dic.Add("TeamName", _DelegationInfo.TeamName);
  5045. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5046. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5047. string missionLeaderName = "",
  5048. missionLeaderJob = "";
  5049. if (DeleClientList.Count > 0)
  5050. {
  5051. missionLeaderName = DeleClientList[0].Name;
  5052. missionLeaderJob = DeleClientList[0].Job;
  5053. }
  5054. dic.Add("MissionLeaderName", missionLeaderName);
  5055. dic.Add("MissionLeaderJob", missionLeaderJob);
  5056. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5057. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5058. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5059. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5060. int rowCount = 10;//总人数行
  5061. int startRowIndex = 7; //起始行
  5062. for (int i = 0; i < DeleClientList.Count; i++)
  5063. {
  5064. builder.MoveToCell(0, startRowIndex, 0, 0);
  5065. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5066. builder.MoveToCell(0, startRowIndex, 1, 0);
  5067. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5068. builder.Write(sex);//性别
  5069. builder.MoveToCell(0, startRowIndex, 2, 0);
  5070. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5071. builder.MoveToCell(0, startRowIndex, 3, 0);
  5072. builder.Write(DeleClientList[i].Company);//工作单位
  5073. builder.MoveToCell(0, startRowIndex, 4, 0);
  5074. builder.Write(DeleClientList[i].Job);//职务及级别
  5075. builder.MoveToCell(0, startRowIndex, 5, 0);
  5076. builder.Write("");//人员属性
  5077. builder.MoveToCell(0, startRowIndex, 6, 0);
  5078. builder.Write("");//上次出国时间
  5079. startRowIndex++;
  5080. }
  5081. int nullRow = rowCount - DeleClientList.Count;//空行
  5082. for (int i = 0; i < nullRow; i++)
  5083. {
  5084. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5085. }
  5086. foreach (var key in dic.Keys)
  5087. {
  5088. builder.MoveToBookmark(key);
  5089. builder.Write(dic[key]);
  5090. }
  5091. //模板文件名
  5092. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5093. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5094. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5095. return Ok(JsonView(true, "成功", new { Url = url }));
  5096. }
  5097. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5098. {
  5099. //获取模板
  5100. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5101. //载入模板
  5102. Document doc = new Document(tempPath);
  5103. DocumentBuilder builder = new DocumentBuilder(doc);
  5104. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5105. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5106. dic.Add("Names", Names);
  5107. int accommodationRows = 12, foodandotherRows = 12;
  5108. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5109. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5110. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5111. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5112. int accommodationStartIndex = 6;
  5113. decimal dac1totalPrice = 0.00M;
  5114. foreach (var dac in dac1)
  5115. {
  5116. if (dac.SubTotal == 0)
  5117. {
  5118. continue;
  5119. }
  5120. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5121. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5122. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5123. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5124. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5125. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5126. builder.Write(currency);//币种
  5127. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5128. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5129. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5130. builder.Write("");//人数
  5131. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5132. builder.Write("");//天数
  5133. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5134. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5135. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5136. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5137. builder.Write(rate.ToString("#0.0000"));//汇率
  5138. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5139. decimal rbmPrice = rate * dac.SubTotal;
  5140. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5141. accommodationStartIndex++;
  5142. dac1totalPrice += rbmPrice;
  5143. }
  5144. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5145. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5146. builder.Write("小计");
  5147. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5148. builder.Write(dac1totalPrice.ToString("#0.00"));
  5149. accommodationStartIndex++;
  5150. int nullRow = accommodationRows - dac1.Count;
  5151. //删除空行
  5152. //if (nullRow > 0)
  5153. //{
  5154. // int rowIndex = accommodationStartIndex;
  5155. // for (int i = 0; i < nullRow; i++)
  5156. // {
  5157. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5158. // row.Remove();
  5159. // rowIndex++;
  5160. // }
  5161. //}
  5162. if (dac2.Count == dac3.Count)//国家 币种 金额
  5163. {
  5164. for (int i = 0; i < dac2.Count; i++)
  5165. {
  5166. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5167. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5168. }
  5169. }
  5170. int foodandotherStartIndex = 19;//
  5171. decimal dac2totalPrice = 0.00M;
  5172. foreach (var dac in dac2)
  5173. {
  5174. if (dac.SubTotal == 0)
  5175. {
  5176. continue;
  5177. }
  5178. //foodandotherStartIndex = 12;
  5179. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5180. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5181. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5182. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5183. builder.Write(currency);//币种
  5184. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5185. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5186. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5187. builder.Write("");//人数
  5188. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5189. builder.Write("");//天数
  5190. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5191. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5192. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5193. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5194. builder.Write(rate.ToString("#0.0000"));//汇率
  5195. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5196. decimal rbmPrice = rate * dac.SubTotal;
  5197. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5198. foodandotherStartIndex++;
  5199. dac2totalPrice += rbmPrice;
  5200. }
  5201. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5202. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5203. //删除空行
  5204. //if (dac2.Count < foodandotherRows)
  5205. //{
  5206. // while (table2.Rows.Count > dac2.Count)
  5207. // {
  5208. // table2.Rows.RemoveAt(dac2.Count);
  5209. // }
  5210. //}
  5211. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5212. string otherFeeStr = "";
  5213. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5214. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5215. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5216. if (otherFeeStr.Length > 0)
  5217. {
  5218. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5219. otherFeeStr = $"({otherFeeStr})";
  5220. dic.Add("OtherFeeStr", otherFeeStr);
  5221. }
  5222. foreach (var key in dic.Keys)
  5223. {
  5224. builder.MoveToBookmark(key);
  5225. builder.Write(dic[key]);
  5226. }
  5227. //模板文件名
  5228. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5229. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5230. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5231. return Ok(JsonView(true, "成功", new { Url = url }));
  5232. }
  5233. }
  5234. else if (dto.ExportType == 3)
  5235. {
  5236. if (dto.SubTypeId == 1) //团组成员名单
  5237. {
  5238. if (DeleClientList.Count < 1)
  5239. {
  5240. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5241. }
  5242. //获取模板
  5243. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5244. //载入模板
  5245. Document doc = new Document(tempPath);
  5246. DocumentBuilder builder = new DocumentBuilder(doc);
  5247. //获取word里所有表格
  5248. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5249. //获取所填表格的序数
  5250. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5251. var rowStart = tableOne.Rows[0]; //获取第1行
  5252. //循环赋值
  5253. for (int i = 0; i < DeleClientList.Count; i++)
  5254. {
  5255. builder.MoveToCell(0, i + 1, 0, 0);
  5256. builder.Write(DeleClientList[i].Name);
  5257. builder.MoveToCell(0, i + 1, 1, 0);
  5258. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5259. builder.Write(sex);
  5260. builder.MoveToCell(0, i + 1, 2, 0);
  5261. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5262. builder.MoveToCell(0, i + 1, 3, 0);
  5263. builder.Write(DeleClientList[i].Company);
  5264. builder.MoveToCell(0, i + 1, 4, 0);
  5265. builder.Write(DeleClientList[i].Job);
  5266. }
  5267. //删除多余行
  5268. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5269. {
  5270. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5271. }
  5272. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5273. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5274. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5275. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5276. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5277. return Ok(JsonView(true, "成功", new { Url = url }));
  5278. }
  5279. }
  5280. return Ok(JsonView(false, "操作失败!"));
  5281. }
  5282. catch (Exception ex)
  5283. {
  5284. return Ok(JsonView(false, ex.Message));
  5285. }
  5286. }
  5287. /// <summary>
  5288. /// 获取三公费用标准city
  5289. /// </summary>
  5290. /// <param name="placeData"></param>
  5291. /// <param name="nationalTravelFeeId"></param>
  5292. /// <returns></returns>
  5293. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5294. {
  5295. string _city = string.Empty;
  5296. if (placeData.Count < 1) return _city;
  5297. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5298. if (data == null) return _city;
  5299. string country = data.Country;
  5300. string city = data.City;
  5301. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5302. else _city = city;
  5303. return _city;
  5304. }
  5305. /// <summary>
  5306. /// 团组模块 - 出入境费用 - 明细表导出
  5307. /// </summary>
  5308. /// <returns></returns>
  5309. [HttpPost]
  5310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5311. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5312. {
  5313. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5314. if (data.Code != 0)
  5315. {
  5316. return Ok(JsonView(false, data.Msg));
  5317. }
  5318. return Ok(JsonView(true, data.Msg, data.Data));
  5319. }
  5320. /// <summary>
  5321. /// 团组模块 - 出入境费用 - 一键清空
  5322. /// </summary>
  5323. /// <returns></returns>
  5324. [HttpPost]
  5325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5326. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5327. {
  5328. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5329. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5330. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5331. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5332. if (_view.Code == 0)
  5333. {
  5334. return Ok(JsonView(true, "操作成功"));
  5335. }
  5336. return Ok(JsonView(false, "操作失败"));
  5337. }
  5338. /// <summary>
  5339. /// 团组模块 - 出入境费用 - 子项删除
  5340. /// </summary>
  5341. /// <returns></returns>
  5342. [HttpPost]
  5343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5344. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5345. {
  5346. try
  5347. {
  5348. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5349. if (data.Code != 0)
  5350. {
  5351. return Ok(JsonView(false, data.Msg));
  5352. }
  5353. return Ok(JsonView(true, "操作成功!", data.Data));
  5354. }
  5355. catch (Exception ex)
  5356. {
  5357. return Ok(JsonView(false, ex.Message));
  5358. }
  5359. }
  5360. /// <summary>
  5361. /// 团组模块 - 出入境国家费用标准 List
  5362. /// </summary>
  5363. /// <returns></returns>
  5364. [HttpPost]
  5365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5366. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5367. {
  5368. try
  5369. {
  5370. Stopwatch sw = new Stopwatch();
  5371. sw.Start();
  5372. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5373. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5374. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5375. Where gntf.Isdel = 0");
  5376. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5377. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5378. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5379. //foreach (var item in nationalTravel)
  5380. //{
  5381. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5382. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5383. // if (otherData != null)
  5384. // {
  5385. // cityData.Remove(otherData);
  5386. // cityData.Add(otherData);
  5387. // }
  5388. // nationalTravelFeeData1.Add(new
  5389. // {
  5390. // Country = item.Country,
  5391. // CityData = cityData
  5392. // });
  5393. //}
  5394. sw.Stop();
  5395. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5396. }
  5397. catch (Exception ex)
  5398. {
  5399. return Ok(JsonView(false, ex.Message));
  5400. throw;
  5401. }
  5402. }
  5403. /// <summary>
  5404. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5405. /// </summary>
  5406. /// <returns></returns>
  5407. [HttpPost]
  5408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5409. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5410. {
  5411. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5412. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5413. List<string> countryData = new List<string>();
  5414. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5415. countryData = countryData.Distinct().ToList();
  5416. List<dynamic> dataSource = new List<dynamic>();
  5417. foreach (var item in countryData)
  5418. {
  5419. List<string> cityData1 = new List<string>();
  5420. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5421. var countryData2 = new
  5422. {
  5423. CountryName = item,
  5424. CityData = cityData1
  5425. };
  5426. dataSource.Add(countryData2);
  5427. }
  5428. return Ok(JsonView(true, "查询成功!", dataSource));
  5429. }
  5430. /// <summary>
  5431. /// 团组模块 - 出入境国家费用标准 Page List
  5432. /// </summary>
  5433. /// <returns></returns>
  5434. [HttpPost]
  5435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5436. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5437. {
  5438. int portId = dto.PortType;
  5439. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5440. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5441. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5442. string whereSql = string.Empty;
  5443. if (!string.IsNullOrEmpty(dto.Country))
  5444. {
  5445. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5446. }
  5447. if (!string.IsNullOrEmpty(dto.City))
  5448. {
  5449. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5450. }
  5451. string pageSql = string.Format(@"Select * From (
  5452. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5453. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5454. From Grp_NationalTravelFee gntf
  5455. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5456. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5457. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5458. RefAsync<int> total = 0;
  5459. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5460. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5461. }
  5462. /// <summary>
  5463. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5464. /// </summary>
  5465. /// <returns></returns>
  5466. [HttpPost]
  5467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5468. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5469. {
  5470. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5471. int portId = dto.PortType;
  5472. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5473. string whereSql = string.Empty;
  5474. if (!string.IsNullOrEmpty(dto.Country))
  5475. {
  5476. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5477. }
  5478. if (!string.IsNullOrEmpty(dto.City))
  5479. {
  5480. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5481. }
  5482. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5483. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5484. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5485. From Grp_NationalTravelFee gntf
  5486. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5487. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5488. Where gntf.Isdel = 0 {0} ", whereSql);
  5489. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5490. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5491. }
  5492. /// <summary>
  5493. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5494. /// </summary>
  5495. /// <returns></returns>
  5496. [HttpPost]
  5497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5498. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5499. {
  5500. try
  5501. {
  5502. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5503. if (data.Code != 0)
  5504. {
  5505. return Ok(JsonView(false, data.Msg));
  5506. }
  5507. return Ok(JsonView(true, "操作成功!", data.Data));
  5508. }
  5509. catch (Exception ex)
  5510. {
  5511. return Ok(JsonView(false, ex.Message));
  5512. }
  5513. }
  5514. /// <summary>
  5515. /// 团组模块 - 出入境国家费用标准 - Del
  5516. /// </summary>
  5517. /// <returns></returns>
  5518. [HttpPost]
  5519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5520. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5521. {
  5522. try
  5523. {
  5524. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5525. {
  5526. Id = dto.Id,
  5527. DeleteUserId = dto.DeleteUserId,
  5528. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5529. IsDel = 1
  5530. };
  5531. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5532. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5533. .WhereColumns(it => new { it.Id })
  5534. .ExecuteCommandAsync();
  5535. if (delStatus <= 0)
  5536. {
  5537. return Ok(JsonView(false, "删除失败!"));
  5538. }
  5539. return Ok(JsonView(true, "操作成功!"));
  5540. }
  5541. catch (Exception ex)
  5542. {
  5543. return Ok(JsonView(false, ex.Message));
  5544. }
  5545. }
  5546. #endregion
  5547. #region 签证费用录入
  5548. /// <summary>
  5549. /// 根据diid查询签证费用列表
  5550. /// </summary>
  5551. /// <param name="dto"></param>
  5552. /// <returns></returns>
  5553. [HttpPost]
  5554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5555. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5556. {
  5557. try
  5558. {
  5559. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5560. if (groupData.Code != 0)
  5561. {
  5562. return Ok(JsonView(false, groupData.Msg));
  5563. }
  5564. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5565. }
  5566. catch (Exception ex)
  5567. {
  5568. return Ok(JsonView(false, ex.Message));
  5569. }
  5570. }
  5571. /// <summary>
  5572. /// 根据签证费用Id查询单条数据及c表数据
  5573. /// </summary>
  5574. /// <param name="dto"></param>
  5575. /// <returns></returns>
  5576. [HttpPost]
  5577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5578. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5579. {
  5580. try
  5581. {
  5582. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5583. if (groupData.Code != 0)
  5584. {
  5585. return Ok(JsonView(false, groupData.Msg));
  5586. }
  5587. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5588. }
  5589. catch (Exception ex)
  5590. {
  5591. return Ok(JsonView(false, ex.Message));
  5592. }
  5593. }
  5594. /// <summary>
  5595. /// 签证费用删除
  5596. /// </summary>
  5597. /// <param name="dto"></param>
  5598. /// <returns></returns>
  5599. [HttpPost]
  5600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5601. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5602. {
  5603. _sqlSugar.BeginTran();
  5604. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5605. if (!res)
  5606. {
  5607. _sqlSugar.RollbackTran();
  5608. return Ok(JsonView(false, "删除失败"));
  5609. }
  5610. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5611. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5612. .SetColumns(a => new Grp_CreditCardPayment()
  5613. {
  5614. IsDel = 1,
  5615. DeleteUserId = dto.DeleteUserId,
  5616. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5617. })
  5618. .ExecuteCommand();
  5619. if (resSub < 1)
  5620. {
  5621. _sqlSugar.RollbackTran();
  5622. return Ok(JsonView(false, "删除失败"));
  5623. }
  5624. _sqlSugar.CommitTran();
  5625. return Ok(JsonView(true, "删除成功!"));
  5626. }
  5627. /// <summary>
  5628. /// 签证费用录入下拉框初始化
  5629. /// </summary>
  5630. /// <returns></returns>
  5631. [HttpPost]
  5632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5633. public async Task<IActionResult> VisaPriceAddSelect()
  5634. {
  5635. //支付方式
  5636. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5637. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5638. //币种
  5639. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5640. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5641. //乘客类型
  5642. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5643. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5644. //卡类型
  5645. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5646. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5647. var data = new
  5648. {
  5649. Payment = _Payment,
  5650. CurrencyList = _CurrencyList,
  5651. PassengerType = _PassengerType,
  5652. BankCard = _BankCard
  5653. };
  5654. return Ok(JsonView(true, "查询成功!", data));
  5655. }
  5656. /// <summary>
  5657. /// 签证费用录入操作(Status:1.新增,2.修改)
  5658. /// </summary>
  5659. /// <param name="dto"></param>
  5660. /// <returns></returns>
  5661. [HttpPost]
  5662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5663. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5664. {
  5665. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5666. if (groupData.Code != 0)
  5667. {
  5668. return Ok(JsonView(false, groupData.Msg));
  5669. }
  5670. #region 应用推送
  5671. try
  5672. {
  5673. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5674. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5675. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5676. }
  5677. catch (Exception ex)
  5678. {
  5679. }
  5680. #endregion
  5681. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5682. }
  5683. #endregion
  5684. #region 签证提成录入
  5685. /// <summary>
  5686. /// 签证提成录入
  5687. /// 基础数据
  5688. /// </summary>
  5689. /// <param name="_dto"></param>
  5690. /// <returns></returns>
  5691. [HttpGet]
  5692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5693. public async Task<IActionResult> VisaCommissionInit()
  5694. {
  5695. return Ok(await _visaCommissionRep.Init());
  5696. }
  5697. /// <summary>
  5698. /// 签证提成录入
  5699. /// Item
  5700. /// </summary>
  5701. /// <param name="_dto"></param>
  5702. /// <returns></returns>
  5703. [HttpPost]
  5704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5705. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5706. {
  5707. var validator = new VisaCommissionItemDtoValidator();
  5708. var validatorRes = await validator.ValidateAsync(_dto);
  5709. if (!validatorRes.IsValid)
  5710. {
  5711. StringBuilder sb = new StringBuilder();
  5712. foreach (var item in validatorRes.Errors)
  5713. {
  5714. sb.AppendLine(item.ErrorMessage);
  5715. }
  5716. return Ok(JsonView(false, sb.ToString()));
  5717. }
  5718. return Ok(await _visaCommissionRep.Item(_dto));
  5719. }
  5720. /// <summary>
  5721. /// 签证提成录入
  5722. /// Save
  5723. /// </summary>
  5724. /// <param name="_dto"></param>
  5725. /// <returns></returns>
  5726. [HttpPost]
  5727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5728. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  5729. {
  5730. //参数验证
  5731. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  5732. foreach (var item in _dto.Items)
  5733. {
  5734. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  5735. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  5736. if (string.IsNullOrEmpty( item.Country) ) return Ok(JsonView(false, "国家为空!"));
  5737. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  5738. }
  5739. return Ok(await _visaCommissionRep.Save(_dto));
  5740. }
  5741. /// <summary>
  5742. /// 签证提成录入
  5743. /// Create
  5744. /// </summary>
  5745. /// <param name="_dto"></param>
  5746. /// <returns></returns>
  5747. [HttpPost]
  5748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5749. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  5750. {
  5751. var validator = new VisaCommissionCreateDtoValidator();
  5752. var validatorRes = await validator.ValidateAsync(_dto);
  5753. if (!validatorRes.IsValid)
  5754. {
  5755. StringBuilder sb = new StringBuilder();
  5756. foreach (var item in validatorRes.Errors)
  5757. {
  5758. sb.AppendLine(item.ErrorMessage);
  5759. }
  5760. return Ok(JsonView(false, sb.ToString()));
  5761. }
  5762. return Ok(await _visaCommissionRep.Create(_dto));
  5763. }
  5764. /// <summary>
  5765. /// 签证提成录入
  5766. /// Put(编辑)
  5767. /// </summary>
  5768. /// <param name="id"></param>
  5769. /// <param name="_dto"></param>
  5770. /// <returns></returns>
  5771. [HttpPut]
  5772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5773. public async Task<IActionResult> VisaCommissionEdit(int id,VisaCommissionCreateDto _dto)
  5774. {
  5775. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5776. var validator = new VisaCommissionCreateDtoValidator();
  5777. var validatorRes = await validator.ValidateAsync(_dto);
  5778. if (!validatorRes.IsValid)
  5779. {
  5780. StringBuilder sb = new StringBuilder();
  5781. foreach (var item in validatorRes.Errors)
  5782. {
  5783. sb.AppendLine(item.ErrorMessage);
  5784. }
  5785. return Ok(JsonView(false, sb.ToString()));
  5786. }
  5787. return Ok(await _visaCommissionRep.Edit(id,_dto));
  5788. }
  5789. /// <summary>
  5790. /// 签证提成录入
  5791. /// Del
  5792. /// </summary>
  5793. /// <param name="id"></param>
  5794. /// <param name="currUserId"></param>
  5795. /// <returns></returns>
  5796. [HttpPost]
  5797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5798. public async Task<IActionResult> VisaCommissionDel(int id,int currUserId)
  5799. {
  5800. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5801. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  5802. return Ok(await _visaCommissionRep.Del(id, currUserId));
  5803. }
  5804. #endregion
  5805. #region op费用录入
  5806. /// <summary>
  5807. /// 根据diid查询op费用列表
  5808. /// </summary>
  5809. /// <param name="dto"></param>
  5810. /// <returns></returns>
  5811. [HttpPost]
  5812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5813. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5814. {
  5815. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5816. if (groupData.Code != 0)
  5817. {
  5818. return Ok(JsonView(false, groupData.Msg));
  5819. }
  5820. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5821. }
  5822. /// <summary>
  5823. /// 根据op费用Id查询单条数据及c表数据
  5824. /// </summary>
  5825. /// <param name="dto"></param>
  5826. /// <returns></returns>
  5827. [HttpPost]
  5828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5829. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5830. {
  5831. try
  5832. {
  5833. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5834. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5835. var data = new
  5836. {
  5837. CarTouristGuideGround = _groupData,
  5838. CreditCardPayment = _creditCardPayment
  5839. };
  5840. return Ok(JsonView(true, "查询成功!", data));
  5841. }
  5842. catch (Exception ex)
  5843. {
  5844. return Ok(JsonView(false, "程序错误!"));
  5845. }
  5846. }
  5847. /// <summary>
  5848. /// op费用删除
  5849. /// </summary>
  5850. /// <param name="dto"></param>
  5851. /// <returns></returns>
  5852. [HttpPost]
  5853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5854. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5855. {
  5856. try
  5857. {
  5858. _sqlSugar.BeginTran();
  5859. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5860. if (!res)
  5861. {
  5862. return Ok(JsonView(false, "删除失败"));
  5863. }
  5864. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5865. {
  5866. IsDel = 1,
  5867. DeleteUserId = dto.DeleteUserId,
  5868. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5869. }).ExecuteCommandAsync();
  5870. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5871. {
  5872. IsDel = 1,
  5873. DeleteUserId = dto.DeleteUserId,
  5874. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5875. }).ExecuteCommandAsync();
  5876. #region 删除超支相关数据
  5877. //删除导入的超支数据
  5878. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5879. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5880. {
  5881. IsDel = 1,
  5882. DeleteUserId = dto.DeleteUserId,
  5883. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5884. }).ExecuteCommand();
  5885. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5886. {
  5887. IsDel = 1,
  5888. DeleteUserId = dto.DeleteUserId,
  5889. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5890. }).ExecuteCommand() ;
  5891. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5892. {
  5893. IsDel = 1,
  5894. DeleteUserId = dto.DeleteUserId,
  5895. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5896. }).ExecuteCommand();
  5897. #endregion
  5898. _sqlSugar.CommitTran();
  5899. return Ok(JsonView(true, "删除成功!"));
  5900. }
  5901. catch (Exception ex)
  5902. {
  5903. _sqlSugar.RollbackTran();
  5904. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5905. }
  5906. }
  5907. /// <summary>
  5908. /// op费用录入操作(Status:1.新增,2.修改)
  5909. /// </summary>
  5910. /// <param name="dto"></param>
  5911. /// <returns></returns>
  5912. [HttpPost]
  5913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5914. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5915. {
  5916. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5917. if (groupData.Code != 0)
  5918. {
  5919. return Ok(JsonView(false, groupData.Msg));
  5920. }
  5921. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5922. }
  5923. /// <summary>
  5924. /// 填写费用详细页面初始化绑定
  5925. /// </summary>
  5926. /// <param name="dto"></param>
  5927. /// <returns></returns>
  5928. [HttpPost]
  5929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5930. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5931. {
  5932. try
  5933. {
  5934. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5935. if (groupData.Code != 0)
  5936. {
  5937. return Ok(JsonView(false, groupData.Msg));
  5938. }
  5939. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5940. }
  5941. catch (Exception ex)
  5942. {
  5943. return Ok(JsonView(false, ex.Message));
  5944. }
  5945. }
  5946. /// <summary>
  5947. /// 根据op费用Id查询详细数据
  5948. /// </summary>
  5949. /// <param name="dto"></param>
  5950. /// <returns></returns>
  5951. [HttpPost]
  5952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5953. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5954. {
  5955. try
  5956. {
  5957. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5958. if (groupData.Code != 0)
  5959. {
  5960. return Ok(JsonView(false, groupData.Msg));
  5961. }
  5962. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5963. }
  5964. catch (Exception ex)
  5965. {
  5966. return Ok(JsonView(false, ex.Message));
  5967. }
  5968. }
  5969. /// <summary>
  5970. /// OP费用录入填写详情
  5971. /// </summary>
  5972. /// <param name="dto"></param>
  5973. /// <returns></returns>
  5974. [HttpPost]
  5975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5976. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5977. {
  5978. try
  5979. {
  5980. #region 参数校验
  5981. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5982. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5983. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5984. #endregion
  5985. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5986. if (groupData.Code != 0)
  5987. {
  5988. return Ok(JsonView(false, groupData.Msg));
  5989. }
  5990. //自动审核
  5991. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5992. #region 应用推送
  5993. try
  5994. {
  5995. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5996. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5997. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5998. }
  5999. catch (Exception ex)
  6000. {
  6001. }
  6002. #endregion
  6003. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6004. }
  6005. catch (Exception ex)
  6006. {
  6007. return Ok(JsonView(false, ex.Message));
  6008. }
  6009. }
  6010. /// <summary>
  6011. /// 获取三公详细所有城市
  6012. /// </summary>
  6013. /// <returns></returns>
  6014. [HttpGet]
  6015. public IActionResult OpCarCityResult()
  6016. {
  6017. var jw = JsonView(false);
  6018. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6019. {
  6020. x.Id,
  6021. x.Country,
  6022. x.City,
  6023. }).ToList();
  6024. if (data.Count > 0)
  6025. {
  6026. jw = JsonView(true, "获取成功!", data);
  6027. }
  6028. else
  6029. {
  6030. jw.Msg = "城市数据为空!";
  6031. jw.Data = new string[0];
  6032. }
  6033. return Ok(jw);
  6034. }
  6035. /// <summary>
  6036. /// 导出地接费用明细
  6037. /// </summary>
  6038. /// <param name="dto"></param>
  6039. /// <returns></returns>
  6040. [HttpPost]
  6041. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6042. {
  6043. var jw = JsonView(false);
  6044. if (dto.Diid < 1)
  6045. {
  6046. jw.Msg = "请输入正确的diid!";
  6047. return Ok(jw);
  6048. }
  6049. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6050. if (group == null)
  6051. {
  6052. jw.Msg = "未找到团组信息!";
  6053. return Ok(jw);
  6054. }
  6055. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6056. if (localGuideArr.Count == 0)
  6057. {
  6058. jw.Msg = "该团组暂无地接信息!";
  6059. return Ok(jw);
  6060. }
  6061. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6062. var overspendSoure = new Dictionary<int, int>
  6063. {
  6064. { 91, 982 }, //车
  6065. { 92 , 1059} ,//导游
  6066. { 994 , 1073}, //翻译
  6067. { 988 , 1074 }, //早餐
  6068. { 93 , 1075 }, //午餐
  6069. { 989 , 1076 }, //晚餐
  6070. };
  6071. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6072. foreach (var groupArr in localGroup)
  6073. {
  6074. var keyValue = groupArr.Key;
  6075. if (int.TryParse(keyValue, out int cityid))
  6076. {
  6077. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6078. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6079. }
  6080. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6081. foreach (var item in groupArr)
  6082. {
  6083. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6084. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6085. new Grp_CarTouristGuideGroundReservationsContentExtend
  6086. {
  6087. Count = a.Count,
  6088. CreateTime = a.CreateTime,
  6089. CreateUserId = a.CreateUserId,
  6090. CTGGRId = a.CTGGRId,
  6091. Currency = a.Currency,
  6092. DatePrice = a.DatePrice,
  6093. DeleteTime = a.DeleteTime,
  6094. DeleteUserId = a.DeleteUserId,
  6095. DiId = a.DiId,
  6096. Id = a.Id,
  6097. IsDel = a.IsDel,
  6098. Price = a.Price,
  6099. PriceContent = a.PriceContent,
  6100. Remark = a.Remark,
  6101. SId = a.SId,
  6102. SidName = b.Name,
  6103. Units = a.Units,
  6104. }
  6105. ).ToList();
  6106. if (content.Count > 0)
  6107. {
  6108. contentArr.Add(content);
  6109. }
  6110. }
  6111. //open excel
  6112. //set excel
  6113. //save excel
  6114. try
  6115. {
  6116. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6117. IWorkbook workbook;
  6118. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6119. {
  6120. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6121. }
  6122. else
  6123. {
  6124. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6125. }
  6126. ISheet sheet = workbook.GetSheetAt(0);
  6127. var rowStartIndex = 2;
  6128. var clounmCount = 10;
  6129. var initStyleRow = sheet.GetRow(2);
  6130. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6131. //var overspendArrDetail =
  6132. var existsId = new List<CarCompare>();
  6133. var lastElem = arr.Last();
  6134. var thisSid = -1;
  6135. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6136. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6137. {
  6138. Name = "未知币种!",
  6139. Remark = "未知币种!",
  6140. };
  6141. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6142. Action cloneRowFn = () =>
  6143. {
  6144. rowStartIndex++;
  6145. var cloneRow = sheet.CreateRow(rowStartIndex);
  6146. // 复制样式
  6147. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6148. {
  6149. ICell sourceCell = initStyleRow.GetCell(i);
  6150. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6151. // 确保单元格存在样式
  6152. if (sourceCell.CellStyle != null)
  6153. {
  6154. targetCell.CellStyle = sourceCell.CellStyle;
  6155. }
  6156. }
  6157. };
  6158. var mergeRow = () =>
  6159. {
  6160. for (int i = 2; i < sheet.LastRowNum; i++)
  6161. {
  6162. var row = sheet.GetRow(i);
  6163. var cellFirst = row.GetCell(0);
  6164. var thisIndex = i + 1;
  6165. while (thisIndex < sheet.LastRowNum)
  6166. {
  6167. var nextRow = sheet.GetRow(thisIndex);
  6168. var nextCellFirst = nextRow.GetCell(0);
  6169. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6170. {
  6171. thisIndex++;
  6172. }
  6173. else
  6174. {
  6175. break;
  6176. }
  6177. }
  6178. thisIndex--;
  6179. if (thisIndex != i)
  6180. {
  6181. //合并row
  6182. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6183. i, // 起始行索引(0-based)
  6184. thisIndex, // 结束行索引(0-based)
  6185. 0, // 起始列索引(0-based)
  6186. 0 // 结束列索引(0-based)
  6187. );
  6188. sheet.AddMergedRegion(cellRangeAddress);
  6189. i = thisIndex;
  6190. }
  6191. }
  6192. };
  6193. var chaoshiNumber = 0;
  6194. var totalNumber = 0.00M;
  6195. string lastStr = "";
  6196. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6197. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6198. {
  6199. b.IsAuditGM,
  6200. x.Id,
  6201. x.Area,
  6202. b.PayPercentage,
  6203. b.PayMoney,
  6204. }).ToList();
  6205. string yesPayment = "", noPayment = "";
  6206. foreach (var item in queryCarArrByCityAndDiid)
  6207. {
  6208. if (item.IsAuditGM == 1)
  6209. {
  6210. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6211. }
  6212. else
  6213. {
  6214. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6215. }
  6216. }
  6217. lastStr = yesPayment + noPayment;
  6218. foreach (var item in arr)
  6219. {
  6220. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6221. {
  6222. if (thisSid != item.SId)
  6223. {
  6224. if (thisSid == -1)
  6225. {
  6226. thisSid = item.SId;
  6227. }
  6228. else
  6229. {
  6230. //合并小计行
  6231. //创建合并区域的实例
  6232. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6233. rowStartIndex, // 起始行索引(0-based)
  6234. rowStartIndex, // 结束行索引(0-based)
  6235. 0, // 起始列索引(0-based)
  6236. 3 // 结束列索引(0-based)
  6237. );
  6238. sheet.AddMergedRegion(cellRangeAddress);
  6239. var CellStyle = workbook.CreateCellStyle();
  6240. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6241. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6242. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6243. for (int i = 0; i <= clounmCount; i++)
  6244. {
  6245. if (i > 6)
  6246. {
  6247. var CellStyle1 = workbook.CreateCellStyle();
  6248. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6249. IFont Font = workbook.CreateFont(); // 创建字体
  6250. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6251. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6252. CellStyle1.SetFont(Font);
  6253. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6254. }
  6255. else
  6256. {
  6257. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6258. }
  6259. }
  6260. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6261. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6262. //超时合计
  6263. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6264. //超时数
  6265. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6266. //超时合计费用
  6267. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6268. thisSid = item.SId;
  6269. cloneRowFn();
  6270. chaoshiNumber = 0;
  6271. totalNumber = 0;
  6272. }
  6273. }
  6274. IRow row = sheet.GetRow(rowStartIndex);
  6275. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6276. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6277. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6278. if (isOpenOverspendSoure)
  6279. {
  6280. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6281. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6282. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6283. }
  6284. for (int i = 0; i <= clounmCount; i++)
  6285. {
  6286. var cell = row.GetCell(i);
  6287. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6288. if (cell == null)
  6289. {
  6290. cell = row.CreateCell(i);
  6291. }
  6292. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6293. fontRed.CloneStyleFrom(cell.CellStyle);
  6294. IFont Font = workbook.CreateFont(); // 创建字体
  6295. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6296. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6297. fontRed.SetFont(Font);
  6298. byte[] rgb = new byte[3] { 255, 242, 204 };
  6299. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6300. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6301. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6302. if (workbook is XSSFWorkbook)
  6303. {
  6304. BackgroundColor255_242_204.FillForegroundColor = 0;
  6305. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6306. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6307. }
  6308. else
  6309. {
  6310. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6311. }
  6312. if (i == 1 || i > 6)
  6313. {
  6314. if (i > 6)
  6315. {
  6316. fontRed.FillForegroundColor = 0;
  6317. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6318. fontRed.FillPattern = FillPattern.SolidForeground;
  6319. }
  6320. cell.CellStyle = fontRed;
  6321. }
  6322. if (i > 2 && i < 7)
  6323. {
  6324. cell.CellStyle = BackgroundColor255_242_204;
  6325. }
  6326. cell.SetCellValue(setCellValue); //写入单元格
  6327. }
  6328. if (overspendSoure.ContainsKey(thisSid))
  6329. {
  6330. var overspendId = overspendSoure[thisSid];
  6331. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6332. }
  6333. cloneRowFn();
  6334. existsId.Add(new CarCompare
  6335. {
  6336. DataPrice = item.DatePrice.ObjToDate(),
  6337. Sid = item.SId
  6338. });
  6339. }
  6340. if (item.Equals(lastElem))
  6341. {
  6342. //合并小计行
  6343. //创建合并区域的实例
  6344. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6345. rowStartIndex, // 起始行索引(0-based)
  6346. rowStartIndex, // 结束行索引(0-based)
  6347. 0, // 起始列索引(0-based)
  6348. 3 // 结束列索引(0-based)
  6349. );
  6350. sheet.AddMergedRegion(cellRangeAddress);
  6351. var CellStyle = workbook.CreateCellStyle();
  6352. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6353. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6354. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6355. for (int i = 0; i <= clounmCount; i++)
  6356. {
  6357. if (i > 6)
  6358. {
  6359. var CellStyle1 = workbook.CreateCellStyle();
  6360. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6361. IFont Font = workbook.CreateFont(); // 创建字体
  6362. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6363. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6364. CellStyle1.SetFont(Font);
  6365. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6366. }
  6367. else
  6368. {
  6369. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6370. }
  6371. }
  6372. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6373. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6374. //超时合计
  6375. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6376. //超时数
  6377. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6378. //超时合计费用
  6379. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6380. cloneRowFn();
  6381. // 创建合并区域的实例
  6382. cellRangeAddress = new CellRangeAddress(
  6383. rowStartIndex, // 起始行索引(0-based)
  6384. rowStartIndex, // 结束行索引(0-based)
  6385. 0, // 起始列索引(0-based)
  6386. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6387. );
  6388. // 添加合并区域
  6389. sheet.AddMergedRegion(cellRangeAddress);
  6390. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6391. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6392. }
  6393. }
  6394. mergeRow();
  6395. // 保存修改后的Excel文件到新文件
  6396. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6397. // new FileStream(newFilePath, FileMode.CreateNew)
  6398. using (var stream = new MemoryStream())
  6399. {
  6400. workbook.Write(stream, true);
  6401. stream.Flush();
  6402. stream.Seek(0, SeekOrigin.Begin);
  6403. MemoryStream memoryStream = new MemoryStream();
  6404. stream.CopyTo(memoryStream);
  6405. memoryStream.Seek(0, SeekOrigin.Begin);
  6406. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6407. }
  6408. workbook.Close();
  6409. workbook.Dispose();
  6410. }
  6411. catch (Exception ex)
  6412. {
  6413. jw.Msg = "出现异常!" + ex.Message;
  6414. return Ok(jw);
  6415. }
  6416. }
  6417. if (Zips.Count > 0)
  6418. {
  6419. IOOperatorHelper io = new IOOperatorHelper();
  6420. var byts = io.ConvertZipStream(Zips);
  6421. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6422. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6423. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6424. }
  6425. else
  6426. {
  6427. jw.Msg = "暂无生成文件!";
  6428. }
  6429. return Ok(jw);
  6430. }
  6431. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6432. {
  6433. string outStr = string.Empty;
  6434. switch (i)
  6435. {
  6436. case 0:
  6437. outStr = arr[0].SidName;
  6438. break;
  6439. case 1:
  6440. outStr = arr[0].DataPriceStr;
  6441. break;
  6442. case 2:
  6443. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6444. break;
  6445. case 4:
  6446. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6447. break;
  6448. case 7:
  6449. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6450. {
  6451. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6452. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6453. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6454. }
  6455. break;
  6456. case 8:
  6457. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6458. {
  6459. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6460. }
  6461. break;
  6462. case 9:
  6463. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6464. {
  6465. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6466. }
  6467. break;
  6468. case 10:
  6469. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6470. {
  6471. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6472. }
  6473. break;
  6474. }
  6475. return outStr;
  6476. }
  6477. #region OP行程单
  6478. /// <summary>
  6479. /// OP行程单初始化
  6480. /// </summary>
  6481. /// <param name="dto"></param>
  6482. /// <returns></returns>
  6483. [HttpPost]
  6484. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6485. {
  6486. var jw = JsonView(false);
  6487. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6488. var group = groupList.First();
  6489. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6490. if (group == null)
  6491. {
  6492. jw.Msg = "暂无团组!";
  6493. return Ok(jw);
  6494. }
  6495. group = groupList.Find(x => x.Id == diid);
  6496. if (group == null)
  6497. {
  6498. jw.Msg = "请输入正确的团组ID!";
  6499. return Ok(jw);
  6500. }
  6501. string city = string.Empty;
  6502. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6503. if (blackCode.Count > 0)
  6504. {
  6505. var black = blackCode.First();
  6506. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6507. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6508. if (blackSp.Length > 0)
  6509. {
  6510. try
  6511. {
  6512. var cityArrCode = new List<string>(20);
  6513. foreach (var item in blackSp)
  6514. {
  6515. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6516. var IndexSelect = itemSp[2];
  6517. var cityArrCodeLength = cityArrCode.Count - 1;
  6518. var startCity = IndexSelect.Substring(0, 3);
  6519. if (cityArrCodeLength > 0)
  6520. {
  6521. var arrEndCity = cityArrCode[cityArrCodeLength];
  6522. if (arrEndCity != startCity)
  6523. {
  6524. cityArrCode.Add(startCity.ToUpper());
  6525. }
  6526. }
  6527. else
  6528. {
  6529. cityArrCode.Add(startCity.ToUpper());
  6530. }
  6531. var endCity = IndexSelect.Substring(3, 3);
  6532. cityArrCode.Add(endCity.ToUpper());
  6533. }
  6534. var cityThree = string.Empty;
  6535. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6536. cityThree = cityThree.TrimEnd(',');
  6537. if (string.IsNullOrWhiteSpace(cityThree))
  6538. {
  6539. throw new
  6540. Exception("error");
  6541. }
  6542. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6543. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6544. foreach (var item in cityArrCode)
  6545. {
  6546. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6547. if (find != null)
  6548. {
  6549. city += find.City + "/";
  6550. }
  6551. else
  6552. {
  6553. city += item + "三字码未收入/";
  6554. }
  6555. }
  6556. city = city.TrimEnd('/');
  6557. }
  6558. catch (Exception e)
  6559. {
  6560. city = "黑屏代码格式不正确!";
  6561. }
  6562. }
  6563. }
  6564. else
  6565. {
  6566. city = "未录入黑屏代码";
  6567. }
  6568. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6569. {
  6570. Date = x.Date,
  6571. Days = x.Days,
  6572. Diffgroup = x.Diffgroup,
  6573. Diid = x.Diid,
  6574. Traffic_First = x.Traffic_First,
  6575. Traffic_Second = x.Traffic_Second,
  6576. Trip = x.Trip,
  6577. WeekDay = x.WeekDay,
  6578. Id = x.Id
  6579. }).ToList();
  6580. jw.Data = new
  6581. {
  6582. groupList = groupList.Select(x => new
  6583. {
  6584. x.Id,
  6585. x.TeamName,
  6586. x.TourCode
  6587. }).ToList(),
  6588. groupInfo = new
  6589. {
  6590. group.VisitDays,
  6591. group.TourCode,
  6592. group.VisitPNumber,
  6593. group.TeamName,
  6594. city
  6595. },
  6596. OpTravelList
  6597. };
  6598. jw.Code = 200;
  6599. jw.Msg = "操作成功!";
  6600. return Ok(jw);
  6601. }
  6602. /// <summary>
  6603. /// 删除团组行程单
  6604. /// </summary>
  6605. /// <returns></returns>
  6606. [HttpPost]
  6607. public IActionResult DelTravel(DelOpTravelDto dto)
  6608. {
  6609. var jw = JsonView(false);
  6610. if (dto.UserId <= 0 || dto.Diid <= 0)
  6611. {
  6612. jw.Msg = "请输入正确的参数!";
  6613. return Ok(jw);
  6614. }
  6615. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6616. .SetColumns(x => new Grp_TravelList
  6617. {
  6618. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6619. DeleteUserId = dto.UserId,
  6620. IsDel = 1,
  6621. }).ExecuteCommand();
  6622. jw = JsonView(true);
  6623. return Ok(jw);
  6624. }
  6625. /// <summary>
  6626. /// 行程单保存
  6627. /// </summary>
  6628. /// <returns></returns>
  6629. [HttpPost]
  6630. public IActionResult TravelSave(TravelSaveDto dto)
  6631. {
  6632. var jw = JsonView(false);
  6633. if (dto.Arr.Count > 0)
  6634. {
  6635. try
  6636. {
  6637. _sqlSugar.BeginTran();
  6638. foreach (var item in dto.Arr)
  6639. {
  6640. if (item.Id == 0)
  6641. {
  6642. throw new Exception("请传入正确的Id");
  6643. }
  6644. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6645. .SetColumns(x => new Grp_TravelList
  6646. {
  6647. Trip = item.Trip
  6648. }).ExecuteCommand();
  6649. }
  6650. _sqlSugar.CommitTran();
  6651. jw = JsonView(true);
  6652. }
  6653. catch (Exception ex)
  6654. {
  6655. _sqlSugar.RollbackTran();
  6656. jw.Msg = "程序异常!" + ex.Message;
  6657. }
  6658. }
  6659. else
  6660. {
  6661. jw.Msg = "请传入正确的参数!";
  6662. }
  6663. return Ok(jw);
  6664. }
  6665. /// <summary>
  6666. /// 导出行程单
  6667. /// </summary>
  6668. /// <param name="dto"></param>
  6669. /// <returns></returns>
  6670. [HttpPost]
  6671. public IActionResult ExportTravel(ExportTravelDto dto)
  6672. {
  6673. var jw = JsonView(false);
  6674. jw.Data = "";
  6675. int diid = 0;
  6676. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6677. if (Find == null)
  6678. {
  6679. jw.Msg = "请选择正确的团组!";
  6680. return Ok(jw);
  6681. }
  6682. else
  6683. {
  6684. diid = Find.Id;
  6685. }
  6686. //数据源
  6687. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6688. DataTable dtBlack = null;
  6689. try
  6690. {
  6691. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6692. }
  6693. catch (Exception)
  6694. {
  6695. jw.Msg = "机票黑屏代码有误!";
  6696. return Ok(jw);
  6697. }
  6698. string CityStr = string.Empty;
  6699. if (dtBlack.Rows.Count == 0)
  6700. {
  6701. jw.Msg = "机票黑屏代码有误!";
  6702. return Ok(jw);
  6703. }
  6704. else
  6705. {
  6706. foreach (DataRow row in dtBlack.Rows)
  6707. {
  6708. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6709. {
  6710. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6711. return Ok(jw);
  6712. }
  6713. }
  6714. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6715. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6716. }
  6717. //创建数据源Table
  6718. DataTable dtSource = new DataTable();
  6719. dtSource.Columns.Add("Days", typeof(string));
  6720. dtSource.Columns.Add("Date", typeof(string));
  6721. dtSource.Columns.Add("Week", typeof(string));
  6722. dtSource.Columns.Add("Traffic", typeof(string));
  6723. dtSource.Columns.Add("Trip", typeof(string));
  6724. //获取数据,放到datatable
  6725. foreach (var item in _travelList)
  6726. {
  6727. DataRow dr = dtSource.NewRow();
  6728. dr["Days"] = item.Days;
  6729. dr["Date"] = item.Date;
  6730. dr["Week"] = item.WeekDay;
  6731. dr["Traffic"] = item.Traffic_First
  6732. + "\r\n"
  6733. + item.Traffic_Second;
  6734. dr["Trip"] = item.Trip;
  6735. dtSource.Rows.Add(dr);
  6736. }
  6737. Dictionary<string, string> dic = new Dictionary<string, string>();
  6738. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6739. dic.Add("City", CityStr);
  6740. dic.Add("Days", Find.VisitDays.ToString());
  6741. dic.Add("DeleCode", Find.TourCode);
  6742. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6743. //模板路径
  6744. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6745. //载入模板
  6746. Document doc = null;
  6747. DocumentBuilder builder = null;
  6748. try
  6749. {
  6750. //载入模板
  6751. doc = new Document(tempPath);
  6752. builder = new DocumentBuilder(doc);
  6753. }
  6754. catch (Exception)
  6755. {
  6756. jw.Msg = "模板位置不存在!";
  6757. return Ok(jw);
  6758. }
  6759. foreach (var key in dic.Keys)
  6760. {
  6761. Bookmark bookmark = doc.Range.Bookmarks[key];
  6762. if (bookmark != null)
  6763. {
  6764. builder.MoveToBookmark(key);
  6765. builder.Write(dic[key]);
  6766. }
  6767. }
  6768. //获取word里所有表格
  6769. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6770. //获取所填表格的序数
  6771. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6772. try
  6773. {
  6774. //循环赋值
  6775. for (int i = 0; i < dtSource.Rows.Count; i++)
  6776. {
  6777. builder.MoveToCell(0, i + 1, 0, 0);
  6778. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6779. builder.MoveToCell(0, i + 1, 1, 0);
  6780. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6781. builder.MoveToCell(0, i + 1, 2, 0);
  6782. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6783. var trip = dtSource.Rows[i]["Trip"].ToString();
  6784. builder.MoveToCell(0, i + 1, 3, 0);
  6785. builder.Write(trip);
  6786. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6787. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6788. // 获取特定索引的段落
  6789. Paragraph paragraph = (Paragraph)paragraphs[0];
  6790. Run run = paragraph.Runs[0];
  6791. Aspose.Words.Font font = run.Font;
  6792. font.Name = "黑体";
  6793. //设置双休红色
  6794. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6795. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6796. paragraph = (Paragraph)paragraphs[1];
  6797. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6798. {
  6799. run = paragraph.Runs[0];
  6800. font = run.Font;
  6801. font.Color = Color.Red;
  6802. }
  6803. }
  6804. }
  6805. catch (Exception ex)
  6806. {
  6807. }
  6808. //删除多余行
  6809. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6810. {
  6811. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6812. }
  6813. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6814. if (!Directory.Exists(savePath))
  6815. {
  6816. try
  6817. {
  6818. Directory.CreateDirectory(savePath);
  6819. }
  6820. catch
  6821. {
  6822. }
  6823. }
  6824. string path = savePath + Find.TeamName + "出访日程";
  6825. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6826. try
  6827. {
  6828. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6829. string postfix = ".docx";
  6830. if (dto.IsPDF == 1)
  6831. {
  6832. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6833. postfix = ".pdf";
  6834. }
  6835. doc.Save(path + postfix, saveFormat);
  6836. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6837. }
  6838. catch (Exception)
  6839. {
  6840. jw = JsonView(false);
  6841. }
  6842. return Ok(jw);
  6843. }
  6844. /// <summary>
  6845. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6846. /// </summary>
  6847. /// <param name="num"></param>
  6848. /// <returns></returns>
  6849. string GetNum(string num)
  6850. {
  6851. string str = "";
  6852. switch (num)
  6853. {
  6854. case "1":
  6855. str = "一";
  6856. break;
  6857. case "2":
  6858. str = "二";
  6859. break;
  6860. case "3":
  6861. str = "三";
  6862. break;
  6863. case "4":
  6864. str = "四";
  6865. break;
  6866. case "5":
  6867. str = "五";
  6868. break;
  6869. case "6":
  6870. str = "六";
  6871. break;
  6872. case "7":
  6873. str = "七";
  6874. break;
  6875. case "8":
  6876. str = "八";
  6877. break;
  6878. case "9":
  6879. str = "九";
  6880. break;
  6881. case "10":
  6882. str = "十";
  6883. break;
  6884. case "11":
  6885. str = "十一";
  6886. break;
  6887. case "12":
  6888. str = "十二";
  6889. break;
  6890. case "一":
  6891. str = "1";
  6892. break;
  6893. case "二":
  6894. str = "2";
  6895. break;
  6896. case "三":
  6897. str = "3";
  6898. break;
  6899. case "四":
  6900. str = "4";
  6901. break;
  6902. case "五":
  6903. str = "5";
  6904. break;
  6905. case "六":
  6906. str = "6";
  6907. break;
  6908. case "七":
  6909. str = "7";
  6910. break;
  6911. case "八":
  6912. str = "8";
  6913. break;
  6914. case "九":
  6915. str = "9";
  6916. break;
  6917. case "十":
  6918. str = "10";
  6919. break;
  6920. case "十一":
  6921. str = "11";
  6922. break;
  6923. case "十二":
  6924. str = "12";
  6925. break;
  6926. }
  6927. return str;
  6928. }
  6929. #endregion
  6930. #endregion
  6931. #region 团组成本
  6932. /// <summary>
  6933. /// 团组成本数据初始化
  6934. /// </summary>
  6935. /// <param name="dto"></param>
  6936. /// <returns></returns>
  6937. [HttpPost]
  6938. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6939. {
  6940. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6941. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6942. WHEN COUNT(*) >= 0 THEN 'True'
  6943. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6944. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6945. ").ToList(); //团组列表
  6946. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6947. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6948. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6949. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6950. if (groupinfoValue != null)
  6951. {
  6952. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6953. var spArr = new string[1] { countryArr };
  6954. if (countryArr.Contains("|"))
  6955. {
  6956. spArr = countryArr.Split("|");
  6957. }
  6958. else if (countryArr.Contains("、"))
  6959. {
  6960. spArr = countryArr.Split("、");
  6961. }
  6962. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6963. {
  6964. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6965. if (dbQueryCountry != null)
  6966. {
  6967. visaCountryInfoArr.Add(dbQueryCountry);
  6968. }
  6969. }
  6970. }
  6971. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6972. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6973. var create = _GroupCostRepository.
  6974. CreateGroupCostByBlackCode(dto.Diid);
  6975. if (groupCost.Count == 0 && create.Code == 0)
  6976. {
  6977. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6978. }
  6979. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6980. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6981. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6982. groupCostMap = groupCostMap.Select(x =>
  6983. {
  6984. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6985. {
  6986. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6987. }
  6988. return x;
  6989. }).ToList();
  6990. //GroupCostParameter.Add(new
  6991. // Grp_GroupCostParameter());
  6992. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6993. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6994. return Ok(JsonView(new
  6995. {
  6996. groupList,
  6997. groupInfo,
  6998. groupChecks,
  6999. groupCost = groupCostMap,
  7000. hotelNumber,
  7001. GroupCostParameter = GroupCostParameterMap,
  7002. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7003. {
  7004. x.VisaCountry,
  7005. x.VisaPrice,
  7006. x.Id,
  7007. }).ToList(),
  7008. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7009. blackCodeIsTrue = create.Code == 0 ? true : false,
  7010. hotelIsTrue = hotelIsTrue,
  7011. }));
  7012. }
  7013. /// <summary>
  7014. /// 团组成本信息保存
  7015. /// </summary>
  7016. /// <param name="dto"></param>
  7017. /// <returns></returns>
  7018. [HttpPost]
  7019. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7020. {
  7021. if (dto.Diid <= 0 || dto.Userid <= 0)
  7022. {
  7023. return Ok(JsonView(false));
  7024. }
  7025. JsonView jw = null;
  7026. bool isTrue = false;
  7027. #region 复制团组成本
  7028. //if (dto.Diid == 2581)
  7029. //{
  7030. // dto.Diid = 2599;
  7031. // dto.CheckBoxs.ForEach(x =>
  7032. // {
  7033. // x.Diid = 2599;
  7034. // });
  7035. // dto.GroupCosts.ForEach(x =>
  7036. // {
  7037. // x.Diid = 2599;
  7038. // });
  7039. // dto.CostTypeHotelNumbers.ForEach(x =>
  7040. // {
  7041. // x.Diid = 2599;
  7042. // });
  7043. // dto.GroupCostParameters.ForEach(x =>
  7044. // {
  7045. // x.DiId = 2599;
  7046. // });
  7047. //}
  7048. #endregion
  7049. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7050. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7051. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7052. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7053. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7054. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7055. try
  7056. {
  7057. _sqlSugar.BeginTran();
  7058. isTrue = await _GroupCostRepository.
  7059. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7060. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7061. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7062. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7063. _sqlSugar.CommitTran();
  7064. jw = JsonView(true, "保存成功!", isTrue);
  7065. }
  7066. catch (Exception)
  7067. {
  7068. _sqlSugar.RollbackTran();
  7069. jw = JsonView(false);
  7070. }
  7071. return Ok(jw);
  7072. }
  7073. /// <summary>
  7074. /// 司兼导数据
  7075. /// </summary>
  7076. /// <param name="dto"></param>
  7077. /// <returns></returns>
  7078. [HttpPost]
  7079. public IActionResult GetCarGuides(CarGuidesDto dto)
  7080. {
  7081. JsonView jw = null;
  7082. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7083. jw = JsonView(true, "获取成功!", Data);
  7084. return Ok(jw);
  7085. }
  7086. /// <summary>
  7087. /// 导游数据
  7088. /// </summary>
  7089. /// <param name="dto"></param>
  7090. /// <returns></returns>
  7091. [HttpPost]
  7092. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7093. {
  7094. JsonView jw = null;
  7095. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7096. // 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
  7097. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7098. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7099. jw = JsonView(true, "获取成功!", Data);
  7100. return Ok(jw);
  7101. }
  7102. /// <summary>
  7103. /// 成本车数据
  7104. /// </summary>
  7105. /// <param name="dto"></param>
  7106. /// <returns></returns>
  7107. [HttpPost]
  7108. public IActionResult GetCarInfo(CarGuidesDto dto)
  7109. {
  7110. JsonView jw = null;
  7111. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7112. jw = JsonView(true, "获取成功!", Data);
  7113. return Ok(jw);
  7114. }
  7115. /// <summary>
  7116. /// 景点数据
  7117. /// </summary>
  7118. /// <param name="dto"></param>
  7119. /// <returns></returns>
  7120. [HttpPost]
  7121. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7122. {
  7123. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7124. return Ok(JsonView(true, "获取成功!", Data));
  7125. }
  7126. /// <summary>
  7127. /// 成本通知
  7128. /// </summary>
  7129. /// <param name="dto"></param>
  7130. /// <returns></returns>
  7131. [HttpPost]
  7132. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7133. {
  7134. if (dto.Diid < 0)
  7135. {
  7136. return Ok(JsonView(false));
  7137. }
  7138. JsonView jw = null;
  7139. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7140. if (GroupCostParameter != null)
  7141. {
  7142. int IsShare = 0;
  7143. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7144. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7145. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7146. string msg = string.Empty;
  7147. if (isTrue)
  7148. {
  7149. if (IsShare == 0)
  7150. {
  7151. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7152. }
  7153. else
  7154. {
  7155. #region 企微通知对应岗位用户
  7156. try
  7157. {
  7158. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7159. }
  7160. catch (Exception ex)
  7161. {
  7162. }
  7163. #endregion
  7164. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7165. }
  7166. jw = JsonView(isTrue, msg, new { IsShare });
  7167. }
  7168. else
  7169. {
  7170. msg = "修改失败!";
  7171. jw = JsonView(isTrue, msg);
  7172. }
  7173. }
  7174. else
  7175. {
  7176. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7177. }
  7178. return Ok(jw);
  7179. }
  7180. /// <summary>
  7181. /// 导出报价单
  7182. /// </summary>
  7183. /// <param name="dto"></param>
  7184. /// <returns></returns>
  7185. [HttpPost]
  7186. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7187. {
  7188. if (dto.Diid == 0)
  7189. {
  7190. return Ok(JsonView(false, "请传递团组id"));
  7191. }
  7192. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7193. if (deleInfo.Code != 0)
  7194. {
  7195. return Ok(JsonView(false, "团组信息查询失败!"));
  7196. }
  7197. var di = deleInfo.Data as DelegationInfoWebView;
  7198. if (di != null)
  7199. {
  7200. di.TeamName = di.TeamName.Replace("|","、");
  7201. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7202. //文件名
  7203. string strFileName = di.TeamName + "-收款账单.doc";
  7204. //获取模板
  7205. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7206. //载入模板
  7207. Document doc = new Document(tmppath);
  7208. decimal TotalPrice = 0.00M;
  7209. string itemStr = string.Empty;
  7210. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7211. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7212. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7213. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7214. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7215. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7216. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7217. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7218. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7219. foreach (var cost in groupCostType)
  7220. {
  7221. var List = cost.ToList();
  7222. if (cost.Key == "A")
  7223. {
  7224. foreach (var ListItem in List)
  7225. {
  7226. if (ListItem.number > 0)
  7227. {
  7228. if (ListItem.code.Contains("TBR"))
  7229. {
  7230. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7231. }
  7232. else
  7233. {
  7234. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7235. }
  7236. TotalPrice += (ListItem.number * ListItem.price);
  7237. }
  7238. }
  7239. }
  7240. else
  7241. {
  7242. itemStr = itemStr.Insert(0, "A段\r\n");
  7243. itemStr += "B段\r\n";
  7244. foreach (var ListItem in List)
  7245. {
  7246. if (ListItem.number > 0)
  7247. {
  7248. if (ListItem.code.Contains("TBR"))
  7249. {
  7250. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7251. }
  7252. else
  7253. {
  7254. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7255. }
  7256. TotalPrice += (ListItem.number * ListItem.price);
  7257. }
  7258. }
  7259. }
  7260. }
  7261. #region 替换Word模板书签内容
  7262. Dictionary<string, string> marks = new Dictionary<string, string>();
  7263. marks.Add("To", di.ClientUnit);//付款方
  7264. marks.Add("ToTel", di.TellPhone);//付款方电话
  7265. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7266. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7267. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7268. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7269. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7270. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7271. marks.Add("PayItemContent", itemStr);//详细信息
  7272. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7273. #endregion
  7274. ////注
  7275. //if (doc.Range.Bookmarks["Attention"] != null)
  7276. //{
  7277. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7278. // mark.Text = frList[0].Attention;
  7279. //}
  7280. foreach (var item in marks.Keys)
  7281. {
  7282. if (doc.Range.Bookmarks[item] != null)
  7283. {
  7284. Bookmark mark = doc.Range.Bookmarks[item];
  7285. mark.Text = marks[item];
  7286. }
  7287. }
  7288. byte[] bytes = null;
  7289. using (MemoryStream stream = new MemoryStream())
  7290. {
  7291. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7292. bytes = stream.ToArray();
  7293. }
  7294. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7295. return Ok(JsonView(true, "", new
  7296. {
  7297. Data = bytes,
  7298. strFileName,
  7299. }));
  7300. }
  7301. else
  7302. {
  7303. return Ok(JsonView(false, "团组信息不存在!"));
  7304. }
  7305. }
  7306. /// <summary>
  7307. /// 导出团组成本
  7308. /// </summary>
  7309. /// <param name="dto"></param>
  7310. /// <returns></returns>
  7311. [HttpPost]
  7312. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7313. {
  7314. var jw = JsonView(false);
  7315. if (dto.Diid == 0)
  7316. {
  7317. return Ok(JsonView(false, "请传递团组id"));
  7318. }
  7319. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7320. if (deleInfo.Code != 0)
  7321. {
  7322. return Ok(JsonView(false, "团组信息查询失败!"));
  7323. }
  7324. var di = deleInfo.Data as DelegationInfoWebView;
  7325. if (di == null)
  7326. {
  7327. return Ok(JsonView(false, "团组信息查询失败!"));
  7328. }
  7329. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7330. WorkbookDesigner designer = new WorkbookDesigner();
  7331. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7332. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7333. for (int i = 0; i < List_GC.Count; i++)
  7334. {
  7335. GroupCost_Excel gc = new GroupCost_Excel();
  7336. gc.Id = List_GC[i].Id;
  7337. gc.Diid = List_GC[i].Diid.ToString();
  7338. gc.DAY = List_GC[i].DAY;
  7339. string week = "";
  7340. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7341. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7342. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7343. gc.ITIN = List_GC[i].ITIN;
  7344. gc.CarType = List_GC[i].CarType;
  7345. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7346. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7347. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7348. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7349. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7350. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7351. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7352. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7353. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7354. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7355. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7356. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7357. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7358. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7359. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7360. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7361. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7362. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7363. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7364. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7365. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7366. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7367. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7368. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7369. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7370. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7371. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7372. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7373. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7374. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7375. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7376. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7377. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7378. List_GC1.Add(gc);
  7379. }
  7380. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7381. dt.TableName = "TB";
  7382. //报表标题等不用dt的值
  7383. designer.SetDataSource("TeamName", dto.title.TeamName);
  7384. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7385. designer.SetDataSource("Tax", dto.title.Tax);
  7386. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7387. designer.SetDataSource("Currency", dto.title.Currency);
  7388. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7389. designer.SetDataSource("Rate", dto.title.Rate);
  7390. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7391. var Aparams = hotels.Find(x => x.Type == "Default");
  7392. if (Aparams == null)
  7393. {
  7394. return Ok(jw);
  7395. }
  7396. //酒店数量
  7397. var txtSGRNumber = Aparams.SGR.ToString();
  7398. var txtTBRNumber = Aparams.TBR.ToString();
  7399. var txtJSESNumber = Aparams.JSES.ToString();
  7400. var txtSUITENumbe = Aparams.SUITE.ToString();
  7401. if (dto.costType == "B")
  7402. {
  7403. Aparams = hotels.Find(x => x.Type == "A");
  7404. var Bparams = hotels.Find(x => x.Type == "B");
  7405. if (Aparams == null || Bparams == null)
  7406. {
  7407. return Ok(jw);
  7408. }
  7409. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7410. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7411. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7412. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7413. }
  7414. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7415. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7416. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7417. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7418. var ws = designer.Workbook.Worksheets[0];
  7419. int Row = List_GC.Count;
  7420. int startIndex = 11;
  7421. int HideRows = 0;
  7422. List<int> hideRowsList = new List<int>();
  7423. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7424. #region A段left数据
  7425. var left = dto.leftInfo.Find(x => x.Type == "A");
  7426. if (left == null)
  7427. {
  7428. return Ok(jw);
  7429. }
  7430. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7431. if (leftBindData != null)
  7432. {
  7433. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7434. designer.SetDataSource("VisaRS", leftBindData.rs);
  7435. designer.SetDataSource("VisaXS", leftBindData.xs);
  7436. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7437. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7438. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7439. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7440. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7441. }
  7442. else
  7443. {
  7444. hideRowsList.Add(Row + startIndex + HideRows);
  7445. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7446. }
  7447. HideRows += 2;
  7448. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7449. if (leftBindData != null)
  7450. {
  7451. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7452. designer.SetDataSource("BXRS", leftBindData.rs);
  7453. designer.SetDataSource("BXXS", leftBindData.xs);
  7454. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7455. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7456. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7457. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7458. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7459. }
  7460. else
  7461. {
  7462. hideRowsList.Add(Row + startIndex + HideRows);
  7463. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7464. }
  7465. HideRows += 2;
  7466. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7467. if (leftBindData != null)
  7468. {
  7469. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7470. designer.SetDataSource("HSRS", leftBindData.rs);
  7471. designer.SetDataSource("HSXS", leftBindData.xs);
  7472. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7473. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7474. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7475. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7476. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7477. }
  7478. else
  7479. {
  7480. hideRowsList.Add(Row + startIndex + HideRows);
  7481. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7482. }
  7483. HideRows += 2;
  7484. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7485. if (leftBindData != null)
  7486. {
  7487. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7488. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7489. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7490. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7491. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7492. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7493. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7494. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7495. }
  7496. else
  7497. {
  7498. hideRowsList.Add(Row + startIndex + HideRows);
  7499. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7500. }
  7501. HideRows += 2;
  7502. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7503. if (leftBindData != null)
  7504. {
  7505. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7506. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7507. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7508. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7509. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7510. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7511. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7512. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7513. }
  7514. else
  7515. {
  7516. hideRowsList.Add(Row + startIndex + HideRows);
  7517. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7518. }
  7519. HideRows += 2;
  7520. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7521. if (leftBindData != null)
  7522. {
  7523. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7524. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7525. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7526. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7527. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7528. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7529. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7530. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7531. }
  7532. else
  7533. {
  7534. hideRowsList.Add(Row + startIndex + HideRows);
  7535. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7536. }
  7537. HideRows += 2;
  7538. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7539. if (leftBindData != null)
  7540. {
  7541. ////TBR
  7542. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7543. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7544. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7545. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7546. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7547. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7548. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7549. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7550. }
  7551. else
  7552. {
  7553. hideRowsList.Add(Row + startIndex + HideRows);
  7554. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7555. }
  7556. HideRows += 2;
  7557. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7558. if (leftBindData != null)
  7559. {
  7560. ////SGR
  7561. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7562. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7563. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7564. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7565. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7566. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7567. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7568. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7569. }
  7570. else
  7571. {
  7572. hideRowsList.Add(Row + startIndex + HideRows);
  7573. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7574. }
  7575. HideRows += 2;
  7576. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7577. if (leftBindData != null)
  7578. {
  7579. ////JS/ES
  7580. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7581. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7582. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7583. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7584. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7585. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7586. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7587. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7588. }
  7589. else
  7590. {
  7591. hideRowsList.Add(Row + startIndex + HideRows);
  7592. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7593. }
  7594. HideRows += 2;
  7595. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7596. if (leftBindData != null)
  7597. {
  7598. ////SUITE
  7599. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7600. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7601. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7602. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7603. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7604. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7605. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7606. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7607. }
  7608. else
  7609. {
  7610. hideRowsList.Add(Row + startIndex + HideRows);
  7611. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7612. }
  7613. HideRows += 2;
  7614. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7615. if (leftBindData != null)
  7616. {
  7617. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7618. designer.SetDataSource("DJRS", leftBindData.rs);
  7619. designer.SetDataSource("DJXS", leftBindData.xs);
  7620. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7621. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7622. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7623. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7624. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7625. }
  7626. else
  7627. {
  7628. hideRowsList.Add(Row + startIndex + HideRows);
  7629. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7630. }
  7631. HideRows += 2;
  7632. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7633. if (leftBindData != null)
  7634. {
  7635. designer.SetDataSource("HCPCB", leftBindData.cb);
  7636. designer.SetDataSource("HCPRS", leftBindData.rs);
  7637. designer.SetDataSource("HCPXS", leftBindData.xs);
  7638. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7639. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7640. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7641. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7642. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7643. }
  7644. else
  7645. {
  7646. hideRowsList.Add(Row + startIndex + HideRows);
  7647. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7648. }
  7649. HideRows += 2;
  7650. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7651. if (leftBindData != null)
  7652. {
  7653. designer.SetDataSource("CPCB", leftBindData.cb);
  7654. designer.SetDataSource("CPRS", leftBindData.rs);
  7655. designer.SetDataSource("CPXS", leftBindData.xs);
  7656. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7657. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7658. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7659. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7660. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7661. }
  7662. else
  7663. {
  7664. hideRowsList.Add(Row + startIndex + HideRows);
  7665. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7666. }
  7667. HideRows += 2;
  7668. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7669. if (leftBindData != null)
  7670. {
  7671. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7672. designer.SetDataSource("GWRS", leftBindData.rs);
  7673. designer.SetDataSource("GWXS", leftBindData.xs);
  7674. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7675. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7676. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7677. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7678. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7679. }
  7680. else
  7681. {
  7682. hideRowsList.Add(Row + startIndex + HideRows);
  7683. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7684. }
  7685. HideRows += 2;
  7686. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7687. if (leftBindData != null)
  7688. {
  7689. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7690. designer.SetDataSource("LYJRS", leftBindData.rs);
  7691. designer.SetDataSource("LYJXS", leftBindData.xs);
  7692. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7693. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7694. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7695. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7696. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7697. }
  7698. else
  7699. {
  7700. hideRowsList.Add(Row + startIndex + HideRows);
  7701. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7702. }
  7703. #endregion
  7704. #region A段Right信息
  7705. var right = dto.rightInfo.Find(x => x.Type == "A");
  7706. if (right == null)
  7707. {
  7708. return Ok(jw);
  7709. }
  7710. HideRows += 4;
  7711. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7712. if (rightBindData != null)
  7713. {
  7714. //经济舱 + 双人间 TBR
  7715. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7716. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7717. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7718. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7719. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7720. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7721. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7722. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7723. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7724. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7725. }
  7726. else
  7727. {
  7728. hideRowsList.Add(Row + startIndex + HideRows);
  7729. }
  7730. HideRows += 2;
  7731. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7732. if (rightBindData != null)
  7733. {
  7734. //经济舱 + 单人间 SGR
  7735. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7736. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7737. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7738. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7739. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7740. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7741. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7742. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7743. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7744. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7745. }
  7746. else
  7747. {
  7748. hideRowsList.Add(Row + startIndex + HideRows);
  7749. }
  7750. HideRows += 2;
  7751. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7752. if (rightBindData != null)
  7753. {
  7754. //公务舱 + 单人间 SGR
  7755. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7756. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7757. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7758. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7759. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7760. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7761. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7762. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7763. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7764. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7765. }
  7766. else
  7767. {
  7768. hideRowsList.Add(Row + startIndex + HideRows);
  7769. }
  7770. HideRows += 2;
  7771. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7772. if (rightBindData != null)
  7773. {
  7774. //公务舱 + 小套房 JSES
  7775. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7776. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7777. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7778. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7779. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7780. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7781. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7782. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7783. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7784. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7785. }
  7786. else
  7787. {
  7788. hideRowsList.Add(Row + startIndex + HideRows);
  7789. }
  7790. HideRows += 2;
  7791. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7792. if (rightBindData != null)
  7793. {
  7794. //公务舱 + 小套房 JSES
  7795. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7796. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7797. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7798. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7799. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7800. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7801. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7802. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7803. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7804. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7805. }
  7806. else
  7807. {
  7808. hideRowsList.Add(Row + startIndex + HideRows);
  7809. }
  7810. HideRows += 2;
  7811. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7812. if (rightBindData != null)
  7813. {
  7814. //经济舱 + 大套房
  7815. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7816. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7817. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7818. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7819. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7820. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7821. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7822. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7823. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7824. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7825. }
  7826. else
  7827. {
  7828. hideRowsList.Add(Row + startIndex + HideRows);
  7829. }
  7830. HideRows += 2;
  7831. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7832. if (rightBindData != null)
  7833. {
  7834. //头等舱 + 小套房 JSES
  7835. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7836. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7837. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7838. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7839. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7840. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7841. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7842. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7843. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7844. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7845. }
  7846. else
  7847. {
  7848. hideRowsList.Add(Row + startIndex + HideRows);
  7849. }
  7850. HideRows += 2;
  7851. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7852. if (rightBindData != null)
  7853. {
  7854. //头等舱 + 大套房
  7855. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7856. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7857. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7858. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7859. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7860. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7861. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7862. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7863. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7864. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7865. }
  7866. else
  7867. {
  7868. hideRowsList.Add(Row + startIndex + HideRows);
  7869. }
  7870. #endregion
  7871. #region B段标题清空
  7872. designer.SetDataSource("CostBDRCB", "");
  7873. designer.SetDataSource("CostBRS", "");
  7874. designer.SetDataSource("CostBXS", "");
  7875. designer.SetDataSource("CostBZCB", "");
  7876. designer.SetDataSource("CostBDRBJ", "");
  7877. designer.SetDataSource("CostBZBJ", "");
  7878. designer.SetDataSource("CostBDRLR", "");
  7879. designer.SetDataSource("CostBZLR", "");
  7880. designer.SetDataSource("CostBDRCBOM", "");
  7881. designer.SetDataSource("CostBRSOM", "");
  7882. designer.SetDataSource("CostBZCBOM", "");
  7883. designer.SetDataSource("CostBDRBJOM", "");
  7884. designer.SetDataSource("CostBZBJOM", "");
  7885. designer.SetDataSource("CostBDRLROM", "");
  7886. designer.SetDataSource("CostBZLROM", "");
  7887. #endregion
  7888. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7889. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7890. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7891. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7892. designer.SetDataSource("DJName", "地接(CNY)");
  7893. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7894. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7895. designer.SetDataSource("GWName", "公务(CNY)");
  7896. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7897. designer.SetDataSource("LYJName", "零用金(CNY)");
  7898. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7899. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7900. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7901. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7902. designer.SetDataSource("BXName", "保险(CNY)");
  7903. designer.SetDataSource("VisaName", "签证(CNY)");
  7904. #region B段基本数据
  7905. if (dto.costType == "B")
  7906. {
  7907. left = dto.leftInfo.Find(x => x.Type == "B");
  7908. if (left == null)
  7909. {
  7910. return Ok(jw);
  7911. }
  7912. #region B段left数据
  7913. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7914. if (leftBindData != null)
  7915. {
  7916. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7917. designer.SetDataSource("BHSRS", leftBindData.rs);
  7918. designer.SetDataSource("BHSXS", leftBindData.xs);
  7919. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7920. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7921. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7922. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7923. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7924. }
  7925. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7926. if (leftBindData != null)
  7927. {
  7928. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7929. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7930. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7931. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7932. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7933. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7934. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7935. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7936. }
  7937. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7938. if (leftBindData != null)
  7939. {
  7940. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7941. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7942. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7943. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7944. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7945. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7946. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7947. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7948. }
  7949. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7950. if (leftBindData != null)
  7951. {
  7952. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  7953. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  7954. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  7955. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7956. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7957. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7958. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7959. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7960. }
  7961. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7962. if (leftBindData != null)
  7963. {
  7964. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7965. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7966. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7967. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7968. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7969. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7970. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7971. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7972. }
  7973. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7974. if (leftBindData != null)
  7975. {
  7976. designer.SetDataSource("BCPCB", leftBindData.cb);
  7977. designer.SetDataSource("BCPRS", leftBindData.rs);
  7978. designer.SetDataSource("BCPXS", leftBindData.xs);
  7979. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7980. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7981. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7982. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7983. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7984. }
  7985. //TBR
  7986. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7987. if (leftBindData != null)
  7988. {
  7989. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7990. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7991. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7992. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7993. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7994. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7995. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7996. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7997. }
  7998. //SGR
  7999. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8000. if (leftBindData != null)
  8001. {
  8002. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8003. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8004. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8005. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8006. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8007. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8008. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8009. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8010. }
  8011. //JS/ES
  8012. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8013. if (leftBindData != null)
  8014. {
  8015. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8016. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8017. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8018. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8019. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8020. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8021. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8022. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8023. }
  8024. //SUITE
  8025. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8026. if (leftBindData != null)
  8027. {
  8028. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8029. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8030. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8031. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8032. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8033. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8034. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8035. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8036. }
  8037. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8038. if (leftBindData != null)
  8039. {
  8040. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8041. designer.SetDataSource("BDJRS", leftBindData.rs);
  8042. designer.SetDataSource("BDJXS", leftBindData.xs);
  8043. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8044. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8045. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8046. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8047. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8048. }
  8049. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8050. if (leftBindData != null)
  8051. {
  8052. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8053. designer.SetDataSource("BGWRS", leftBindData.rs);
  8054. designer.SetDataSource("BGWXS", leftBindData.xs);
  8055. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8056. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8057. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8058. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8059. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8060. }
  8061. #region 优化方案
  8062. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8063. //excelBind.Add("零用金", new {
  8064. //cb="",
  8065. //rs="",
  8066. //xs ="",
  8067. //zcb = "",
  8068. //});
  8069. #endregion
  8070. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8071. if (leftBindData != null)
  8072. {
  8073. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8074. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8075. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8076. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8077. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8078. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8079. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8080. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8081. }
  8082. #endregion
  8083. #region B段Right信息
  8084. right = dto.rightInfo.Find(x => x.Type == "B");
  8085. if (right == null)
  8086. {
  8087. return Ok(jw);
  8088. }
  8089. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8090. if (rightBindData != null)
  8091. {
  8092. //经济舱 + 双人间 TBR
  8093. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8094. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8095. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8096. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8097. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8098. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8099. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8100. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8101. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8102. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8103. }
  8104. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8105. if (rightBindData != null)
  8106. {
  8107. //经济舱 + 单人间 SGR
  8108. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8109. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8110. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8111. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8112. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8113. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8114. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8115. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8116. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8117. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8118. }
  8119. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8120. if (rightBindData != null)
  8121. {
  8122. //公务舱 + 单人间 SGR
  8123. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8124. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8125. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8126. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8127. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8128. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8129. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8130. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8131. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8132. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8133. }
  8134. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8135. if (rightBindData != null)
  8136. {
  8137. //公务舱 + 小套房 JSES
  8138. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8139. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8140. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8141. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8142. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8143. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8144. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8145. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8146. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8147. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8148. }
  8149. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8150. if (rightBindData != null)
  8151. {
  8152. //公务舱 + 小套房 JSES
  8153. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8154. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8155. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8156. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8157. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8158. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8159. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8160. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8161. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8162. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8163. }
  8164. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8165. if (rightBindData != null)
  8166. {
  8167. //经济舱 + 大套房
  8168. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8169. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8170. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8171. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8172. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8173. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8174. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8175. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8176. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8177. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8178. }
  8179. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8180. if (rightBindData != null)
  8181. {
  8182. //头等舱 + 小套房 JSES
  8183. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8184. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8185. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8186. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8187. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8188. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8189. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8190. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8191. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8192. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8193. }
  8194. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8195. if (rightBindData != null)
  8196. {
  8197. //头等舱 + 大套房
  8198. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8199. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8200. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8201. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8202. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8203. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8204. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8205. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8206. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8207. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8208. }
  8209. #endregion
  8210. #region 标题
  8211. designer.SetDataSource("CostBDRCB", "单人成本");
  8212. designer.SetDataSource("CostBRS", "人数");
  8213. designer.SetDataSource("CostBXS", "系数");
  8214. designer.SetDataSource("CostBZCB", "总成本");
  8215. designer.SetDataSource("CostBDRBJ", "单人报价");
  8216. designer.SetDataSource("CostBZBJ", "总报价");
  8217. designer.SetDataSource("CostBDRLR", "单人利润");
  8218. designer.SetDataSource("CostBZLR", "总利润");
  8219. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8220. designer.SetDataSource("CostBRSOM", "人数");
  8221. designer.SetDataSource("CostBZCBOM", "总成本");
  8222. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8223. designer.SetDataSource("CostBZBJOM", "总报价");
  8224. designer.SetDataSource("CostBDRLROM", "单人利润");
  8225. designer.SetDataSource("CostBZLROM", "总利润");
  8226. #endregion
  8227. }
  8228. #endregion
  8229. designer.SetDataSource("TzZCB2", TzZCB2);
  8230. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8231. designer.SetDataSource("TzZLR2", TzZLR2);
  8232. string[] dataSourceKeys = new string[]
  8233. {
  8234. "VF",
  8235. "TGS",
  8236. "TGOF",
  8237. "TGM",
  8238. "TGA",
  8239. "TGTF",
  8240. "TGEF",
  8241. "CFM",
  8242. "CFOF",
  8243. "B",
  8244. "L",
  8245. "D",
  8246. "TBR",
  8247. "SGR",
  8248. "JSES",
  8249. "Suite",
  8250. "TV",
  8251. "1L",
  8252. "IF",
  8253. "EF",
  8254. "BRF",
  8255. "TE",
  8256. "TGT",
  8257. "DRVT",
  8258. "PC",
  8259. "TLF",
  8260. "ECT"
  8261. };
  8262. foreach (var item in dataSourceKeys)
  8263. {
  8264. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8265. if (find != null)
  8266. {
  8267. designer.SetDataSource(item, find.text);
  8268. }
  8269. else
  8270. {
  8271. designer.SetDataSource(item, 0);
  8272. }
  8273. }
  8274. designer.SetDataSource(dt);
  8275. //根据数据源处理生成报表内容
  8276. designer.Process();
  8277. designer.Workbook.Worksheets[0].Name = "清单";
  8278. Worksheet sheet = designer.Workbook.Worksheets[0];
  8279. foreach (var Rowindex in hideRowsList)
  8280. {
  8281. ws.Cells.HideRows(Rowindex, 2);
  8282. }
  8283. byte[] bytes = null;
  8284. string strFileName = di.TeamName + "-团组-成本.xls";
  8285. using (MemoryStream stream = new MemoryStream())
  8286. {
  8287. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8288. bytes = stream.ToArray();
  8289. }
  8290. return Ok(JsonView(true, "", new
  8291. {
  8292. Data = bytes,
  8293. strFileName,
  8294. }));
  8295. }
  8296. /// <summary>
  8297. /// 导出客户报表
  8298. /// </summary>
  8299. /// <returns></returns>
  8300. [HttpPost]
  8301. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8302. {
  8303. var jw = JsonView(false);
  8304. if (dto.Diid == 0)
  8305. {
  8306. return Ok(JsonView(false, "请传递团组id"));
  8307. }
  8308. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8309. if (deleInfo.Code != 0)
  8310. {
  8311. return Ok(JsonView(false, "团组信息查询失败!"));
  8312. }
  8313. var di = deleInfo.Data as DelegationInfoWebView;
  8314. if (di == null)
  8315. {
  8316. return Ok(JsonView(false, "团组信息查询失败!"));
  8317. }
  8318. //文件名
  8319. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8320. //获取模板
  8321. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8322. //载入模板
  8323. Document doc = new Document(tmppath);
  8324. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8325. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8326. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8327. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8328. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8329. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8330. if (AParameter == null)
  8331. {
  8332. return Ok(JsonView(false, "系数不存在!"));
  8333. }
  8334. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8335. , TzAirDesc, TzZCost;
  8336. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8337. = TzAirDesc = TzZCost = string.Empty;
  8338. TzNumber = AParameter.CostTypenumber.ToString();
  8339. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8340. CarGuides1 = dto.CarGuides1;
  8341. Meal = dto.Meal;
  8342. SubsidizedMeals = dto.SubsidizedMeals;
  8343. NightRepair = dto.NightRepair;
  8344. AttractionsTickets = dto.AttractionsTickets;
  8345. MiscellaneousFees = dto.MiscellaneousFees;
  8346. ATip = dto.ATip;
  8347. TzHotelDesc = "";
  8348. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8349. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8350. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8351. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8352. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8353. TzAirDesc = "";
  8354. TzZCost = dto.TzZCost;
  8355. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8356. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8357. var index = 1;
  8358. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8359. foreach (var item in TzHotelDescArr)
  8360. {
  8361. if (AinfoArr != null)
  8362. {
  8363. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8364. if (Ainfo != null)
  8365. {
  8366. if (int.Parse(Ainfo.rs) <= 0)
  8367. {
  8368. continue;
  8369. }
  8370. var hotelText = string.Empty;
  8371. switch (item)
  8372. {
  8373. case "SGR":
  8374. hotelText = "单人间";
  8375. break;
  8376. case "JSES":
  8377. hotelText = "小套房";
  8378. break;
  8379. case "SUITE":
  8380. hotelText = "套房";
  8381. break;
  8382. case "TBR":
  8383. hotelText = "双人间";
  8384. break;
  8385. }
  8386. if (item != "TBR")
  8387. {
  8388. 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";
  8389. }
  8390. else
  8391. {
  8392. 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";
  8393. }
  8394. index++;
  8395. }
  8396. }
  8397. }
  8398. index = 1;
  8399. foreach (var item in TzAirDescArr)
  8400. {
  8401. if (AinfoArr != null)
  8402. {
  8403. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8404. if (Ainfo != null)
  8405. {
  8406. if (int.Parse(Ainfo.rs) <= 0)
  8407. {
  8408. continue;
  8409. }
  8410. 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";
  8411. index++;
  8412. }
  8413. }
  8414. }
  8415. if (dto.costType == "B")
  8416. {
  8417. if (BParameter == null)
  8418. {
  8419. return Ok(JsonView(false, "B段系数不存在!"));
  8420. }
  8421. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8422. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8423. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8424. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8425. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8426. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8427. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8428. foreach (var item in TzHotelDescArr)
  8429. {
  8430. if (AinfoArr != null)
  8431. {
  8432. TzHotelDesc += "B段信息 \r\n";
  8433. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8434. if (Ainfo != null)
  8435. {
  8436. if (int.Parse(Ainfo.rs) <= 0)
  8437. {
  8438. continue;
  8439. }
  8440. var hotelText = string.Empty;
  8441. switch (item)
  8442. {
  8443. case "SGR":
  8444. hotelText = "单人间";
  8445. break;
  8446. case "JSES":
  8447. hotelText = "小套房";
  8448. break;
  8449. case "SUITE":
  8450. hotelText = "套房";
  8451. break;
  8452. case "TBR":
  8453. hotelText = "双人间";
  8454. break;
  8455. }
  8456. if (item != "TBR")
  8457. {
  8458. 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";
  8459. }
  8460. else
  8461. {
  8462. 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";
  8463. }
  8464. index++;
  8465. }
  8466. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8467. }
  8468. }
  8469. index = 1;
  8470. foreach (var item in TzAirDescArr)
  8471. {
  8472. if (AinfoArr != null)
  8473. {
  8474. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8475. if (Ainfo != null)
  8476. {
  8477. if (int.Parse(Ainfo.rs) <= 0)
  8478. {
  8479. continue;
  8480. }
  8481. 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";
  8482. index++;
  8483. }
  8484. }
  8485. }
  8486. }
  8487. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8488. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8489. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8490. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8491. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8492. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8493. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8494. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8495. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8496. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8497. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8498. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8499. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8500. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8501. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8502. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8503. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8504. DickeyValue.Add("TzZCost", TzZCost);
  8505. foreach (var key in DickeyValue.Keys)
  8506. {
  8507. if (doc.Range.Bookmarks[key] != null)
  8508. {
  8509. Bookmark mark = doc.Range.Bookmarks[key];
  8510. mark.Text = DickeyValue[key];
  8511. }
  8512. }
  8513. byte[] bytes = null;
  8514. string strFileName = di.TeamName + "-客户报价.doc";
  8515. using (MemoryStream stream = new MemoryStream())
  8516. {
  8517. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8518. bytes = stream.ToArray();
  8519. }
  8520. return Ok(JsonView(true, "", new
  8521. {
  8522. Data = bytes,
  8523. strFileName,
  8524. }));
  8525. }
  8526. /// <summary>
  8527. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8528. /// </summary>
  8529. /// <param name="dto"></param>
  8530. /// <returns></returns>
  8531. [HttpPost]
  8532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8533. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8534. {
  8535. try
  8536. {
  8537. #region 参数验证
  8538. if (dto.DiId < 0)
  8539. {
  8540. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8541. }
  8542. List<int> cTableIds = new List<int>() {
  8543. 76 ,//酒店预订
  8544. 77 ,//行程
  8545. 79 ,//车/导游地接
  8546. 80 ,//签证
  8547. 81 ,//邀请/公务活
  8548. 82 ,//团组客户保险
  8549. 85 ,//机票预订
  8550. 98 ,//其他款项
  8551. 285 ,//收款退还
  8552. 751 ,//酒店早餐
  8553. 1015 // 超支费用
  8554. };
  8555. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8556. {
  8557. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8558. }
  8559. #endregion
  8560. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8561. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8562. if (_GroupCostParameters.Count <= 0)
  8563. {
  8564. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8565. }
  8566. if (_GroupCostParameters[0].IsShare == 0)
  8567. {
  8568. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8569. }
  8570. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8571. //处理date为空问题
  8572. if (_GroupCosts.Count > 0)
  8573. {
  8574. for (int i = 0; i < _GroupCosts.Count; i++)
  8575. {
  8576. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8577. {
  8578. if (i > 0)
  8579. {
  8580. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8581. }
  8582. }
  8583. }
  8584. }
  8585. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8586. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8587. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8588. string currCode = "";
  8589. #region currCode 验证
  8590. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8591. if (isInt)
  8592. {
  8593. var currData = currDatas.Find(it => it.Id == intCurrency);
  8594. if (currData != null)
  8595. {
  8596. currCode = currData.Name;
  8597. }
  8598. }
  8599. else
  8600. {
  8601. currCode = _GroupCostParameters[0].Currency.Trim();
  8602. }
  8603. #endregion
  8604. //op,酒店单段模式存储
  8605. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8606. {
  8607. CurrencyCode = currCode,
  8608. Rate = _GroupCostParameters[0].Rate,
  8609. CostType = _GroupCostParameters[0].CostType,
  8610. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8611. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8612. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8613. };
  8614. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8615. if (_GroupCostParameters.Count == 2)
  8616. {
  8617. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8618. }
  8619. foreach (var item in _GroupCostParameters)
  8620. {
  8621. decimal _rate = 1;
  8622. decimal _rate1 = item.Rate;
  8623. decimal _scale = 1;
  8624. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8625. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8626. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8627. //if (userInfo != null)
  8628. //{
  8629. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8630. // {
  8631. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8632. // {
  8633. // _scale = 1.00M;
  8634. // }
  8635. // }
  8636. //}
  8637. #endregion
  8638. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8639. {
  8640. CurrencyCode = currCode,
  8641. Rate = _rate1,
  8642. CostType = item.CostType,
  8643. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8644. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8645. CostTypeNumber = item.CostTypenumber
  8646. };
  8647. if (_GroupCostParameters.Count > 1)
  8648. {
  8649. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8650. }
  8651. else
  8652. {
  8653. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8654. }
  8655. if (dto.CTable == 79)//
  8656. {
  8657. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8658. modulePromptInfo.TotalCost = item.DJCB;
  8659. }
  8660. List<string> costTypes = new List<string>() { "A", "B" };
  8661. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8662. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8663. if (_GroupCostsDuplicates.Count() == 1)
  8664. {
  8665. _GroupCostsTypeData = _GroupCosts;
  8666. }
  8667. else
  8668. {
  8669. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8670. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8671. }
  8672. /*
  8673. * 76 酒店预订
  8674. * 77 行程
  8675. * 79 车/导游地接
  8676. * 80 签证
  8677. * 81 邀请/公务活动
  8678. * 82 团组客户保险
  8679. * 85 机票预订
  8680. * 98 其他款项
  8681. * 285 收款退还
  8682. * 751 酒店早餐
  8683. * 1015 超支费用
  8684. */
  8685. switch (dto.CTable)
  8686. {
  8687. case 76: // 酒店预订
  8688. _ModuleSubPromptInfo.AddRange(
  8689. _GroupCostsTypeData.Select(it => new
  8690. {
  8691. it.DAY,
  8692. it.Date,
  8693. it.ACCON,
  8694. it.ITIN,
  8695. it.SGR,
  8696. it.TBR,
  8697. it.JS_ES,
  8698. it.Suite
  8699. })
  8700. );
  8701. break;
  8702. case 79: // 车/导游地接
  8703. _ModuleSubPromptInfo.AddRange(
  8704. _GroupCostsTypeData.Select(it => new
  8705. {
  8706. Date = it.Date, //日期
  8707. CarFee = it.CarCost * _rate * _scale, //车费用
  8708. CarType = it.CarType, //车型
  8709. DriverFee = it.CFS * _rate * _scale, //司机工资
  8710. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8711. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8712. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8713. GuideFee = it.TGS * _rate * _scale, //导游费用
  8714. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8715. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8716. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8717. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8718. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8719. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8720. Breakfast = it.B * _rate * _scale, //早餐费
  8721. Lunch = it.L * _rate * _scale, //午餐费
  8722. Dinner = it.D * _rate * _scale, //晚餐费
  8723. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8724. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8725. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8726. TicketFee = it.EF * _rate * _scale, //门票费
  8727. TicketRemark = it.EFR, //门票费描述
  8728. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8729. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8730. SpentCash = it.PC * _rate * _scale, //零用金
  8731. LeadersFee = it.TLF * _rate * _scale, //领队费
  8732. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8733. })
  8734. );
  8735. break;
  8736. case 85: // 机票
  8737. List<dynamic> datas = new List<dynamic>();
  8738. datas.Add(
  8739. new
  8740. {
  8741. AirType = "经济舱",
  8742. AirNum = item.JJCRS,
  8743. AirDRCB = item.JJCCB,
  8744. AirZCB = (item.JJCRS * item.JJCCB)
  8745. }
  8746. );
  8747. datas.Add(
  8748. new
  8749. {
  8750. AirType = "公务舱",
  8751. AirNum = item.GWCRS,
  8752. AirDRCB = item.GWCCB,
  8753. AirZCB = (item.GWCRS * item.GWCCB)
  8754. }
  8755. );
  8756. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8757. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8758. modulePromptInfo.Data = new
  8759. {
  8760. airFeeData = datas,
  8761. airInitData = initDatas
  8762. };
  8763. _ModulePromptInfos.Add(modulePromptInfo);
  8764. break;
  8765. default:
  8766. break;
  8767. }
  8768. }
  8769. if (dto.CTable != 85)
  8770. {
  8771. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8772. _ModulePromptInfos.Add(_ModulePromptInfo);
  8773. }
  8774. _view.ModulePromptInfos = _ModulePromptInfos;
  8775. return Ok(JsonView(true, "操作成功!", _view));
  8776. }
  8777. catch (Exception ex)
  8778. {
  8779. return Ok(JsonView(false, ex.Message));
  8780. }
  8781. }
  8782. /// <summary>
  8783. /// 根据黑屏代码重新生成行程
  8784. /// </summary>
  8785. /// <param name="dto"></param>
  8786. /// <returns></returns>
  8787. [HttpPost]
  8788. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8789. {
  8790. var jw = JsonView(false);
  8791. var Create = _GroupCostRepository.
  8792. CreateGroupCostByBlackCode(dto.Diid);
  8793. jw.Msg = Create.Msg;
  8794. if (Create.Code == 0)
  8795. {
  8796. jw.Code = 200;
  8797. jw.Data = new
  8798. {
  8799. groupCost = Create.Data,
  8800. blackCodeIsTrue = true
  8801. };
  8802. }
  8803. else
  8804. {
  8805. jw.Code = 400;
  8806. jw.Data = new
  8807. {
  8808. groupCost = Create.Data,
  8809. blackCodeIsTrue = false,
  8810. };
  8811. }
  8812. return Ok(jw);
  8813. }
  8814. /// <summary>
  8815. /// 成本获取OP历史车费用
  8816. /// </summary>
  8817. /// <param name="dto"></param>
  8818. /// <returns></returns>
  8819. [HttpPost]
  8820. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8821. {
  8822. var jw = JsonView(false);
  8823. try
  8824. {
  8825. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8826. //获取现有所有车的数据
  8827. if (!dto.Param.IsNullOrWhiteSpace())
  8828. {
  8829. string sql = $@"
  8830. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8831. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8832. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8833. 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
  8834. AND gctggr.ServiceEndTime is not NULL
  8835. ORDER by gctggrc.id DESC
  8836. ";
  8837. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8838. var numeberResult = await Task.Run(() =>
  8839. {
  8840. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8841. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8842. return numberArr;
  8843. });
  8844. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8845. foreach (var item in numeberResult)
  8846. {
  8847. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8848. {
  8849. Country = "数据异常!",
  8850. City = string.Empty,
  8851. };
  8852. item.Area = find.Country + " " + find.City;
  8853. }
  8854. dbResult.AddRange(numeberResult);
  8855. if (dto.Param.Contains("、"))
  8856. {
  8857. var sp = dto.Param.Split("、");
  8858. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8859. .Where(x =>
  8860. {
  8861. return System.Array.Exists(sp, e =>
  8862. {
  8863. bool where = false;
  8864. if (x.Area != null)
  8865. {
  8866. where = x.Area.Contains(e);
  8867. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8868. {
  8869. return false;
  8870. }
  8871. }
  8872. if (x.PriceName != null && !where)
  8873. {
  8874. where = x.PriceName.Contains(e);
  8875. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8876. {
  8877. return false;
  8878. }
  8879. }
  8880. return where;
  8881. });
  8882. }).ToList();
  8883. }
  8884. else
  8885. {
  8886. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8887. .Where(x =>
  8888. {
  8889. bool where = false;
  8890. if (x.Area != null)
  8891. {
  8892. where = x.Area.Contains(dto.Param);
  8893. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8894. {
  8895. return false;
  8896. }
  8897. }
  8898. if (x.PriceName != null && !where)
  8899. {
  8900. where = x.PriceName.Contains(dto.Param);
  8901. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8902. {
  8903. return false;
  8904. }
  8905. }
  8906. return where;
  8907. }
  8908. )
  8909. .ToList();
  8910. }
  8911. }
  8912. var view = dbResult.Select(x =>
  8913. {
  8914. decimal dp = 0.00M;
  8915. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8916. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8917. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8918. {
  8919. if (startB && endB)
  8920. {
  8921. var timesp = endD.Subtract(startD);
  8922. if ((timesp.Days + 1) != 0)
  8923. {
  8924. dp = x.Price / (timesp.Days + 1);
  8925. }
  8926. }
  8927. }
  8928. else
  8929. {
  8930. dp = x.Price;
  8931. }
  8932. return new
  8933. {
  8934. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8935. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8936. x.Area,
  8937. x.id,
  8938. price = x.Price.ToString("F2"),
  8939. x.PriceName,
  8940. x.PriceContent,
  8941. x.TeamName,
  8942. x.DatePrice,
  8943. dayPrice = dp.ToString("F2"),
  8944. };
  8945. }).OrderByDescending(x => x.id).ToList();
  8946. jw = JsonView(true, "获取成功!", view);
  8947. }
  8948. catch (Exception e)
  8949. {
  8950. jw = JsonView(false, e.Message);
  8951. }
  8952. return Ok(jw);
  8953. }
  8954. #endregion
  8955. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8956. /// <summary>
  8957. /// 酒店预订
  8958. /// 酒店费用列表 根据团组Id查询
  8959. /// </summary>
  8960. /// <param name="_dto"></param>
  8961. /// <returns></returns>
  8962. [HttpPost]
  8963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8964. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8965. {
  8966. #region 参数验证
  8967. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8968. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8969. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8970. #region 团组操作权限验证 76 酒店预定模块
  8971. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8972. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8973. #endregion
  8974. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8975. #region 页面操作权限验证
  8976. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8977. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8978. #endregion
  8979. #endregion
  8980. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8981. }
  8982. /// <summary>
  8983. /// 酒店预订
  8984. /// 基础数据
  8985. /// </summary>
  8986. /// <param name="_dto"></param>
  8987. /// <returns></returns>
  8988. [HttpPost]
  8989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8990. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8991. {
  8992. #region 参数验证
  8993. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8994. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8995. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8996. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8997. #region 页面操作权限验证
  8998. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8999. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9000. #endregion
  9001. #region 团组操作权限验证 76 酒店预定模块
  9002. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9003. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9004. #endregion
  9005. #endregion
  9006. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9007. }
  9008. /// <summary>
  9009. /// 酒店预订
  9010. /// 创建 入住卷号码
  9011. /// </summary>
  9012. /// <param name="_dto"></param>
  9013. /// <returns></returns>
  9014. [HttpPost]
  9015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9016. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _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. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9023. #region 页面操作权限验证
  9024. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9025. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9026. #endregion
  9027. #region 团组操作权限验证 76 酒店预定模块
  9028. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9029. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9030. #endregion
  9031. #endregion
  9032. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9033. if (data.Code != 0)
  9034. {
  9035. return Ok(JsonView(false, data.Msg));
  9036. }
  9037. return Ok(JsonView(true, data.Msg, data.Data));
  9038. }
  9039. /// <summary>
  9040. /// 酒店预订
  9041. /// 详情
  9042. /// </summary>
  9043. /// <param name="_dto"></param>
  9044. /// <returns></returns>
  9045. [HttpPost]
  9046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9047. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9048. {
  9049. #region 参数验证
  9050. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9051. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9052. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  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. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9058. #region 页面操作权限验证
  9059. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9060. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9061. #endregion
  9062. #endregion
  9063. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9064. }
  9065. /// <summary>
  9066. /// 酒店预订
  9067. /// Add Or Edit
  9068. /// </summary>
  9069. /// <param name="_dto"></param>
  9070. /// <returns></returns>
  9071. [HttpPost]
  9072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9073. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9074. {
  9075. #region 参数验证
  9076. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9077. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9078. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9079. #region 团组操作权限验证 76 酒店预定模块
  9080. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9081. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9082. #endregion
  9083. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9084. #region 页面操作权限验证
  9085. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9086. if (_dto.Id == 0) // Add
  9087. {
  9088. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9089. }
  9090. else if (_dto.Id > 1) // Edit
  9091. {
  9092. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9093. }
  9094. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9095. #endregion
  9096. #endregion
  9097. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9098. if (_view.Code != 200)
  9099. {
  9100. return Ok(_view);
  9101. }
  9102. #region 应用推送
  9103. try
  9104. {
  9105. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9106. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9107. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9108. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9109. //自动审核
  9110. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9111. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9112. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9113. }
  9114. catch (Exception ex)
  9115. {
  9116. }
  9117. #endregion
  9118. return Ok(_view);
  9119. }
  9120. /// <summary>
  9121. /// 酒店自动审核测试
  9122. /// Add Or Edit
  9123. /// </summary>
  9124. /// <param name="_dto"></param>
  9125. /// <returns></returns>
  9126. [HttpPost]
  9127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9128. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  9129. {
  9130. #region 应用推送
  9131. try
  9132. {
  9133. //自动审核
  9134. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9135. }
  9136. catch (Exception ex)
  9137. {
  9138. return Ok(JsonView(false, "操作失败"));
  9139. }
  9140. #endregion
  9141. return Ok(JsonView(false,"操作成功"));
  9142. }
  9143. /// <summary>
  9144. /// 酒店预订
  9145. /// Del
  9146. /// </summary>
  9147. /// <param name="_dto"></param>
  9148. /// <returns></returns>
  9149. [HttpPost]
  9150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9151. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9152. {
  9153. #region 参数验证
  9154. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9155. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9156. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9157. #region 团组操作权限验证 76 酒店预定模块
  9158. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9159. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9160. #endregion
  9161. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9162. #region 页面操作权限验证
  9163. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9164. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9165. #endregion
  9166. #endregion
  9167. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9168. }
  9169. /// <summary>
  9170. /// 酒店预订
  9171. /// 生成VOUCHER
  9172. /// 2024.05.06 之前版本
  9173. /// </summary>
  9174. /// <param name="_dto"></param>
  9175. /// <returns></returns>
  9176. [HttpPost]
  9177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9178. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9179. {
  9180. try
  9181. {
  9182. #region 参数验证
  9183. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9184. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9185. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9186. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9187. #region 团组操作权限验证 76 酒店预定模块
  9188. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9189. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9190. #endregion
  9191. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9192. #region 页面操作权限验证
  9193. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9194. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9195. #endregion
  9196. #endregion
  9197. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9198. //判断数据是否完整
  9199. if (hr != null)
  9200. {
  9201. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9202. {
  9203. string strFileName = "HotelStatement/";
  9204. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9205. if (dele != null)
  9206. strFileName += dele.TourCode;
  9207. //载入模板
  9208. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9209. Document doc = new Document(sss);
  9210. DocumentBuilder builder = new DocumentBuilder(doc);
  9211. #region 替换Word模板书签内容
  9212. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9213. //入住卷预定号码
  9214. if (doc.Range.Bookmarks["VNO"] != null)
  9215. {
  9216. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9217. mark.Text = hr.CheckNumber;
  9218. }
  9219. //酒店时间
  9220. if (doc.Range.Bookmarks["Date"] != null)
  9221. {
  9222. Bookmark mark = doc.Range.Bookmarks["Date"];
  9223. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9224. }
  9225. //团号
  9226. if (doc.Range.Bookmarks["TNo"] != null)
  9227. {
  9228. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9229. mark.Text = dele.TourCode;
  9230. }
  9231. //预定号码
  9232. if (doc.Range.Bookmarks["BookingId"] != null)
  9233. {
  9234. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9235. mark.Text = hr.ReservationsNo;
  9236. }
  9237. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9238. {
  9239. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9240. mark.Text = hr.DetermineNo;
  9241. }
  9242. //酒店城市
  9243. if (doc.Range.Bookmarks["City"] != null)
  9244. {
  9245. Bookmark mark = doc.Range.Bookmarks["City"];
  9246. mark.Text = hr.City;
  9247. }
  9248. //酒店名称
  9249. if (doc.Range.Bookmarks["HName"] != null)
  9250. {
  9251. Bookmark mark = doc.Range.Bookmarks["HName"];
  9252. mark.Text = hr.HotelName;
  9253. }
  9254. //酒店地址
  9255. if (doc.Range.Bookmarks["Address"] != null)
  9256. {
  9257. Bookmark mark = doc.Range.Bookmarks["Address"];
  9258. mark.Text = hr.HotelAddress;
  9259. }
  9260. //酒店电话
  9261. if (doc.Range.Bookmarks["Tel"] != null)
  9262. {
  9263. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9264. mark.Text = hr.HotelTel;
  9265. }
  9266. //酒店传真
  9267. if (doc.Range.Bookmarks["Fax"] != null)
  9268. {
  9269. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9270. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9271. {
  9272. mark.Text = hr.HotelFax;
  9273. }
  9274. }
  9275. //入住时间
  9276. if (doc.Range.Bookmarks["CIn"] != null)
  9277. {
  9278. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9279. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9280. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9281. }
  9282. //退房时间
  9283. if (doc.Range.Bookmarks["COut"] != null)
  9284. {
  9285. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9286. Bookmark mark = doc.Range.Bookmarks["COut"];
  9287. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9288. }
  9289. //客户名称
  9290. if (doc.Range.Bookmarks["GName"] != null)
  9291. {
  9292. string guestName = "";
  9293. string[] clients = new string[] { };
  9294. if (hr.GuestName.Contains(","))
  9295. {
  9296. clients = hr.GuestName.Split(",");
  9297. }
  9298. else
  9299. {
  9300. clients = new string[] { hr.GuestName };
  9301. }
  9302. List<int> clientIds_int = new List<int>();
  9303. if (clients.Length > 0)
  9304. {
  9305. foreach (var item in clients)
  9306. {
  9307. if (item.IsNumeric())
  9308. {
  9309. clientIds_int.Add(int.Parse(item));
  9310. }
  9311. }
  9312. }
  9313. if (clientIds_int.Count > 0)
  9314. {
  9315. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9316. foreach (var client in _clientDatas)
  9317. {
  9318. //男
  9319. if (client.Sex == 0) guestName += $"Mr.";
  9320. //女
  9321. else if (client.Sex == 1) guestName += $"Ms.";
  9322. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9323. {
  9324. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9325. }
  9326. //guestName += $"{client.Pinyin},";
  9327. }
  9328. if (guestName.Length > 0)
  9329. {
  9330. guestName = guestName.Substring(0, guestName.Length - 1);
  9331. }
  9332. }
  9333. else
  9334. {
  9335. guestName = hr.GuestName;
  9336. }
  9337. Bookmark mark = doc.Range.Bookmarks["GName"];
  9338. mark.Text = guestName;
  9339. }
  9340. //房间介绍
  9341. if (doc.Range.Bookmarks["ROOM"] != null)
  9342. {
  9343. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9344. mark.Text = hr.RoomExplanation;
  9345. }
  9346. //报价描述
  9347. if (doc.Range.Bookmarks["NOTE"] != null)
  9348. {
  9349. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9350. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9351. if (ss != null)
  9352. mark.Text = ss.Name;
  9353. }
  9354. //入住时间
  9355. if (doc.Range.Bookmarks["CheckIn"] != null)
  9356. {
  9357. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9358. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9359. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9360. }
  9361. //退房时间
  9362. if (doc.Range.Bookmarks["CheckOut"] != null)
  9363. {
  9364. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9365. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9366. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9367. }
  9368. //日期
  9369. if (doc.Range.Bookmarks["DT"] != null)
  9370. {
  9371. Bookmark mark = doc.Range.Bookmarks["DT"];
  9372. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9373. }
  9374. //名称
  9375. if (doc.Range.Bookmarks["VName"] != null)
  9376. {
  9377. Bookmark mark = doc.Range.Bookmarks["VName"];
  9378. mark.Text = hr.HotelName;
  9379. }
  9380. //号码
  9381. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9382. {
  9383. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9384. mark.Text = hr.CheckNumber;
  9385. }
  9386. #endregion
  9387. strFileName += "VOUCHER.doc";
  9388. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9389. doc.Save(fileDir);
  9390. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9391. return Ok(JsonView(true, "操作成功!", Url));
  9392. }
  9393. else
  9394. {
  9395. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9396. }
  9397. }
  9398. else
  9399. {
  9400. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9401. }
  9402. }
  9403. catch (Exception ex)
  9404. {
  9405. return Ok(JsonView(false, ex.Message));
  9406. }
  9407. }
  9408. /// <summary>
  9409. /// 酒店预订
  9410. /// 生成VOUCHER
  9411. /// 2024.05.06 之后版本
  9412. /// </summary>
  9413. /// <param name="_dto"></param>
  9414. /// <returns></returns>
  9415. [HttpPost]
  9416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9417. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9418. {
  9419. #region 参数验证
  9420. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9421. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9422. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9423. #region 团组操作权限验证 76 酒店预定模块
  9424. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9425. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9426. #endregion
  9427. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9428. #region 页面操作权限验证
  9429. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9430. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9431. #endregion
  9432. #endregion
  9433. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9434. //判断数据是否完整
  9435. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9436. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9437. string strFileName = "HotelStatement/";
  9438. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9439. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9440. #region 数据处理
  9441. List<int> guestIds = new List<int>();
  9442. int index = 0;
  9443. foreach (var item in hrDtas)
  9444. {
  9445. if (item.GuestName.Contains(","))
  9446. {
  9447. string[] guestIdArr = item.GuestName.Split(',');
  9448. foreach (var guestIdStr in guestIdArr)
  9449. {
  9450. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9451. if (guestBool)
  9452. {
  9453. guestIds.Add(guestId);
  9454. }
  9455. }
  9456. }
  9457. else guestNames += item.GuestName;
  9458. var voucherInfo = new HotelVoucherInfoView()
  9459. {
  9460. HotelName = item.HotelName,
  9461. CheckInDate = item.CheckInDate,
  9462. CheckOutDate = item.CheckOutDate,
  9463. ConfirmationNumber = item.DetermineNo.Trim(),
  9464. RoomType = item.RoomExplanation
  9465. };
  9466. vouchers.Add(voucherInfo);
  9467. }
  9468. if (guestIds.Count > 0)
  9469. {
  9470. guestIds = guestIds.Distinct().ToList();
  9471. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9472. if (guestDatas.Count > 0)
  9473. {
  9474. guestNames = "";
  9475. foreach (var guest in guestDatas)
  9476. {
  9477. string guestName = "";
  9478. if (guest.Sex == 0) guestName += @"MR.";
  9479. else if (guest.Sex == 1) guestName += @"MS.";
  9480. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9481. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9482. guestNames += @$"{guestName.Trim()}、";
  9483. }
  9484. if (guestNames.Length > 0)
  9485. {
  9486. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9487. }
  9488. }
  9489. }
  9490. #endregion
  9491. //载入模板
  9492. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9493. Document doc = new Document(sss);
  9494. DocumentBuilder builder = new DocumentBuilder(doc);
  9495. if (doc.Range.Bookmarks["GuestName"] != null)
  9496. {
  9497. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9498. mark.Text = guestNames;
  9499. }
  9500. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9501. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9502. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9503. for (int i = 1; i <= vouchers.Count; i++)
  9504. {
  9505. HotelVoucherInfoView hviv = vouchers[i - 1];
  9506. builder.MoveToCell(0, i, 0, 0);
  9507. builder.Write(hviv.HotelName);
  9508. builder.MoveToCell(0, i, 1, 0);
  9509. builder.Write(hviv.CheckInDate);
  9510. builder.MoveToCell(0, i, 2, 0);
  9511. builder.Write(hviv.CheckOutDate);
  9512. builder.MoveToCell(0, i, 3, 0);
  9513. builder.Write(hviv.RoomType);
  9514. builder.MoveToCell(0, i, 4, 0);
  9515. builder.Write(hviv.ConfirmationNumber);
  9516. }
  9517. //删除多余行
  9518. int currRowIndex = vouchers.Count + 1;
  9519. int delRows = 21 - currRowIndex;
  9520. if (delRows > 0)
  9521. {
  9522. for (int i = 0; i < delRows; i++)
  9523. {
  9524. table.Rows.RemoveAt(currRowIndex);
  9525. //cultivateRowIndex++;
  9526. }
  9527. }
  9528. strFileName += "VOUCHER.docx";
  9529. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9530. doc.Save(fileDir);
  9531. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9532. return Ok(JsonView(true, "操作成功!", Url));
  9533. }
  9534. /// <summary>
  9535. /// 酒店预订
  9536. /// 生成VOUCHER 批量生成
  9537. /// New
  9538. /// </summary>
  9539. /// <param name="_dto"></param>
  9540. /// <returns></returns>
  9541. [HttpPost]
  9542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9543. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9544. {
  9545. #region 参数验证
  9546. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9547. if (_dto.PageId < 1) _dto.PageId = 28;
  9548. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9549. #region 团组操作权限验证 76 酒店预定模块
  9550. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9551. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9552. #endregion
  9553. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9554. #region 页面操作权限验证
  9555. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9556. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9557. #endregion
  9558. #endregion
  9559. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9560. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9561. .OrderBy(x => x.CreateTime)
  9562. .ToListAsync();
  9563. //判断数据是否完整
  9564. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9565. string strFileName = "HotelStatement/";
  9566. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9567. if (dele != null)
  9568. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9569. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9570. for (int i = 0; i < hrDtas.Count; i++)
  9571. {
  9572. string guestNames = string.Empty;
  9573. List<int> guestIds = new List<int>();
  9574. var item = hrDtas[i];
  9575. //处理客户姓名
  9576. if (item.GuestName.Contains(","))
  9577. {
  9578. string[] guestIdArr = item.GuestName.Split(',');
  9579. foreach (var guestIdStr in guestIdArr)
  9580. if (int.TryParse(guestIdStr, out int guestId))
  9581. guestIds.Add(guestId);
  9582. }
  9583. else {
  9584. //NaN
  9585. if (item.GuestName.Contains("NaN"))
  9586. {
  9587. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9588. }
  9589. }
  9590. if (guestIds.Count > 0)
  9591. {
  9592. guestIds = guestIds.Distinct().ToList();
  9593. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9594. if (guestDatas1.Count > 0)
  9595. {
  9596. guestNames = "";
  9597. foreach (var guest in guestDatas1)
  9598. {
  9599. string guestName = "";
  9600. if (guest.Sex == 0) guestName += @"MR.";
  9601. else if (guest.Sex == 1) guestName += @"MS.";
  9602. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9603. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9604. guestNames += @$"{guestName.Trim()}、";
  9605. }
  9606. if (guestNames.Length > 0)
  9607. {
  9608. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9609. }
  9610. }
  9611. }
  9612. //if (!string.IsNullOrEmpty(guestNames))
  9613. //{
  9614. hrDtas[i].GuestName = guestNames;
  9615. //}
  9616. }
  9617. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9618. Document doc = new Document();
  9619. DocumentBuilder builder = new DocumentBuilder(doc);
  9620. try
  9621. {
  9622. builder.MoveToDocumentStart();
  9623. foreach (var item in hrDtas)
  9624. {
  9625. //标题
  9626. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9627. builder.ParagraphFormat.LineSpacing = 1;
  9628. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9629. builder.ParagraphFormat.Style.Font.Size = 9;
  9630. builder.ParagraphFormat.Style.Font.Bold = true;
  9631. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9632. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9633. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9634. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9635. builder.ParagraphFormat.LineSpacing = 1;
  9636. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9637. builder.ParagraphFormat.Style.Font.Size = 9;
  9638. builder.ParagraphFormat.Style.Font.Bold = true;
  9639. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9640. builder.StartTable();
  9641. // 设置边框颜色
  9642. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9643. //设置边框样式
  9644. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9645. //表格
  9646. #region 第一行
  9647. builder.InsertCell();
  9648. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9649. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9650. //builder.CellFormat.AllowAutoFit = false;
  9651. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9652. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9653. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9654. builder.CellFormat.WrapText = true; //自动换行
  9655. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9656. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  9657. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9658. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9659. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9660. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9661. builder.Write("TOUR NO:");
  9662. builder.InsertCell();
  9663. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9664. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9665. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9666. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9667. builder.ParagraphFormat.Style.Font.Bold = false;
  9668. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9669. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9670. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9671. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9672. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9673. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9674. builder.Write($"{dele?.TourCode ?? "-"}");
  9675. builder.InsertCell();
  9676. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9677. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9678. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9679. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9680. builder.ParagraphFormat.Style.Font.Bold = false;
  9681. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9682. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9683. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9684. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9685. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9686. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9687. builder.Write($"CITY:");
  9688. builder.InsertCell();
  9689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9690. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9691. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9692. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9693. builder.ParagraphFormat.Style.Font.Bold = false;
  9694. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9695. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9696. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9697. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9698. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9699. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9700. builder.Write($"{item.City}");
  9701. builder.EndRow();
  9702. #endregion
  9703. #region 第二行
  9704. builder.InsertCell();
  9705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9706. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9707. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9708. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9709. builder.ParagraphFormat.Style.Font.Bold = false;
  9710. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9712. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9713. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9714. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9715. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9716. builder.Write("CONFIRMATION NO:");
  9717. builder.InsertCell();
  9718. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9719. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9720. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9721. builder.ParagraphFormat.Style.Font.Bold = false;
  9722. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9723. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9724. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9725. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9726. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9727. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9728. builder.CellFormat.VerticalMerge = CellMerge.None;
  9729. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9730. builder.Write($"{item.DetermineNo}");
  9731. builder.InsertCell();
  9732. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9733. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9734. builder.InsertCell();
  9735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9736. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9737. builder.EndRow();
  9738. #endregion
  9739. #region 第三行
  9740. builder.InsertCell();
  9741. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9742. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9743. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9744. builder.ParagraphFormat.Style.Font.Bold = false;
  9745. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9746. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9747. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9748. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9749. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9750. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9751. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9752. builder.Write($"HOTEL NAME:");
  9753. builder.InsertCell();
  9754. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9755. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9756. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9757. builder.ParagraphFormat.Style.Font.Bold = false;
  9758. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9759. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9760. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9761. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9762. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9763. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9764. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9765. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9766. builder.Write($"{item.HotelName}");
  9767. builder.InsertCell();
  9768. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9769. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9770. builder.InsertCell();
  9771. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9772. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9773. builder.EndRow();
  9774. #endregion
  9775. #region 第四行
  9776. builder.InsertCell();
  9777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9778. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9779. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9780. builder.ParagraphFormat.Style.Font.Bold = false;
  9781. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9782. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9783. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9784. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9785. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9786. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9787. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9788. builder.Write($"HOTEL ADDRESS:");
  9789. builder.InsertCell();
  9790. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9791. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9792. builder.ParagraphFormat.Style.Font.Size = 8;
  9793. builder.ParagraphFormat.Style.Font.Bold = false;
  9794. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9795. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9796. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9797. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9798. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9799. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9800. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9801. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9802. builder.Write($"{item.HotelAddress}");
  9803. builder.InsertCell();
  9804. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9805. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9806. builder.InsertCell();
  9807. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9808. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9809. builder.EndRow();
  9810. #endregion
  9811. #region 第五行
  9812. builder.InsertCell();
  9813. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  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.Right;//对齐
  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.Write("TEL:");
  9825. builder.InsertCell();
  9826. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9827. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9828. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9829. builder.ParagraphFormat.Style.Font.Bold = false;
  9830. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9831. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9832. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9833. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9834. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9835. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9836. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9837. builder.Write($"{item.HotelTel}");
  9838. builder.InsertCell();
  9839. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9840. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9841. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9842. builder.ParagraphFormat.Style.Font.Bold = false;
  9843. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9844. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9845. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9846. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9847. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9848. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9849. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9850. builder.Write($"FAX:");
  9851. builder.InsertCell();
  9852. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9853. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9854. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9855. builder.ParagraphFormat.Style.Font.Bold = false;
  9856. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9857. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9858. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9859. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9860. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9861. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9862. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9863. builder.Write($"{item.HotelFax}");
  9864. builder.EndRow();
  9865. #endregion
  9866. #region 第六行
  9867. builder.InsertCell();
  9868. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9869. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9870. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9871. builder.ParagraphFormat.Style.Font.Bold = false;
  9872. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9873. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9874. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9875. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9876. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9877. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9878. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9879. builder.Write("CHECK IN:");
  9880. builder.InsertCell();
  9881. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9882. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9883. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9884. builder.ParagraphFormat.Style.Font.Bold = false;
  9885. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9886. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9887. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9888. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9889. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9890. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9891. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9892. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  9893. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9894. builder.Write($"{checkInStr}");
  9895. builder.InsertCell();
  9896. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9897. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9898. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9899. builder.ParagraphFormat.Style.Font.Bold = false;
  9900. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9901. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9902. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9903. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9904. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9905. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9906. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9907. builder.Write($"CHECK OUT:");
  9908. builder.InsertCell();
  9909. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9910. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9911. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9912. builder.ParagraphFormat.Style.Font.Bold = false;
  9913. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9914. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9915. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9916. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9917. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9918. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9919. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9920. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  9921. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  9922. builder.Write($"{checkOutStr}");
  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($"GUEST NAME:");
  9939. builder.InsertCell();
  9940. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9941. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9942. builder.ParagraphFormat.Style.Font.Size = 8;
  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. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9952. builder.Write($"{item.GuestName}");
  9953. builder.InsertCell();
  9954. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9955. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9956. builder.InsertCell();
  9957. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9958. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9959. builder.EndRow();
  9960. #endregion
  9961. #region 第八行
  9962. builder.InsertCell();
  9963. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9964. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9965. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9966. builder.ParagraphFormat.Style.Font.Bold = false;
  9967. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9968. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9969. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9970. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9971. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9972. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9973. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9974. builder.Write($"ROOM TYPE:");
  9975. builder.InsertCell();
  9976. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9977. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9978. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9979. builder.ParagraphFormat.Style.Font.Bold = false;
  9980. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9981. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9982. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9983. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9984. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9985. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9986. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9987. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9988. builder.Write($"{item.RoomExplanation}");
  9989. builder.InsertCell();
  9990. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9991. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9992. builder.InsertCell();
  9993. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9994. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9995. builder.EndRow();
  9996. #endregion
  9997. #region 第九行
  9998. builder.InsertCell();
  9999. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10000. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10001. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10002. builder.ParagraphFormat.Style.Font.Bold = false;
  10003. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10004. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10005. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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.Write($"NOTE:");
  10011. builder.InsertCell();
  10012. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10013. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10014. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10015. builder.ParagraphFormat.Style.Font.Bold = false;
  10016. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10017. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10018. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10019. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10020. 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.");
  10021. builder.InsertCell();
  10022. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10023. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10024. builder.InsertCell();
  10025. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10026. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10027. builder.EndRow();
  10028. #endregion
  10029. builder.EndTable();
  10030. //换行
  10031. builder.Writeln("");
  10032. builder.Writeln("");
  10033. }
  10034. #region 获取文档中的所有表格 设置文字自适应
  10035. // 获取文档中的所有表格。
  10036. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10037. {
  10038. // 遍历表格中的所有行。
  10039. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10040. {
  10041. foreach (Cell cell in row.Cells)
  10042. {
  10043. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10044. cellFormat.Width = 0;
  10045. }
  10046. }
  10047. }
  10048. #endregion
  10049. #region 设置页眉
  10050. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10051. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10052. if (System.IO.File.Exists(voucherHeaderPath))
  10053. {
  10054. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10055. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10056. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10057. Shape shape = builder.InsertImage(imageBytes);
  10058. // 调整图片位置
  10059. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10060. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10061. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10062. shape.Left = 0; // 将图片距离页面左边缘的距离
  10063. shape.Width = 81; // 设置图片宽度
  10064. shape.Height = 36; // 设置图片高度
  10065. }
  10066. //靠右
  10067. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10068. //// 设置页脚上下边距
  10069. //builder.PageSetup.HeaderDistance = 42;
  10070. // 添加页眉线
  10071. Aspose.Words.Border borderHeader = null;
  10072. try
  10073. {
  10074. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10075. }
  10076. catch (Exception e)
  10077. {
  10078. // TODO Auto-generated catch block
  10079. //e.printStackTrace();
  10080. }
  10081. borderHeader.Shadow = true;
  10082. borderHeader.DistanceFromText = 2;
  10083. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10084. #endregion
  10085. }
  10086. catch (Exception ex)
  10087. {
  10088. }
  10089. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10090. doc.Save(fileDir);
  10091. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10092. return Ok(JsonView(true, "操作成功!", Url));
  10093. }
  10094. /// <summary>
  10095. /// 酒店预订
  10096. /// 生成 预定成本 Excel
  10097. /// </summary>
  10098. /// <param name="_dto"></param>
  10099. /// <returns></returns>
  10100. [HttpPost]
  10101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10102. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10103. {
  10104. #region 参数验证
  10105. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10106. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10107. if (!vadalitorRes.IsValid)
  10108. {
  10109. var errors = new StringBuilder();
  10110. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10111. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10112. }
  10113. #region 团组操作权限验证 76 酒店预定模块
  10114. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10115. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10116. #endregion
  10117. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10118. #region 页面操作权限验证
  10119. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10120. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10121. #endregion
  10122. #endregion
  10123. decimal _rate = 1.00M;
  10124. string _currency = "";
  10125. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10126. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10127. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10128. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10129. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10130. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10131. {
  10132. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10133. }
  10134. _currency = _GroupCostParameter.Currency;
  10135. bool isIntType = int.TryParse(_currency, out int currId);
  10136. if (isIntType)
  10137. {
  10138. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10139. }
  10140. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10141. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10142. if (currInfo == null)
  10143. {
  10144. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10145. }
  10146. if (!_currency.ToUpper().Equals("CNY"))
  10147. {
  10148. _rate = _GroupCostParameter.Rate;
  10149. }
  10150. _rate = currInfo.Rate;
  10151. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10152. string strFileName = "HotelStatement/";
  10153. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10154. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10155. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10156. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10157. #region 数据处理
  10158. foreach (var item in hrDtas)
  10159. {
  10160. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10161. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10162. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10163. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10164. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10165. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10166. string singleRoomFeeStr = string.Empty,
  10167. doubleRoomFeeStr = string.Empty,
  10168. suiteRoomFeeStr = string.Empty,
  10169. otherRoomFeeStr = string.Empty,
  10170. payMoneyStr = string.Empty,
  10171. cardPriceStr = string.Empty;
  10172. if (roomCurr.Equals(_currency))
  10173. {
  10174. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10175. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10176. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10177. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10178. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10179. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10180. }
  10181. else
  10182. {
  10183. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10184. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10185. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10186. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10187. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10188. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10189. }
  10190. string breakfastPriceStr = string.Empty,
  10191. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10192. governmentRentStr = string.Empty,
  10193. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10194. cityTaxStrStr = string.Empty,
  10195. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10196. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10197. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10198. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10199. int payDId = roomInfo?.PayDId ?? 0;
  10200. pcfds.Add(new HotelReservations_PCFD_View()
  10201. {
  10202. City = item.City,
  10203. HotelName = item.HotelName,
  10204. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10205. // SingleRoomCount = item.SingleRoomCount,
  10206. SingleRoomPrice = singleRoomFeeStr,
  10207. // DoubleRoomCount = item.DoubleRoomCount,
  10208. DoubleRoomPrice = doubleRoomFeeStr,
  10209. //SuiteRoomCount = item.SuiteRoomCount,
  10210. SuiteRoomPrice = suiteRoomFeeStr,
  10211. OtherRoomPrice = otherRoomFeeStr,
  10212. //OtherRoomCount = item.OtherRoomCount,
  10213. BreakfastPrice = breakfastPriceStr,
  10214. GovernmentRent = governmentRentStr,
  10215. CityTax = cityTaxStrStr,
  10216. RoomExplanation = item.RoomExplanation,
  10217. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10218. PayTime = roomInfo?.ConsumptionDate,
  10219. BankNo = roomInfo?.BankNo,
  10220. PayMoney = payMoneyStr,
  10221. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10222. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10223. CardPrice = cardPriceStr,
  10224. Remark = ccpInfo.Remark
  10225. });
  10226. }
  10227. #endregion
  10228. //载入模板
  10229. WorkbookDesigner designer = new WorkbookDesigner();
  10230. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10231. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10232. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10233. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10234. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10235. designer.SetDataSource("Opertor", userInfo.CnName);
  10236. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10237. dt.TableName = "ViewMyHotelReservations";
  10238. designer.SetDataSource(dt);
  10239. designer.Process();
  10240. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10241. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10242. designer.Workbook.Save(serverPath);
  10243. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10244. #region 删除指定行
  10245. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10246. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10247. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10248. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10249. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10250. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10251. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10252. cssIndex = dt.Columns["CityTax"].Ordinal,
  10253. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10254. remarkIndex = dt.Columns["Remark"].Ordinal;
  10255. //删除指定列
  10256. foreach (DataRow item in dt.Rows)
  10257. {
  10258. string singleStr = item["SingleRoomPrice"].ToString();
  10259. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10260. if (containsDigitButNotZero1) singleDel = false;
  10261. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10262. string doubleStr = item["DoubleRoomPrice"].ToString();
  10263. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10264. if (containsDigitButNotZero2) doubleDel = false;
  10265. string suiteStr = item["SuiteRoomPrice"].ToString();
  10266. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10267. if (containsDigitButNotZero3) suiteDel = false;
  10268. string otherStr = item["OtherRoomPrice"].ToString();
  10269. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10270. if (containsDigitButNotZero4) otherDel = false;
  10271. string zcStr = item["BreakfastPrice"].ToString();
  10272. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10273. if (containsDigitButNotZero5) zcDel = false;
  10274. string dsStr = item["GovernmentRent"].ToString();
  10275. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10276. if (containsDigitButNotZero6) dsDel = false;
  10277. string cssStr = item["CityTax"].ToString();
  10278. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10279. if (containsDigitButNotZero7) cssDel = false;
  10280. string cpStr = item["ConsumptionPatterns"].ToString();
  10281. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10282. string remarkStr = item["Remark"].ToString();
  10283. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10284. }
  10285. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10286. DeleteColumn(serverPath, cpIndex, cpDel);
  10287. DeleteColumn(serverPath, dsIndex, dsDel);
  10288. DeleteColumn(serverPath, cssIndex, cssDel);
  10289. DeleteColumn(serverPath, zcIndex, zcDel);
  10290. DeleteColumn(serverPath, otherIndex, otherDel);
  10291. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10292. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10293. DeleteColumn(serverPath, singleIndex, singleDel);
  10294. #endregion
  10295. //只保留第一个表格
  10296. DeleteSheet(serverPath);
  10297. return Ok(JsonView(true, "操作成功", url = rst));
  10298. }
  10299. /// <summary>
  10300. /// 删除指定列
  10301. /// </summary>
  10302. /// <param name="file"></param>
  10303. /// <param name="columnIndex"></param>
  10304. /// <param name="isDel"></param>
  10305. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10306. {
  10307. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10308. //wb.Save(file);
  10309. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10310. if (sheet1 != null)
  10311. {
  10312. if (isDel)
  10313. {
  10314. Cells cells = sheet1.Cells;
  10315. cells.DeleteColumn(columnIndex);
  10316. }
  10317. }
  10318. wb.Save(file);
  10319. }
  10320. /// <summary>
  10321. /// 删除sheet
  10322. /// </summary>
  10323. /// <param name="file"></param>
  10324. /// <param name="sheetName"></param>
  10325. private void DeleteSheet(string file, string sheetName = "")
  10326. {
  10327. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10328. //wb.Save(file);
  10329. List<string> sheets = new List<string>();
  10330. foreach (var item in wb.Worksheets)
  10331. {
  10332. sheets.Add(item.Name);
  10333. }
  10334. if (sheets.Count > 0)
  10335. {
  10336. sheets.RemoveAt(0);//不删除第一个sheet
  10337. foreach (var item in sheets)
  10338. {
  10339. wb.Worksheets.RemoveAt(item);
  10340. }
  10341. }
  10342. wb.Save(file);
  10343. }
  10344. /// <summary>
  10345. /// 酒店预订
  10346. /// 确认单
  10347. /// </summary>
  10348. /// <param name="_dto"></param>
  10349. /// <returns></returns>
  10350. [HttpPost]
  10351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10352. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10353. {
  10354. try
  10355. {
  10356. #region 参数验证
  10357. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10358. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10359. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10360. #region 团组操作权限验证 76 酒店预定模块
  10361. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10362. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10363. #endregion
  10364. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10365. #region 页面操作权限验证
  10366. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10367. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10368. #endregion
  10369. #endregion
  10370. //团组信息
  10371. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10372. //酒店数据
  10373. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10374. if (listhoteldata.Count < 0)
  10375. {
  10376. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10377. }
  10378. //利datatable存储
  10379. DataTable dt = new DataTable();
  10380. dt.Columns.Add("CheckInDate", typeof(string));
  10381. dt.Columns.Add("City", typeof(string));
  10382. dt.Columns.Add("Hotel", typeof(string));
  10383. dt.Columns.Add("Room", typeof(string));
  10384. for (int i = 0; i < listhoteldata.Count; i++)
  10385. {
  10386. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10387. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10388. while (dayStart < dayEnd)
  10389. {
  10390. string temp = "";
  10391. DataRow row = dt.NewRow();
  10392. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10393. row["City"] = listhoteldata[i].City;
  10394. row["Hotel"] = listhoteldata[i].HotelName;
  10395. if (listhoteldata[i].SingleRoomCount > 0)
  10396. {
  10397. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10398. }
  10399. if (listhoteldata[i].DoubleRoomCount > 0)
  10400. {
  10401. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10402. }
  10403. if (listhoteldata[i].SuiteRoomCount > 0)
  10404. {
  10405. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10406. }
  10407. if (listhoteldata[i].OtherRoomCount > 0)
  10408. {
  10409. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10410. }
  10411. row["Room"] = temp;
  10412. dt.Rows.Add(row);
  10413. dayStart = dayStart.AddDays(1);
  10414. }
  10415. }
  10416. Dictionary<string, string> dic = new Dictionary<string, string>();
  10417. dic.Add("Dele", di.TeamName);
  10418. dic.Add("City", di.VisitCountry);
  10419. //模板路径
  10420. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10421. //载入模板
  10422. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10423. DocumentBuilder builder = new DocumentBuilder(doc);
  10424. foreach (var key in dic.Keys)
  10425. {
  10426. builder.MoveToBookmark(key);
  10427. builder.Write(dic[key]);
  10428. }
  10429. //获取word里所有表格
  10430. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10431. //获取所填表格的序数
  10432. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10433. var rowStart = tableOne.Rows[0]; //获取第1行
  10434. //循环赋值
  10435. for (int i = 0; i < dt.Rows.Count; i++)
  10436. {
  10437. builder.MoveToCell(0, i + 1, 0, 0);
  10438. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10439. builder.MoveToCell(0, i + 1, 1, 0);
  10440. builder.Write(dt.Rows[i]["City"].ToString());
  10441. builder.MoveToCell(0, i + 1, 2, 0);
  10442. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10443. builder.MoveToCell(0, i + 1, 3, 0);
  10444. builder.Write(dt.Rows[i]["Room"].ToString());
  10445. }
  10446. //删除多余行
  10447. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10448. {
  10449. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10450. }
  10451. string strFileName = di.TeamName + "酒店确认单.doc";
  10452. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10453. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10454. return Ok(JsonView(true, "成功", url));
  10455. }
  10456. catch (Exception ex)
  10457. {
  10458. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10459. }
  10460. }
  10461. #endregion
  10462. #region 团组状态
  10463. /// <summary>
  10464. /// 团组状态列表 Page
  10465. /// </summary>
  10466. /// <param name="dto">团组列表请求dto</param>
  10467. /// <returns></returns>
  10468. [HttpPost]
  10469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10470. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10471. {
  10472. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10473. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10474. {
  10475. string sqlWhere = string.Empty;
  10476. if (dto.IsSure == 0) //未完成
  10477. {
  10478. sqlWhere += string.Format(@" And IsSure = 0");
  10479. }
  10480. else if (dto.IsSure == 1) //已完成
  10481. {
  10482. sqlWhere += string.Format(@" And IsSure = 1");
  10483. }
  10484. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10485. {
  10486. string tj = dto.SearchCriteria;
  10487. 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}%')",
  10488. tj, tj, tj, tj, tj);
  10489. }
  10490. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10491. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10492. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10493. From (
  10494. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10495. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10496. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10497. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10498. From Grp_DelegationInfo gdi
  10499. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10500. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10501. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10502. Where gdi.IsDel = 0 {0}
  10503. ) temp ", sqlWhere);
  10504. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10505. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10506. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10507. }
  10508. else
  10509. {
  10510. return Ok(JsonView(false, "查询失败"));
  10511. }
  10512. }
  10513. /// <summary>
  10514. /// 团组状态
  10515. /// 设置操作完成
  10516. /// </summary>
  10517. /// <param name="dto">团组列表请求dto</param>
  10518. /// <returns></returns>
  10519. [HttpPost]
  10520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10521. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10522. {
  10523. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10524. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10525. {
  10526. Id = dto.Id,
  10527. IsSure = 1
  10528. };
  10529. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10530. .UpdateColumns(it => new { it.IsSure })
  10531. .WhereColumns(it => new { it.Id })
  10532. .ExecuteCommandAsync();
  10533. if (result > 0)
  10534. {
  10535. return Ok(JsonView(true, "操作完成!"));
  10536. }
  10537. return Ok(JsonView(false, "操作失败!"));
  10538. }
  10539. #endregion
  10540. #region 保险费用录入
  10541. /// <summary>
  10542. /// 根据团组Id查询保险费用列表
  10543. /// </summary>
  10544. /// <param name="dto"></param>
  10545. /// <returns></returns>
  10546. [HttpPost]
  10547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10548. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10549. {
  10550. try
  10551. {
  10552. Result groupData = await _customersRep.CustomersByDiId(dto);
  10553. if (groupData.Code != 0)
  10554. {
  10555. return Ok(JsonView(false, groupData.Msg));
  10556. }
  10557. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10558. }
  10559. catch (Exception ex)
  10560. {
  10561. return Ok(JsonView(false, ex.Message));
  10562. }
  10563. }
  10564. /// <summary>
  10565. /// 根据保险费用Id查询保险费用详细
  10566. /// </summary>
  10567. /// <param name="dto"></param>
  10568. /// <returns></returns>
  10569. [HttpPost]
  10570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10571. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10572. {
  10573. try
  10574. {
  10575. Result groupData = await _customersRep.CustomersById(dto);
  10576. if (groupData.Code != 0)
  10577. {
  10578. return Ok(JsonView(false, groupData.Msg));
  10579. }
  10580. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10581. }
  10582. catch (Exception ex)
  10583. {
  10584. return Ok(JsonView(false, ex.Message));
  10585. }
  10586. }
  10587. /// <summary>
  10588. /// 保险费用录入页面初始化绑定
  10589. /// </summary>
  10590. /// <param name="dto"></param>
  10591. /// <returns></returns>
  10592. [HttpPost]
  10593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10594. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10595. {
  10596. try
  10597. {
  10598. Result groupData = await _customersRep.CustomersInitialize(dto);
  10599. if (groupData.Code != 0)
  10600. {
  10601. return Ok(JsonView(false, groupData.Msg));
  10602. }
  10603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10604. }
  10605. catch (Exception ex)
  10606. {
  10607. return Ok(JsonView(false, ex.Message));
  10608. }
  10609. }
  10610. /// <summary>
  10611. /// 保险费用操作(Status:1.新增,2.修改)
  10612. /// </summary>
  10613. /// <param name="dto"></param>
  10614. /// <returns></returns>
  10615. [HttpPost]
  10616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10617. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10618. {
  10619. Result groupData = await _customersRep.OpCustomers(dto);
  10620. if (groupData.Code != 0)
  10621. {
  10622. return Ok(JsonView(false, groupData.Msg));
  10623. }
  10624. #region 应用推送
  10625. try
  10626. {
  10627. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10628. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10629. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10630. }
  10631. catch (Exception ex)
  10632. {
  10633. }
  10634. #endregion
  10635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10636. }
  10637. /// <summary>
  10638. /// 保险文件上传
  10639. /// </summary>
  10640. /// <param name="file"></param>
  10641. /// <returns></returns>
  10642. [HttpPost]
  10643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10644. public async Task<IActionResult> UploadCus(IFormFile file)
  10645. {
  10646. try
  10647. {
  10648. if (file != null)
  10649. {
  10650. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10651. //文件名称
  10652. string projectFileName = file.FileName;
  10653. //上传的文件的路径
  10654. string filePath = "";
  10655. if (!Directory.Exists(fileDir))
  10656. {
  10657. Directory.CreateDirectory(fileDir);
  10658. }
  10659. //上传的文件的路径
  10660. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10661. using (FileStream fs = System.IO.File.Create(filePath))
  10662. {
  10663. file.CopyTo(fs);
  10664. fs.Flush();
  10665. }
  10666. return Ok(JsonView(true, "上传成功!", projectFileName));
  10667. }
  10668. else
  10669. {
  10670. return Ok(JsonView(false, "上传失败!"));
  10671. }
  10672. }
  10673. catch (Exception ex)
  10674. {
  10675. return Ok(JsonView(false, "程序错误!"));
  10676. throw;
  10677. }
  10678. }
  10679. /// <summary>
  10680. /// 保险删除指定文件
  10681. /// </summary>
  10682. /// <param name="dto"></param>
  10683. /// <returns></returns>
  10684. [HttpPost]
  10685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10686. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10687. {
  10688. try
  10689. {
  10690. string filePath = "";
  10691. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10692. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10693. //int id = 0;
  10694. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10695. // 删除该文件
  10696. try
  10697. {
  10698. System.IO.File.Delete(filePath);
  10699. 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()
  10700. {
  10701. Attachment = "",
  10702. }).ExecuteCommandAsync();
  10703. if (result != 0)
  10704. {
  10705. return Ok(JsonView(true, "成功!"));
  10706. }
  10707. else
  10708. {
  10709. return Ok(JsonView(false, "失败!"));
  10710. }
  10711. }
  10712. catch (Exception)
  10713. {
  10714. 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()
  10715. {
  10716. Attachment = "",
  10717. }).ExecuteCommandAsync();
  10718. if (result != 0)
  10719. {
  10720. return Ok(JsonView(true, "成功!"));
  10721. }
  10722. else
  10723. {
  10724. return Ok(JsonView(false, "失败!"));
  10725. }
  10726. }
  10727. }
  10728. catch (Exception ex)
  10729. {
  10730. return Ok(JsonView(false, "程序错误!"));
  10731. throw;
  10732. }
  10733. }
  10734. /// <summary>
  10735. /// 保险费用操作(删除)
  10736. /// </summary>
  10737. /// <param name="dto"></param>
  10738. /// <returns></returns>
  10739. [HttpPost]
  10740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10741. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10742. {
  10743. try
  10744. {
  10745. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10746. if (!res)
  10747. {
  10748. return Ok(JsonView(false, "删除失败"));
  10749. }
  10750. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10751. {
  10752. IsDel = 1,
  10753. DeleteUserId = dto.DeleteUserId,
  10754. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10755. }).ExecuteCommandAsync();
  10756. return Ok(JsonView(true, "删除成功!"));
  10757. }
  10758. catch (Exception ex)
  10759. {
  10760. return Ok(JsonView(false, "程序错误!"));
  10761. throw;
  10762. }
  10763. }
  10764. #endregion
  10765. #region 接团客户名单 PageId 104
  10766. /// <summary>
  10767. /// 接团客户名单
  10768. /// 迁移数据(慎用!)
  10769. /// </summary>
  10770. /// <param name="dto"></param>
  10771. /// <returns></returns>
  10772. [HttpPost]
  10773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10774. public async Task<IActionResult> PostTourClientListChange()
  10775. {
  10776. try
  10777. {
  10778. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10779. //var groupClinetData1
  10780. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10781. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10782. int updateCount = 0;
  10783. if (oldOAClientList.Count > 0)
  10784. {
  10785. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10786. _sqlSugar.BeginTran();
  10787. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10788. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10789. foreach (var item in oldOAClientList)
  10790. {
  10791. int comId = 0;
  10792. string format = "yyyy-MM-dd HH:mm:ss";
  10793. string data11 = "1990-01-01 00:00";
  10794. var data1 = IsValidDate(item.OPdate, format);
  10795. if (data1) data11 = item.OPdate;
  10796. //客户公司验证
  10797. if (!string.IsNullOrEmpty(item.Company))
  10798. {
  10799. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10800. if (clientComInfo == null) // add
  10801. {
  10802. var addInfo = new Crm_CustomerCompany()
  10803. {
  10804. CompanyAbbreviation = "",
  10805. CompanyFullName = item.Company,
  10806. Address = "",
  10807. PostCodes = "",
  10808. LastedOpUserId = item.OPer,
  10809. LastedOpDt = Convert.ToDateTime(data11),
  10810. CreateUserId = item.OPer,
  10811. CreateTime = Convert.ToDateTime(data11),
  10812. IsDel = 0
  10813. };
  10814. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10815. if (comId1 > 0) comId = comId1;
  10816. }
  10817. else comId = clientComInfo.Id;
  10818. }
  10819. //客户人员验证
  10820. int clientId = 0;
  10821. string name = item.LastName + item.Name;
  10822. if (!string.IsNullOrEmpty(name))
  10823. {
  10824. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10825. if (clientInfo == null)
  10826. {
  10827. DateTime? dateTime = null;
  10828. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10829. if (isDt) dateTime = birthDayDt;
  10830. var addInfo1 = new Crm_DeleClient()
  10831. {
  10832. CrmCompanyId = comId,
  10833. DiId = -1,
  10834. LastName = item.LastName,
  10835. FirstName = item.Name,
  10836. OldName = "",
  10837. Pinyin = item.Pinyin,
  10838. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10839. Marriage = 0,
  10840. Phone = item.Phone,
  10841. Job = item.Job,
  10842. BirthDay = dateTime
  10843. };
  10844. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10845. if (clientId1 > 0) clientId = clientId1;
  10846. }
  10847. else clientId = clientInfo.Id;
  10848. }
  10849. if (clientId < 1)
  10850. {
  10851. continue;
  10852. }
  10853. int airType = 0;
  10854. if (item.AirType == "超经舱") airType = 459;
  10855. else if (item.AirType == "公务舱") airType = 458;
  10856. else if (item.AirType == "经济舱") airType = 460;
  10857. else if (item.AirType == "其他") airType = 565;
  10858. else if (item.AirType == "头等舱") airType = 457;
  10859. var _TourClientListEntity = new Grp_TourClientList()
  10860. {
  10861. DiId = item.Diid,
  10862. ClientId = clientId,
  10863. CreateUserId = item.OPer,
  10864. CreateTime = Convert.ToDateTime(data11),
  10865. Remark = item.Remark,
  10866. IsDel = item.Isdel,
  10867. ShippingSpaceTypeId = airType,
  10868. ShippingSpaceSpecialNeeds = item.AirRemark,
  10869. HotelSpecialNeeds = item.RoomType
  10870. };
  10871. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10872. if (_TourClientList > 0)
  10873. {
  10874. updateCount++;
  10875. }
  10876. }
  10877. _sqlSugar.CommitTran();
  10878. }
  10879. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10880. }
  10881. catch (Exception ex)
  10882. {
  10883. _sqlSugar.RollbackTran();
  10884. return Ok(JsonView(false, ex.Message));
  10885. }
  10886. return Ok(JsonView(true));
  10887. }
  10888. private bool IsValidDate(string dateString, string format)
  10889. {
  10890. DateTime dateValue;
  10891. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10892. return valid;
  10893. }
  10894. /// <summary>
  10895. /// 接团客户名单
  10896. /// 根据团组Id查询List
  10897. /// </summary>
  10898. /// <param name="dto"></param>
  10899. /// <returns></returns>
  10900. [HttpPost]
  10901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10902. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10903. {
  10904. #region 参数验证
  10905. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10906. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10907. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10908. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10909. #region 页面操作权限验证
  10910. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10911. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10912. #endregion
  10913. #endregion
  10914. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10915. if (viewData.Code != 0)
  10916. {
  10917. return Ok(JsonView(false, viewData.Msg));
  10918. }
  10919. return Ok(JsonView(viewData.Data));
  10920. }
  10921. /// <summary>
  10922. /// 接团客户名单
  10923. /// 基础数据 Init
  10924. /// </summary>
  10925. /// <param name="_dto"></param>
  10926. /// <returns></returns>
  10927. [HttpPost]
  10928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10929. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10930. {
  10931. #region 参数验证
  10932. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10933. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10934. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10935. #region 页面操作权限验证
  10936. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10937. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10938. #endregion
  10939. #endregion
  10940. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10941. if (viewData.Code != 0)
  10942. {
  10943. return Ok(JsonView(false, viewData.Msg));
  10944. }
  10945. return Ok(JsonView(viewData.Data));
  10946. }
  10947. /// <summary>
  10948. /// 接团客户名单
  10949. /// 根据 Id查询 Details
  10950. /// </summary>
  10951. /// <param name="_dto"></param>
  10952. /// <returns></returns>
  10953. [HttpPost]
  10954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10955. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10956. {
  10957. #region 参数验证
  10958. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10959. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10960. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10961. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10962. #region 页面操作权限验证
  10963. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10964. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10965. #endregion
  10966. #endregion
  10967. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10968. if (viewData.Code != 0)
  10969. {
  10970. return Ok(JsonView(false, viewData.Msg));
  10971. }
  10972. return Ok(JsonView(viewData.Data));
  10973. }
  10974. /// <summary>
  10975. /// 接团客户名单
  10976. /// Add Or Edit
  10977. /// </summary>
  10978. /// <param name="_dto"></param>
  10979. /// <returns></returns>
  10980. [HttpPost]
  10981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10982. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10983. {
  10984. #region 参数验证
  10985. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10986. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10987. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10988. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10989. #region 页面操作权限验证
  10990. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10991. if (_dto.Id == 0) //添加
  10992. {
  10993. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10994. }
  10995. else if (_dto.Id >= 0) //修改
  10996. {
  10997. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10998. }
  10999. #endregion
  11000. #endregion
  11001. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11002. if (viewData.Code != 0)
  11003. {
  11004. return Ok(JsonView(false, viewData.Msg));
  11005. }
  11006. return Ok(JsonView(true));
  11007. }
  11008. /// <summary>
  11009. /// 接团客户名单
  11010. /// AddMultiple(添加多个)
  11011. /// </summary>
  11012. /// <param name="_dto"></param>
  11013. /// <returns></returns>
  11014. [HttpPost]
  11015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11016. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11017. {
  11018. #region 参数验证
  11019. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11020. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11021. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11022. #region 页面操作权限验证
  11023. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11024. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11025. #endregion
  11026. #endregion
  11027. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11028. if (viewData.Code != 0)
  11029. {
  11030. return Ok(JsonView(false, viewData.Msg));
  11031. }
  11032. return Ok(JsonView(true));
  11033. }
  11034. /// <summary>
  11035. /// 接团客户名单
  11036. /// Del
  11037. /// </summary>
  11038. /// <param name="_dto"></param>
  11039. /// <returns></returns>
  11040. [HttpPost]
  11041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11042. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11043. {
  11044. #region 参数验证
  11045. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11046. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11047. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11048. #region 页面操作权限验证
  11049. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11050. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11051. #endregion
  11052. #endregion
  11053. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11054. if (viewData.Code != 0)
  11055. {
  11056. return Ok(JsonView(false, viewData.Msg));
  11057. }
  11058. return Ok(JsonView(true));
  11059. }
  11060. /// <summary>
  11061. /// 接团客户名单
  11062. /// 文件下载 客户名单
  11063. /// </summary>
  11064. /// <param name="_dto"></param>
  11065. /// <returns></returns>
  11066. [HttpPost]
  11067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11068. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11069. {
  11070. #region 参数验证
  11071. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11072. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11073. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11074. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11075. #region 页面操作权限验证
  11076. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11077. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11078. #endregion
  11079. #endregion
  11080. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11081. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11082. From Grp_TourClientList tcl
  11083. Left Join
  11084. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11085. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11086. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11087. From Crm_DeleClient dc
  11088. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11089. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11090. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11091. Where dc.IsDel = 0) temp
  11092. On temp.DcId =tcl.ClientId
  11093. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11094. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11095. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11096. //载入模板
  11097. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11098. if (_dto.Language == 1)
  11099. {
  11100. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11101. }
  11102. //载入模板
  11103. var doc = new Document(tempPath);
  11104. DocumentBuilder builder = new DocumentBuilder(doc);
  11105. //获取word里所有表格
  11106. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11107. //获取所填表格的序数
  11108. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11109. var rowStart = tableOne.Rows[0]; //获取第1行
  11110. if (_dto.Language == 0)
  11111. {
  11112. //循环赋值
  11113. for (int i = 0; i < DcList.Count; i++)
  11114. {
  11115. builder.MoveToCell(0, i + 1, 0, 0);
  11116. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11117. builder.MoveToCell(0, i + 1, 1, 0);
  11118. int sex = DcList[i].Sex;
  11119. string sexStr = string.Empty;
  11120. if (sex == 0) sexStr = "男";
  11121. else if (sex == 1) sexStr = "女";
  11122. else sexStr = "未设置";
  11123. builder.Write(sexStr);
  11124. builder.MoveToCell(0, i + 1, 2, 0);
  11125. string birthDay = DcList[i].BirthDay;
  11126. string birthDayStr = string.Empty;
  11127. if (!string.IsNullOrEmpty(birthDay))
  11128. {
  11129. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11130. }
  11131. builder.Write(birthDayStr);
  11132. builder.MoveToCell(0, i + 1, 3, 0);
  11133. string company = "";
  11134. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11135. {
  11136. company = DcList[i].CompanyFullName.ToString();
  11137. }
  11138. builder.Write(company);
  11139. builder.MoveToCell(0, i + 1, 4, 0);
  11140. builder.Write(DcList[i].Job);
  11141. }
  11142. }
  11143. else if (_dto.Language == 1)
  11144. {
  11145. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11146. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11147. List<string> transArrayStr = new List<string>();
  11148. string transStrRes1 = "";
  11149. for (int i = 0; i < DcList.Count; i++)
  11150. {
  11151. var dc = DcList[i];
  11152. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11153. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11154. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11155. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11156. else transStrRes1 += $"{str1}|";
  11157. }
  11158. //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";
  11159. string transStrRes = "";
  11160. if (transStrRes1.Length > 0 )
  11161. {
  11162. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11163. }
  11164. //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
  11165. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11166. //List<string> transArray = new List<string> { };
  11167. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11168. if (transStrRes.Contains("|"))
  11169. {
  11170. string[] transArray1 = transStrRes.Split('|');
  11171. if (transArray1.Length > 0)
  11172. {
  11173. foreach (var item in transArray1)
  11174. {
  11175. if (item.Contains("&"))
  11176. {
  11177. string[] transArray2 = item.Split('&');
  11178. int index = 0;
  11179. string companyName = "", job = "";
  11180. if (transArray2.Length > 0)
  11181. {
  11182. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11183. if (1 < transArray2.Length) companyName = transArray2[1];
  11184. if (2 < transArray2.Length) job = transArray2[2];
  11185. }
  11186. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11187. }
  11188. }
  11189. }
  11190. }
  11191. //循环赋值
  11192. for (int i = 0; i < DcList.Count; i++)
  11193. {
  11194. string PYName = "";
  11195. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11196. {
  11197. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11198. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11199. PYName = PY_First + " " + PY_Last;
  11200. }
  11201. else
  11202. {
  11203. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11204. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11205. PYName = PY_First + " " + PY_Last;
  11206. }
  11207. builder.MoveToCell(0, i + 1, 0, 0);
  11208. builder.Write(PYName);
  11209. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11210. builder.MoveToCell(0, i + 1, 1, 0);
  11211. builder.Write(sex);
  11212. DateTime birthDt;
  11213. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11214. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11215. builder.MoveToCell(0, i + 1, 2, 0);
  11216. builder.Write(birthday);
  11217. string company = string.Empty,job = string.Empty;
  11218. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11219. if (dcTransInfo != null)
  11220. {
  11221. company = dcTransInfo.CompanyName;
  11222. job = dcTransInfo.Job;
  11223. }
  11224. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11225. {
  11226. //查询对照表
  11227. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11228. if (tempCec != null)
  11229. {
  11230. company = tempCec.enName;
  11231. }
  11232. //翻译
  11233. else
  11234. {
  11235. }
  11236. }
  11237. builder.MoveToCell(0, i + 1, 3, 0);
  11238. builder.Write(company);
  11239. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11240. {
  11241. //查询对照表
  11242. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11243. if (tempPec != null)
  11244. {
  11245. job = tempPec.enName;
  11246. }
  11247. //翻译
  11248. else
  11249. {
  11250. }
  11251. }
  11252. builder.MoveToCell(0, i + 1, 4, 0);
  11253. builder.Write(job);
  11254. }
  11255. }
  11256. //删除多余行
  11257. while (tableOne.Rows.Count > DcList.Count + 1)
  11258. {
  11259. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11260. }
  11261. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11262. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11263. doc.Save(fileDir);
  11264. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11265. return Ok(JsonView(true, "操作成功!", Url));
  11266. }
  11267. private class TranslateInfo
  11268. {
  11269. public int Index { get; set; }
  11270. public string CompanyName { get; set; }
  11271. public string Job { get; set; }
  11272. }
  11273. #endregion
  11274. #region 团组倒推表
  11275. /// <summary>
  11276. /// 倒推表基础数据
  11277. /// Init
  11278. /// </summary>
  11279. /// <param name="dto"></param>
  11280. /// <returns></returns>
  11281. [HttpPost]
  11282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11283. public async Task<IActionResult> PostInvertedListInit()
  11284. {
  11285. var viewData = await _invertedListRep._Init();
  11286. if (viewData.Code != 0)
  11287. {
  11288. return Ok(JsonView(false, viewData.Msg));
  11289. }
  11290. return Ok(JsonView(viewData.Data));
  11291. }
  11292. /// <summary>
  11293. /// 倒推表
  11294. /// Info
  11295. /// </summary>
  11296. /// <param name="dto"></param>
  11297. /// <returns></returns>
  11298. [HttpPost]
  11299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11300. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11301. {
  11302. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11303. if (viewData.Code != 0)
  11304. {
  11305. return Ok(JsonView(false, viewData.Msg));
  11306. }
  11307. return Ok(JsonView(viewData.Data));
  11308. }
  11309. /// <summary>
  11310. /// 倒推表
  11311. /// Create
  11312. /// </summary>
  11313. /// <param name="dto"></param>
  11314. /// <returns></returns>
  11315. [HttpPost]
  11316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11317. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11318. {
  11319. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11320. if (viewData.Code != 0)
  11321. {
  11322. return Ok(JsonView(false, viewData.Msg));
  11323. }
  11324. return Ok(JsonView(viewData.Data));
  11325. }
  11326. /// <summary>
  11327. /// 倒推表
  11328. /// Update
  11329. /// </summary>
  11330. /// <param name="dto"></param>
  11331. /// <returns></returns>
  11332. [HttpPost]
  11333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11334. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11335. {
  11336. var viewData = await _invertedListRep._Update(dto);
  11337. if (viewData.Code != 0)
  11338. {
  11339. return Ok(JsonView(false, viewData.Msg));
  11340. }
  11341. return Ok(JsonView(viewData.Data));
  11342. }
  11343. /// <summary>
  11344. /// 倒推表
  11345. /// File Download
  11346. /// </summary>
  11347. /// <param name="dto"></param>
  11348. /// <returns></returns>
  11349. [HttpPost]
  11350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11351. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11352. {
  11353. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11354. if (info2.Code != 0)
  11355. {
  11356. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11357. }
  11358. var info1 = info2.Data as InvertedListInfoView;
  11359. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11360. string teamName = "";
  11361. if (info != null) teamName = info.TeamName;
  11362. //载入模板
  11363. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11364. DocumentBuilder builder = new DocumentBuilder(doc);
  11365. //利用键值对存放数据
  11366. Dictionary<string, string> dic = new Dictionary<string, string>();
  11367. dic.Add("TeamName", teamName);
  11368. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11369. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11370. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11371. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11372. dic.Add("SQRemark", info1.ApprovalRemark);
  11373. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11374. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11375. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11376. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11377. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11378. dic.Add("QZRemark", info1.VisaInformationRemark);
  11379. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11380. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11381. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11382. dic.Add("CQRemark", info1.IssueVisaRemark);
  11383. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11384. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11385. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11386. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11387. #region 填充word模板书签内容
  11388. foreach (var key in dic.Keys)
  11389. {
  11390. builder.MoveToBookmark(key);
  11391. builder.Write(dic[key]);
  11392. }
  11393. #endregion
  11394. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11395. string fileName = $"{teamName}团出行准备流程表.doc";
  11396. string filePath = fileDir + $@"InvertedList/{fileName}";
  11397. doc.Save(filePath);
  11398. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11399. return Ok(JsonView(true, "操作成功!", Url));
  11400. }
  11401. #endregion
  11402. #region 三公签证费用(签证费、代办费)
  11403. /// <summary>
  11404. /// 三公签证费用(签证费、代办费)
  11405. /// List
  11406. /// </summary>
  11407. /// <returns></returns>
  11408. [HttpPost]
  11409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11410. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11411. {
  11412. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11413. if (_view.Code != 0)
  11414. {
  11415. return Ok(JsonView(false, _view.Msg));
  11416. }
  11417. return Ok(JsonView(true, "操作成功!", _view.Data));
  11418. }
  11419. /// <summary>
  11420. /// 三公签证费用(签证费、代办费)
  11421. /// Add Or Update
  11422. /// </summary>
  11423. /// <returns></returns>
  11424. [HttpPost]
  11425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11426. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11427. {
  11428. var _view = await _visaFeeInfoRep._Update(_dto);
  11429. if (_view.Code != 0)
  11430. {
  11431. return Ok(JsonView(false, _view.Msg));
  11432. }
  11433. return Ok(JsonView(true, _view.Msg));
  11434. }
  11435. #endregion
  11436. #region 酒店询价
  11437. /// <summary>
  11438. /// 酒店询价
  11439. /// Init
  11440. /// </summary>
  11441. /// <param name="dto"></param>
  11442. /// <returns></returns>
  11443. [HttpPost]
  11444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11445. public async Task<IActionResult> PostHotelInquiryInit()
  11446. {
  11447. var res = await _hotelInquiryRep._Init();
  11448. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11449. return Ok(JsonView(true, res.Msg, res.Data));
  11450. }
  11451. /// <summary>
  11452. /// 酒店询价
  11453. /// page Item
  11454. /// </summary>
  11455. /// <param name="_dto"></param>
  11456. /// <returns></returns>
  11457. [HttpPost]
  11458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11459. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11460. {
  11461. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11462. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11463. var view = res.Data as PageDataViewBase;
  11464. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11465. }
  11466. /// <summary>
  11467. /// 酒店询价
  11468. /// info
  11469. /// </summary>
  11470. /// <param name="_dto"></param>
  11471. /// <returns></returns>
  11472. [HttpPost]
  11473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11474. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11475. {
  11476. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11477. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11478. return Ok(JsonView(true, res.Msg, res.Data));
  11479. }
  11480. /// <summary>
  11481. /// 酒店询价
  11482. /// Add Or Edit
  11483. /// </summary>
  11484. /// <param name="_dto"></param>
  11485. /// <returns></returns>
  11486. [HttpPost]
  11487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11488. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11489. {
  11490. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11491. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11492. return Ok(JsonView(true, res.Msg, res.Data));
  11493. }
  11494. /// <summary>
  11495. /// 酒店询价
  11496. /// Del
  11497. /// </summary>
  11498. /// <param name="_dto"></param>
  11499. /// <returns></returns>
  11500. [HttpPost]
  11501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11502. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11503. {
  11504. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11505. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11506. return Ok(JsonView(true, res.Msg, res.Data));
  11507. }
  11508. #endregion
  11509. #region 下载匹配op行程单
  11510. /// <summary>
  11511. /// 匹配op行程单
  11512. /// Init
  11513. /// </summary>
  11514. /// <param name="dto">团组列表请求dto</param>
  11515. /// <returns></returns>
  11516. [HttpPost]
  11517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11518. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11519. {
  11520. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11521. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11522. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11523. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11524. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11525. .Where(it => it.IsDel == 0)
  11526. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11527. .OrderByDescending(it => it.CreateUserId)
  11528. .ToList();
  11529. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11530. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11531. var diids = groupInfos.Select(it => it.Id).ToList();
  11532. List<string> countrys = new List<string>();
  11533. foreach (var item in country)
  11534. {
  11535. var data = _groupRepository.FormartTeamName(item);
  11536. var dataArray = _groupRepository.GroupSplitCountry(data);
  11537. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11538. }
  11539. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11540. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11541. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11542. foreach (var item in areaItem)
  11543. {
  11544. string areaStr = item.Value;
  11545. if (!string.IsNullOrEmpty(areaStr))
  11546. {
  11547. string[] str1 = areaStr.Split("-");
  11548. if (str1.Length > 0)
  11549. {
  11550. areaArray.AddRange(str1);
  11551. }
  11552. }
  11553. }
  11554. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11555. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11556. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11557. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11558. .ToList();
  11559. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11560. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11561. .Where(it => countriesIds.Contains(it.Id))
  11562. .Select(it => new { it.Id, Name = it.Name_CN })
  11563. .ToList();
  11564. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11565. .Select(it => it.TeamName).ToList();
  11566. stopwatch.Stop();
  11567. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11568. }
  11569. ///// <summary>
  11570. ///// 匹配op行程单
  11571. ///// Init 查询区域数据
  11572. ///// </summary>
  11573. ///// <param name="dto">团组列表请求dto</param>
  11574. ///// <returns></returns>
  11575. //[HttpPost]
  11576. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11577. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11578. //{
  11579. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11580. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11581. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11582. // if (string.IsNullOrEmpty(countriesDataStr))
  11583. // {
  11584. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11585. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11586. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11587. // }
  11588. // else
  11589. // {
  11590. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11591. // }
  11592. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11593. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11594. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11595. // List<dynamic> childList = new List<dynamic>();
  11596. // int parentId = dto.CountriesId;
  11597. // if (provinceData.Count > 1)
  11598. // {
  11599. // foreach (var item1 in provinceData)
  11600. // {
  11601. // List<dynamic> childList1 = new List<dynamic>();
  11602. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11603. // foreach (var item2 in citiesData1)
  11604. // {
  11605. // List<dynamic> childList2 = new List<dynamic>();
  11606. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11607. // foreach (var item3 in countiesData1)
  11608. // {
  11609. // childList2.Add(new
  11610. // {
  11611. // id = item3.Id,
  11612. // parentId = item2.Id,
  11613. // level = "district",
  11614. // name = item3.Name_CN,
  11615. // });
  11616. // }
  11617. // childList1.Add(new
  11618. // {
  11619. // id = item2.Id,
  11620. // parentId = item1.Id,
  11621. // level = "city",
  11622. // name = item2.Name_CN,
  11623. // childList = childList2
  11624. // });
  11625. // }
  11626. // childList.Add(new
  11627. // {
  11628. // id = item1.Id,
  11629. // parentId = parentId,
  11630. // level = "province",
  11631. // name = item1.Name_CN,
  11632. // childList = childList1
  11633. // });
  11634. // }
  11635. // //城市
  11636. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11637. // foreach (var item2 in citiesData2)
  11638. // {
  11639. // List<dynamic> childList22 = new List<dynamic>();
  11640. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11641. // foreach (var item3 in countiesData1)
  11642. // {
  11643. // childList22.Add(new
  11644. // {
  11645. // id = item3.Id,
  11646. // parentId = item2.Id,
  11647. // level = "district",
  11648. // name = item3.Name_CN,
  11649. // });
  11650. // }
  11651. // childList.Add(new
  11652. // {
  11653. // id = item2.Id,
  11654. // parentId = parentId,
  11655. // level = "city",
  11656. // name = item2.Name_CN,
  11657. // childList = childList22
  11658. // });
  11659. // }
  11660. // }
  11661. // else
  11662. // {
  11663. // foreach (var item2 in citiesData)
  11664. // {
  11665. // string cname = item2.Name_CN;
  11666. // List<dynamic> childList1 = new List<dynamic>();
  11667. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11668. // foreach (var item3 in countiesData1)
  11669. // {
  11670. // childList1.Add(new
  11671. // {
  11672. // Id = item3.Id,
  11673. // parentId = item2.Id,
  11674. // level = "district",
  11675. // name = item3.Name_CN
  11676. // });
  11677. // }
  11678. // childList.Add(new
  11679. // {
  11680. // id = item2.Id,
  11681. // parentId = parentId,
  11682. // level = "city",
  11683. // name = item2.Name_CN,
  11684. // childList = childList1
  11685. // });
  11686. // }
  11687. // }
  11688. // stopwatch.Stop();
  11689. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11690. //}
  11691. /// <summary>
  11692. /// 匹配op行程单
  11693. /// 接团信息列表 Page
  11694. /// </summary>
  11695. /// <param name="dto">团组列表请求dto</param>
  11696. /// <returns></returns>
  11697. [HttpPost]
  11698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11699. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11700. {
  11701. var swatch = new Stopwatch();
  11702. swatch.Start();
  11703. #region 参数验证
  11704. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11705. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11706. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11707. #region 页面操作权限验证
  11708. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11709. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11710. #endregion
  11711. #endregion
  11712. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11713. {
  11714. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11715. string sqlWhere = "";
  11716. if (!string.IsNullOrEmpty(dto.Country))
  11717. {
  11718. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11719. }
  11720. if (!string.IsNullOrEmpty(dto.Area))
  11721. {
  11722. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11723. }
  11724. if (!string.IsNullOrEmpty(dto.TeamName))
  11725. {
  11726. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11727. }
  11728. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11729. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11730. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11731. swatch.Stop();
  11732. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11733. }
  11734. else
  11735. {
  11736. return Ok(JsonView(false, "查询失败"));
  11737. }
  11738. }
  11739. /// <summary>
  11740. /// 匹配op行程单
  11741. /// 行程单下载
  11742. /// </summary>
  11743. /// <param name="dto">团组列表请求dto</param>
  11744. /// <returns></returns>
  11745. [HttpPost]
  11746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11747. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11748. {
  11749. #region 参数验证
  11750. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11751. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11752. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11753. #region 页面操作权限验证
  11754. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11755. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11756. #endregion
  11757. #endregion
  11758. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11759. {
  11760. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11761. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11762. }
  11763. else
  11764. {
  11765. return Ok(JsonView(false, "下载失败!"));
  11766. }
  11767. }
  11768. #endregion
  11769. #region 国家信息 数据 注释
  11770. //[HttpPost]
  11771. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11772. //{
  11773. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11774. // foreach (var item in dto)
  11775. // {
  11776. // infos.Add(new Grp_GroupsTaskAssignment()
  11777. // {
  11778. // DIId = item,
  11779. // CTId = 82,
  11780. // UId = 248,
  11781. // IsEnable = 1,
  11782. // CreateUserId = 233,
  11783. // CreateTime = DateTime.Now,
  11784. // IsDel = 0
  11785. // });
  11786. // infos.Add(new Grp_GroupsTaskAssignment()
  11787. // {
  11788. // DIId = item,
  11789. // CTId = 82,
  11790. // UId = 286,
  11791. // IsEnable = 1,
  11792. // CreateUserId = 233,
  11793. // CreateTime = DateTime.Now,
  11794. // IsDel = 0
  11795. // });
  11796. // }
  11797. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11798. // return Ok("操作成功");
  11799. //}
  11800. //public class paramJsonDto
  11801. //{
  11802. // public List<CountriesInfo> str { get; set; }
  11803. //}
  11804. //[HttpPost]
  11805. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11806. //{
  11807. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11808. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11809. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11810. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11811. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11812. // _sqlSugar.BeginTran();
  11813. // int countitiesIndex = 0;
  11814. // foreach (var item in dto.str)
  11815. // {
  11816. // dynamic data = item.c;
  11817. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11818. // if (data != null)
  11819. // {
  11820. // countitiesIndex++;
  11821. // foreach (var item1 in data)
  11822. // {
  11823. // string cnname = item1.cn;
  11824. // string enname = item1.en;
  11825. // Sys_Cities provinceInfo = new Sys_Cities()
  11826. // {
  11827. // CountriesId = countriesId,
  11828. // Name_CN = cnname,
  11829. // Name_EN = enname,
  11830. // ParentId = 0,
  11831. // IsCapital = 1,
  11832. // CreateUserId = 208,
  11833. // CreateTime = DateTime.Now,
  11834. // IsDel = 0
  11835. // };
  11836. // if (item1.lv == "province") //省份
  11837. // {
  11838. // provinceInfo.Level = 1;
  11839. // int provinceId = 0;
  11840. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11841. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11842. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11843. // var data1 = item1.c;
  11844. // foreach (var item2 in data1)
  11845. // {
  11846. // if (item2.lv == "city")
  11847. // {
  11848. // string citycnname = item2.cn;
  11849. // string cityenname = item2.en;
  11850. // Sys_Cities cityInfo = new Sys_Cities()
  11851. // {
  11852. // CountriesId = countriesId,
  11853. // ParentId = provinceId,
  11854. // Level = 2,
  11855. // Name_CN = citycnname,
  11856. // Name_EN = cityenname,
  11857. // IsCapital = 1,
  11858. // CreateUserId = 208,
  11859. // CreateTime = DateTime.Now,
  11860. // IsDel = 0
  11861. // };
  11862. // if (item2.c != null)
  11863. // {
  11864. // int cityId = 0;
  11865. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11866. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11867. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11868. // foreach (var item3 in item2.c)
  11869. // {
  11870. // if (item3.lv == "district")
  11871. // {
  11872. // var districtInfo = new Sys_Cities()
  11873. // {
  11874. // CountriesId = countriesId,
  11875. // Name_CN = item3.cn,
  11876. // Name_EN = item3.en,
  11877. // Level = 3,
  11878. // ParentId = cityId,
  11879. // IsCapital = 1,
  11880. // CreateUserId = 208,
  11881. // CreateTime = DateTime.Now,
  11882. // IsDel = 0
  11883. // };
  11884. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11885. // //{
  11886. // districts.Add(districtInfo);
  11887. // //}
  11888. // }
  11889. // }
  11890. // }
  11891. // else
  11892. // {
  11893. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11894. // //{
  11895. // cities.Add(cityInfo);
  11896. // //}
  11897. // }
  11898. // }
  11899. // }
  11900. // }
  11901. // else if (item1.lv == "city")//城市
  11902. // {
  11903. // provinceInfo.Level = 2;
  11904. // if (item1.c != null)
  11905. // {
  11906. // int cityId = 0;
  11907. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11908. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11909. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11910. // foreach (var item3 in item1.c)
  11911. // {
  11912. // if (item3.lv == "district")
  11913. // {
  11914. // var districtInfo = new Sys_Cities()
  11915. // {
  11916. // CountriesId = countriesId,
  11917. // Name_CN = item3.cn,
  11918. // Name_EN = item3.en,
  11919. // Level = 3,
  11920. // ParentId = cityId,
  11921. // IsCapital = 1,
  11922. // CreateUserId = 208,
  11923. // CreateTime = DateTime.Now,
  11924. // IsDel = 0
  11925. // };
  11926. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11927. // //{
  11928. // districts.Add(districtInfo);
  11929. // //}
  11930. // }
  11931. // }
  11932. // }
  11933. // else
  11934. // {
  11935. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11936. // //{
  11937. // cities.Add(provinceInfo);
  11938. // //}
  11939. // }
  11940. // }
  11941. // }
  11942. // }
  11943. // }
  11944. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11945. // cities = cities.Distinct().ToList();
  11946. // districts = districts.Distinct().ToList();
  11947. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11948. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11949. // cities.AddRange(districts);
  11950. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11951. // //_sqlSugar.RollbackTran();
  11952. // _sqlSugar.CommitTran();
  11953. // return Ok(JsonView(false, "操作成功!"));
  11954. //}
  11955. //[HttpPost]
  11956. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11957. //{
  11958. // List<CountitiesInfo> infos = dto.MyProperty;
  11959. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11960. // _sqlSugar.BeginTran();
  11961. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11962. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11963. // foreach (var item in infos)
  11964. // {
  11965. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11966. // if (countryInfo != null)
  11967. // {
  11968. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11969. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11970. // if (cityInfo1 != null)
  11971. // {
  11972. // cityInfo1.IsCapital = 0;
  11973. // cityInfos.Add(cityInfo1);
  11974. // }
  11975. // }
  11976. // }
  11977. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11978. // .UpdateColumns(it => it.IsCapital)
  11979. // .WhereColumns(it => it.Id)
  11980. // .ExecuteCommand();
  11981. // //_sqlSugar.RollbackTran();
  11982. // _sqlSugar.CommitTran();
  11983. // return Ok(JsonView(false, "操作成功!"));
  11984. //}
  11985. //public class CounrtiesDto
  11986. //{
  11987. // public List<CountitiesInfo> MyProperty { get; set; }
  11988. //}
  11989. //public class CountitiesInfo
  11990. //{
  11991. // /// <summary>
  11992. // /// 圣约翰
  11993. // /// </summary>
  11994. // public string capital_name_chinese { get; set; }
  11995. // /// <summary>
  11996. // ///
  11997. // /// </summary>
  11998. // public string capital_name { get; set; }
  11999. // /// <summary>
  12000. // ///
  12001. // /// </summary>
  12002. // public string country_type { get; set; }
  12003. // /// <summary>
  12004. // /// 安提瓜和巴布达
  12005. // /// </summary>
  12006. // public string country_name_chinese { get; set; }
  12007. // /// <summary>
  12008. // /// 安提瓜和巴布达
  12009. // /// </summary>
  12010. // public string country_name_chinese_short { get; set; }
  12011. // /// <summary>
  12012. // /// 安提瓜和巴布达
  12013. // /// </summary>
  12014. // public string country_name_chinese_UN { get; set; }
  12015. // /// <summary>
  12016. // ///
  12017. // /// </summary>
  12018. // public string country_name_english_abbreviation { get; set; }
  12019. // /// <summary>
  12020. // ///
  12021. // /// </summary>
  12022. // public string country_name_english_formal { get; set; }
  12023. // /// <summary>
  12024. // ///
  12025. // /// </summary>
  12026. // public string country_name_english_UN { get; set; }
  12027. // /// <summary>
  12028. // ///
  12029. // /// </summary>
  12030. // public string continent_name { get; set; }
  12031. // /// <summary>
  12032. // ///
  12033. // /// </summary>
  12034. // public string subregion_name { get; set; }
  12035. // /// <summary>
  12036. // ///
  12037. // /// </summary>
  12038. // public string country_code2 { get; set; }
  12039. // /// <summary>
  12040. // ///
  12041. // /// </summary>
  12042. // public string country_code3 { get; set; }
  12043. // /// <summary>
  12044. // ///
  12045. // /// </summary>
  12046. // public string phone_code { get; set; }
  12047. //}
  12048. //public class CountriesInfo : BasicInfo
  12049. //{
  12050. // public List<CitiesInfo> c { get; set; }
  12051. //}
  12052. //public class CitiesInfo : BasicInfo
  12053. //{
  12054. // public List<AreaInfo> c { get; set; }
  12055. //}
  12056. //public class AreaInfo : BasicInfo
  12057. //{
  12058. // public List<AreaInfo> c { get; set; }
  12059. //}
  12060. //public class BasicInfo
  12061. //{
  12062. // public string code { get; set; }
  12063. // public string cn { get; set; }
  12064. // public string lv { get; set; }
  12065. // public string en { get; set; }
  12066. //}
  12067. #endregion
  12068. #region 查看邀请方
  12069. /// <summary>
  12070. /// 查看邀请方
  12071. /// 邀请方信息 Init
  12072. /// </summary>
  12073. /// <param name="dto"></param>
  12074. /// <returns></returns>
  12075. [HttpPost]
  12076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12077. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12078. {
  12079. string sqlWhere = string.Empty;
  12080. if (!string.IsNullOrEmpty(dto.Search))
  12081. {
  12082. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12083. }
  12084. string sql = string.Format($@"Select
  12085. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12086. Id,
  12087. UnitName
  12088. From Res_InvitationOfficialActivityData
  12089. Where IsDel = 0
  12090. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12091. RefAsync<int> total = 0;
  12092. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12093. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12094. }
  12095. /// <summary>
  12096. /// 查看邀请方
  12097. /// 国家信息 Init
  12098. /// </summary>
  12099. /// <param name="dto"></param>
  12100. /// <returns></returns>
  12101. [HttpPost]
  12102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12103. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12104. {
  12105. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12106. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12107. var diids = groupInfos.Select(it => it.Id).ToList();
  12108. List<string> countrys = new List<string>();
  12109. foreach (var item in country)
  12110. {
  12111. var data = _groupRepository.FormartTeamName(item);
  12112. var dataArray = _groupRepository.GroupSplitCountry(data);
  12113. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12114. }
  12115. countrys = countrys.Distinct().ToList();
  12116. for (int i = 0; i < countrys.Count; i++)
  12117. {
  12118. string item = countrys[i];
  12119. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12120. {
  12121. countrys.Remove(item);
  12122. i--;
  12123. }
  12124. }
  12125. RefAsync<int> total = 0;
  12126. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12127. .Where(it => countrys.Contains(it.Name_CN))
  12128. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12129. .Select(it => new { id = it.Id, name = it.Name_CN })
  12130. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12131. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12132. }
  12133. /// <summary>
  12134. /// 查看邀请方
  12135. /// 城市信息 Init
  12136. /// </summary>
  12137. /// <param name="dto"></param>
  12138. /// <returns></returns>
  12139. [HttpPost]
  12140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12141. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12142. {
  12143. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12144. RefAsync<int> total = 0;
  12145. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12146. .Where(it => it.CountriesId == dto.CountiesId)
  12147. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12148. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12149. .Select(it => new { id = it.Id, name = it.Name_CN })
  12150. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12151. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12152. }
  12153. /// <summary>
  12154. /// 查看邀请方
  12155. /// 团组名称 Init
  12156. /// </summary>
  12157. /// <param name="dto"></param>
  12158. /// <returns></returns>
  12159. [HttpPost]
  12160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12161. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12162. {
  12163. var watch = new Stopwatch();
  12164. watch.Start();
  12165. RefAsync<int> total = 0;
  12166. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12167. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12168. .Where((oa, di) => oa.IsDel == 0)
  12169. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12170. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12171. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12172. .Distinct()
  12173. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12174. watch.Stop();
  12175. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12176. }
  12177. /// <summary>
  12178. /// 查看邀请方
  12179. /// 团组 & 邀请方信息
  12180. /// </summary>
  12181. /// <param name="dto"></param>
  12182. /// <returns></returns>
  12183. [HttpPost]
  12184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12185. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12186. {
  12187. var watch = new Stopwatch();
  12188. watch.Start();
  12189. RefAsync<int> total = 0;
  12190. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12191. .AS("Grp_DelegationInfo")
  12192. .Includes(x => x.InvitingInfos)
  12193. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12194. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12195. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12196. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12197. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12198. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12199. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12200. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12201. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12202. infos.ForEach(x =>
  12203. {
  12204. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12205. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12206. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12207. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12208. });
  12209. watch.Stop();
  12210. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12211. }
  12212. #endregion
  12213. #region 报批行程
  12214. /// <summary>
  12215. /// 报批行程初始化
  12216. /// </summary>
  12217. /// <param name="dto"></param>
  12218. /// <returns></returns>
  12219. [HttpPost]
  12220. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12221. {
  12222. const int chiNumber = 5;
  12223. var jw = JsonView(false);
  12224. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12225. var group = groupList.First();
  12226. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12227. group = groupList.First(x => x.Id == diid);
  12228. if (group == null)
  12229. {
  12230. jw.Msg = "暂无团组!";
  12231. return Ok(jw);
  12232. }
  12233. var data = new
  12234. {
  12235. groupList = groupList.Select(x => new
  12236. {
  12237. x.TeamName,
  12238. x.Id
  12239. }),
  12240. content = new ArrayList(),
  12241. groupInfo = new
  12242. {
  12243. group.VisitDays,
  12244. group.TourCode,
  12245. group.VisitPNumber,
  12246. group.TeamName,
  12247. group.Id,
  12248. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12249. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12250. },
  12251. };
  12252. var resultArr = new ArrayList();
  12253. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12254. if (content.Count == 0)
  12255. {
  12256. var stay = "-";
  12257. var cityPath = "-";
  12258. //添加城市路径以及住宿地
  12259. //黑屏代码数据
  12260. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12261. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12262. {
  12263. jw = JsonView(true, "黑屏代码有误!", data);
  12264. return Ok(jw);
  12265. }
  12266. foreach (DataRow row in dtBlack.Rows)
  12267. {
  12268. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12269. {
  12270. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12271. return Ok(jw);
  12272. }
  12273. }
  12274. //黑屏代码获取时间区间
  12275. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12276. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12277. _sqlSugar.BeginTran();
  12278. for (int i = 0; i < timeArr.Count; i++)
  12279. {
  12280. stay = "-";
  12281. cityPath = "-";
  12282. DateTime NewData = DateTime.Parse(timeArr[i]);
  12283. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12284. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12285. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12286. if (tbSelect.Length > 0)
  12287. {
  12288. List<string> threeCodeStr = new List<string>();
  12289. foreach (var item in tbSelect)
  12290. {
  12291. var threeCode = item["Three"].ToString() ?? "";
  12292. if (threeCode.Length == 6)
  12293. {
  12294. var start = threeCode.Substring(0, 3);
  12295. var end = threeCode.Substring(3, 3);
  12296. if (threeCodeStr.Count == 0)
  12297. {
  12298. threeCodeStr.Add(start);
  12299. threeCodeStr.Add(end);
  12300. }
  12301. else
  12302. {
  12303. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12304. {
  12305. threeCodeStr.Add(end);
  12306. }
  12307. else
  12308. {
  12309. threeCodeStr.Add(start);
  12310. threeCodeStr.Add(end);
  12311. }
  12312. }
  12313. }
  12314. }
  12315. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12316. var last = threeCodeStr.Last();
  12317. foreach (var item in threeCodeStr)
  12318. {
  12319. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12320. if (item.Equals(last))
  12321. {
  12322. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12323. }
  12324. }
  12325. cityPath = cityPath.Trim('-');
  12326. }
  12327. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12328. appro.Diid = diid ?? -1;
  12329. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12330. appro.Id = thisId;
  12331. appro.CreateUserId = dto.UserId;
  12332. appro.CreateTime = DateTime.Now;
  12333. content.Add(appro);
  12334. }
  12335. _sqlSugar.CommitTran();
  12336. }
  12337. foreach (var x in content)
  12338. {
  12339. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12340. if (chiList.Count < chiNumber)
  12341. {
  12342. for (int i = chiList.Count; i < chiNumber; i++)
  12343. {
  12344. chiList.Add(new Grp_ApprovalTravelDetails());
  12345. }
  12346. }
  12347. resultArr.Add(new
  12348. {
  12349. x.Id,
  12350. x.Date,
  12351. x.Diid,
  12352. chiList = chiList.Select(x1 => new
  12353. {
  12354. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12355. x1.Details,
  12356. x1.ParentId,
  12357. x1.Id
  12358. })
  12359. });
  12360. }
  12361. data = data with
  12362. {
  12363. content = resultArr,
  12364. };
  12365. jw = JsonView(true, "获取成功!", data);
  12366. return Ok(jw);
  12367. }
  12368. /// <summary>
  12369. /// 报批行程删除
  12370. /// </summary>
  12371. /// <param name="dto"></param>
  12372. /// <returns></returns>
  12373. [HttpPost]
  12374. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12375. {
  12376. var jw = JsonView(false);
  12377. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12378. if (group == null)
  12379. {
  12380. jw.Msg = "团组参数有误!";
  12381. return Ok(jw);
  12382. }
  12383. try
  12384. {
  12385. _sqlSugar.BeginTran();
  12386. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12387. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12388. {
  12389. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12390. DeleteUserId = dto.uesrId,
  12391. IsDel = 1
  12392. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12393. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12394. {
  12395. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12396. DeleteUserId = dto.uesrId,
  12397. IsDel = 1
  12398. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12399. _sqlSugar.CommitTran();
  12400. jw = JsonView(true, "删除成功");
  12401. }
  12402. catch (Exception ex)
  12403. {
  12404. jw = JsonView(false, ex.Message);
  12405. }
  12406. return Ok(jw);
  12407. }
  12408. /// <summary>
  12409. /// 报批行程保存
  12410. /// </summary>
  12411. /// <param name="dto"></param>
  12412. /// <returns></returns>
  12413. [HttpPost]
  12414. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12415. {
  12416. var jw = JsonView(false);
  12417. var Find = dto.Arr.Find(x => x.id == 0);
  12418. if (Find != null)
  12419. {
  12420. jw.Msg = "生成的ID为0!";
  12421. return Ok(jw);
  12422. }
  12423. foreach (var item in dto.Arr)
  12424. {
  12425. foreach (var chi in item.chiList)
  12426. {
  12427. if (chi.parentId == 0)
  12428. {
  12429. chi.parentId = item.id;
  12430. }
  12431. }
  12432. }
  12433. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12434. _sqlSugar.BeginTran();
  12435. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12436. {
  12437. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12438. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12439. {
  12440. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12441. DeleteUserId = dto.UserId,
  12442. IsDel = 1
  12443. }).ExecuteCommand();
  12444. }
  12445. try
  12446. {
  12447. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12448. {
  12449. CreateTime = DateTime.Now,
  12450. CreateUserId = dto.UserId,
  12451. Details = x.details,
  12452. ParentId = x.parentId,
  12453. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12454. Remark = "",
  12455. IsDel = 0
  12456. }).ToList()).ExecuteCommand();
  12457. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12458. {
  12459. Id = x.id,
  12460. Details = x.details,
  12461. ParentId = x.parentId,
  12462. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12463. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12464. {
  12465. Details = x.Details,
  12466. ParentId = x.ParentId,
  12467. Time = x.Time
  12468. }).ExecuteCommand();
  12469. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12470. {
  12471. Id = x.id,
  12472. Date = x.date,
  12473. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12474. {
  12475. Date = x.Date
  12476. }).ExecuteCommand();
  12477. _sqlSugar.CommitTran();
  12478. jw = JsonView(true, "保存成功!");
  12479. }
  12480. catch (Exception ex)
  12481. {
  12482. _sqlSugar.RollbackTran();
  12483. jw = JsonView(false, "保存失败!" + ex.Message);
  12484. }
  12485. return Ok(jw);
  12486. }
  12487. /// <summary>
  12488. /// 报批行程生成
  12489. /// </summary>
  12490. /// <param name="dto"></param>
  12491. /// <returns></returns>
  12492. [HttpPost]
  12493. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12494. {
  12495. var jw = JsonView(false);
  12496. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12497. if (group == null)
  12498. {
  12499. jw.Msg = "暂无该团组!";
  12500. return Ok(jw);
  12501. }
  12502. //黑屏代码数据
  12503. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12504. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12505. {
  12506. jw.Msg = "黑屏代码有误!";
  12507. return Ok(jw);
  12508. }
  12509. foreach (DataRow row in dtBlack.Rows)
  12510. {
  12511. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12512. {
  12513. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12514. return Ok(jw);
  12515. }
  12516. }
  12517. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12518. var resultArr = new ArrayList();
  12519. if (officialActivitiesArr.Count == 0)
  12520. {
  12521. jw.Msg = "暂无公务出访信息!";
  12522. return Ok(jw);
  12523. }
  12524. try
  12525. {
  12526. _sqlSugar.BeginTran();
  12527. DeleteApprovalJourney(new
  12528. Domain.Dtos.Groups.DeleteApprovalJourney
  12529. {
  12530. Diid = dto.Diid,
  12531. uesrId = dto.Userid
  12532. });
  12533. var stay = "-";
  12534. var cityPath = "-";
  12535. //添加城市路径以及住宿地
  12536. //黑屏代码获取时间区间
  12537. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12538. var empty = "【未收入该三字码!请机票同事录入】";
  12539. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12540. for (int i = 0; i < timeArr.Count; i++)
  12541. {
  12542. stay = "-";
  12543. cityPath = "-";
  12544. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12545. DateTime NewData = DateTime.Parse(timeArr[i]);
  12546. 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();
  12547. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12548. if (tbSelect.Length > 0)
  12549. {
  12550. List<string> threeCodeStr = new List<string>();
  12551. bool isTrade = false;
  12552. string trip = string.Empty;
  12553. var rowLast = tbSelect.Last();
  12554. var rowFirst = tbSelect.First();
  12555. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12556. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12557. var takeOffTime = DateTime.Parse(timeArr[i]);
  12558. var fallToTime = DateTime.Parse(timeArr[i]);
  12559. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12560. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12561. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12562. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12563. foreach (var item in tbSelect)
  12564. {
  12565. var start = string.Empty;
  12566. var end = string.Empty;
  12567. var threeCode = item["Three"].ToString() ?? "";
  12568. if (threeCode.Length == 6)
  12569. {
  12570. start = threeCode.Substring(0, 3);
  12571. end = threeCode.Substring(3, 3);
  12572. if (threeCodeStr.Count == 0)
  12573. {
  12574. threeCodeStr.Add(start);
  12575. threeCodeStr.Add(end);
  12576. }
  12577. else
  12578. {
  12579. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12580. {
  12581. threeCodeStr.Add(end);
  12582. }
  12583. else
  12584. {
  12585. threeCodeStr.Add(start);
  12586. threeCodeStr.Add(end);
  12587. }
  12588. }
  12589. }
  12590. //处理机票信息
  12591. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12592. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12593. if (start_Object == null)
  12594. {
  12595. start_Object = new Res_ThreeCode()
  12596. {
  12597. AirPort = empty,
  12598. AirPort_En = empty,
  12599. City = empty,
  12600. Country = empty,
  12601. Four = empty,
  12602. Three = empty,
  12603. };
  12604. }
  12605. if (end_Object == null)
  12606. {
  12607. end_Object = new Res_ThreeCode()
  12608. {
  12609. AirPort = empty,
  12610. AirPort_En = empty,
  12611. City = empty,
  12612. Country = empty,
  12613. Four = empty,
  12614. Three = empty,
  12615. };
  12616. }
  12617. //机型判断
  12618. string airModel = item["AirModel"].ToString();
  12619. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12620. string flightTime = item["FlightTime"].ToString();
  12621. if (flightTime!.Contains(":"))
  12622. {
  12623. flightTime = flightTime.Replace(":", "小时");
  12624. flightTime += "分钟";
  12625. }
  12626. if (flightTime.Contains("H"))
  12627. {
  12628. flightTime = flightTime.Replace("H", "小时");
  12629. }
  12630. if (flightTime.Contains("M"))
  12631. {
  12632. flightTime = flightTime.Replace("M", "分钟");
  12633. }
  12634. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12635. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12636. {
  12637. flightTime = flightDataTime.Hour > 0
  12638. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12639. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12640. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12641. }
  12642. //航班号
  12643. string flightcode = item["Fliagtcode"].ToString();
  12644. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12645. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12646. if (aircompany == null)
  12647. {
  12648. aircompany = new Res_AirCompany
  12649. {
  12650. CnName = hsEmpty,
  12651. EnName = hsEmpty,
  12652. ShortCode = hsEmpty,
  12653. };
  12654. }
  12655. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12656. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12657. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12658. if (isTrade)
  12659. {
  12660. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12661. }
  12662. else
  12663. {
  12664. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12665. }
  12666. }
  12667. chiarr.Add(new Grp_ApprovalTravelDetails
  12668. {
  12669. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12670. CreateTime = DateTime.Now,
  12671. CreateUserId = dto.Userid,
  12672. ParentId = 0,
  12673. Details = trip
  12674. });
  12675. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12676. var last = threeCodeStr.Last();
  12677. foreach (var item in threeCodeStr)
  12678. {
  12679. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12680. if (item.Equals(last))
  12681. {
  12682. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12683. }
  12684. }
  12685. cityPath = cityPath.Trim('-');
  12686. }
  12687. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12688. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12689. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12690. appro.Diid = dto.Diid;
  12691. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12692. appro.Id = thisId;
  12693. appro.CreateUserId = dto.Userid;
  12694. appro.CreateTime = DateTime.Now;
  12695. foreach (var item in gwinfo)
  12696. {
  12697. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12698. chi.Details = "拜访" + item.Client;
  12699. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12700. {
  12701. chi.Details += "," + item.ReqSample;
  12702. }
  12703. chi.ParentId = thisId;
  12704. chi.Time = item.Time;
  12705. chiarr.Add(chi);
  12706. }
  12707. if (chiarr.Count < 5)
  12708. {
  12709. for (int j = chiarr.Count; j < 5; j++)
  12710. {
  12711. chiarr.Add(new
  12712. Grp_ApprovalTravelDetails());
  12713. }
  12714. }
  12715. resultArr.Add(new
  12716. {
  12717. appro.Id,
  12718. appro.Date,
  12719. appro.Diid,
  12720. chiList = chiarr.Select(x1 => new
  12721. {
  12722. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12723. x1.Details,
  12724. x1.ParentId,
  12725. x1.Id
  12726. })
  12727. });
  12728. }
  12729. _sqlSugar.CommitTran();
  12730. jw = JsonView(true, "生成成功!", resultArr);
  12731. }
  12732. catch (Exception ex)
  12733. {
  12734. jw.Code = 400;
  12735. jw.Msg = "生成失败!" + ex.Message;
  12736. }
  12737. return Ok(jw);
  12738. }
  12739. /// <summary>
  12740. /// 报批行程word导出
  12741. /// </summary>
  12742. /// <param name="dto"></param>
  12743. /// <returns></returns>
  12744. [HttpPost]
  12745. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12746. {
  12747. var jw = JsonView(false);
  12748. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12749. if (group == null)
  12750. {
  12751. jw.Msg = "暂无该团组!";
  12752. return Ok(jw);
  12753. }
  12754. //模板路径
  12755. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12756. //载入模板
  12757. Document doc = new Document(tempPath);
  12758. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12759. //获取所填表格的序数
  12760. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12761. Aspose.Words.Tables.Row titleRowClone = null;
  12762. Aspose.Words.Tables.Row CenterRowClone = null;
  12763. int index = 0;
  12764. int indexChi = 0;
  12765. int SetIndex = 0;
  12766. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12767. //获取数据,放到datatable
  12768. foreach (var item in ApprovalTravelArr)
  12769. {
  12770. if (index > 0)
  12771. {
  12772. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12773. tableOne.AppendChild(titleRowClone);
  12774. }
  12775. var textTime = item.Date;
  12776. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12777. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12778. SetIndex++;
  12779. if (ChiRep.Count > 0)
  12780. {
  12781. foreach (var itemChi in ChiRep)
  12782. {
  12783. var txtTime = itemChi.Time;
  12784. var txtDetail = itemChi.Details;
  12785. if (indexChi > 0)
  12786. {
  12787. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12788. tableOne.AppendChild(CenterRowClone);
  12789. }
  12790. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12791. {
  12792. SetCells(tableOne, doc, SetIndex, 0, "");
  12793. SetCells(tableOne, doc, SetIndex, 1, "");
  12794. indexChi++;
  12795. SetIndex++;
  12796. break;
  12797. }
  12798. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12799. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12800. indexChi++;
  12801. SetIndex++;
  12802. }
  12803. }
  12804. else
  12805. {
  12806. if (indexChi > 0)
  12807. {
  12808. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12809. tableOne.AppendChild(CenterRowClone);
  12810. }
  12811. SetCells(tableOne, doc, SetIndex, 0, "");
  12812. SetCells(tableOne, doc, SetIndex, 1, "");
  12813. indexChi++;
  12814. SetIndex++;
  12815. }
  12816. index++;
  12817. }
  12818. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12819. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12820. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12821. jw.Code = 200;
  12822. jw.Msg = "";
  12823. return Ok(jw);
  12824. }
  12825. private string intToString(int numberVal)
  12826. {
  12827. string numberval = numberVal.ToString();
  12828. Dictionary<char, string> Number = new Dictionary<char, string>();
  12829. Number.Add('1', "一");
  12830. Number.Add('2', "二");
  12831. Number.Add('3', "三");
  12832. Number.Add('4', "四");
  12833. Number.Add('5', "五");
  12834. Number.Add('6', "六");
  12835. Number.Add('7', "七");
  12836. Number.Add('8', "八");
  12837. Number.Add('9', "九");
  12838. string stringNumberVal = string.Empty;
  12839. for (int i = 0; i < numberval.Length; i++)
  12840. {
  12841. if (i == 0)
  12842. {
  12843. stringNumberVal += Number[numberval[i]];
  12844. }
  12845. else if (i >= 1)
  12846. {
  12847. if (numberval[i] == '0')
  12848. {
  12849. stringNumberVal = "十";
  12850. }
  12851. else
  12852. {
  12853. stringNumberVal += "十" + Number[numberval[i]];
  12854. }
  12855. }
  12856. }
  12857. return stringNumberVal;
  12858. }
  12859. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12860. {
  12861. //获取table中的某个单元格,从0开始
  12862. Cell lshCell = table.Rows[rows].Cells[cells];
  12863. //将单元格中段落移除
  12864. foreach (Node item in lshCell.Paragraphs)
  12865. {
  12866. lshCell.Paragraphs.Remove(item);
  12867. }
  12868. if (val.Contains("\r\n"))
  12869. {
  12870. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12871. foreach (var item in spArr)
  12872. {
  12873. //新建一个段落
  12874. Paragraph p = new Paragraph(doc);
  12875. var r = new Run(doc, item);
  12876. //把设置的值赋给之前新建的段落
  12877. p.AppendChild(r);
  12878. //将此段落加到单元格内
  12879. lshCell.AppendChild(p);
  12880. }
  12881. }
  12882. else
  12883. {
  12884. //新建一个段落
  12885. Paragraph p = new Paragraph(doc);
  12886. var r = new Run(doc, val);
  12887. //把设置的值赋给之前新建的段落
  12888. p.AppendChild(r);
  12889. //将此段落加到单元格内
  12890. lshCell.AppendChild(p);
  12891. }
  12892. }
  12893. [HttpPost]
  12894. public async Task<IActionResult> ServerHttp(string paramStr)
  12895. {
  12896. paramStr = paramStr.TrimEnd('\'');
  12897. paramStr = paramStr.TrimStart('\'');
  12898. JsonView jw = JsonView(false);
  12899. JObject param = JObject.Parse(paramStr);
  12900. if (!param.ContainsKey("url"))
  12901. {
  12902. jw.Msg = "url null";
  12903. return Ok(jw);
  12904. }
  12905. string url = param["url"]!.ToString();
  12906. var methon = "get";
  12907. Dictionary<string, string> bodyValues = null;
  12908. Dictionary<string, string> headValues = null;
  12909. if (param.ContainsKey("methon"))
  12910. {
  12911. methon = param["methon"]!.ToString();
  12912. }
  12913. if (param.ContainsKey("header"))
  12914. {
  12915. var header = param["header"]!.ToString();
  12916. JObject headerJobject = JObject.Parse(header);
  12917. headValues = new Dictionary<string, string>();
  12918. foreach (JProperty item in headerJobject.Properties())
  12919. {
  12920. var value = item.Value.ToString();
  12921. var head = item.Path;
  12922. headValues.Add(head, value);
  12923. }
  12924. }
  12925. if (param.ContainsKey("body"))
  12926. {
  12927. var body = param["body"]!.ToString();
  12928. bodyValues = new Dictionary<string, string>();
  12929. JObject bodyJobject = JObject.Parse(body);
  12930. foreach (JProperty item in bodyJobject.Properties())
  12931. {
  12932. var value = item.Value.ToString();
  12933. var head = item.Path;
  12934. bodyValues.Add(head, value);
  12935. }
  12936. }
  12937. HttpClient client = new HttpClient();
  12938. string responseString = string.Empty;
  12939. if (param.ContainsKey("isJson"))
  12940. {
  12941. }
  12942. if (headValues != null)
  12943. {
  12944. foreach (var item in headValues.Keys)
  12945. {
  12946. client.DefaultRequestHeaders.Add(item, headValues[item]);
  12947. }
  12948. }
  12949. try
  12950. {
  12951. if (methon == "get")
  12952. {
  12953. responseString = await client.GetStringAsync(url);
  12954. }
  12955. else if (methon == "post")
  12956. {
  12957. if (bodyValues == null)
  12958. {
  12959. jw.Msg = "methon post body null";
  12960. return Ok(jw);
  12961. }
  12962. // 数据转化为 key=val 格式
  12963. var content = new FormUrlEncodedContent(bodyValues);
  12964. var response = await client.PostAsync(url, content);
  12965. // 获取数据
  12966. responseString = await response.Content.ReadAsStringAsync();
  12967. }
  12968. else
  12969. {
  12970. jw.Msg = "methon error";
  12971. }
  12972. jw = JsonView(true, "success", responseString);
  12973. }
  12974. catch (Exception ex)
  12975. {
  12976. jw.Msg = "error " + ex.Message;
  12977. jw.Data = ex.StackTrace;
  12978. }
  12979. finally
  12980. {
  12981. client.Dispose();
  12982. }
  12983. return Ok(jw);
  12984. }
  12985. #endregion
  12986. // /// <summary>
  12987. // ///
  12988. // /// </summary>
  12989. // /// <param name="_dto"></param>
  12990. // /// <returns></returns>
  12991. // [HttpPost]
  12992. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12993. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12994. // {
  12995. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12996. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  12997. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  12998. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12999. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13000. // dic_psg.Add("客人", 974);
  13001. // dic_psg.Add("司机", 975);
  13002. // dic_psg.Add("导游", 976);
  13003. // dic_psg.Add("公司内部人员", 977);
  13004. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13005. // foreach (var item in list_visa)
  13006. // {
  13007. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13008. // temp.Id = item.Id;
  13009. // temp.DIId = item.DIId;
  13010. // temp.VisaClient = item.VisaClient;
  13011. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13012. // temp.VisaCurrency = item.VisaCurrency;
  13013. // temp.IsThird = item.IsThird;
  13014. // if (dic_psg.ContainsKey(item.PassengerType))
  13015. // {
  13016. // temp.PassengerType = dic_psg[item.PassengerType];
  13017. // }
  13018. // else {
  13019. // temp.PassengerType = -1;
  13020. // }
  13021. // temp.VisaNumber = item.VisaNumber;
  13022. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13023. // temp.CreateUserId = item.Operators;
  13024. // DateTime dt_ct;
  13025. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13026. // if (b_ct)
  13027. // {
  13028. // temp.CreateTime = dt_ct;
  13029. // }
  13030. // else
  13031. // {
  13032. // temp.CreateTime = DateTime.Now;
  13033. // }
  13034. // temp.DeleteTime = "";
  13035. // temp.DeleteUserId = 0;
  13036. // temp.Remark = item.Remark;
  13037. // if (string.IsNullOrEmpty(temp.Remark)) {
  13038. // temp.Remark = "";
  13039. // }
  13040. // temp.IsDel = item.IsDel;
  13041. // temp.VisaDescription = item.VisaAttachment;
  13042. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13043. //([Id]
  13044. // ,[DIId]
  13045. // ,[VisaClient]
  13046. // ,[VisaPrice]
  13047. // ,[VisaCurrency]
  13048. // ,[IsThird]
  13049. // ,[PassengerType]
  13050. // ,[VisaNumber]
  13051. // ,[VisaFreeNumber]
  13052. // ,[CreateUserId]
  13053. // ,[CreateTime]
  13054. // ,[DeleteTime]
  13055. // ,[DeleteUserId]
  13056. // ,[Remark]
  13057. // ,[IsDel]
  13058. // ,[visaDescription])
  13059. // VALUES
  13060. // ({0},{1},'{2}',{3},{4}
  13061. //,{5},{6},{7},{8},{9}
  13062. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13063. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13064. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13065. //);
  13066. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13067. // }
  13068. // return Ok(JsonView(true, "操作成功!"));
  13069. // }
  13070. /// <summary>
  13071. /// 123132123
  13072. /// </summary>
  13073. /// <param name="_dto"></param>
  13074. /// <returns></returns>
  13075. [HttpPost]
  13076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13077. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13078. {
  13079. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13080. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13081. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13082. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13083. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13084. dicDetail.Add(789, 1034);
  13085. dicDetail.Add(790, 1035);
  13086. dicDetail.Add(791, 1036);
  13087. dicDetail.Add(792, 1037);
  13088. dicDetail.Add(793, 1038);
  13089. dicDetail.Add(794, 1039);
  13090. dicDetail.Add(795, 1040);
  13091. dicDetail.Add(796, 1041);
  13092. dicDetail.Add(797, 1042);
  13093. dicDetail.Add(798, 1043);
  13094. dicDetail.Add(801, 1044);
  13095. dicDetail.Add(802, 1045);
  13096. dicDetail.Add(803, 1046);
  13097. Dictionary<int, int> dic = new Dictionary<int, int>();
  13098. dic.Add(806, 1027);
  13099. dic.Add(807, 1028);
  13100. dic.Add(808, 1029);
  13101. dic.Add(809, 1030);
  13102. dic.Add(810, 1031);
  13103. dic.Add(811, 1032);
  13104. dic.Add(812, 1033);
  13105. foreach (var item in list_visa)
  13106. {
  13107. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13108. temp.Coefficient = item.coefficient;
  13109. DateTime dtCrt;
  13110. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13111. if (b1)
  13112. {
  13113. temp.CreateTime = dtCrt;
  13114. }
  13115. else
  13116. {
  13117. temp.CreateTime = DateTime.Now;
  13118. }
  13119. temp.CreateUserId = item.Operators;
  13120. temp.DeleteTime = "";
  13121. temp.DeleteUserId = 0;
  13122. temp.DiId = int.Parse(item.DIID);
  13123. temp.FilePath = item.FilePath;
  13124. temp.IsDel = item.IsDel;
  13125. temp.Price = item.Price;
  13126. temp.PriceCount = 1;
  13127. temp.PriceCurrency = item.Currency;
  13128. int detailId = 0;
  13129. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13130. {
  13131. detailId = dicDetail[item.PriceTypeDetail];
  13132. }
  13133. temp.PriceDetailType = detailId;
  13134. temp.PriceDt = DateTime.Now;
  13135. temp.PriceName = item.PriceName;
  13136. temp.PriceSum = item.Price;
  13137. int tid = 0;
  13138. if (dic.ContainsKey(item.PriceType))
  13139. {
  13140. tid = dic[item.PriceType];
  13141. }
  13142. temp.PriceType = tid;
  13143. temp.Remark = item.Remark;
  13144. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13145. }
  13146. return Ok(JsonView(true, "操作成功!"));
  13147. }
  13148. }
  13149. }