GroupsController.cs 711 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using Microsoft.AspNetCore.SignalR;
  6. using MySqlX.XDevAPI.Relational;
  7. using NPOI.HSSF.UserModel;
  8. using NPOI.SS.Format;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.File;
  14. using OASystem.API.OAMethodLib.Hub.HubClients;
  15. using OASystem.API.OAMethodLib.Hub.Hubs;
  16. using OASystem.API.OAMethodLib.JuHeAPI;
  17. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  18. using OASystem.Domain.Dtos.CRM;
  19. using OASystem.Domain.Dtos.FileDto;
  20. using OASystem.Domain.Dtos.Financial;
  21. using OASystem.Domain.Dtos.Groups;
  22. using OASystem.Domain.Entities.Customer;
  23. using OASystem.Domain.Entities.Financial;
  24. using OASystem.Domain.Entities.Groups;
  25. using OASystem.Domain.ViewModels.Groups;
  26. using OASystem.Infrastructure.Repositories.Financial;
  27. using OASystem.Infrastructure.Repositories.Groups;
  28. using Quartz.Util;
  29. using SqlSugar;
  30. using SqlSugar.Extensions;
  31. using System.Collections;
  32. using System.Data;
  33. using System.Diagnostics;
  34. using System.Globalization;
  35. using System.IO;
  36. using System.Reflection.PortableExecutable;
  37. using Ubiety.Dns.Core;
  38. using static OASystem.API.OAMethodLib.JWTHelper;
  39. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  40. using Bookmark = Aspose.Words.Bookmark;
  41. using Cell = Aspose.Words.Tables.Cell;
  42. using Table = Aspose.Words.Tables.Table;
  43. namespace OASystem.API.Controllers
  44. {
  45. /// <summary>
  46. /// 团组相关
  47. /// </summary>
  48. //[Authorize]
  49. [Route("api/[controller]/[action]")]
  50. public class GroupsController : ControllerBase
  51. {
  52. private readonly ILogger<GroupsController> _logger;
  53. private readonly GrpScheduleRepository _grpScheduleRep;
  54. private readonly IMapper _mapper;
  55. private readonly DelegationInfoRepository _groupRepository;
  56. private readonly TaskAssignmentRepository _taskAssignmentRep;
  57. private readonly AirTicketResRepository _airTicketResRep;
  58. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  59. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  60. private readonly DelegationEnDataRepository _delegationEnDataRep;
  61. private readonly DelegationVisaRepository _delegationVisaRep;
  62. private readonly VisaPriceRepository _visaPriceRep;
  63. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  64. private readonly HotelPriceRepository _hotelPriceRep;
  65. private readonly CustomersRepository _customersRep;
  66. private readonly MessageRepository _message;
  67. private readonly SqlSugarClient _sqlSugar;
  68. private readonly TourClientListRepository _tourClientListRep;
  69. private readonly TeamRateRepository _teamRateRep;
  70. #region 成本相关
  71. private readonly CheckBoxsRepository _checkBoxs;
  72. private readonly GroupCostRepository _GroupCostRepository;
  73. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  74. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  75. #endregion
  76. private readonly SetDataRepository _setDataRep;
  77. private string url;
  78. private string path;
  79. private readonly EnterExitCostRepository _enterExitCostRep;
  80. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  81. private readonly UsersRepository _usersRep;
  82. private readonly IJuHeApiService _juHeApi;
  83. private readonly InvertedListRepository _invertedListRep;
  84. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  85. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  86. private readonly ThreeCodeRepository _threeCodeRepository;
  87. private readonly HotelInquiryRepository _hotelInquiryRep;
  88. private readonly FeeAuditRepository _feeAuditRep;
  89. private readonly VisaCommissionRepository _visaCommissionRep;
  90. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  91. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  92. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  93. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  94. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  95. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  96. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  97. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  98. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  99. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep)
  100. {
  101. _logger = logger;
  102. _mapper = mapper;
  103. _grpScheduleRep = grpScheduleRep;
  104. _groupRepository = groupRepository;
  105. _taskAssignmentRep = taskAssignmentRep;
  106. _airTicketResRep = airTicketResRep;
  107. _sqlSugar = sqlSugar;
  108. url = AppSettingsHelper.Get("ExcelBaseUrl");
  109. path = AppSettingsHelper.Get("ExcelBasePath");
  110. if (!System.IO.Directory.Exists(path))
  111. {
  112. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  113. }
  114. _decreasePaymentsRep = decreasePaymentsRep;
  115. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  116. _delegationEnDataRep = delegationEnDataRep;
  117. _enterExitCostRep = enterExitCostRep;
  118. _delegationVisaRep = delegationVisaRep;
  119. _message = message;
  120. _visaPriceRep = visaPriceRep;
  121. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  122. _checkBoxs = checkBoxs;
  123. _GroupCostRepository = GroupCostRepository;
  124. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  125. _GroupCostParameterRepository = GroupCostParameterRepository;
  126. _hotelPriceRep = hotelPriceRep;
  127. _customersRep = customersRep;
  128. _setDataRep = setDataRep;
  129. _tourClientListRep = tourClientListRep;
  130. _teamRateRep = teamRateRep;
  131. _hubContext = hubContext;
  132. _usersRep = usersRep;
  133. _juHeApi = juHeApi;
  134. _invertedListRep = invertedListRep;
  135. _visaFeeInfoRep = visaFeeInfoRep;
  136. _ticketBlackCodeRep = ticketBlackCodeRep;
  137. _hotelInquiryRep = hotelInquiryRep;
  138. _threeCodeRepository = threeCodeRepository;
  139. _feeAuditRep = feeAuditRep;
  140. _visaCommissionRep = visaCommissionRep;
  141. _ffrRep = ffrRep;
  142. }
  143. #region 流程管控
  144. /// <summary>
  145. /// 获取团组流程管控信息
  146. /// </summary>
  147. /// <param name="paras">参数Json字符串</param>
  148. /// <returns></returns>
  149. [HttpPost]
  150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  151. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  152. {
  153. if (string.IsNullOrEmpty(_jsonDto.Paras))
  154. {
  155. return Ok(JsonView(false, "参数为空"));
  156. }
  157. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  158. if (_ScheduleDto != null)
  159. {
  160. if (_ScheduleDto.SearchType == 2)//获取列表
  161. {
  162. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  163. return Ok(JsonView(_grpScheduleViewList));
  164. }
  165. else//获取对象
  166. {
  167. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  168. if (_grpScheduleView != null)
  169. {
  170. return Ok(JsonView(_grpScheduleView));
  171. }
  172. }
  173. }
  174. else
  175. {
  176. return Ok(JsonView(false, "参数反序列化失败"));
  177. }
  178. return Ok(JsonView(false, "暂无数据!"));
  179. }
  180. /// <summary>
  181. /// 修改团组流程管控详细表数据
  182. /// </summary>
  183. /// <param name="paras"></param>
  184. /// <returns></returns>
  185. [HttpPost]
  186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  187. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  188. {
  189. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  190. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  191. .SetColumns(it => it.Duty == _detail.Duty)
  192. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  193. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  194. .SetColumns(it => it.JobContent == _detail.JobContent)
  195. .SetColumns(it => it.Remark == _detail.Remark)
  196. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  197. .Where(s => s.Id == dto.Id)
  198. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  199. .ExecuteCommandAsync();
  200. if (result > 0)
  201. {
  202. return Ok(JsonView(true, "保存成功!"));
  203. }
  204. return Ok(JsonView(false, "保存失败!"));
  205. }
  206. /// <summary>
  207. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  208. /// </summary>
  209. /// <param name="dto"></param>
  210. /// <returns></returns>
  211. [HttpPost]
  212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  213. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  214. {
  215. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  216. _detail.IsDel = 1;
  217. _detail.DeleteUserId = dto.Duty;
  218. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  219. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  220. .SetColumns(it => it.IsDel == _detail.IsDel)
  221. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  222. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  223. .Where(it => it.Id == dto.Id)
  224. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  225. //.WhereColumns(s => s.Id == dto.Id)
  226. .ExecuteCommandAsync();
  227. if (result > 0)
  228. {
  229. return Ok(JsonView(true, "删除成功!"));
  230. }
  231. return Ok(JsonView(false, "删除失败!"));
  232. }
  233. /// <summary>
  234. /// 增加团组流程管控详细表数据
  235. /// </summary>
  236. /// <param name="dto"></param>
  237. /// <returns></returns>
  238. [HttpPost]
  239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  240. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  241. {
  242. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  243. if (DateTime.Now < _detail.ExpectBeginDt)
  244. {
  245. _detail.StepStatus = 0;
  246. }
  247. else
  248. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  249. _detail.StepStatus = 1;
  250. }
  251. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  252. if (result > 0)
  253. {
  254. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  255. return Ok(JsonView(true, "添加成功!", _result));
  256. }
  257. return Ok(JsonView(false, "添加失败!"));
  258. }
  259. #endregion
  260. #region 团组基本信息
  261. /// <summary>
  262. /// 接团信息列表
  263. /// </summary>
  264. /// <param name="dto">团组列表请求dto</param>
  265. /// <returns></returns>
  266. [HttpPost]
  267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  268. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  269. {
  270. var groupData = await _groupRepository.GetGroupList(dto);
  271. if (groupData.Code != 0)
  272. {
  273. return Ok(JsonView(false, groupData.Msg));
  274. }
  275. return Ok(JsonView(groupData.Data));
  276. }
  277. /// <summary>
  278. /// 分页查询团组列表
  279. /// </summary>
  280. /// <param name="dto"></param>
  281. /// <returns></returns>
  282. [HttpPost]
  283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  284. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  285. {
  286. var watch = new Stopwatch();
  287. watch.Start();
  288. RefAsync<int> total = 0;
  289. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  290. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  291. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  292. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  293. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  294. .Distinct()
  295. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  296. watch.Stop();
  297. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  298. }
  299. /// <summary>
  300. /// 接团信息列表 Page
  301. /// </summary>
  302. /// <param name="dto">团组列表请求dto</param>
  303. /// <returns></returns>
  304. [HttpPost]
  305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  306. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  307. {
  308. #region 参数验证
  309. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  310. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  311. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  312. #region 页面操作权限验证
  313. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  314. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  315. #endregion
  316. #endregion
  317. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  318. {
  319. string sqlWhere = string.Empty;
  320. if (dto.IsSure == 0) //未完成
  321. {
  322. sqlWhere += string.Format(@" And IsSure = 0");
  323. }
  324. else if (dto.IsSure == 1) //已完成
  325. {
  326. sqlWhere += string.Format(@" And IsSure = 1");
  327. }
  328. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  329. {
  330. string tj = dto.SearchCriteria;
  331. 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}%')",
  332. tj, tj, tj, tj, tj);
  333. }
  334. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  335. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  336. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  337. JietuanOperator,IsSure,CreateTime,IsBid
  338. From (
  339. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  340. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  341. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  342. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  343. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  344. From Grp_DelegationInfo gdi
  345. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  346. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  347. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  348. Where gdi.IsDel = 0 {0}
  349. ) temp", sqlWhere);
  350. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  351. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  352. #region 处理所属部门
  353. /*
  354. * 1.sq 和 gyy 等显示 市场部
  355. * 2.王鸽和主管及张总还有管理员号统一国交部
  356. * 2-1. 4 管理员 ,21 张海麟
  357. */
  358. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  359. List<int> userIds1 = new List<int>() { 4, 21 };
  360. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  361. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  362. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  363. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  364. .ToList();
  365. foreach (var item in _DelegationList)
  366. {
  367. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  368. }
  369. #endregion
  370. var _view = new
  371. {
  372. PageFuncAuth = pageFunAuthView,
  373. Data = _DelegationList
  374. };
  375. return Ok(JsonView(true, "查询成功!", _view, total));
  376. }
  377. else
  378. {
  379. return Ok(JsonView(false, "查询失败"));
  380. }
  381. }
  382. /// <summary>
  383. /// 团组列表
  384. /// </summary>
  385. /// <returns></returns>
  386. [HttpPost]
  387. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  388. {
  389. #region 参数验证
  390. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  391. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  392. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  393. #region 页面操作权限验证
  394. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  395. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  396. #endregion
  397. #endregion
  398. if (dto.PortType != 1 && dto.PortType != 2)
  399. {
  400. return Ok(JsonView(false, "查询失败!"));
  401. }
  402. string orderbyStr = "order by gdi.CreateTime Desc";
  403. string sqlWhere = string.Empty;
  404. if (dto.IsSure == 0) //未完成
  405. {
  406. sqlWhere += string.Format(@" And IsSure = 0");
  407. }
  408. else if (dto.IsSure == 1) //已完成
  409. {
  410. sqlWhere += string.Format(@" And IsSure = 1");
  411. }
  412. //团组类型
  413. if (dto.TeamDid > 0)
  414. {
  415. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  416. }
  417. //团组名称
  418. if (!string.IsNullOrEmpty(dto.TeamName))
  419. {
  420. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  421. }
  422. //客户名称
  423. if (!string.IsNullOrEmpty(dto.ClientName))
  424. {
  425. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  426. }
  427. //客户单位
  428. if (!string.IsNullOrEmpty(dto.ClientUnit))
  429. {
  430. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  431. }
  432. //出访时间
  433. if (!string.IsNullOrEmpty(dto.visitDataTime))
  434. {
  435. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  436. orderbyStr = "order by gdi.VisitDate";
  437. }
  438. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  439. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  440. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  441. JietuanOperator,IsSure,CreateTime
  442. From (
  443. Select row_number() over({0}) as Row_Number,
  444. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  445. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  446. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  447. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  448. From Grp_DelegationInfo gdi
  449. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  450. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  451. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  452. Where gdi.IsDel = 0 {1}
  453. ) temp ", orderbyStr, sqlWhere);
  454. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  455. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  456. #region 处理所属部门
  457. /*
  458. * 1.sq 和 gyy 等显示 市场部
  459. * 2.王鸽和主管及张总还有管理员号统一国交部
  460. * 2-1. 4 管理员 ,21 张海麟
  461. */
  462. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  463. List<int> userIds1 = new List<int>() { 4, 21 };
  464. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  465. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  466. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  467. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  468. .ToList();
  469. foreach (var item in _DelegationList)
  470. {
  471. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  472. }
  473. #endregion
  474. var _view = new
  475. {
  476. PageFuncAuth = pageFunAuthView,
  477. Data = _DelegationList
  478. };
  479. return Ok(JsonView(true, "查询成功!", _view, total));
  480. }
  481. /// <summary>
  482. /// 接团信息详情
  483. /// </summary>
  484. /// <param name="dto">团组info请求dto</param>
  485. /// <returns></returns>
  486. [HttpPost]
  487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  488. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  489. {
  490. var groupData = await _groupRepository.GetGroupInfo(dto);
  491. if (groupData.Code != 0)
  492. {
  493. return Ok(JsonView(false, groupData.Msg));
  494. }
  495. return Ok(JsonView(groupData.Data));
  496. }
  497. /// <summary>
  498. /// 接团信息 编辑添加
  499. /// 基础信息数据源
  500. /// </summary>
  501. /// <param name="dto"></param>
  502. /// <returns></returns>
  503. [HttpPost]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  506. {
  507. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  508. if (groupData.Code != 0)
  509. {
  510. return Ok(JsonView(false, groupData.Msg));
  511. }
  512. return Ok(JsonView(groupData.Data));
  513. }
  514. /// <summary>
  515. /// 接团信息 操作(增改)
  516. /// </summary>
  517. /// <param name="dto"></param>
  518. /// <returns></returns>
  519. [HttpPost]
  520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  521. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  522. {
  523. try
  524. {
  525. decimal ffrPrice = 0.00M;
  526. DateTime? visitDt = null;
  527. if (dto.Status == 2)
  528. {
  529. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  530. if (groupInfo != null)
  531. {
  532. ffrPrice = groupInfo.PaymentMoney;
  533. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  534. }
  535. }
  536. var groupData = await _groupRepository.GroupOperation(dto);
  537. if (groupData.Code != 0)
  538. {
  539. return Ok(JsonView(false, groupData.Msg));
  540. }
  541. int diId = 0;
  542. //添加时 默认加入团组汇率
  543. if (dto.Status == 1) //添加
  544. {
  545. diId = groupData.Data;
  546. //添加默认币种
  547. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  548. //默认分配权限
  549. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  550. //消息提示 王鸽 主管号
  551. List<int> _managerIds = new List<int>() { 22, 32 };
  552. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  553. if (userIds.Count > 0)
  554. {
  555. userIds.Add(208);
  556. //创建团组管控
  557. GroupStepForDelegation.CreateWorkStep(diId);
  558. //发送消息
  559. string groupName = dto.TeamName;
  560. string createGroupUser = string.Empty;
  561. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  562. if (userInfo != null) createGroupUser = userInfo.CnName;
  563. string title = $"系统通知";
  564. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  565. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  566. }
  567. //默认创建倒推表
  568. await _invertedListRep._Create(dto.UserId, diId);
  569. }
  570. else if (dto.Status == 2)
  571. {
  572. diId = dto.Id;
  573. }
  574. #region 团组操作默认添加/修改收款账单
  575. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  576. {
  577. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  578. .Where(x => x.IsDel == 0 &&
  579. x.Diid == diId &&
  580. x.Remark.Equals("预付款")
  581. )
  582. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  583. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  584. .FirstAsync();
  585. ffrInfo = new Fin_ForeignReceivables()
  586. {
  587. Diid = diId,
  588. PriceName = dto.ClientUnit,
  589. Price = dto.PaymentMoney,
  590. Count = 1,
  591. Unit = $"元",
  592. ItemSumPrice = dto.PaymentMoney,
  593. Rate = 1.0000M,
  594. Currency = 836,
  595. AddingWay = 0,
  596. CreateUserId = dto.UserId,
  597. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  598. Remark = $"预付款"
  599. };
  600. if (ffrInfo == null) //Add
  601. {
  602. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  603. }
  604. else //修改
  605. {
  606. await _sqlSugar.Updateable(ffrInfo)
  607. .UpdateColumns(x => new
  608. {
  609. x.PriceName,
  610. x.Price,
  611. x.ItemSumPrice,
  612. x.CreateTime,
  613. x.CreateUserId
  614. })
  615. .WhereColumns(x => x.Id)
  616. .ExecuteCommandAsync();
  617. }
  618. }
  619. #endregion
  620. return Ok(JsonView(true, "操作成功!", diId));
  621. }
  622. catch (Exception ex)
  623. {
  624. Logs("[response]" + JsonConvert.SerializeObject(dto));
  625. Logs(ex.Message);
  626. return Ok(JsonView(false, ex.Message));
  627. }
  628. }
  629. /// <summary>
  630. /// 接团流程操作(增改)
  631. /// 安卓端使用 建团时添加客户名单
  632. /// </summary>
  633. /// <param name="dto"></param>
  634. /// <returns></returns>
  635. [HttpPost]
  636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  637. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  638. {
  639. try
  640. {
  641. #region 参数验证
  642. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  643. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  644. #region 页面操作权限验证
  645. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  646. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  647. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  648. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  649. #endregion
  650. #endregion
  651. _sqlSugar.BeginTran();
  652. decimal ffrPrice = 0.00M;
  653. DateTime? visitDt = null;
  654. if (dto.Status == 2)
  655. {
  656. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  657. if (groupInfo != null)
  658. {
  659. ffrPrice = groupInfo.PaymentMoney;
  660. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  661. }
  662. }
  663. var _dto = new GroupOperationDto();
  664. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  665. var groupData = await _groupRepository.GroupOperation(_dto);
  666. if (groupData.Code != 0)
  667. {
  668. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  669. }
  670. int diId = 0;
  671. //添加时 默认加入团组汇率
  672. if (dto.Status == 1) //添加
  673. {
  674. diId = groupData.Data;
  675. //添加默认币种
  676. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  677. //默认分配权限
  678. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  679. //消息提示 王鸽 主管号
  680. List<int> _managerIds = new List<int>() { 22, 32 };
  681. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  682. if (userIds.Count > 0)
  683. {
  684. userIds.Add(208);
  685. //创建团组管控
  686. GroupStepForDelegation.CreateWorkStep(diId);
  687. //发送消息
  688. string groupName = dto.TeamName;
  689. string createGroupUser = string.Empty;
  690. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  691. if (userInfo != null) createGroupUser = userInfo.CnName;
  692. string title = $"系统通知";
  693. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  694. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  695. }
  696. //默认创建倒推表
  697. await _invertedListRep._Create(dto.UserId, diId);
  698. }
  699. if (dto.Status == 2)
  700. {
  701. diId = dto.Id;
  702. if (diId == 0)
  703. {
  704. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  705. }
  706. }
  707. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  708. if (viewData.Code != 0)
  709. {
  710. _sqlSugar.RollbackTran();
  711. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  712. }
  713. #region 团组操作默认添加/修改收款账单
  714. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  715. {
  716. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  717. .Where(x => x.IsDel == 0 &&
  718. x.Diid == diId &&
  719. x.Remark.Equals("预付款")
  720. )
  721. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  722. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  723. .FirstAsync();
  724. ffrInfo = new Fin_ForeignReceivables()
  725. {
  726. Diid = diId,
  727. PriceName = dto.ClientUnit,
  728. Price = dto.PaymentMoney,
  729. Count = 1,
  730. Unit = $"元",
  731. ItemSumPrice = dto.PaymentMoney,
  732. Rate = 1.0000M,
  733. Currency = 836,
  734. AddingWay = 0,
  735. CreateUserId = dto.UserId,
  736. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  737. Remark = $"预付款"
  738. };
  739. if (ffrInfo == null) //Add
  740. {
  741. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  742. }
  743. else //修改
  744. {
  745. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  746. .UpdateColumns(x => new
  747. {
  748. x.PriceName,
  749. x.Price,
  750. x.ItemSumPrice,
  751. x.CreateTime,
  752. x.CreateUserId
  753. })
  754. .WhereColumns(x => x.Id)
  755. .ExecuteCommandAsync();
  756. }
  757. }
  758. #endregion
  759. _sqlSugar.CommitTran();
  760. return Ok(JsonView(true, "添加成功"));
  761. }
  762. catch (Exception ex)
  763. {
  764. _sqlSugar.RollbackTran();
  765. return Ok(JsonView(false, ex.Message));
  766. }
  767. }
  768. /// <summary>
  769. /// 接团信息 操作(删除)
  770. /// </summary>
  771. /// <param name="dto"></param>
  772. /// <returns></returns>
  773. [HttpPost]
  774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  775. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  776. {
  777. try
  778. {
  779. var groupData = await _groupRepository.GroupDel(dto);
  780. if (groupData.Code != 0)
  781. {
  782. return Ok(JsonView(false, groupData.Msg));
  783. }
  784. return Ok(JsonView(true));
  785. }
  786. catch (Exception ex)
  787. {
  788. Logs("[response]" + JsonConvert.SerializeObject(dto));
  789. Logs(ex.Message);
  790. return Ok(JsonView(false, ex.Message));
  791. }
  792. }
  793. /// <summary>
  794. /// 获取团组销售报价号
  795. /// 团组添加时 使用
  796. /// </summary>
  797. /// <returns></returns>
  798. [HttpPost]
  799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  800. public async Task<IActionResult> GetGroupSalesQuoteNo()
  801. {
  802. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  803. if (groupData.Code != 0)
  804. {
  805. return Ok(JsonView(false, groupData.Msg));
  806. }
  807. object salesQuoteNo = new
  808. {
  809. SalesQuoteNo = groupData.Data
  810. };
  811. return Ok(JsonView(salesQuoteNo));
  812. }
  813. /// <summary>
  814. /// 设置确认出团
  815. /// </summary>
  816. /// <param name="dto"></param>
  817. /// <returns></returns>
  818. [HttpPost]
  819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  820. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  821. {
  822. var groupData = await _groupRepository.ConfirmationGroup(dto);
  823. if (groupData.Code != 0)
  824. {
  825. return Ok(JsonView(false, groupData.Msg));
  826. }
  827. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  828. #region OA消息推送
  829. try
  830. {
  831. string groupName = groupInfo.TeamName;
  832. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  833. List<int> userIds = new List<int>();
  834. listUser.ForEach(s => userIds.Add(s.Id));
  835. string title = $"系统通知";
  836. string content = $"团组[{groupName}]已确认出团!";
  837. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  838. }
  839. catch (Exception ex)
  840. {
  841. }
  842. #endregion
  843. #region 应用推送
  844. try
  845. {
  846. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  847. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  848. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  849. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  850. {
  851. List<string> userList = new List<string>() { users.QiyeChatUserId };
  852. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  853. }
  854. }
  855. catch (Exception ex)
  856. {
  857. }
  858. #endregion
  859. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  860. return Ok(JsonView(true, "操作成功!", groupData.Data));
  861. }
  862. /// <summary>
  863. /// 获取团组名称data And 签证国别Data
  864. /// </summary>
  865. /// <param name="dto"></param>
  866. /// <returns></returns>
  867. [HttpPost]
  868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  869. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  870. {
  871. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  872. if (groupData.Code != 0)
  873. {
  874. return Ok(JsonView(false, groupData.Msg));
  875. }
  876. return Ok(JsonView(groupData.Data));
  877. }
  878. /// <summary>
  879. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  880. /// </summary>
  881. /// <returns></returns>
  882. [HttpPost]
  883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  884. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  885. {
  886. try
  887. {
  888. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  889. if (groupData.Code != 0)
  890. {
  891. return Ok(JsonView(false, groupData.Msg));
  892. }
  893. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  894. }
  895. catch (Exception ex)
  896. {
  897. return Ok(JsonView(false, "程序错误!"));
  898. throw;
  899. }
  900. }
  901. /// <summary>
  902. /// 团组清单 Excel
  903. /// </summary>
  904. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  905. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  906. /// <returns></returns>
  907. [HttpGet]
  908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  909. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  910. {
  911. DateTime _beginDt, _endDt;
  912. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  913. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  914. if (!beginBool && !endBool)
  915. {
  916. return Ok(JsonView(false, "开始或结束时间不正确!"));
  917. }
  918. string sql = string.Format(@"
  919. SELECT
  920. ROW_NUMBER,
  921. Id,
  922. SalesQuoteNo,
  923. TourCode,
  924. TeamTypeId,
  925. TeamType,
  926. TeamLevId,
  927. TeamLev,
  928. TeamName,
  929. ClientName,
  930. ClientUnit,
  931. VisitDate,
  932. VisitDays,
  933. VisitPNumber,
  934. JietuanOperatorId,
  935. JietuanOperator,
  936. IsSure,
  937. CreateTime,
  938. IsBid
  939. FROM
  940. (
  941. SELECT
  942. ROW_NUMBER() OVER(
  943. ORDER BY
  944. gdi.CreateTime Desc
  945. ) AS ROW_NUMBER,
  946. gdi.Id,
  947. SalesQuoteNo,
  948. TourCode,
  949. ssd.Id TeamTypeId,
  950. ssd.Name TeamType,
  951. ssd1.Id TeamLevId,
  952. ssd1.Name TeamLev,
  953. TeamName,
  954. ClientName,
  955. ClientUnit,
  956. VisitDate,
  957. VisitDays,
  958. VisitPNumber,
  959. JietuanOperator JietuanOperatorId,
  960. su.CnName JietuanOperator,
  961. IsSure,
  962. gdi.CreateTime,
  963. gdi.IsBid
  964. FROM
  965. Grp_DelegationInfo gdi
  966. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  967. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  968. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  969. WHERE
  970. gdi.IsDel = 0
  971. AND gdi.IsBid = 0
  972. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  973. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  974. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  975. #region 处理所属部门
  976. /*
  977. * 1.sq 和 gyy 等显示 市场部
  978. * 2.王鸽和主管及张总还有管理员号统一国交部
  979. * 2-1. 4 管理员 ,21 张海麟
  980. */
  981. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  982. List<int> userIds1 = new List<int>() { 4, 21 };
  983. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  984. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  985. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  986. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  987. .ToListAsync();
  988. foreach (var item in groupList)
  989. {
  990. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  991. }
  992. #endregion
  993. #region Excel
  994. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  995. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  996. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  997. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  998. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  999. //载入模板
  1000. WorkbookDesigner designer = new WorkbookDesigner();
  1001. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1002. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1003. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1004. dt.TableName = "GroupList";
  1005. designer.SetDataSource(dt);
  1006. designer.Process();
  1007. if (!Directory.Exists(savePath))
  1008. {
  1009. Directory.CreateDirectory(savePath);
  1010. }
  1011. string serverPath = $"{savePath}{fileName}";
  1012. designer.Workbook.Save(serverPath);
  1013. string rst = $"{servicePath}{ftpPath}{fileName}";
  1014. #endregion
  1015. return Ok(JsonView(true, "操作成功!", rst));
  1016. }
  1017. #endregion
  1018. #region 团组&签证
  1019. /// <summary>
  1020. /// 根据团组Id获取签证客户信息List
  1021. /// </summary>
  1022. /// <param name="dto">请求dto</param>
  1023. /// <returns></returns>
  1024. [HttpPost]
  1025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1026. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1027. {
  1028. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1029. if (groupData.Code != 0)
  1030. {
  1031. return Ok(JsonView(false, groupData.Msg));
  1032. }
  1033. return Ok(JsonView(groupData.Data));
  1034. }
  1035. /// <summary>
  1036. /// IOS获取团组签证拍照上传进度01(团组列表)
  1037. /// </summary>
  1038. /// <param name="dto">请求dto</param>
  1039. /// <returns></returns>
  1040. [HttpPost]
  1041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1042. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1043. {
  1044. if (dto == null)
  1045. {
  1046. return Ok(JsonView(false, "参数为空"));
  1047. }
  1048. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1049. return Ok(JsonView(visaList));
  1050. }
  1051. /// <summary>
  1052. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1053. /// </summary>
  1054. /// <returns></returns>
  1055. [HttpPost]
  1056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1057. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1058. {
  1059. if (dto == null)
  1060. {
  1061. return Ok(JsonView(false, "请求错误:"));
  1062. }
  1063. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1064. return Ok(JsonView(list));
  1065. }
  1066. /// <summary>
  1067. /// IOS获取团组签证拍照上传进度03(相册)
  1068. /// </summary>
  1069. /// <returns></returns>
  1070. [HttpPost]
  1071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1072. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1073. {
  1074. if (dto == null)
  1075. {
  1076. return Ok(JsonView(false, "请求错误:"));
  1077. }
  1078. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1079. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1080. list.ForEach(s => s.url = url);
  1081. return Ok(JsonView(list));
  1082. }
  1083. /// <summary>
  1084. /// IOS获取团组签证拍照上传进度04(图片上传)
  1085. /// </summary>
  1086. /// <param name="dto"></param>
  1087. /// <returns></returns>
  1088. [HttpPost]
  1089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1090. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1091. {
  1092. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1093. //if (!string.IsNullOrEmpty(result))
  1094. //{
  1095. //}
  1096. //else {
  1097. // return Ok(JsonView(false, "上传失败"));
  1098. //}
  1099. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1100. int sucNum = 0;
  1101. try
  1102. {
  1103. foreach (var item in dto.base64DataList)
  1104. {
  1105. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1106. string result = decodeBase64ToImage(item, imageName);
  1107. if (!string.IsNullOrEmpty(result))
  1108. {
  1109. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1110. pic.CreateUserId = dto.CreateUserId;
  1111. pic.PicName = imageName;
  1112. pic.PicPath = result;
  1113. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1114. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1115. if (insertResult > 0)
  1116. {
  1117. sucNum++;
  1118. }
  1119. }
  1120. }
  1121. }
  1122. catch (Exception ex)
  1123. {
  1124. return Ok(JsonView(false, ex.Message));
  1125. }
  1126. string msg = string.Format(@"成功上传{0}张", sucNum);
  1127. return Ok(JsonView(true, msg));
  1128. }
  1129. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1130. {
  1131. string filename = "";//声明一个string类型的相对路径
  1132. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1133. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1134. try//会有异常抛出,try,catch一下
  1135. {
  1136. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1137. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1138. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1139. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1140. //文件名称
  1141. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1142. //上传的文件的路径
  1143. string filePath = "";
  1144. if (!Directory.Exists(fileDir))
  1145. {
  1146. Directory.CreateDirectory(fileDir);
  1147. }
  1148. //上传的文件的路径
  1149. filePath = fileDir + filename;
  1150. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1151. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1152. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1153. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1154. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1155. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1156. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1157. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1158. bitmap.Dispose();
  1159. }
  1160. catch (Exception e)
  1161. {
  1162. string massage = e.Message;
  1163. Logs("IOS图片上传Error:" + massage);
  1164. //filename = e.Message;
  1165. }
  1166. return filename;//返回相对路径
  1167. }
  1168. /// <summary>
  1169. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1170. /// </summary>
  1171. /// <param name="dto"></param>
  1172. /// <returns></returns>
  1173. [HttpPost]
  1174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1175. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1176. {
  1177. if (dto == null)
  1178. {
  1179. return Ok(JsonView(false, "请求错误:"));
  1180. }
  1181. string msg = "参数错误";
  1182. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1183. {
  1184. try
  1185. {
  1186. //_delegationVisaRep.BeginTran();
  1187. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1188. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1189. .Where(s => s.Id == dto.visaProgressCustomerId)
  1190. .ExecuteCommandAsync();
  1191. if (updCount > 0 && dto.publishCode == 1)
  1192. {
  1193. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1194. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1195. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1196. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1197. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1198. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1199. if (groupData == null)
  1200. {
  1201. _delegationVisaRep.RollbackTran();
  1202. }
  1203. string title = string.Format(@"[签证进度更新]");
  1204. string content = string.Format(@"测试文本");
  1205. bool rst = await _message.AddMsg(new MessageDto()
  1206. {
  1207. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1208. IssuerId = dto.publisher,
  1209. Title = title,
  1210. Content = content,
  1211. ReleaseTime = DateTime.Now,
  1212. UIdList = new List<int> {
  1213. 234
  1214. }
  1215. });
  1216. if (rst)
  1217. {
  1218. return Ok(JsonView(true, "发送通知成功"));
  1219. }
  1220. }
  1221. //_delegationVisaRep.CommitTran();
  1222. }
  1223. catch (Exception)
  1224. {
  1225. //_delegationVisaRep.RollbackTran();
  1226. }
  1227. }
  1228. return Ok(JsonView(true, msg));
  1229. }
  1230. #endregion
  1231. #region 团组任务分配
  1232. /// <summary>
  1233. /// 团组任务分配初始化
  1234. /// </summary>
  1235. /// <param name="dto"></param>
  1236. /// <returns></returns>
  1237. [HttpPost]
  1238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1239. public async Task<IActionResult> GetTaskAssignmen()
  1240. {
  1241. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1242. if (groupData.Code != 0)
  1243. {
  1244. return Ok(JsonView(false, groupData.Msg));
  1245. }
  1246. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1247. }
  1248. /// <summary>
  1249. /// 团组任务分配查询
  1250. /// </summary>
  1251. /// <param name="dto"></param>
  1252. /// <returns></returns>
  1253. [HttpPost]
  1254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1255. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1256. {
  1257. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1258. if (groupData.Code != 0)
  1259. {
  1260. return Ok(JsonView(false, groupData.Msg));
  1261. }
  1262. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1263. }
  1264. /// <summary>
  1265. /// 团组任务分配操作
  1266. /// </summary>
  1267. /// <param name="dto"></param>
  1268. /// <returns></returns>
  1269. [HttpPost]
  1270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1271. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1272. {
  1273. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1274. if (groupData.Code != 0)
  1275. {
  1276. return Ok(JsonView(false, groupData.Msg));
  1277. }
  1278. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1279. }
  1280. /// <summary>
  1281. /// 团组任务分配
  1282. /// 批量分配
  1283. /// 查询团组
  1284. /// </summary>
  1285. /// <param name="dto"></param>
  1286. /// <returns></returns>
  1287. [HttpPost]
  1288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1289. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1290. {
  1291. //参数验证
  1292. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1293. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1294. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1295. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1296. }
  1297. /// <summary>
  1298. /// 团组任务分配
  1299. /// 批量分配
  1300. /// </summary>
  1301. /// <param name="dto"></param>
  1302. /// <returns></returns>
  1303. [HttpPost]
  1304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1305. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1306. {
  1307. //参数验证
  1308. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1309. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1310. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1311. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1312. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1313. }
  1314. #endregion
  1315. #region 团组费用审核
  1316. /// <summary>
  1317. /// 费用审核
  1318. /// 团组列表 Page
  1319. /// </summary>
  1320. /// <param name="_dto">团组列表请求dto</param>
  1321. /// <returns></returns>
  1322. [HttpPost]
  1323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1324. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1325. {
  1326. #region 参数验证
  1327. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1328. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1329. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1330. #region 页面操作权限验证
  1331. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1332. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1333. #endregion
  1334. #endregion
  1335. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1336. {
  1337. string sqlWhere = string.Empty;
  1338. if (_dto.IsSure == 0) //未完成
  1339. {
  1340. sqlWhere += string.Format(@" And IsSure = 0");
  1341. }
  1342. else if (_dto.IsSure == 1) //已完成
  1343. {
  1344. sqlWhere += string.Format(@" And IsSure = 1");
  1345. }
  1346. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1347. {
  1348. string tj = _dto.SearchCriteria;
  1349. 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}%')",
  1350. tj, tj, tj, tj, tj);
  1351. }
  1352. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1353. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1354. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1355. From (
  1356. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1357. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1358. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1359. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1360. From Grp_DelegationInfo gdi
  1361. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1362. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1363. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1364. Where gdi.IsDel = 0 {0}
  1365. ) temp ", sqlWhere);
  1366. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1367. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1368. var _view = new
  1369. {
  1370. PageFuncAuth = pageFunAuthView,
  1371. Data = _DelegationList
  1372. };
  1373. return Ok(JsonView(true, "查询成功!", _view, total));
  1374. }
  1375. else
  1376. {
  1377. return Ok(JsonView(false, "查询失败"));
  1378. }
  1379. }
  1380. /// <summary>
  1381. /// 获取团组费用审核
  1382. /// </summary>
  1383. /// <param name="paras">参数Json字符串</param>
  1384. /// <returns></returns>
  1385. [HttpPost]
  1386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1387. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1388. {
  1389. try
  1390. {
  1391. #region 参数验证
  1392. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1393. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1394. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1395. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1396. #region 页面操作权限验证
  1397. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1398. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1399. #endregion
  1400. #endregion
  1401. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1402. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1403. #region 费用清单
  1404. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1405. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1406. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1407. List<Grp_CreditCardPayment> entityList = _groupRepository
  1408. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1409. .Where(exp.ToExpression())
  1410. .ToList();
  1411. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1412. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1413. /*
  1414. * 76://酒店预订
  1415. */
  1416. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1417. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1418. .ToListAsync();
  1419. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1420. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1421. .ToListAsync();
  1422. /*
  1423. * 79://车/导游地接
  1424. */
  1425. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1426. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1427. .ToListAsync();
  1428. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1429. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1430. .ToListAsync();
  1431. /*
  1432. * 80: //签证
  1433. */
  1434. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1435. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1436. .ToListAsync();
  1437. /*
  1438. *81: //邀请/公务活动
  1439. */
  1440. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1441. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1442. .ToListAsync();
  1443. /*
  1444. * 82: //团组客户保险
  1445. */
  1446. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1447. /*
  1448. * Lable = 85 机票预订
  1449. */
  1450. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1451. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1452. .ToListAsync();
  1453. /*
  1454. * 85 机票预定
  1455. */
  1456. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1457. /*
  1458. * 98 其他款项
  1459. */
  1460. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1461. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1462. .ToListAsync();
  1463. /*
  1464. * 285:收款退还
  1465. */
  1466. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1467. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1468. .ToListAsync();
  1469. /*
  1470. * 1015: //超支费用
  1471. */
  1472. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1473. /*
  1474. * 币种信息
  1475. */
  1476. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1477. /*
  1478. * 车/导游地接 费用类型
  1479. */
  1480. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1481. /*
  1482. * 车/导游地接 费用类型
  1483. */
  1484. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1485. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1486. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1487. /*
  1488. * 用户信息
  1489. */
  1490. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1491. /*
  1492. * 费用模块
  1493. */
  1494. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1495. string priceModule = string.Empty;
  1496. if (sdPriceName != null)
  1497. {
  1498. priceModule = sdPriceName.Name;
  1499. }
  1500. /*
  1501. * 成本信息
  1502. */
  1503. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1504. decimal _groupRate = 0.0000M;
  1505. string _groupCurrencyCode = "-";
  1506. if (groupCost != null)
  1507. {
  1508. _groupRate = groupCost.Rate;
  1509. if (int.TryParse(groupCost.Currency, out int _currency))
  1510. {
  1511. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1512. }
  1513. else _groupCurrencyCode = groupCost.Currency;
  1514. }
  1515. string costContentSql = $"Select * From Grp_GroupCost";
  1516. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1517. //处理日期为空的天数
  1518. for (int i = 0; i < groupCostDetails.Count; i++)
  1519. if (i != 0)
  1520. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1521. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1522. /*
  1523. * 处理详情数据
  1524. */
  1525. foreach (var entity in entityList)
  1526. {
  1527. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1528. _detail.Id = entity.Id;
  1529. _detail.PriceName = priceModule;
  1530. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1531. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1532. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1533. /*
  1534. * 应付款金额
  1535. */
  1536. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1537. string PaymentCurrency_WaitPay = "Unknown";
  1538. string hotelCurrncyCode = "Unknown";
  1539. string hotelCurrncyName = "Unknown";
  1540. if (sdPaymentCurrency_WaitPay != null)
  1541. {
  1542. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1543. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1544. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1545. if (hotelCurrncyCode.Equals("CNY"))
  1546. {
  1547. entity.DayRate = 1.0000M;
  1548. }
  1549. }
  1550. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1551. /*
  1552. * 此次付款金额
  1553. */
  1554. decimal CurrPayStr = 0.00M,
  1555. OriginalCurrPay = 0.00M;
  1556. if (entity.PayPercentage == 0)
  1557. {
  1558. if (entity.PayThenMoney != 0)
  1559. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1560. }
  1561. else
  1562. {
  1563. if (entity.PayMoney != 0)
  1564. {
  1565. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1566. }
  1567. }
  1568. if (_dto.Label == 79)
  1569. {
  1570. string original = string.Empty;
  1571. if (hotelCurrncyCode.Equals("CNY"))
  1572. {
  1573. OriginalCurrPay = CurrPayStr;
  1574. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1575. }
  1576. else
  1577. {
  1578. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1579. //760 EUR(7600.00 CNY)
  1580. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1581. }
  1582. }
  1583. else
  1584. {
  1585. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1586. }
  1587. /*
  1588. * 剩余尾款
  1589. */
  1590. decimal BalanceStr = 0;
  1591. if (CurrPayStr != 0)
  1592. {
  1593. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1594. BalanceStr = 0;
  1595. else
  1596. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1597. }
  1598. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1599. /*
  1600. * Bus名称
  1601. */
  1602. _detail.BusName = "待增加";
  1603. /*
  1604. *费用所属
  1605. */
  1606. switch (entity.CTable)
  1607. {
  1608. case 76://酒店预订
  1609. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1610. if (hotelReservations != null)
  1611. {
  1612. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1613. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1614. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1615. string roomFeeStr = "", roomFeestr1 = "";
  1616. //是否比较房型价格
  1617. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1618. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1619. roomFeeStr += $"<br/>";
  1620. if (hotelReservations.SingleRoomPrice > 0)
  1621. {
  1622. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1623. __isSingle = true;
  1624. }
  1625. if (hotelReservations.DoubleRoomPrice > 0)
  1626. {
  1627. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1628. __isDouble = true;
  1629. }
  1630. if (hotelReservations.SuiteRoomPrice > 0)
  1631. {
  1632. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1633. __isSuite = true;
  1634. }
  1635. if (hotelReservations.OtherRoomPrice > 0)
  1636. {
  1637. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1638. __isOther = true;
  1639. }
  1640. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1641. else roomFeeStr += " 0.00 * 0";
  1642. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1643. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1644. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1645. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1646. /*
  1647. * 费用类型
  1648. * 1:房费
  1649. * 2:早餐
  1650. * 3:地税
  1651. * 4:城市税
  1652. * </summary>
  1653. */
  1654. //地税
  1655. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1656. if (governmentRentData != null)
  1657. {
  1658. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1659. governmentRentFee = governmentRentData.Price;
  1660. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1661. if (governmentRentCurrData != null)
  1662. {
  1663. governmentRentCode = governmentRentCurrData.Name;
  1664. governmentRentName = $"({governmentRentCurrData.Remark})";
  1665. }
  1666. }
  1667. //城市税
  1668. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1669. if (cityTaxData != null)
  1670. {
  1671. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1672. cityTaxFee = cityTaxData.Price;
  1673. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1674. if (cityTaxCurrData != null)
  1675. {
  1676. cityTaxCode = cityTaxCurrData.Name;
  1677. cityTaxName = $"({cityTaxCurrData.Remark})";
  1678. }
  1679. }
  1680. //酒店早餐
  1681. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1682. if (breakfastData != null)
  1683. {
  1684. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1685. breakfastFee = breakfastData.Price;
  1686. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1687. if (breakfastCurrData != null)
  1688. {
  1689. breakfastCode = breakfastCurrData.Name;
  1690. breakfastName = $"({breakfastCurrData.Remark})";
  1691. }
  1692. }
  1693. //房间费用
  1694. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1695. if (roomData != null)
  1696. {
  1697. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1698. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1699. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1700. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1701. roomFee = roomData.Price;
  1702. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1703. if (roomCurrData != null)
  1704. {
  1705. roomCode = roomCurrData.Name;
  1706. roomName = $"({roomCurrData.Remark})";
  1707. }
  1708. }
  1709. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1710. string hotelCostStr = "";
  1711. decimal hotelCsotTotal = 0.00M;
  1712. if (groupCost != null)
  1713. {
  1714. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1715. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1716. }
  1717. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1718. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1719. string hotelCost_day = "";
  1720. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1721. foreach (var item in hotelCostDetails1)
  1722. {
  1723. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1724. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1725. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1726. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1727. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1728. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1729. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1730. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1731. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1732. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1733. hotelCost_day += @$"</br>";
  1734. }
  1735. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1736. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1737. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1738. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1739. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1740. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1741. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1742. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1743. $"房间说明: {hotelReservations.Remark} <br/>" +
  1744. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1745. $"{hotelBreakfastStr}" +
  1746. $"{hotelGovernmentRentStr}" +
  1747. $"{hotelCityTaxStr}";
  1748. _detail.PriceNameContent = hotelReservations.HotelName;
  1749. }
  1750. break;
  1751. case 79://车/导游地接
  1752. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1753. if (touristGuideGroundReservations != null)
  1754. {
  1755. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1756. {
  1757. _detail.BusName = touristGuideGroundReservations.BusName;
  1758. }
  1759. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1760. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1761. //if (isInt)
  1762. //{
  1763. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1764. // if (cityInfo != null)
  1765. // {
  1766. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1767. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1768. // if (carFeeItem != null)
  1769. // {
  1770. // nameContent += $@"({carFeeItem.Name})";
  1771. // }
  1772. // _detail.PriceNameContent = nameContent;
  1773. // }
  1774. //}
  1775. //else
  1776. //{
  1777. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1778. //}
  1779. var touristGuideGroundReservationsContents =
  1780. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1781. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1782. foreach (var item in touristGuideGroundReservationsContents)
  1783. {
  1784. string typeName = "Unknown";
  1785. string carCurrencyCode = "Unknown";
  1786. string carCurrencyName = "Unknown";
  1787. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1788. if (carTypeData != null) typeName = carTypeData.Name;
  1789. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1790. if (currencyData != null)
  1791. {
  1792. carCurrencyCode = currencyData.Name;
  1793. carCurrencyName = currencyData.Remark;
  1794. }
  1795. //op、成本 币种是否一致
  1796. bool IsCurrencyAgreement = false;
  1797. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1798. string opCostStr = string.Empty;
  1799. decimal opCostTypePrice = 0.00M;
  1800. #region 处理成本各项费用
  1801. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1802. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1803. if (opCost.Count > 0)
  1804. {
  1805. switch (item.SId)
  1806. {
  1807. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1808. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1809. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1810. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1811. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1812. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1813. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1814. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1815. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1816. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1817. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1818. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1819. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1820. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1821. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1822. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1823. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1824. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1825. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1826. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1827. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1828. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1829. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1830. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1831. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1832. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1833. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1834. }
  1835. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1836. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1837. }
  1838. #endregion
  1839. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1840. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1841. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1842. $"{opTypeStr} {opCostStr}<br/>" +
  1843. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1844. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1845. }
  1846. _detail.PriceMsgContent = priceMsg;
  1847. }
  1848. break;
  1849. case 80: //签证
  1850. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1851. if (visaInfo != null)
  1852. {
  1853. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1854. _detail.PriceNameContent = visaInfo.VisaDescription;
  1855. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1856. }
  1857. break;
  1858. case 81: //邀请/公务活动
  1859. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1860. if (_ioa != null)
  1861. {
  1862. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1863. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1864. sendCurrName = "Unknown", //快递费用币种 Name
  1865. sendCurrCode = "Unknown", //快递费用币种 Code
  1866. eventsCurrName = "Unknown", //公务活动费币种 Name
  1867. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1868. translateCurrName = "Unknown", //公务翻译费 Name
  1869. translateCurrCode = "Unknown"; //公务翻译费 Code
  1870. #region 处理费用币种
  1871. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1872. if (inviteCurrData != null)
  1873. {
  1874. inviteCurrName = inviteCurrData.Remark;
  1875. inviteCurrCode = inviteCurrData.Name;
  1876. }
  1877. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1878. if (sendCurrData != null)
  1879. {
  1880. sendCurrName = sendCurrData.Remark;
  1881. sendCurrCode = sendCurrData.Name;
  1882. }
  1883. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1884. if (eventsCurrData != null)
  1885. {
  1886. eventsCurrName = eventsCurrData.Remark;
  1887. eventsCurrCode = eventsCurrData.Name;
  1888. }
  1889. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1890. if (translateCurrData != null)
  1891. {
  1892. translateCurrName = translateCurrData.Remark;
  1893. translateCurrCode = translateCurrData.Name;
  1894. }
  1895. #endregion
  1896. _detail.PriceNameContent = _ioa.InviterArea;
  1897. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1898. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1899. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1900. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1901. $@"备注:" + _ioa.Remark + "<br/>";
  1902. }
  1903. break;
  1904. case 82: //团组客户保险
  1905. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1906. if (customers != null)
  1907. {
  1908. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1909. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1910. }
  1911. break;
  1912. case 85: //机票预订
  1913. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1914. if (jpRes != null)
  1915. {
  1916. string FlightsDescription = jpRes.FlightsDescription;
  1917. string PriceDescription = jpRes.PriceDescription;
  1918. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1919. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1920. }
  1921. break;
  1922. case 98://其他款项
  1923. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1924. if (gdpRes != null)
  1925. {
  1926. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1927. _detail.PriceNameContent = gdpRes.PriceName;
  1928. }
  1929. break;
  1930. case 285://收款退还
  1931. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1932. if (refundAndOtherMoney != null)
  1933. {
  1934. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1935. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1936. }
  1937. break;
  1938. case 751://酒店早餐
  1939. break;
  1940. case 1015://超支费用
  1941. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1942. if (groupExtraCost != null)
  1943. {
  1944. _detail.PriceNameContent = groupExtraCost.PriceName;
  1945. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1946. }
  1947. break;
  1948. default:
  1949. break;
  1950. }
  1951. /*
  1952. * 申请人
  1953. */
  1954. string operatorName = " - ";
  1955. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1956. if (_opUser != null)
  1957. {
  1958. operatorName = _opUser.CnName;
  1959. }
  1960. _detail.OperatorName = operatorName;
  1961. /*
  1962. * 审核人
  1963. */
  1964. string auditOperatorName = "Unknown";
  1965. if (entity.AuditGMOperate == 0)
  1966. auditOperatorName = " - ";
  1967. else if (entity.AuditGMOperate == 4)
  1968. auditOperatorName = "自动审核";
  1969. else
  1970. {
  1971. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1972. if (_adUser != null)
  1973. {
  1974. auditOperatorName = _adUser.CnName;
  1975. }
  1976. }
  1977. _detail.AuditOperatorName = auditOperatorName;
  1978. /*
  1979. * 超预算比例
  1980. */
  1981. string overBudgetStr = "";
  1982. if (entity.ExceedBudget == -1)
  1983. overBudgetStr = sdPriceName.Name + "尚无预算";
  1984. else if (entity.ExceedBudget == 0)
  1985. {
  1986. if (entity.CTable == 76 || entity.CTable == 79)
  1987. {
  1988. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1989. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1990. }
  1991. else
  1992. {
  1993. overBudgetStr = "未超预算";
  1994. }
  1995. }
  1996. else
  1997. overBudgetStr = entity.ExceedBudget.ToString("P");
  1998. _detail.OverBudget = overBudgetStr;
  1999. /*
  2000. * 已审核金额
  2001. */
  2002. decimal auditFee = 0.00M;
  2003. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2004. /*
  2005. * 费用总计
  2006. */
  2007. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2008. {
  2009. CurrencyId = entity.PaymentCurrency,
  2010. CurrencyName = PaymentCurrency_WaitPay,
  2011. AmountPayable = entity.PayMoney,
  2012. ThisPayment = OriginalCurrPay,
  2013. BalancePayment = BalanceStr,
  2014. AuditedFunds = auditFee
  2015. });
  2016. _detail.IsAuditGM = entity.IsAuditGM;
  2017. detailList.Add(_detail);
  2018. }
  2019. #endregion
  2020. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2021. /*
  2022. * 下方描述处理
  2023. */
  2024. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2025. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2026. if (ccpCurrencyPrice != null)
  2027. {
  2028. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2029. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2030. }
  2031. else
  2032. {
  2033. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2034. }
  2035. string amountPayableStr = string.Format(@"应付款总金额: ");
  2036. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2037. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2038. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2039. foreach (var item in nonDuplicat)
  2040. {
  2041. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2042. if (strs.Count > 0)
  2043. {
  2044. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2045. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2046. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2047. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2048. //单独处理此次付款金额
  2049. if (item.CurrencyId == 836) //人民币
  2050. {
  2051. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2052. }
  2053. else
  2054. {
  2055. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2056. }
  2057. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2058. //单独处理已审核费用
  2059. if (item.CurrencyId == 836) //人民币
  2060. {
  2061. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2062. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2063. }
  2064. else
  2065. {
  2066. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2067. }
  2068. }
  2069. }
  2070. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2071. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2072. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2073. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2074. var _view1 = new
  2075. {
  2076. PageFuncAuth = pageFunAuthView,
  2077. Data = _view
  2078. };
  2079. return Ok(JsonView(_view1));
  2080. }
  2081. catch (Exception ex)
  2082. {
  2083. return Ok(JsonView(false, ex.Message));
  2084. }
  2085. }
  2086. /// <summary>
  2087. /// 费用审核
  2088. /// 修改团组费用审核状态
  2089. /// </summary>
  2090. /// <param name="_dto">参数Json字符串</param>
  2091. /// <returns></returns>
  2092. [HttpPost]
  2093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2094. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2095. {
  2096. #region 参数验证
  2097. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2098. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2099. #endregion
  2100. #region 页面操作权限验证
  2101. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2102. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2103. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2104. #endregion
  2105. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2106. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2107. DateTime dtNow = DateTime.Now;
  2108. _groupRepository.BeginTran();
  2109. int rst = 0;
  2110. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2111. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2112. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2113. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2114. List<dynamic> msgDatas = new List<dynamic>();
  2115. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2116. foreach (var item in idList)
  2117. {
  2118. int CreditId = int.Parse(item);
  2119. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2120. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2121. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2122. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2123. .Where(s => s.Id == CreditId)
  2124. .ExecuteCommandAsync();
  2125. if (result < 1)
  2126. {
  2127. rst = -1;
  2128. _groupRepository.RollbackTran();
  2129. return Ok(JsonView(false, "操作失败并回滚!"));
  2130. }
  2131. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2132. if (creditData != null)
  2133. {
  2134. #region 应用通知配置
  2135. try
  2136. {
  2137. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2138. }
  2139. catch (Exception ex)
  2140. {
  2141. }
  2142. #endregion
  2143. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2144. string groupNameStr = string.Empty;
  2145. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2146. if (groupData != null) groupNameStr = groupData.TeamName;
  2147. string creditTypeStr = string.Empty;
  2148. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2149. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2150. string creditCurrency = string.Empty;
  2151. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2152. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2153. if (creditCurrency.Equals("CNY"))
  2154. {
  2155. creditData.DayRate = 1.0000M;
  2156. }
  2157. if (creditData.PayPercentage == 0.00M)
  2158. {
  2159. creditData.PayPercentage = 100M;
  2160. }
  2161. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2162. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2163. string msgContent = "";
  2164. if (creditCurrency.Equals("CNY"))
  2165. {
  2166. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2167. }
  2168. else
  2169. {
  2170. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2171. }
  2172. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2173. }
  2174. }
  2175. if (rst == 0)
  2176. {
  2177. _groupRepository.CommitTran();
  2178. foreach (var item in msgDatas)
  2179. {
  2180. //发送消息
  2181. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2182. }
  2183. #region 应用推送
  2184. try
  2185. {
  2186. foreach (var ccpId in dic_ccp_user.Keys)
  2187. {
  2188. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2189. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2190. }
  2191. }
  2192. catch (Exception)
  2193. {
  2194. }
  2195. #endregion
  2196. return Ok(JsonView(true, "操作成功!"));
  2197. }
  2198. return Ok(JsonView(false, "操作失败!"));
  2199. }
  2200. #endregion
  2201. #region 机票费用录入
  2202. /// <summary>
  2203. /// 机票录入当前登录人可操作团组
  2204. /// </summary>
  2205. /// <param name="dto"></param>
  2206. /// <returns></returns>
  2207. [HttpPost]
  2208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2209. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2210. {
  2211. try
  2212. {
  2213. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2214. if (groupData.Code != 0)
  2215. {
  2216. return Ok(JsonView(false, groupData.Msg));
  2217. }
  2218. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2219. }
  2220. catch (Exception ex)
  2221. {
  2222. return Ok(JsonView(false, "程序错误!"));
  2223. throw;
  2224. }
  2225. }
  2226. /// <summary>
  2227. /// 机票费用录入列表
  2228. /// </summary>
  2229. /// <param name="dto"></param>
  2230. /// <returns></returns>
  2231. [HttpPost]
  2232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2233. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2234. {
  2235. try
  2236. {
  2237. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2238. if (groupData.Code != 0)
  2239. {
  2240. return Ok(JsonView(false, groupData.Msg));
  2241. }
  2242. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2243. }
  2244. catch (Exception ex)
  2245. {
  2246. return Ok(JsonView(false, ex.Message));
  2247. throw;
  2248. }
  2249. }
  2250. /// <summary>
  2251. /// 根据id查询费用录入信息
  2252. /// </summary>
  2253. /// <param name="dto"></param>
  2254. /// <returns></returns>
  2255. [HttpPost]
  2256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2257. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2258. {
  2259. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2260. if (groupData.Code != 0)
  2261. {
  2262. return Ok(JsonView(false, groupData.Msg));
  2263. }
  2264. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2265. }
  2266. /// <summary>
  2267. /// 机票费用录入操作(Status:1.新增,2.修改)
  2268. /// </summary>
  2269. /// <param name="dto"></param>
  2270. /// <returns></returns>
  2271. [HttpPost]
  2272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2273. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2274. {
  2275. try
  2276. {
  2277. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2278. if (groupData.Code != 0)
  2279. {
  2280. return Ok(JsonView(false, groupData.Msg));
  2281. }
  2282. #region 应用推送
  2283. try
  2284. {
  2285. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2286. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2287. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2288. }
  2289. catch (Exception ex)
  2290. {
  2291. }
  2292. #endregion
  2293. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2294. }
  2295. catch (Exception ex)
  2296. {
  2297. return Ok(JsonView(false, "程序错误!"));
  2298. throw;
  2299. }
  2300. }
  2301. /// <summary>
  2302. /// 根据舱位类型查询接团客户名单信息
  2303. /// </summary>
  2304. /// <param name="dto"></param>
  2305. /// <returns></returns>
  2306. [HttpPost]
  2307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2308. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2309. {
  2310. try
  2311. {
  2312. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2313. if (crm_Groups.Count != 0)
  2314. {
  2315. List<dynamic> Customer = new List<dynamic>();
  2316. foreach (var item in crm_Groups)
  2317. {
  2318. var data = new
  2319. {
  2320. Id = item.Id,
  2321. Pinyin = item.Pinyin,
  2322. Name = item.LastName + item.FirstName
  2323. };
  2324. Customer.Add(data);
  2325. }
  2326. return Ok(JsonView(true, "查询成功!", Customer));
  2327. }
  2328. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2329. }
  2330. catch (Exception ex)
  2331. {
  2332. return Ok(JsonView(false, "程序错误!"));
  2333. throw;
  2334. }
  2335. }
  2336. /// <summary>
  2337. /// 根据团号获取客户信息
  2338. /// </summary>
  2339. /// <param name="dto"></param>
  2340. /// <returns></returns>
  2341. [HttpPost]
  2342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2343. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2344. {
  2345. var jw = JsonView(false);
  2346. if (dto.DIID < 1)
  2347. {
  2348. jw.Msg += "请输入正确的diid";
  2349. return Ok(jw);
  2350. }
  2351. var arr = getSimplClientList(dto.DIID);
  2352. jw = JsonView(true, "获取成功!", arr);
  2353. return Ok(jw);
  2354. }
  2355. private List<SimplClientInfo> getSimplClientList(int diId)
  2356. {
  2357. 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);
  2358. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2359. return arr;
  2360. }
  2361. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2362. {
  2363. string result = origin;
  2364. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2365. {
  2366. string[] temparr = origin.Split(',');
  2367. string fistrStr = temparr[0];
  2368. int count = temparr.Count();
  2369. int tempId;
  2370. bool success = int.TryParse(fistrStr, out tempId);
  2371. if (success)
  2372. {
  2373. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2374. if (tempInfo != null)
  2375. {
  2376. if (count > 1)
  2377. {
  2378. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2379. }
  2380. else
  2381. {
  2382. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2383. }
  2384. }
  2385. }
  2386. }
  2387. return result;
  2388. }
  2389. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2390. {
  2391. string result = origin;
  2392. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2393. {
  2394. string[] temparr = origin.Split(',');
  2395. result = "";
  2396. foreach (var item in temparr)
  2397. {
  2398. int tempId;
  2399. bool success = int.TryParse(item, out tempId);
  2400. if (success)
  2401. {
  2402. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2403. if (tempInfo != null)
  2404. {
  2405. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2406. }
  2407. }
  2408. }
  2409. }
  2410. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2411. return result;
  2412. }
  2413. /// <summary>
  2414. /// 机票费用录入,删除
  2415. /// </summary>
  2416. /// <param name="dto"></param>
  2417. /// <returns></returns>
  2418. [HttpPost]
  2419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2420. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2421. {
  2422. try
  2423. {
  2424. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2425. if (res)
  2426. {
  2427. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2428. {
  2429. IsDel = 1,
  2430. DeleteUserId = dto.DeleteUserId,
  2431. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2432. }).ExecuteCommandAsync();
  2433. return Ok(JsonView(true, "删除成功!"));
  2434. }
  2435. return Ok(JsonView(false, "删除失败!"));
  2436. }
  2437. catch (Exception ex)
  2438. {
  2439. return Ok(JsonView(false, "程序错误!"));
  2440. throw;
  2441. }
  2442. }
  2443. /// <summary>
  2444. /// 导出机票录入报表
  2445. /// </summary>
  2446. /// <param name="dto"></param>
  2447. /// <returns></returns>
  2448. [HttpPost]
  2449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2450. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2451. {
  2452. try
  2453. {
  2454. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2455. if (groupData.Code != 0)
  2456. {
  2457. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2458. }
  2459. else
  2460. {
  2461. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2462. if (AirTicketReservations.Count != 0)
  2463. {
  2464. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2465. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2466. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2467. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2468. WorkbookDesigner designer = new WorkbookDesigner();
  2469. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2470. decimal countCost = 0;
  2471. foreach (var item in AirTicketReservations)
  2472. {
  2473. #region 处理客人姓名
  2474. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2475. item.ClientName = clientNames;
  2476. #endregion
  2477. if (item.BankType == "其他")
  2478. {
  2479. item.BankNo = "--";
  2480. }
  2481. else
  2482. {
  2483. if (!string.IsNullOrEmpty(item.BankType))
  2484. {
  2485. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2486. }
  2487. }
  2488. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2489. item.Price = System.Decimal.Round(item.Price, 2);
  2490. countCost += Convert.ToDecimal(item.Price);
  2491. }
  2492. designer.SetDataSource("Export", AirTicketReservations);
  2493. designer.SetDataSource("ExportDiCode", diCode);
  2494. designer.SetDataSource("ExportDiName", diName);
  2495. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2496. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2497. designer.Process();
  2498. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2499. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2500. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2501. return Ok(JsonView(true, "成功", url = rst));
  2502. }
  2503. else
  2504. {
  2505. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2506. }
  2507. }
  2508. }
  2509. catch (Exception ex)
  2510. {
  2511. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2512. throw;
  2513. }
  2514. }
  2515. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2516. /// <summary>
  2517. /// 行程单导出
  2518. /// </summary>
  2519. /// <param name="dto"></param>
  2520. /// <returns></returns>
  2521. [HttpPost]
  2522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2523. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2524. {
  2525. try
  2526. {
  2527. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2528. if (groupData.Code != 0)
  2529. {
  2530. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2531. }
  2532. else
  2533. {
  2534. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2535. if (dto.Language == "CN")
  2536. {
  2537. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2538. DocumentBuilder builder = new DocumentBuilder(doc);
  2539. int tableIndex = 0;//表格索引
  2540. //得到文档中的第一个表格
  2541. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2542. foreach (var item in _AirTicketReservations)
  2543. {
  2544. #region 处理固定数据
  2545. string[] FlightsCode = item.FlightsCode.Split('/');
  2546. if (FlightsCode.Length != 0)
  2547. {
  2548. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2549. if (_AirCompany != null)
  2550. {
  2551. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2552. }
  2553. else
  2554. {
  2555. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2556. }
  2557. }
  2558. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2559. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2560. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2561. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2562. string name = "";
  2563. foreach (string clientName in nameArray)
  2564. {
  2565. if (!name.Contains(clientName))
  2566. {
  2567. name += clientName + ",";
  2568. }
  2569. }
  2570. if (!string.IsNullOrWhiteSpace(name))
  2571. {
  2572. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2573. }
  2574. else
  2575. {
  2576. table.Range.Bookmarks["ClientName"].Text = "--";
  2577. }
  2578. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2579. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2580. table.Range.Bookmarks["JointTicket"].Text = "--";
  2581. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2582. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2583. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2584. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2585. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2586. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2587. #endregion
  2588. #region 循环数据处理
  2589. List<AirInfo> airs = new List<AirInfo>();
  2590. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2591. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2592. for (int i = 0; i < FlightsCode.Length; i++)
  2593. {
  2594. AirInfo air = new AirInfo();
  2595. string[] tempstr = DayArray[i]
  2596. .Replace("\r\n", string.Empty)
  2597. .Replace("\\r\\n", string.Empty)
  2598. .TrimStart().TrimEnd()
  2599. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2600. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2601. string starCity = "";
  2602. if (star_Three != null)
  2603. {
  2604. starCity = star_Three.AirPort;
  2605. }
  2606. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2607. string EndCity = "";
  2608. if (End_Three != null)
  2609. {
  2610. EndCity = End_Three.AirPort;
  2611. }
  2612. air.Destination = starCity + "/" + EndCity;
  2613. air.Flight = FlightsCode[i];
  2614. air.SeatingClass = item.CTypeName;
  2615. string dateTime = tempstr[2];
  2616. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2617. air.FlightDate = DateTemp;
  2618. air.DepartureTime = tempstr[5];
  2619. air.LandingTime = tempstr[6];
  2620. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2621. air.TicketStatus = "--";
  2622. air.Luggage = "--";
  2623. air.DepartureTerminal = "--";
  2624. air.LandingTerminal = "--";
  2625. airs.Add(air);
  2626. }
  2627. int row = 13;
  2628. for (int i = 0; i < airs.Count; i++)
  2629. {
  2630. if (airs.Count > 2)
  2631. {
  2632. for (int j = 0; j < airs.Count - 2; j++)
  2633. {
  2634. var CopyRow = table.Rows[12].Clone(true);
  2635. table.Rows.Add(CopyRow);
  2636. }
  2637. }
  2638. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2639. int index = 0;
  2640. foreach (PropertyInfo property in properties)
  2641. {
  2642. string value = property.GetValue(airs[i]).ToString();
  2643. Cell ishcel0 = table.Rows[row].Cells[index];
  2644. Paragraph p = new Paragraph(doc);
  2645. string s = value;
  2646. p.AppendChild(new Run(doc, s));
  2647. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2648. ishcel0.AppendChild(p);
  2649. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2650. index++;
  2651. }
  2652. row++;
  2653. }
  2654. #endregion
  2655. Paragraph lastParagraph = new Paragraph(doc);
  2656. //第一个表格末尾加段落
  2657. table.ParentNode.InsertAfter(lastParagraph, table);
  2658. //复制第一个表格
  2659. Table cloneTable = (Table)table.Clone(true);
  2660. //在文档末尾段落后面加入复制的表格
  2661. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2662. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2663. {
  2664. int rownewsIndex = 13;
  2665. for (int i = 0; i < 2; i++)
  2666. {
  2667. var CopyRow = table.Rows[12].Clone(true);
  2668. table.Rows.RemoveAt(13);
  2669. table.Rows.Add(CopyRow);
  2670. rownewsIndex++;
  2671. }
  2672. }
  2673. else
  2674. {
  2675. table.Rows.RemoveAt(12);
  2676. }
  2677. cloneTable.Rows.RemoveAt(12);
  2678. }
  2679. if (_AirTicketReservations.Count != 0)
  2680. {
  2681. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2682. if (FlightsCode.Length != 0)
  2683. {
  2684. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2685. if (_AirCompany != null)
  2686. {
  2687. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2688. }
  2689. else
  2690. {
  2691. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2692. }
  2693. }
  2694. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2695. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2696. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2697. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2698. string name = "";
  2699. foreach (string clientName in nameArray)
  2700. {
  2701. if (!name.Contains(clientName))
  2702. {
  2703. name += clientName + ",";
  2704. }
  2705. }
  2706. if (!string.IsNullOrWhiteSpace(name))
  2707. {
  2708. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2709. }
  2710. else
  2711. {
  2712. table.Range.Bookmarks["ClientName"].Text = "--";
  2713. }
  2714. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2715. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2716. table.Range.Bookmarks["JointTicket"].Text = "--";
  2717. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2718. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2719. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2720. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2721. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2722. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2723. }
  2724. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2725. //保存合并后的文档
  2726. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2727. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2728. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2729. return Ok(JsonView(true, "成功!", rst));
  2730. }
  2731. else
  2732. {
  2733. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2734. DocumentBuilder builder = new DocumentBuilder(doc);
  2735. int tableIndex = 0;//表格索引
  2736. //得到文档中的第一个表格
  2737. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2738. List<string> texts = new List<string>();
  2739. foreach (var item in _AirTicketReservations)
  2740. {
  2741. string[] FlightsCode = item.FlightsCode.Split('/');
  2742. if (FlightsCode.Length != 0)
  2743. {
  2744. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2745. if (_AirCompany != null)
  2746. {
  2747. if (!transDic.ContainsKey(_AirCompany.CnName))
  2748. {
  2749. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2750. }
  2751. }
  2752. else
  2753. {
  2754. if (!transDic.ContainsKey("--"))
  2755. {
  2756. transDic.Add("--", "--");
  2757. }
  2758. }
  2759. }
  2760. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2761. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2762. string name = "";
  2763. foreach (string clientName in nameArray)
  2764. {
  2765. name += clientName + ",";
  2766. }
  2767. if (!texts.Contains(name))
  2768. {
  2769. texts.Add(name);
  2770. }
  2771. List<AirInfo> airs = new List<AirInfo>();
  2772. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2773. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2774. for (int i = 0; i < FlightsCode.Length; i++)
  2775. {
  2776. AirInfo air = new AirInfo();
  2777. string[] tempstr = DayArray[i]
  2778. .Replace("\r\n", string.Empty)
  2779. .Replace("\\r\\n", string.Empty)
  2780. .TrimStart().TrimEnd()
  2781. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2782. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2783. if (star_Three != null)
  2784. {
  2785. if (!transDic.ContainsKey(star_Three.AirPort))
  2786. {
  2787. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2788. }
  2789. }
  2790. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2791. if (End_Three != null)
  2792. {
  2793. if (!transDic.ContainsKey(End_Three.AirPort))
  2794. {
  2795. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2796. }
  2797. }
  2798. if (!texts.Contains(item.CTypeName))
  2799. {
  2800. texts.Add(item.CTypeName);
  2801. }
  2802. }
  2803. }
  2804. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2805. if (transData.Count > 0)
  2806. {
  2807. foreach (TranslateResult item in transData)
  2808. {
  2809. if (!transDic.ContainsKey(item.Query))
  2810. {
  2811. transDic.Add(item.Query, item.Translation);
  2812. }
  2813. }
  2814. }
  2815. foreach (var item in _AirTicketReservations)
  2816. {
  2817. #region 处理固定数据
  2818. string[] FlightsCode = item.FlightsCode.Split('/');
  2819. if (FlightsCode.Length != 0)
  2820. {
  2821. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2822. if (_AirCompany != null)
  2823. {
  2824. string str = "--";
  2825. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2826. if (!string.IsNullOrEmpty(translateResult))
  2827. {
  2828. str = translateResult;
  2829. str = _airTicketResRep.Processing(str);
  2830. }
  2831. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2832. }
  2833. else
  2834. {
  2835. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2836. }
  2837. }
  2838. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2839. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2840. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2841. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2842. string names = "";
  2843. foreach (string clientName in nameArray)
  2844. {
  2845. names += clientName + ",";
  2846. }
  2847. if (!string.IsNullOrWhiteSpace(names))
  2848. {
  2849. string str = "--";
  2850. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2851. if (!string.IsNullOrEmpty(translateResult))
  2852. {
  2853. str = translateResult;
  2854. str = _airTicketResRep.Processing(str);
  2855. }
  2856. table.Range.Bookmarks["ClientName"].Text = str;
  2857. }
  2858. else
  2859. {
  2860. table.Range.Bookmarks["ClientName"].Text = "--";
  2861. }
  2862. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2863. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2864. table.Range.Bookmarks["JointTicket"].Text = "--";
  2865. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2866. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2867. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2868. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2869. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2870. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2871. #endregion
  2872. #region 循环数据处理
  2873. List<AirInfo> airs = new List<AirInfo>();
  2874. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2875. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2876. for (int i = 0; i < FlightsCode.Length; i++)
  2877. {
  2878. AirInfo air = new AirInfo();
  2879. string[] tempstr = DayArray[i]
  2880. .Replace("\r\n", string.Empty)
  2881. .Replace("\\r\\n", string.Empty)
  2882. .TrimStart().TrimEnd()
  2883. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2884. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2885. string starCity = "";
  2886. if (star_Three != null)
  2887. {
  2888. string str2 = "--";
  2889. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2890. if (!string.IsNullOrEmpty(translateResult2))
  2891. {
  2892. str2 = translateResult2;
  2893. str2 = _airTicketResRep.Processing(str2);
  2894. }
  2895. starCity = str2;
  2896. }
  2897. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2898. string EndCity = "";
  2899. if (End_Three != null)
  2900. {
  2901. string str1 = "--";
  2902. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2903. if (!string.IsNullOrEmpty(translateResult1))
  2904. {
  2905. str1 = translateResult1;
  2906. str1 = _airTicketResRep.Processing(str1);
  2907. }
  2908. EndCity = str1;
  2909. }
  2910. air.Destination = starCity + "/" + EndCity;
  2911. air.Flight = FlightsCode[i];
  2912. string str = "--";
  2913. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2914. if (!string.IsNullOrEmpty(translateResult))
  2915. {
  2916. str = translateResult;
  2917. str = _airTicketResRep.Processing(str);
  2918. }
  2919. air.SeatingClass = str;
  2920. string dateTime = tempstr[2];
  2921. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2922. air.FlightDate = DateTemp;
  2923. air.DepartureTime = tempstr[5];
  2924. air.LandingTime = tempstr[6];
  2925. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2926. air.TicketStatus = "--";
  2927. air.Luggage = "--";
  2928. air.DepartureTerminal = "--";
  2929. air.LandingTerminal = "--";
  2930. airs.Add(air);
  2931. }
  2932. int row = 13;
  2933. for (int i = 0; i < airs.Count; i++)
  2934. {
  2935. if (airs.Count > 2)
  2936. {
  2937. for (int j = 0; j < airs.Count - 2; j++)
  2938. {
  2939. var CopyRow = table.Rows[12].Clone(true);
  2940. table.Rows.Add(CopyRow);
  2941. }
  2942. }
  2943. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2944. int index = 0;
  2945. foreach (PropertyInfo property in properties)
  2946. {
  2947. string value = property.GetValue(airs[i]).ToString();
  2948. Cell ishcel0 = table.Rows[row].Cells[index];
  2949. Paragraph p = new Paragraph(doc);
  2950. string s = value;
  2951. p.AppendChild(new Run(doc, s));
  2952. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2953. ishcel0.AppendChild(p);
  2954. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2955. //ishcel0.CellFormat.VerticalAlignment=
  2956. index++;
  2957. }
  2958. row++;
  2959. }
  2960. #endregion
  2961. Paragraph lastParagraph = new Paragraph(doc);
  2962. //第一个表格末尾加段落
  2963. table.ParentNode.InsertAfter(lastParagraph, table);
  2964. //复制第一个表格
  2965. Table cloneTable = (Table)table.Clone(true);
  2966. //在文档末尾段落后面加入复制的表格
  2967. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2968. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2969. {
  2970. int rownewsIndex = 13;
  2971. for (int i = 0; i < 2; i++)
  2972. {
  2973. var CopyRow = table.Rows[12].Clone(true);
  2974. table.Rows.RemoveAt(13);
  2975. table.Rows.Add(CopyRow);
  2976. rownewsIndex++;
  2977. }
  2978. }
  2979. else
  2980. {
  2981. table.Rows.RemoveAt(12);
  2982. }
  2983. cloneTable.Rows.RemoveAt(12);
  2984. }
  2985. if (_AirTicketReservations.Count != 0)
  2986. {
  2987. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2988. if (FlightsCode.Length != 0)
  2989. {
  2990. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2991. if (_AirCompany != null)
  2992. {
  2993. string str = "--";
  2994. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2995. if (!string.IsNullOrEmpty(translateResult))
  2996. {
  2997. str = translateResult;
  2998. str = _airTicketResRep.Processing(str);
  2999. }
  3000. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3001. }
  3002. else
  3003. {
  3004. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3005. }
  3006. }
  3007. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3008. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3009. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3010. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3011. string names = "";
  3012. foreach (string clientName in nameArray)
  3013. {
  3014. names += clientName + ",";
  3015. }
  3016. if (!string.IsNullOrWhiteSpace(names))
  3017. {
  3018. string str = "--";
  3019. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3020. if (!string.IsNullOrEmpty(translateResult))
  3021. {
  3022. str = translateResult;
  3023. str = _airTicketResRep.Processing(str);
  3024. }
  3025. table.Range.Bookmarks["ClientName"].Text = str;
  3026. }
  3027. else
  3028. {
  3029. table.Range.Bookmarks["ClientName"].Text = "--";
  3030. }
  3031. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3032. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3033. table.Range.Bookmarks["JointTicket"].Text = "--";
  3034. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3035. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3036. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3037. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3038. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3039. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3040. }
  3041. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3042. //保存合并后的文档
  3043. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3044. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3045. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3046. return Ok(JsonView(true, "成功!", rst));
  3047. }
  3048. }
  3049. }
  3050. catch (Exception ex)
  3051. {
  3052. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3053. throw;
  3054. }
  3055. }
  3056. #endregion
  3057. #region 团组增减款项 --> 其他款项
  3058. /// <summary>
  3059. /// 团组增减款项下拉框绑定
  3060. /// </summary>
  3061. /// <param name="dto"></param>
  3062. /// <returns></returns>
  3063. [HttpPost]
  3064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3065. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3066. {
  3067. #region 参数验证
  3068. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3069. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3070. #endregion
  3071. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3072. }
  3073. /// <summary>
  3074. /// 根据团组Id查询团组增减款项
  3075. /// </summary>
  3076. /// <param name="dto"></param>
  3077. /// <returns></returns>
  3078. [HttpPost]
  3079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3080. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3081. {
  3082. #region 参数验证
  3083. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3084. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3085. #endregion
  3086. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3087. }
  3088. /// <summary>
  3089. /// 团组增减款项操作(Status:1.新增,2.修改)
  3090. /// </summary>
  3091. /// <param name="dto"></param>
  3092. /// <returns></returns>
  3093. [HttpPost]
  3094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3095. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3096. {
  3097. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3098. if (groupData.Code != 200)
  3099. {
  3100. return Ok(JsonView(false, groupData.Msg));
  3101. }
  3102. #region 应用推送
  3103. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3104. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3105. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3106. #endregion
  3107. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3108. }
  3109. /// <summary>
  3110. /// 团组增减款项操作 删除
  3111. /// </summary>
  3112. /// <param name="dto"></param>
  3113. /// <returns></returns>
  3114. [HttpPost]
  3115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3116. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3117. {
  3118. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3119. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3120. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3121. if (res.Code == 0)
  3122. {
  3123. return Ok(JsonView(true, "删除成功!"));
  3124. }
  3125. return Ok(JsonView(false, "删除失败!"));
  3126. }
  3127. /// <summary>
  3128. /// 根据团组增减款项Id查询
  3129. /// </summary>
  3130. /// <param name="dto"></param>
  3131. /// <returns></returns>
  3132. [HttpPost]
  3133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3134. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3135. {
  3136. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3137. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3138. }
  3139. /// <summary>
  3140. /// 查询供应商名称
  3141. /// </summary>
  3142. /// <param name="dto"></param>
  3143. /// <returns></returns>
  3144. [HttpPost]
  3145. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3146. {
  3147. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3148. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3149. ?? new List<Grp_DecreasePayments>();
  3150. dbResult = dbResult.Distinct(new
  3151. ProductComparer()).ToList();
  3152. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3153. {
  3154. x.Id,
  3155. x.SupplierAddress,
  3156. x.SupplierArea,
  3157. x.SupplierContact,
  3158. x.SupplierContactNumber,
  3159. x.SupplierEmail,
  3160. x.SupplierName,
  3161. x.SupplierSocialAccount,
  3162. x.SupplierTypeId,
  3163. }).ToList());
  3164. return Ok(jw);
  3165. }
  3166. #endregion
  3167. #region 文件上传、删除
  3168. /// <summary>
  3169. /// region 文件上传 可以带参数
  3170. /// </summary>
  3171. /// <param name="file"></param>
  3172. /// <returns></returns>
  3173. [HttpPost]
  3174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3175. public async Task<IActionResult> UploadProject(IFormFile file)
  3176. {
  3177. //var TypeName = Request.Headers["TypeName"].ToString();
  3178. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3179. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3180. ////文件名称
  3181. //string projectFileName = file.FileName;
  3182. ////上传的文件的路径
  3183. //string filePath = $"{fileDir}/{projectFileName}";
  3184. //if (TypeName == "A")//A代表团组增减款项
  3185. //{
  3186. // filePath = fileDir + $@"\团组增减款项相关文件";
  3187. // if (!Directory.Exists(filePath))
  3188. // {
  3189. // Directory.CreateDirectory(filePath);
  3190. // }
  3191. // //上传的文件的路径
  3192. // filePath += $@"\{projectFileName}";
  3193. //}
  3194. //else if (TypeName == "B")//B代表商邀相关文件
  3195. //{
  3196. // //上传的文件的路径
  3197. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3198. // if (!Directory.Exists(filePath))
  3199. // {
  3200. // Directory.CreateDirectory(filePath);
  3201. // }
  3202. // //上传的文件的路径
  3203. // filePath = $@"\{projectFileName}";
  3204. //}
  3205. //try
  3206. //{
  3207. // using (FileStream fs = System.IO.File.Create(filePath))
  3208. // {
  3209. // file.CopyTo(fs);
  3210. // fs.Flush();
  3211. // }
  3212. //}
  3213. //catch (Exception ex)
  3214. //{
  3215. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3216. //}
  3217. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3218. try
  3219. {
  3220. var TypeName = Request.Headers["TypeName"].ToString();
  3221. if (file != null)
  3222. {
  3223. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3224. //文件名称
  3225. string projectFileName = file.FileName;
  3226. //上传的文件的路径
  3227. string filePath = $"{fileDir}/{projectFileName}";
  3228. if (TypeName == "A")//A代表团组增减款项
  3229. {
  3230. if (!Directory.Exists(fileDir))
  3231. {
  3232. Directory.CreateDirectory(fileDir);
  3233. }
  3234. //上传的文件的路径
  3235. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3236. }
  3237. else if (TypeName == "B")//B代表商邀相关文件
  3238. {
  3239. if (!Directory.Exists(fileDir))
  3240. {
  3241. Directory.CreateDirectory(fileDir);
  3242. }
  3243. //上传的文件的路径
  3244. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3245. }
  3246. using (FileStream fs = System.IO.File.Create(filePath))
  3247. {
  3248. file.CopyTo(fs);
  3249. fs.Flush();
  3250. }
  3251. return Ok(JsonView(true, "上传成功!", projectFileName));
  3252. }
  3253. else
  3254. {
  3255. return Ok(JsonView(false, "上传失败!"));
  3256. }
  3257. }
  3258. catch (Exception ex)
  3259. {
  3260. return Ok(JsonView(false, "程序错误!"));
  3261. }
  3262. }
  3263. /// <summary>
  3264. /// 删除指定文件
  3265. /// </summary>
  3266. /// <param name="dto"></param>
  3267. /// <returns></returns>
  3268. [HttpPost]
  3269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3270. public async Task<IActionResult> DelFile(DelFileDto dto)
  3271. {
  3272. try
  3273. {
  3274. var TypeName = Request.Headers["TypeName"].ToString();
  3275. string filePath = "";
  3276. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3277. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3278. int id = 0;
  3279. if (TypeName == "A")
  3280. {
  3281. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3282. // 删除该文件
  3283. System.IO.File.Delete(filePath);
  3284. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  3285. }
  3286. else if (TypeName == "B")
  3287. {
  3288. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3289. // 删除该文件
  3290. System.IO.File.Delete(filePath);
  3291. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  3292. }
  3293. if (id != 0)
  3294. {
  3295. return Ok(JsonView(true, "成功!"));
  3296. }
  3297. else
  3298. {
  3299. return Ok(JsonView(false, "失败!"));
  3300. }
  3301. }
  3302. catch (Exception ex)
  3303. {
  3304. return Ok(JsonView(false, "程序错误!"));
  3305. throw;
  3306. }
  3307. }
  3308. #endregion
  3309. #region 商邀费用录入
  3310. /// <summary>
  3311. /// 根据团组Id查询商邀费用列表
  3312. /// </summary>
  3313. /// <param name="dto"></param>
  3314. /// <returns></returns>
  3315. [HttpPost]
  3316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3317. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3318. {
  3319. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3320. if (groupData.Code != 0)
  3321. {
  3322. return Ok(JsonView(false, groupData.Msg));
  3323. }
  3324. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3325. }
  3326. //
  3327. /// <summary>
  3328. /// 商邀费用 Info Page 基础数据源
  3329. /// </summary>
  3330. /// <param name="dto"></param>
  3331. /// <returns></returns>
  3332. [HttpPost]
  3333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3334. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3335. {
  3336. try
  3337. {
  3338. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3339. if (groupData.Code != 0)
  3340. {
  3341. return Ok(JsonView(false, groupData.Msg));
  3342. }
  3343. return Ok(JsonView(true, "操作成功", groupData.Data));
  3344. }
  3345. catch (Exception ex)
  3346. {
  3347. return Ok(JsonView(false, ex.Message));
  3348. throw;
  3349. }
  3350. }
  3351. /// <summary>
  3352. /// 根据商邀费用ID查询C表和商邀费用数据
  3353. /// </summary>
  3354. /// <param name="dto"></param>
  3355. /// <returns></returns>
  3356. [HttpPost]
  3357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3358. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3359. {
  3360. try
  3361. {
  3362. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3363. if (groupData.Code != 0)
  3364. {
  3365. return Ok(JsonView(false, groupData.Msg));
  3366. }
  3367. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3368. }
  3369. catch (Exception ex)
  3370. {
  3371. return Ok(JsonView(false, ex.Message));
  3372. throw;
  3373. }
  3374. }
  3375. /// <summary>
  3376. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3377. /// </summary>
  3378. /// <param name="dto"></param>
  3379. /// <returns></returns>
  3380. [HttpPost]
  3381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3382. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3383. {
  3384. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3385. if (groupData.Code != 0)
  3386. {
  3387. return Ok(JsonView(false, groupData.Msg));
  3388. }
  3389. #region 应用推送
  3390. try
  3391. {
  3392. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3393. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3394. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3395. }
  3396. catch (Exception ex)
  3397. {
  3398. }
  3399. #endregion
  3400. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3401. }
  3402. /// <summary>
  3403. /// 商邀删除
  3404. /// </summary>
  3405. /// <param name="dto"></param>
  3406. /// <returns></returns>
  3407. [HttpPost]
  3408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3409. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3410. {
  3411. try
  3412. {
  3413. _sqlSugar.BeginTran();
  3414. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3415. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3416. {
  3417. IsDel = 1,
  3418. DeleteUserId = dto.DeleteUserId,
  3419. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3420. })
  3421. .Where(it => it.Id == dto.Id)
  3422. .ExecuteCommand();
  3423. if (res1 > 0)
  3424. {
  3425. int _diId = 0;
  3426. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3427. if (_ioaInfo != null)
  3428. {
  3429. _diId = _ioaInfo.DiId;
  3430. }
  3431. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3432. .SetColumns(a => new Grp_CreditCardPayment()
  3433. {
  3434. IsDel = 1,
  3435. DeleteUserId = dto.DeleteUserId,
  3436. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3437. })
  3438. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3439. .ExecuteCommand();
  3440. if (res2 > 0)
  3441. {
  3442. _sqlSugar.CommitTran();
  3443. return Ok(JsonView(true, "删除成功!"));
  3444. }
  3445. }
  3446. _sqlSugar.RollbackTran();
  3447. return Ok(JsonView(false, "删除失败"));
  3448. }
  3449. catch (Exception ex)
  3450. {
  3451. _sqlSugar.RollbackTran();
  3452. return Ok(JsonView(false, ex.Message));
  3453. }
  3454. }
  3455. /// <summary>
  3456. /// 团组模块文件上传
  3457. /// </summary>
  3458. /// <param name="dto"></param>
  3459. /// <returns></returns>
  3460. [HttpPost]
  3461. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3462. {
  3463. var jw = JsonView(false);
  3464. long M = 1024 * 1024;
  3465. if (dto.Files == null || dto.Files.Count == 0)
  3466. {
  3467. jw.Msg = "无文件信息!";
  3468. return Ok(jw);
  3469. }
  3470. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3471. {
  3472. jw.Msg = "文件大小超过20M!";
  3473. return Ok(jw);
  3474. }
  3475. //var nameSp = dto.File.FileName.Split(".");
  3476. //if (nameSp.Length < 2)
  3477. //{
  3478. // jw.Msg = "拓展名称有误!";
  3479. // return Ok(jw);
  3480. //}
  3481. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3482. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3483. //{
  3484. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3485. // return Ok(jw);
  3486. //}
  3487. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3488. if (Ctable == null)
  3489. {
  3490. jw.Msg = "Ctable指向有误!";
  3491. return Ok(jw);
  3492. }
  3493. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3494. if (groupInfo == null)
  3495. {
  3496. jw.Msg = "团组信息不存在!";
  3497. return Ok(jw);
  3498. }
  3499. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3500. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3501. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3502. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3503. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3504. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3505. try
  3506. {
  3507. if (!Directory.Exists(fileBase))
  3508. {
  3509. Directory.CreateDirectory(fileBase);
  3510. }
  3511. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3512. foreach (var fileStream in dto.Files)
  3513. {
  3514. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3515. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3516. {
  3517. Cid = dto.Cid,
  3518. CreateTime = DateTime.Now,
  3519. CreateUserId = dto.Userid,
  3520. Ctable = dto.Ctable,
  3521. Diid = dto.Diid,
  3522. IsDel = 0,
  3523. FilePath = saveFilePath,
  3524. FileName = fileStream.FileName
  3525. };
  3526. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3527. {
  3528. fileStream.CopyTo(fs);
  3529. fs.Flush();
  3530. }
  3531. saveArr.Add(file);
  3532. }
  3533. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3534. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3535. jw = JsonView(true, "保存成功!", new
  3536. {
  3537. count = addResult,
  3538. filesName = saveArr.Select(x => x.FileName)
  3539. });
  3540. }
  3541. catch (Exception ex)
  3542. {
  3543. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3544. {
  3545. count = 0,
  3546. filesName = new string[0],
  3547. });
  3548. }
  3549. return Ok(jw);
  3550. }
  3551. /// <summary>
  3552. /// 查询各模块已保存文件
  3553. /// </summary>
  3554. /// <param name="dto"></param>
  3555. /// <returns></returns>
  3556. [HttpPost]
  3557. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3558. {
  3559. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3560. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3561. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3562. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3563. {
  3564. expression = Expressionable.Create<Grp_GroupModelFile>()
  3565. .And(x => visaIds.Contains(x.CreateUserId));
  3566. }
  3567. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3568. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3569. .Where(expression.ToExpression())
  3570. .ToList();
  3571. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3572. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3573. {
  3574. x.FileName,
  3575. x.Id,
  3576. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3577. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3578. })));
  3579. }
  3580. /// <summary>
  3581. /// 下载该团组下的所有文件
  3582. /// </summary>
  3583. /// <param name="dto"></param>
  3584. /// <returns></returns>
  3585. [HttpPost]
  3586. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3587. {
  3588. var jw = JsonView(false);
  3589. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3590. if (groupInfo == null)
  3591. {
  3592. jw.Msg = "团组信息不存在!";
  3593. return Ok(jw);
  3594. }
  3595. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3596. var isModule = Convert.ToBoolean(dto.isModule);
  3597. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3598. IOOperatorHelper io = new IOOperatorHelper();
  3599. if (isModule)
  3600. {
  3601. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3602. foreach (var moduleArr in moduleGroup)
  3603. {
  3604. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3605. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3606. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3607. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3608. foreach (var item in moduleArr)
  3609. {
  3610. if (System.IO.File.Exists(item.FilePath))
  3611. {
  3612. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3613. {
  3614. byte[] bytes = new byte[fileStream.Length];
  3615. fileStream.Read(bytes, 0, bytes.Length);
  3616. fileStream.Close();
  3617. Stream stream = new MemoryStream(bytes);
  3618. chiZips.Add(item.FileName, stream);
  3619. }
  3620. }
  3621. }
  3622. if (chiZips.Count > 0)
  3623. {
  3624. var byts = io.ConvertZipStream(chiZips);
  3625. Stream stream = new MemoryStream(byts);
  3626. Zips.Add(key.Name + "_.zip", stream);
  3627. }
  3628. }
  3629. }
  3630. else
  3631. {
  3632. foreach (var item in dbQuery)
  3633. {
  3634. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3635. {
  3636. byte[] bytes = new byte[fileStream.Length];
  3637. fileStream.Read(bytes, 0, bytes.Length);
  3638. fileStream.Close();
  3639. Stream stream = new MemoryStream(bytes);
  3640. while (Zips.Keys.Contains(item.FileName))
  3641. {
  3642. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3643. }
  3644. Zips.Add(item.FileName, stream);
  3645. }
  3646. }
  3647. }
  3648. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3649. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3650. if (Zips.Count > 0)
  3651. {
  3652. var byts = io.ConvertZipStream(Zips);
  3653. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3654. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3655. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3656. }
  3657. else
  3658. {
  3659. jw.Msg = "暂无生成文件!";
  3660. }
  3661. return Ok(jw);
  3662. }
  3663. /// <summary>
  3664. /// 下载该团组下此模块的所有文件
  3665. /// </summary>
  3666. /// <param name="dto"></param>
  3667. /// <returns></returns>
  3668. [HttpPost]
  3669. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3670. {
  3671. var jw = JsonView(false);
  3672. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3673. if (groupInfo == null)
  3674. {
  3675. jw.Msg = "团组信息不存在!";
  3676. return Ok(jw);
  3677. }
  3678. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3679. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3680. && x.IsDel == 0);
  3681. if (key == null)
  3682. {
  3683. jw.Msg = "Ctable指向错误!";
  3684. return Ok(jw);
  3685. }
  3686. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3687. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3688. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3689. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3690. IOOperatorHelper io = new IOOperatorHelper();
  3691. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3692. foreach (var item in dbQuery)
  3693. {
  3694. if (System.IO.File.Exists(item.FilePath))
  3695. {
  3696. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3697. {
  3698. byte[] bytes = new byte[fileStream.Length];
  3699. fileStream.Read(bytes, 0, bytes.Length);
  3700. fileStream.Close();
  3701. Stream stream = new MemoryStream(bytes);
  3702. while (Zips.Keys.Contains(item.FileName))
  3703. {
  3704. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3705. }
  3706. Zips.Add(item.FileName, stream);
  3707. }
  3708. }
  3709. }
  3710. if (Zips.Count > 0)
  3711. {
  3712. var byts = io.ConvertZipStream(Zips);
  3713. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3714. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3715. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3716. }
  3717. else
  3718. {
  3719. jw.Msg = "暂无生成文件!";
  3720. }
  3721. return Ok(jw);
  3722. }
  3723. /// <summary>
  3724. /// 删除该团组下的指定文件
  3725. /// </summary>
  3726. /// <param name="dto"></param>
  3727. /// <returns></returns>
  3728. [HttpPost]
  3729. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3730. {
  3731. var jw = JsonView(false);
  3732. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3733. if (sing == null)
  3734. {
  3735. jw.Msg = "暂无";
  3736. return Ok(jw);
  3737. }
  3738. if (System.IO.File.Exists(sing.FilePath))
  3739. {
  3740. try
  3741. {
  3742. System.IO.File.Delete(sing.FilePath);
  3743. }
  3744. catch (Exception ex)
  3745. {
  3746. jw.Msg = "删除失败!" + ex.Message;
  3747. return Ok(jw);
  3748. }
  3749. }
  3750. sing.IsDel = 1;
  3751. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3752. sing.DeleteUserId = dto.UserId;
  3753. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3754. jw = JsonView(true, "删除成功!");
  3755. return Ok(jw);
  3756. }
  3757. #endregion
  3758. #region 团组英文资料
  3759. /// <summary>
  3760. /// 查询团组英文所有资料
  3761. /// </summary>
  3762. /// <param name="dto"></param>
  3763. /// <returns></returns>
  3764. [HttpPost]
  3765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3766. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3767. {
  3768. try
  3769. {
  3770. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3771. if (groupData.Code != 0)
  3772. {
  3773. return Ok(JsonView(false, groupData.Msg));
  3774. }
  3775. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3776. }
  3777. catch (Exception ex)
  3778. {
  3779. return Ok(JsonView(false, "程序错误!"));
  3780. throw;
  3781. }
  3782. }
  3783. /// <summary>
  3784. /// 团组英文资料操作(Status:1.新增,2.修改)
  3785. /// </summary>
  3786. /// <param name="dto"></param>
  3787. /// <returns></returns>
  3788. [HttpPost]
  3789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3790. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3791. {
  3792. try
  3793. {
  3794. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3795. if (groupData.Code != 0)
  3796. {
  3797. return Ok(JsonView(false, groupData.Msg));
  3798. }
  3799. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3800. }
  3801. catch (Exception ex)
  3802. {
  3803. return Ok(JsonView(false, "程序错误!"));
  3804. throw;
  3805. }
  3806. }
  3807. /// <summary>
  3808. /// 团组英文资料Id查询数据
  3809. /// </summary>
  3810. /// <param name="dto"></param>
  3811. /// <returns></returns>
  3812. [HttpPost]
  3813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3814. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3815. {
  3816. try
  3817. {
  3818. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3819. if (_DelegationEnData != null)
  3820. {
  3821. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3822. }
  3823. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3824. }
  3825. catch (Exception ex)
  3826. {
  3827. return Ok(JsonView(false, "程序错误!"));
  3828. throw;
  3829. }
  3830. }
  3831. /// <summary>
  3832. /// 团组英文资料删除
  3833. /// </summary>
  3834. /// <param name="dto"></param>
  3835. /// <returns></returns>
  3836. [HttpPost]
  3837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3838. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3839. {
  3840. try
  3841. {
  3842. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3843. if (!res)
  3844. {
  3845. return Ok(JsonView(false, "删除失败"));
  3846. }
  3847. return Ok(JsonView(true, "删除成功!"));
  3848. }
  3849. catch (Exception ex)
  3850. {
  3851. return Ok(JsonView(false, "程序错误!"));
  3852. throw;
  3853. }
  3854. }
  3855. #endregion
  3856. #region 导出邀请函
  3857. /// <summary>
  3858. /// 导出邀请函页面初始化
  3859. /// </summary>
  3860. /// <param name="dto"></param>
  3861. /// <returns></returns>
  3862. [HttpPost]
  3863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3864. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3865. {
  3866. try
  3867. {
  3868. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3869. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3870. if (dto.DiId == 0)
  3871. {
  3872. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3873. }
  3874. else
  3875. {
  3876. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3877. }
  3878. return Ok(JsonView(true, "查询成功!", new
  3879. {
  3880. deleClient = crm_Deles,
  3881. delegations = grp_Delegations
  3882. }));
  3883. }
  3884. catch (Exception ex)
  3885. {
  3886. return Ok(JsonView(false, "程序错误!"));
  3887. throw;
  3888. }
  3889. }
  3890. /// <summary>
  3891. /// 导出邀请函
  3892. /// </summary>
  3893. /// <param name="dto"></param>
  3894. /// <returns></returns>
  3895. [HttpPost]
  3896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3897. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3898. {
  3899. #region 参数验证
  3900. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3901. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3902. #endregion
  3903. try
  3904. {
  3905. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3906. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3907. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3908. From Grp_TourClientList tcl
  3909. Left Join
  3910. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3911. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3912. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3913. From Crm_DeleClient dc
  3914. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3915. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3916. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3917. Where dc.IsDel = 0) temp
  3918. On temp.DcId =tcl.ClientId
  3919. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3920. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3921. List<string> texts = new List<string>();
  3922. if (datas.Count != 0)
  3923. {
  3924. foreach (TourClientListDetailsView item in datas)
  3925. {
  3926. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3927. {
  3928. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3929. }
  3930. else
  3931. {
  3932. string name = item.LastName + item.FirstName;
  3933. texts.Add(name);
  3934. }
  3935. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3936. {
  3937. if (!transDic.ContainsKey(item.Job))
  3938. {
  3939. texts.Add(item.Job);
  3940. }
  3941. }
  3942. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3943. {
  3944. texts.Add(item.CompanyFullName);
  3945. }
  3946. }
  3947. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3948. if (transData.Count > 0)
  3949. {
  3950. foreach (TranslateResult item in transData)
  3951. {
  3952. if (!transDic.ContainsKey(item.Query))
  3953. {
  3954. transDic.Add(item.Query, item.Translation);
  3955. }
  3956. }
  3957. }
  3958. List<GuestList> list = new List<GuestList>();
  3959. foreach (TourClientListDetailsView dele in datas)
  3960. {
  3961. GuestList guestList = new GuestList();
  3962. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3963. {
  3964. guestList.Name = dele.Pinyin;
  3965. }
  3966. else
  3967. {
  3968. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3969. guestList.Name = Name;
  3970. }
  3971. if (dele.Sex == 0)
  3972. {
  3973. guestList.Sex = "Male";
  3974. }
  3975. else if (dele.Sex == 1)
  3976. {
  3977. guestList.Sex = "Female";
  3978. }
  3979. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3980. if (!string.IsNullOrEmpty(dele.Job))
  3981. {
  3982. guestList.Job = dele.Job;
  3983. }
  3984. list.Add(guestList);
  3985. }
  3986. //载入模板
  3987. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3988. DocumentBuilder builder = new DocumentBuilder(doc);
  3989. //获取word里所有表格
  3990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3991. //获取所填表格的序数
  3992. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3993. var rowStart = tableOne.Rows[0]; //获取第1行
  3994. //循环赋值
  3995. for (int i = 0; i < list.Count; i++)
  3996. {
  3997. builder.MoveToCell(0, i + 1, 0, 0);
  3998. builder.Write(list[i].Name.ToString());
  3999. builder.MoveToCell(0, i + 1, 1, 0);
  4000. builder.Write(list[i].Sex.ToString());
  4001. builder.MoveToCell(0, i + 1, 2, 0);
  4002. builder.Write(list[i].DOB.ToString());
  4003. builder.MoveToCell(0, i + 1, 3, 0);
  4004. builder.Write(list[i].Job.ToString());
  4005. }
  4006. //删除多余行
  4007. while (tableOne.Rows.Count > list.Count + 1)
  4008. {
  4009. tableOne.Rows.RemoveAt(list.Count + 1);
  4010. }
  4011. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4012. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4013. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4014. doc.Save(filePath);
  4015. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4016. return Ok(JsonView(true, "操作成功!", Url));
  4017. }
  4018. else
  4019. {
  4020. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4021. }
  4022. }
  4023. catch (Exception ex)
  4024. {
  4025. return Ok(JsonView(false, ex.Message));
  4026. throw;
  4027. }
  4028. }
  4029. #endregion
  4030. #region 团组经理模块 出入境费用
  4031. ///// <summary>
  4032. ///// 团组模块 - 出入境费用
  4033. ///// </summary>
  4034. ///// <returns></returns>
  4035. //[HttpPost]
  4036. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4037. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4038. //{
  4039. // try
  4040. // {
  4041. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4042. // if (data.Code != 0)
  4043. // {
  4044. // return Ok(JsonView(false, data.Msg));
  4045. // }
  4046. // return Ok(JsonView(true, "查询成功!"));
  4047. // }
  4048. // catch (Exception ex)
  4049. // {
  4050. // return Ok(JsonView(false, ex.Message));
  4051. // throw;
  4052. // }
  4053. //}
  4054. /// <summary>
  4055. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4056. /// </summary>
  4057. /// <returns></returns>
  4058. [HttpPost]
  4059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4060. public async Task<IActionResult> SetDayAndCostAreaChange()
  4061. {
  4062. try
  4063. {
  4064. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4065. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4066. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4067. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4068. foreach (var item in unite) //处理交集数据
  4069. {
  4070. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4071. }
  4072. foreach (var item in merge) //处理差集数据
  4073. {
  4074. int nationalTravelFeeId = 0;
  4075. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4076. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4077. else
  4078. {
  4079. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4080. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4081. }
  4082. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4083. }
  4084. //只更新dayAndCost 的 nationalTravelFeeId;
  4085. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4086. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4087. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4088. }
  4089. catch (Exception ex)
  4090. {
  4091. return Ok(JsonView(false, ex.Message));
  4092. throw;
  4093. }
  4094. }
  4095. /// <summary>
  4096. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4097. /// </summary>
  4098. /// <returns></returns>
  4099. [HttpPost]
  4100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4101. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4102. {
  4103. try
  4104. {
  4105. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4106. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4107. //SetDataInfoView
  4108. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4109. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4110. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4111. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4112. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4113. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4114. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4115. //默认币种显示
  4116. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4117. {
  4118. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4119. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4120. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4121. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4122. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4123. };
  4124. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4125. if (_currencyRate.Count > 0)
  4126. {
  4127. foreach (var item in _currencyInfos)
  4128. {
  4129. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4130. if (rateInfo != null)
  4131. {
  4132. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4133. rate1 *= 1.035M;
  4134. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4135. }
  4136. }
  4137. }
  4138. return Ok(JsonView(true, "查询成功!", new
  4139. {
  4140. GroupNameData = groupNameData.Data,
  4141. CurrencyData = _CurrencyData,
  4142. WordTypeData = _WordTypeData,
  4143. ExcelTypeData = _ExcelTypeData,
  4144. CurrencyInit = _currencyInfos
  4145. }));
  4146. }
  4147. catch (Exception ex)
  4148. {
  4149. return Ok(JsonView(false, ex.Message));
  4150. throw;
  4151. }
  4152. }
  4153. /// <summary>
  4154. /// 团组模块 - 出入境费用
  4155. /// 实时汇率 tips
  4156. /// 签证费用 tips
  4157. /// </summary>
  4158. /// <returns></returns>
  4159. [HttpPost]
  4160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4161. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4162. {
  4163. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4164. //默认币种显示
  4165. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4166. {
  4167. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4168. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4169. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4170. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4171. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4172. };
  4173. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4174. List<dynamic> reteInfos = new List<dynamic>();
  4175. if (_currencyRate.Count > 0)
  4176. {
  4177. foreach (var item in _currencyInfos)
  4178. {
  4179. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4180. if (rateInfo != null)
  4181. {
  4182. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4183. decimal rate1 = item.Rate;
  4184. rate1 *= 1.03M;
  4185. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4186. reteInfos.Add(new
  4187. {
  4188. currCode = item.CurrencyCode,
  4189. currName = item.CurrencyName,
  4190. rate = rate2,
  4191. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4192. });
  4193. }
  4194. }
  4195. }
  4196. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4197. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4198. return Ok(JsonView(true, "查询成功!", new
  4199. {
  4200. //GroupNameData = groupNameData.Data,
  4201. visaData = visaData.Data,
  4202. airData = airData.Data,
  4203. reteInfos = reteInfos
  4204. }));
  4205. }
  4206. /// <summary>
  4207. /// 团组模块 - 出入境费用 - Info
  4208. /// </summary>
  4209. /// <returns></returns>
  4210. [HttpPost]
  4211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4212. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4213. {
  4214. try
  4215. {
  4216. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4217. if (data.Code != 0)
  4218. {
  4219. return Ok(JsonView(false, data.Msg));
  4220. }
  4221. return Ok(JsonView(true, "查询成功!", data.Data));
  4222. }
  4223. catch (Exception ex)
  4224. {
  4225. return Ok(JsonView(false, ex.Message));
  4226. }
  4227. }
  4228. /// <summary>
  4229. /// 团组模块 - 出入境费用 - Add And Update
  4230. /// </summary>
  4231. /// <returns></returns>
  4232. [HttpPost]
  4233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4234. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4235. {
  4236. try
  4237. {
  4238. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4239. if (data.Code != 0)
  4240. {
  4241. return Ok(JsonView(false, data.Msg));
  4242. }
  4243. //生成默认文件pdf并且通知人员
  4244. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4245. {
  4246. DiId = dto.DiId,
  4247. ExportType = 1,
  4248. SubTypeId = 1005
  4249. }, "pdf");
  4250. //发送通知
  4251. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4252. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4253. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4254. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4255. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4256. return Ok(JsonView(true, data.Msg, data.Data));
  4257. }
  4258. catch (Exception ex)
  4259. {
  4260. return Ok(JsonView(false, ex.Message));
  4261. }
  4262. }
  4263. /// <summary>
  4264. /// 团组模块 - 出入境费用 - Confirm 费用
  4265. /// </summary>
  4266. /// <returns></returns>
  4267. [HttpPost]
  4268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4269. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4270. {
  4271. //TODO:测试完毕需把对应的用户ID更改
  4272. //1、数据表添加字段
  4273. //2、更改字段接口()
  4274. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4275. //3、确认成功 给财务发送消息
  4276. if (_view.Code == 200)
  4277. {
  4278. if (dto.Type == 1)
  4279. {
  4280. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4281. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4282. }
  4283. }
  4284. return Ok(_view);
  4285. }
  4286. /// <summary>
  4287. /// 团组模块 - 出入境费用 - File downlaod
  4288. /// </summary>
  4289. /// <param name="dto"></param>
  4290. /// <returns></returns>
  4291. [HttpPost]
  4292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4293. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4294. {
  4295. try
  4296. {
  4297. if (dto.DiId < 1)
  4298. {
  4299. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4300. }
  4301. if (dto.ExportType < 1)
  4302. {
  4303. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4304. }
  4305. if (dto.SubTypeId < 1)
  4306. {
  4307. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4308. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4309. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4310. 3 团组成员名单 1 团组成员名单"));
  4311. }
  4312. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4313. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4314. if (_EnterExitCosts == null)
  4315. {
  4316. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4317. }
  4318. //数据源
  4319. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4320. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4321. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4322. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4323. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4324. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4325. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4326. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4327. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4328. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4329. .Select((tcl, dc, cc) => new
  4330. {
  4331. Name = dc.LastName + dc.FirstName,
  4332. Sex = dc.Sex,
  4333. Birthday = dc.BirthDay,
  4334. Company = cc.CompanyFullName,
  4335. Job = dc.Job
  4336. })
  4337. .ToList();
  4338. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4339. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4340. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4341. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4342. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4343. if (dto.ExportType == 1) //明细表
  4344. {
  4345. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4346. {
  4347. //获取模板
  4348. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4349. //载入模板
  4350. Document doc = new Document(tempPath);
  4351. DocumentBuilder builder = new DocumentBuilder(doc);
  4352. //利用键值对存放数据
  4353. Dictionary<string, string> dic = new Dictionary<string, string>();
  4354. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4355. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4356. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4357. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4358. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4359. //境内费用(其他费用)
  4360. if (_EnterExitCosts.ChoiceOne == 1)
  4361. {
  4362. string row1_1 = "";
  4363. if (_EnterExitCosts.Visa > 0)
  4364. {
  4365. //insidePayTotal += _EnterExitCosts.Visa;
  4366. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4367. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4368. {
  4369. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4370. }
  4371. }
  4372. string row1_2 = "";
  4373. if (_EnterExitCosts.YiMiao > 0)
  4374. {
  4375. //insidePayTotal += _EnterExitCosts.YiMiao;
  4376. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4377. }
  4378. if (_EnterExitCosts.HeSuan > 0)
  4379. {
  4380. //insidePayTotal += _EnterExitCosts.HeSuan;
  4381. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4382. }
  4383. if (_EnterExitCosts.Service > 0)
  4384. {
  4385. //insidePayTotal += _EnterExitCosts.Service;
  4386. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4387. }
  4388. string row1_3 = "";
  4389. if (_EnterExitCosts.Safe > 0)
  4390. {
  4391. //insidePayTotal += _EnterExitCosts.Safe;
  4392. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4393. }
  4394. if (_EnterExitCosts.Ticket > 0)
  4395. {
  4396. //insidePayTotal += _EnterExitCosts.Ticket;
  4397. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4398. }
  4399. string row1 = "";
  4400. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4401. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4402. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4403. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4404. dic.Add("Row1Str", row1);
  4405. }
  4406. string airTotalStr = string.Empty,
  4407. airPriceStr = string.Empty;
  4408. //经济舱
  4409. if (_EnterExitCosts.SumJJC == 1)
  4410. {
  4411. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4412. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4413. }
  4414. //公务舱
  4415. if (_EnterExitCosts.SumGWC == 1)
  4416. {
  4417. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4418. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4419. }
  4420. //头等舱
  4421. if (_EnterExitCosts.SumTDC == 1)
  4422. {
  4423. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4424. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4425. }
  4426. dic.Add("AirTotalStr", airTotalStr);
  4427. dic.Add("AirPriceStr", airPriceStr);
  4428. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4429. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4430. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4431. int table1Row = 0,
  4432. table2Row = 0,
  4433. table3Row = 0,
  4434. table4Row = 0;
  4435. //住宿费
  4436. if (_EnterExitCosts.ChoiceThree == 1)
  4437. {
  4438. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4439. table1Row = dac1.Count;
  4440. #region 填充word表格内容
  4441. for (int i = 0; i < dac1.Count; i++)
  4442. {
  4443. Grp_DayAndCost dac = dac1[i];
  4444. if (dac == null) continue;
  4445. builder.MoveToCell(0, i, 0, 0);
  4446. builder.Write("第" + dac.Days.ToString() + "晚:");
  4447. builder.MoveToCell(0, i, 1, 0);
  4448. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4449. //builder.Write(dac.Place == null ? "" : dac.Place);
  4450. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4451. builder.MoveToCell(0, i, 2, 0);
  4452. builder.Write("费用标准:");
  4453. string curr = "";
  4454. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4455. if (currData != null)
  4456. {
  4457. curr = currData.Name;
  4458. }
  4459. builder.MoveToCell(0, i, 3, 0);
  4460. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4461. builder.MoveToCell(0, i, 4, 0);
  4462. builder.Write("费用小计:");
  4463. builder.MoveToCell(0, i, 5, 0);
  4464. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4465. }
  4466. #endregion
  4467. }
  4468. else dic.Add("SubZS", "0.00");
  4469. //删除多余行
  4470. while (table1.Rows.Count > table1Row)
  4471. {
  4472. table1.Rows.RemoveAt(table1Row);
  4473. }
  4474. //伙食费
  4475. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4476. if (_EnterExitCosts.ChoiceFour == 1)
  4477. {
  4478. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4479. table2Row = dac2.Count;
  4480. #region 填充word表格内容
  4481. for (int i = 0; i < dac2.Count; i++)
  4482. {
  4483. Grp_DayAndCost dac = dac2[i];
  4484. if (dac == null) continue;
  4485. builder.MoveToCell(1, i, 0, 0);
  4486. builder.Write("第" + dac.Days.ToString() + "天:");
  4487. builder.MoveToCell(1, i, 1, 0);
  4488. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4489. builder.MoveToCell(1, i, 2, 0);
  4490. builder.Write("费用标准:");
  4491. string curr = "";
  4492. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4493. if (currData != null)
  4494. {
  4495. curr = currData.Name;
  4496. }
  4497. builder.MoveToCell(1, i, 3, 0);
  4498. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4499. builder.MoveToCell(1, i, 4, 0);
  4500. builder.Write("费用小计:");
  4501. builder.MoveToCell(1, i, 5, 0);
  4502. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4503. }
  4504. #endregion
  4505. }
  4506. else dic.Add("SubHS", "0.00");
  4507. //删除多余行
  4508. while (table2.Rows.Count > table2Row)
  4509. {
  4510. table2.Rows.RemoveAt(table2Row);
  4511. }
  4512. //公杂费
  4513. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4514. if (_EnterExitCosts.ChoiceFive == 1)
  4515. {
  4516. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4517. table3Row = dac3.Count;
  4518. #region 填充word表格内容
  4519. for (int i = 0; i < dac3.Count; i++)
  4520. {
  4521. Grp_DayAndCost dac = dac3[i];
  4522. if (dac == null) continue;
  4523. builder.MoveToCell(2, i, 0, 0);
  4524. builder.Write("第" + dac.Days.ToString() + "天:");
  4525. builder.MoveToCell(2, i, 1, 0);
  4526. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4527. builder.MoveToCell(2, i, 2, 0);
  4528. builder.Write("费用标准:");
  4529. string curr = "";
  4530. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4531. if (currData != null)
  4532. {
  4533. curr = currData.Name;
  4534. }
  4535. builder.MoveToCell(2, i, 3, 0);
  4536. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4537. builder.MoveToCell(2, i, 4, 0);
  4538. builder.Write("费用小计:");
  4539. builder.MoveToCell(2, i, 5, 0);
  4540. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4541. }
  4542. //删除多余行
  4543. while (table3.Rows.Count > table3Row)
  4544. {
  4545. table3.Rows.RemoveAt(table3Row);
  4546. }
  4547. #endregion
  4548. }
  4549. else dic.Add("SubGZF", "0.00");
  4550. //删除多余行
  4551. while (table3.Rows.Count > table3Row)
  4552. {
  4553. table3.Rows.RemoveAt(table3Row);
  4554. }
  4555. //培训费
  4556. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4557. if (_EnterExitCosts.ChoiceSix == 1)
  4558. {
  4559. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4560. dic.Add("SubPX", pxStr);
  4561. table4Row = dac4.Count;
  4562. #region 填充word表格内容
  4563. for (int i = 0; i < dac4.Count; i++)
  4564. {
  4565. Grp_DayAndCost dac = dac4[i];
  4566. if (dac == null) continue;
  4567. builder.MoveToCell(3, i, 0, 0);
  4568. builder.Write("第" + dac.Days.ToString() + "天:");
  4569. builder.MoveToCell(3, i, 1, 0);
  4570. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4571. builder.MoveToCell(3, i, 2, 0);
  4572. builder.Write("费用标准:");
  4573. string curr = "";
  4574. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4575. if (currData != null)
  4576. {
  4577. curr = currData.Name;
  4578. }
  4579. builder.MoveToCell(3, i, 3, 0);
  4580. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4581. builder.MoveToCell(3, i, 4, 0);
  4582. builder.Write("费用小计:");
  4583. builder.MoveToCell(3, i, 5, 0);
  4584. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4585. }
  4586. #endregion
  4587. }
  4588. //else dic.Add("SubPX","0.00");
  4589. //删除多余行
  4590. while (table4.Rows.Count > table4Row)
  4591. {
  4592. table4.Rows.RemoveAt(table4Row);
  4593. }
  4594. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4595. decimal subJJC = 0.00M,
  4596. subGWC = 0.00M,
  4597. subTDC = 0.00M;
  4598. //经济舱
  4599. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4600. //公务舱
  4601. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4602. //头等舱
  4603. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4604. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4605. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4606. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4607. #region 填充word模板书签内容
  4608. foreach (var key in dic.Keys)
  4609. {
  4610. builder.MoveToBookmark(key);
  4611. builder.Write(dic[key]);
  4612. }
  4613. #endregion
  4614. //文件名
  4615. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4616. AsposeHelper.removewatermark_v2180();
  4617. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4618. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4619. return Ok(JsonView(true, "成功", new { Url = url }));
  4620. }
  4621. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4622. {
  4623. //获取模板
  4624. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4625. //载入模板
  4626. Document doc = new Document(tempPath);
  4627. DocumentBuilder builder = new DocumentBuilder(doc);
  4628. Dictionary<string, string> dic = new Dictionary<string, string>();
  4629. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4630. {
  4631. List<string> list = new List<string>();
  4632. try
  4633. {
  4634. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4635. foreach (var item in spilitArr)
  4636. {
  4637. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4638. var depCode = spDotandEmpty[2].Substring(0, 3);
  4639. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4640. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4641. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4642. list.Add(depName);
  4643. list.Add(arrName);
  4644. }
  4645. list = list.Distinct().ToList();
  4646. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4647. }
  4648. catch (Exception)
  4649. {
  4650. dic.Add("ReturnCode", "行程录入不正确!");
  4651. }
  4652. }
  4653. else
  4654. {
  4655. dic.Add("ReturnCode", "未录入行程!");
  4656. }
  4657. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4658. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4659. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4660. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4661. {
  4662. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4663. dic.Add("Day", sp.Days.ToString());
  4664. }
  4665. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4666. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4667. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4668. //dic.Add("Names", Names);
  4669. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4670. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4671. decimal dac1totalPrice = 0.00M;
  4672. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4673. foreach (var dac in dac1)
  4674. {
  4675. if (dac.SubTotal == 0.00M)
  4676. {
  4677. continue;
  4678. }
  4679. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4680. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4681. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4682. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4683. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4684. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4685. builder.Write(currency);//币种
  4686. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4687. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4688. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4689. builder.Write("");//人数
  4690. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4691. builder.Write("");//天数
  4692. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4693. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4694. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4695. decimal rate = 0.00M;
  4696. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4697. builder.Write(rate.ToString("#0.0000"));//汇率
  4698. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4699. decimal rbmPrice = dac.SubTotal;
  4700. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4701. accommodationStartIndex++;
  4702. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4703. }
  4704. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4705. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4706. {
  4707. table1.Rows.RemoveAt(i - 1);
  4708. foodandotherStartIndex--;
  4709. }
  4710. if (dac2.Count == dac3.Count)//国家 币种 金额
  4711. {
  4712. for (int i = 0; i < dac2.Count; i++)
  4713. {
  4714. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4715. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4716. }
  4717. }
  4718. decimal dac2totalPrice = 0.00M;
  4719. foreach (var dac in dac2)
  4720. {
  4721. if (dac.SubTotal == 0)
  4722. {
  4723. continue;
  4724. }
  4725. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4726. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4727. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4728. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4729. builder.Write(currency);//币种
  4730. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4731. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4732. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4733. builder.Write("");//人数
  4734. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4735. builder.Write("");//天数
  4736. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4737. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4738. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4739. decimal rate = 0.00M;
  4740. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4741. builder.Write(rate.ToString("#0.0000"));//汇率
  4742. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4743. decimal rbmPrice = dac.SubTotal;
  4744. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4745. foodandotherStartIndex++;
  4746. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4747. }
  4748. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4749. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4750. {
  4751. table1.Rows.RemoveAt(i - 1);
  4752. }
  4753. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4754. string otherFeeStr = "";
  4755. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4756. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4757. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4758. if (otherFeeStr.Length > 0)
  4759. {
  4760. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4761. otherFeeStr = $"({otherFeeStr})";
  4762. dic.Add("OtherFeeStr", otherFeeStr);
  4763. }
  4764. //总计
  4765. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4766. //国际旅费
  4767. string outsideAir = string.Empty;
  4768. string allPriceAir = string.Empty;
  4769. if (_EnterExitCosts.SumJJC == 1)
  4770. {
  4771. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4772. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4773. }
  4774. if (_EnterExitCosts.SumGWC == 1)
  4775. {
  4776. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4777. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4778. }
  4779. if (_EnterExitCosts.SumTDC == 1)
  4780. {
  4781. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4782. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4783. }
  4784. dic.Add("InTravelPrice", $"({outsideAir})");
  4785. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4786. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4787. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4788. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4789. foreach (var key in dic.Keys)
  4790. {
  4791. builder.MoveToBookmark(key);
  4792. builder.Write(dic[key]);
  4793. }
  4794. //模板文件名
  4795. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4796. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4797. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4798. return Ok(JsonView(true, "成功", new { Url = url }));
  4799. }
  4800. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4801. {
  4802. //获取模板
  4803. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4804. //载入模板
  4805. WorkbookDesigner designer = new WorkbookDesigner();
  4806. designer.Workbook = new Workbook(tempPath);
  4807. Dictionary<string, string> dic = new Dictionary<string, string>();
  4808. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4809. {
  4810. List<string> list = new List<string>();
  4811. try
  4812. {
  4813. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4814. foreach (var item in spilitArr)
  4815. {
  4816. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4817. var depCode = spDotandEmpty[2].Substring(0, 3);
  4818. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4819. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4820. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4821. list.Add(depName);
  4822. list.Add(arrName);
  4823. }
  4824. list = list.Distinct().ToList();
  4825. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4826. }
  4827. catch (Exception)
  4828. {
  4829. dic.Add("ReturnCode", "行程录入不正确!");
  4830. }
  4831. }
  4832. else
  4833. {
  4834. dic.Add("ReturnCode", "未录入行程!");
  4835. }
  4836. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4837. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4838. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4839. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4840. {
  4841. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4842. dic.Add("Day", sp.Days.ToString());
  4843. }
  4844. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4845. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4846. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4847. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4848. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4849. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4850. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4851. designer.SetDataSource("Name", Names);
  4852. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4853. designer.SetDataSource("Day", dic["Day"] + "天");
  4854. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4855. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4856. int startIndex = 10;
  4857. const int startIndexcopy = 10;
  4858. if (dac2.Count == dac3.Count)//国家 币种 金额
  4859. {
  4860. for (int i = 0; i < dac2.Count; i++)
  4861. {
  4862. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4863. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4864. }
  4865. }
  4866. DataTable dtdac1 = new DataTable();
  4867. List<string> place = new List<string>();
  4868. dtdac1.Columns.AddRange(new DataColumn[] {
  4869. new DataColumn(){ ColumnName = "city"},
  4870. new DataColumn(){ ColumnName = "curr"},
  4871. new DataColumn(){ ColumnName = "criterion"},
  4872. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4873. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4874. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4875. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4876. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4877. });
  4878. DataTable dtdac2 = new DataTable();
  4879. dtdac2.Columns.AddRange(new DataColumn[] {
  4880. new DataColumn(){ ColumnName = "city"},
  4881. new DataColumn(){ ColumnName = "curr"},
  4882. new DataColumn(){ ColumnName = "criterion"},
  4883. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4884. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4885. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4886. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4887. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4888. });
  4889. dtdac1.TableName = "tb1";
  4890. dtdac2.TableName = "tb2";
  4891. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4892. foreach (var item in dac1)
  4893. {
  4894. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4895. if (place.Contains(item.Place))
  4896. {
  4897. continue;
  4898. }
  4899. DataRow row = dtdac1.NewRow();
  4900. row["city"] = item.Place;
  4901. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4902. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4903. row["curr"] = currency;
  4904. row["rate"] = rate.ToString("#0.0000");
  4905. row["criterion"] = item.Cost.ToString("#0.00");
  4906. row["number"] = 1;
  4907. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4908. //row["costRMB"] = rbmPrice;
  4909. dtdac1.Rows.Add(row);
  4910. place.Add(item.Place);
  4911. }
  4912. place = new List<string>();
  4913. foreach (var item in dac2)
  4914. {
  4915. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4916. if (place.Contains(item.Place))
  4917. {
  4918. continue;
  4919. }
  4920. DataRow row = dtdac2.NewRow();
  4921. row["city"] = item.Place;
  4922. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4923. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4924. row["curr"] = currency;
  4925. row["rate"] = rate.ToString("#0.0000");
  4926. row["criterion"] = item.Cost.ToString("#0.00");
  4927. row["number"] = 1;
  4928. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4929. //row["cost"] = item.SubTotal;
  4930. //row["costRMB"] = rbmPrice;
  4931. dtdac2.Rows.Add(row);
  4932. place.Add(item.Place);
  4933. //dac2totalPrice += rbmPrice;
  4934. }
  4935. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4936. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4937. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4938. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4939. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4940. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4941. string cell4Str1 = string.Empty;
  4942. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4943. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4944. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4945. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4946. string cellStr = $" 5.其他费用(";
  4947. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4948. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4949. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4950. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4951. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4952. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4953. if (cellStr.Length > 8)
  4954. {
  4955. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4956. }
  4957. cellStr += ")";
  4958. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4959. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4960. decimal pxFee = dac4.Sum(it => it.Cost);
  4961. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4962. string celllastStr1 = "";
  4963. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4964. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4965. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4966. celllastStr1 += $",国际旅费 元";
  4967. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4968. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4969. designer.SetDataSource("cell4Str", cell4Str);
  4970. designer.SetDataSource("cellStr", cellStr);
  4971. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4972. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4973. designer.SetDataSource("celllastStr", celllastStr);
  4974. Workbook wb = designer.Workbook;
  4975. var sheet = wb.Worksheets[0];
  4976. //绑定datatable数据集
  4977. designer.SetDataSource(dtdac1);
  4978. designer.SetDataSource(dtdac2);
  4979. designer.Process();
  4980. var rowStart = dtdac1.Rows.Count;
  4981. while (rowStart > 0)
  4982. {
  4983. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4984. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4985. startIndex++;
  4986. rowStart--;
  4987. }
  4988. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4989. startIndex += 1; //总计行
  4990. rowStart = dtdac2.Rows.Count;
  4991. while (rowStart > 0)
  4992. {
  4993. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4994. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4995. startIndex++;
  4996. rowStart--;
  4997. }
  4998. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4999. wb.CalculateFormula(true);
  5000. //模板文件名
  5001. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5002. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5003. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5004. return Ok(JsonView(true, "成功", new { Url = url }));
  5005. }
  5006. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5007. {
  5008. //获取模板
  5009. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5010. //载入模板
  5011. Document doc = new Document(tempPath);
  5012. DocumentBuilder builder = new DocumentBuilder(doc);
  5013. Dictionary<string, string> dic = new Dictionary<string, string>();
  5014. dic.Add("GroupName", _DelegationInfo.TeamName);
  5015. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5016. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5017. string missionLeaderJob = "";//负责人job
  5018. int groupNumber = 0; //团人数
  5019. if (DeleClientList.Count > 0)
  5020. {
  5021. missionLeader = DeleClientList[0]?.Name ?? "";
  5022. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5023. }
  5024. dic.Add("MissionLeader", missionLeader); //团负责人
  5025. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5026. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5027. #region MyRegion
  5028. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5029. //{
  5030. // List<string> list = new List<string>();
  5031. // try
  5032. // {
  5033. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5034. // foreach (var item in spilitArr)
  5035. // {
  5036. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5037. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5038. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5039. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5040. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5041. // list.Add(depName);
  5042. // list.Add(arrName);
  5043. // }
  5044. // list = list.Distinct().ToList();
  5045. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5046. // }
  5047. // catch (Exception)
  5048. // {
  5049. // dic.Add("ReturnCode", "行程录入不正确!");
  5050. // }
  5051. //}
  5052. //else
  5053. //{
  5054. // dic.Add("ReturnCode", "未录入行程!");
  5055. //}
  5056. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5057. dic.Add("ReturnCode", string.Join("、", countrys));
  5058. #endregion
  5059. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5060. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5061. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5062. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5063. //{
  5064. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5065. // dic.Add("Day", sp.Days.ToString());
  5066. //}
  5067. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5068. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5069. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5070. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5071. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5072. //培训人员名单
  5073. int cultivateRowIndex = 7;
  5074. foreach (var item in DeleClientList)
  5075. {
  5076. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5077. builder.Write(item.Name);
  5078. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5079. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5080. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5081. string birthDay = "";
  5082. if (item.Birthday != null)
  5083. {
  5084. DateTime dt = Convert.ToDateTime(item.Birthday);
  5085. birthDay = $"{dt.Year}.{dt.Month}";
  5086. }
  5087. builder.Write(birthDay);
  5088. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5089. builder.Write(item.Company);
  5090. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5091. builder.Write(item.Job);
  5092. cultivateRowIndex++;
  5093. }
  5094. //删除多余行
  5095. //cultivateRowIndex -= 2;
  5096. int delRows = 10 + 7 - cultivateRowIndex;
  5097. if (delRows > 0)
  5098. {
  5099. for (int i = 0; i < delRows; i++)
  5100. {
  5101. table1.Rows.RemoveAt(cultivateRowIndex);
  5102. //cultivateRowIndex++;
  5103. }
  5104. }
  5105. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5106. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5107. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5108. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5109. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5110. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5111. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5112. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5113. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5114. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5115. //其他费用
  5116. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5117. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5118. //其他费用合计
  5119. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5120. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5121. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5122. //公务舱合计
  5123. //国际旅费
  5124. string outsideJJ = "";
  5125. string allPriceJJ = "";
  5126. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5127. {
  5128. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5129. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5130. }
  5131. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5132. {
  5133. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5134. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5135. }
  5136. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5137. {
  5138. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5139. dic.Add("AirFeeTotal", airFeeTotalStr);
  5140. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5141. dic.Add("FeeTotal", feeTotalStr);
  5142. }
  5143. foreach (var key in dic.Keys)
  5144. {
  5145. builder.MoveToBookmark(key);
  5146. builder.Write(dic[key]);
  5147. }
  5148. //模板文件名
  5149. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5150. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5151. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5152. return Ok(JsonView(true, "成功", new { Url = url }));
  5153. }
  5154. }
  5155. else if (dto.ExportType == 2) //表格
  5156. {
  5157. //利用键值对存放数据
  5158. Dictionary<string, string> dic = new Dictionary<string, string>();
  5159. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5160. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5161. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5162. dic.Add("Day", sp.Days.ToString());
  5163. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5164. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5165. {
  5166. //获取模板
  5167. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5168. //载入模板
  5169. Document doc = new Document(tempPath);
  5170. DocumentBuilder builder = new DocumentBuilder(doc);
  5171. dic.Add("TeamName", _DelegationInfo.TeamName);
  5172. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5173. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5174. string missionLeaderName = "",
  5175. missionLeaderJob = "";
  5176. if (DeleClientList.Count > 0)
  5177. {
  5178. missionLeaderName = DeleClientList[0].Name;
  5179. missionLeaderJob = DeleClientList[0].Job;
  5180. }
  5181. dic.Add("MissionLeaderName", missionLeaderName);
  5182. dic.Add("MissionLeaderJob", missionLeaderJob);
  5183. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5184. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5185. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5186. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5187. int rowCount = 10;//总人数行
  5188. int startRowIndex = 7; //起始行
  5189. for (int i = 0; i < DeleClientList.Count; i++)
  5190. {
  5191. builder.MoveToCell(0, startRowIndex, 0, 0);
  5192. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5193. builder.MoveToCell(0, startRowIndex, 1, 0);
  5194. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5195. builder.Write(sex);//性别
  5196. builder.MoveToCell(0, startRowIndex, 2, 0);
  5197. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5198. builder.MoveToCell(0, startRowIndex, 3, 0);
  5199. builder.Write(DeleClientList[i].Company);//工作单位
  5200. builder.MoveToCell(0, startRowIndex, 4, 0);
  5201. builder.Write(DeleClientList[i].Job);//职务及级别
  5202. builder.MoveToCell(0, startRowIndex, 5, 0);
  5203. builder.Write("");//人员属性
  5204. builder.MoveToCell(0, startRowIndex, 6, 0);
  5205. builder.Write("");//上次出国时间
  5206. startRowIndex++;
  5207. }
  5208. int nullRow = rowCount - DeleClientList.Count;//空行
  5209. for (int i = 0; i < nullRow; i++)
  5210. {
  5211. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5212. }
  5213. foreach (var key in dic.Keys)
  5214. {
  5215. builder.MoveToBookmark(key);
  5216. builder.Write(dic[key]);
  5217. }
  5218. //模板文件名
  5219. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5220. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5221. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5222. return Ok(JsonView(true, "成功", new { Url = url }));
  5223. }
  5224. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5225. {
  5226. //获取模板
  5227. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5228. //载入模板
  5229. Document doc = new Document(tempPath);
  5230. DocumentBuilder builder = new DocumentBuilder(doc);
  5231. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5232. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5233. dic.Add("Names", Names);
  5234. int accommodationRows = 12, foodandotherRows = 12;
  5235. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5236. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5237. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5238. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5239. int accommodationStartIndex = 6;
  5240. decimal dac1totalPrice = 0.00M;
  5241. foreach (var dac in dac1)
  5242. {
  5243. if (dac.SubTotal == 0)
  5244. {
  5245. continue;
  5246. }
  5247. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5248. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5249. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5250. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5251. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5252. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5253. builder.Write(currency);//币种
  5254. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5255. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5256. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5257. builder.Write("");//人数
  5258. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5259. builder.Write("");//天数
  5260. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5261. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5262. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5263. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5264. builder.Write(rate.ToString("#0.0000"));//汇率
  5265. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5266. decimal rbmPrice = rate * dac.SubTotal;
  5267. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5268. accommodationStartIndex++;
  5269. dac1totalPrice += rbmPrice;
  5270. }
  5271. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5272. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5273. builder.Write("小计");
  5274. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5275. builder.Write(dac1totalPrice.ToString("#0.00"));
  5276. accommodationStartIndex++;
  5277. int nullRow = accommodationRows - dac1.Count;
  5278. //删除空行
  5279. //if (nullRow > 0)
  5280. //{
  5281. // int rowIndex = accommodationStartIndex;
  5282. // for (int i = 0; i < nullRow; i++)
  5283. // {
  5284. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5285. // row.Remove();
  5286. // rowIndex++;
  5287. // }
  5288. //}
  5289. if (dac2.Count == dac3.Count)//国家 币种 金额
  5290. {
  5291. for (int i = 0; i < dac2.Count; i++)
  5292. {
  5293. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5294. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5295. }
  5296. }
  5297. int foodandotherStartIndex = 19;//
  5298. decimal dac2totalPrice = 0.00M;
  5299. foreach (var dac in dac2)
  5300. {
  5301. if (dac.SubTotal == 0)
  5302. {
  5303. continue;
  5304. }
  5305. //foodandotherStartIndex = 12;
  5306. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5307. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5308. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5309. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5310. builder.Write(currency);//币种
  5311. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5312. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5313. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5314. builder.Write("");//人数
  5315. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5316. builder.Write("");//天数
  5317. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5318. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5319. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5320. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5321. builder.Write(rate.ToString("#0.0000"));//汇率
  5322. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5323. decimal rbmPrice = rate * dac.SubTotal;
  5324. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5325. foodandotherStartIndex++;
  5326. dac2totalPrice += rbmPrice;
  5327. }
  5328. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5329. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5330. //删除空行
  5331. //if (dac2.Count < foodandotherRows)
  5332. //{
  5333. // while (table2.Rows.Count > dac2.Count)
  5334. // {
  5335. // table2.Rows.RemoveAt(dac2.Count);
  5336. // }
  5337. //}
  5338. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5339. string otherFeeStr = "";
  5340. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5341. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5342. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5343. if (otherFeeStr.Length > 0)
  5344. {
  5345. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5346. otherFeeStr = $"({otherFeeStr})";
  5347. dic.Add("OtherFeeStr", otherFeeStr);
  5348. }
  5349. foreach (var key in dic.Keys)
  5350. {
  5351. builder.MoveToBookmark(key);
  5352. builder.Write(dic[key]);
  5353. }
  5354. //模板文件名
  5355. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5356. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5357. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5358. return Ok(JsonView(true, "成功", new { Url = url }));
  5359. }
  5360. }
  5361. else if (dto.ExportType == 3)
  5362. {
  5363. if (dto.SubTypeId == 1) //团组成员名单
  5364. {
  5365. if (DeleClientList.Count < 1)
  5366. {
  5367. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5368. }
  5369. //获取模板
  5370. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5371. //载入模板
  5372. Document doc = new Document(tempPath);
  5373. DocumentBuilder builder = new DocumentBuilder(doc);
  5374. //获取word里所有表格
  5375. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5376. //获取所填表格的序数
  5377. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5378. var rowStart = tableOne.Rows[0]; //获取第1行
  5379. //循环赋值
  5380. for (int i = 0; i < DeleClientList.Count; i++)
  5381. {
  5382. builder.MoveToCell(0, i + 1, 0, 0);
  5383. builder.Write(DeleClientList[i].Name);
  5384. builder.MoveToCell(0, i + 1, 1, 0);
  5385. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5386. builder.Write(sex);
  5387. builder.MoveToCell(0, i + 1, 2, 0);
  5388. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5389. builder.MoveToCell(0, i + 1, 3, 0);
  5390. builder.Write(DeleClientList[i].Company);
  5391. builder.MoveToCell(0, i + 1, 4, 0);
  5392. builder.Write(DeleClientList[i].Job);
  5393. }
  5394. //删除多余行
  5395. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5396. {
  5397. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5398. }
  5399. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5400. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5401. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5402. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5403. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5404. return Ok(JsonView(true, "成功", new { Url = url }));
  5405. }
  5406. }
  5407. return Ok(JsonView(false, "操作失败!"));
  5408. }
  5409. catch (Exception ex)
  5410. {
  5411. return Ok(JsonView(false, ex.Message));
  5412. }
  5413. }
  5414. /// <summary>
  5415. /// 获取三公费用标准city
  5416. /// </summary>
  5417. /// <param name="placeData"></param>
  5418. /// <param name="nationalTravelFeeId"></param>
  5419. /// <returns></returns>
  5420. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5421. {
  5422. string _city = string.Empty;
  5423. if (placeData.Count < 1) return _city;
  5424. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5425. if (data == null) return _city;
  5426. string country = data.Country;
  5427. string city = data.City;
  5428. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5429. else _city = city;
  5430. return _city;
  5431. }
  5432. /// <summary>
  5433. /// 团组模块 - 出入境费用 - 明细表导出
  5434. /// </summary>
  5435. /// <returns></returns>
  5436. [HttpPost]
  5437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5438. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5439. {
  5440. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5441. if (data.Code != 0)
  5442. {
  5443. return Ok(JsonView(false, data.Msg));
  5444. }
  5445. return Ok(JsonView(true, data.Msg, data.Data));
  5446. }
  5447. /// <summary>
  5448. /// 团组模块 - 出入境费用 - 一键清空
  5449. /// </summary>
  5450. /// <returns></returns>
  5451. [HttpPost]
  5452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5453. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5454. {
  5455. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5456. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5457. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5458. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5459. if (_view.Code == 0)
  5460. {
  5461. return Ok(JsonView(true, "操作成功"));
  5462. }
  5463. return Ok(JsonView(false, "操作失败"));
  5464. }
  5465. /// <summary>
  5466. /// 团组模块 - 出入境费用 - 子项删除
  5467. /// </summary>
  5468. /// <returns></returns>
  5469. [HttpPost]
  5470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5471. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5472. {
  5473. try
  5474. {
  5475. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5476. if (data.Code != 0)
  5477. {
  5478. return Ok(JsonView(false, data.Msg));
  5479. }
  5480. return Ok(JsonView(true, "操作成功!", data.Data));
  5481. }
  5482. catch (Exception ex)
  5483. {
  5484. return Ok(JsonView(false, ex.Message));
  5485. }
  5486. }
  5487. /// <summary>
  5488. /// 团组模块 - 出入境国家费用标准 List
  5489. /// </summary>
  5490. /// <returns></returns>
  5491. [HttpPost]
  5492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5493. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5494. {
  5495. try
  5496. {
  5497. Stopwatch sw = new Stopwatch();
  5498. sw.Start();
  5499. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5500. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5501. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5502. Where gntf.Isdel = 0");
  5503. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5504. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5505. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5506. //foreach (var item in nationalTravel)
  5507. //{
  5508. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5509. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5510. // if (otherData != null)
  5511. // {
  5512. // cityData.Remove(otherData);
  5513. // cityData.Add(otherData);
  5514. // }
  5515. // nationalTravelFeeData1.Add(new
  5516. // {
  5517. // Country = item.Country,
  5518. // CityData = cityData
  5519. // });
  5520. //}
  5521. sw.Stop();
  5522. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5523. }
  5524. catch (Exception ex)
  5525. {
  5526. return Ok(JsonView(false, ex.Message));
  5527. throw;
  5528. }
  5529. }
  5530. /// <summary>
  5531. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5532. /// </summary>
  5533. /// <returns></returns>
  5534. [HttpPost]
  5535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5536. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5537. {
  5538. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5539. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5540. List<string> countryData = new List<string>();
  5541. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5542. countryData = countryData.Distinct().ToList();
  5543. List<dynamic> dataSource = new List<dynamic>();
  5544. foreach (var item in countryData)
  5545. {
  5546. List<string> cityData1 = new List<string>();
  5547. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5548. var countryData2 = new
  5549. {
  5550. CountryName = item,
  5551. CityData = cityData1
  5552. };
  5553. dataSource.Add(countryData2);
  5554. }
  5555. return Ok(JsonView(true, "查询成功!", dataSource));
  5556. }
  5557. /// <summary>
  5558. /// 团组模块 - 出入境国家费用标准 Page List
  5559. /// </summary>
  5560. /// <returns></returns>
  5561. [HttpPost]
  5562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5563. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5564. {
  5565. int portId = dto.PortType;
  5566. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5567. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5568. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5569. string whereSql = string.Empty;
  5570. if (!string.IsNullOrEmpty(dto.Country))
  5571. {
  5572. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5573. }
  5574. if (!string.IsNullOrEmpty(dto.City))
  5575. {
  5576. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5577. }
  5578. string pageSql = string.Format(@"Select * From (
  5579. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5580. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5581. From Grp_NationalTravelFee gntf
  5582. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5583. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5584. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5585. RefAsync<int> total = 0;
  5586. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5587. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5588. }
  5589. /// <summary>
  5590. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5591. /// </summary>
  5592. /// <returns></returns>
  5593. [HttpPost]
  5594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5595. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5596. {
  5597. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5598. int portId = dto.PortType;
  5599. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5600. string whereSql = string.Empty;
  5601. if (!string.IsNullOrEmpty(dto.Country))
  5602. {
  5603. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5604. }
  5605. if (!string.IsNullOrEmpty(dto.City))
  5606. {
  5607. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5608. }
  5609. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5610. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5611. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5612. From Grp_NationalTravelFee gntf
  5613. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5614. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5615. Where gntf.Isdel = 0 {0} ", whereSql);
  5616. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5617. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5618. }
  5619. /// <summary>
  5620. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5621. /// </summary>
  5622. /// <returns></returns>
  5623. [HttpPost]
  5624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5625. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5626. {
  5627. try
  5628. {
  5629. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5630. if (data.Code != 0)
  5631. {
  5632. return Ok(JsonView(false, data.Msg));
  5633. }
  5634. return Ok(JsonView(true, "操作成功!", data.Data));
  5635. }
  5636. catch (Exception ex)
  5637. {
  5638. return Ok(JsonView(false, ex.Message));
  5639. }
  5640. }
  5641. /// <summary>
  5642. /// 团组模块 - 出入境国家费用标准 - Del
  5643. /// </summary>
  5644. /// <returns></returns>
  5645. [HttpPost]
  5646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5647. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5648. {
  5649. try
  5650. {
  5651. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5652. {
  5653. Id = dto.Id,
  5654. DeleteUserId = dto.DeleteUserId,
  5655. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5656. IsDel = 1
  5657. };
  5658. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5659. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5660. .WhereColumns(it => new { it.Id })
  5661. .ExecuteCommandAsync();
  5662. if (delStatus <= 0)
  5663. {
  5664. return Ok(JsonView(false, "删除失败!"));
  5665. }
  5666. return Ok(JsonView(true, "操作成功!"));
  5667. }
  5668. catch (Exception ex)
  5669. {
  5670. return Ok(JsonView(false, ex.Message));
  5671. }
  5672. }
  5673. /// <summary>
  5674. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  5675. /// 注:Get 请求Headers 加 Token
  5676. /// </summary>
  5677. /// <param name="groupId"></param>
  5678. /// <returns></returns>
  5679. [HttpGet("{groupId}")]
  5680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5681. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  5682. {
  5683. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5684. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  5685. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  5686. data.ForEach(x =>
  5687. {
  5688. x.CreateUserId = _currUserInfo.UserId;
  5689. });
  5690. if (data.Count > 0)
  5691. {
  5692. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  5693. if (add > 0)
  5694. {
  5695. return Ok(JsonView(true, "操作成功!"));
  5696. }
  5697. }
  5698. return Ok(JsonView(false, "未操作!"));
  5699. }
  5700. #endregion
  5701. #region 签证费用录入
  5702. /// <summary>
  5703. /// 根据diid查询签证费用列表
  5704. /// </summary>
  5705. /// <param name="dto"></param>
  5706. /// <returns></returns>
  5707. [HttpPost]
  5708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5709. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5710. {
  5711. try
  5712. {
  5713. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5714. if (groupData.Code != 0)
  5715. {
  5716. return Ok(JsonView(false, groupData.Msg));
  5717. }
  5718. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5719. }
  5720. catch (Exception ex)
  5721. {
  5722. return Ok(JsonView(false, ex.Message));
  5723. }
  5724. }
  5725. /// <summary>
  5726. /// 根据签证费用Id查询单条数据及c表数据
  5727. /// </summary>
  5728. /// <param name="dto"></param>
  5729. /// <returns></returns>
  5730. [HttpPost]
  5731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5732. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5733. {
  5734. try
  5735. {
  5736. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5737. if (groupData.Code != 0)
  5738. {
  5739. return Ok(JsonView(false, groupData.Msg));
  5740. }
  5741. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5742. }
  5743. catch (Exception ex)
  5744. {
  5745. return Ok(JsonView(false, ex.Message));
  5746. }
  5747. }
  5748. /// <summary>
  5749. /// 签证费用删除
  5750. /// </summary>
  5751. /// <param name="dto"></param>
  5752. /// <returns></returns>
  5753. [HttpPost]
  5754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5755. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5756. {
  5757. _sqlSugar.BeginTran();
  5758. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5759. if (!res)
  5760. {
  5761. _sqlSugar.RollbackTran();
  5762. return Ok(JsonView(false, "删除失败"));
  5763. }
  5764. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5765. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5766. .SetColumns(a => new Grp_CreditCardPayment()
  5767. {
  5768. IsDel = 1,
  5769. DeleteUserId = dto.DeleteUserId,
  5770. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5771. })
  5772. .ExecuteCommand();
  5773. if (resSub < 1)
  5774. {
  5775. _sqlSugar.RollbackTran();
  5776. return Ok(JsonView(false, "删除失败"));
  5777. }
  5778. _sqlSugar.CommitTran();
  5779. return Ok(JsonView(true, "删除成功!"));
  5780. }
  5781. /// <summary>
  5782. /// 签证费用录入下拉框初始化
  5783. /// </summary>
  5784. /// <returns></returns>
  5785. [HttpPost]
  5786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5787. public async Task<IActionResult> VisaPriceAddSelect()
  5788. {
  5789. //支付方式
  5790. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5791. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5792. //币种
  5793. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5794. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5795. //乘客类型
  5796. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5797. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5798. //卡类型
  5799. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5800. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5801. var data = new
  5802. {
  5803. Payment = _Payment,
  5804. CurrencyList = _CurrencyList,
  5805. PassengerType = _PassengerType,
  5806. BankCard = _BankCard
  5807. };
  5808. return Ok(JsonView(true, "查询成功!", data));
  5809. }
  5810. /// <summary>
  5811. /// 签证费用录入操作(Status:1.新增,2.修改)
  5812. /// </summary>
  5813. /// <param name="dto"></param>
  5814. /// <returns></returns>
  5815. [HttpPost]
  5816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5817. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5818. {
  5819. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5820. if (groupData.Code != 0)
  5821. {
  5822. return Ok(JsonView(false, groupData.Msg));
  5823. }
  5824. #region 应用推送
  5825. try
  5826. {
  5827. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5828. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5829. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5830. }
  5831. catch (Exception ex)
  5832. {
  5833. }
  5834. #endregion
  5835. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5836. }
  5837. #endregion
  5838. #region 签证提成录入
  5839. /// <summary>
  5840. /// 签证提成录入
  5841. /// 基础数据
  5842. /// </summary>
  5843. /// <param name="_dto"></param>
  5844. /// <returns></returns>
  5845. [HttpGet]
  5846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5847. public async Task<IActionResult> VisaCommissionInit()
  5848. {
  5849. return Ok(await _visaCommissionRep.Init());
  5850. }
  5851. /// <summary>
  5852. /// 签证提成录入
  5853. /// Item
  5854. /// </summary>
  5855. /// <param name="_dto"></param>
  5856. /// <returns></returns>
  5857. [HttpPost]
  5858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5859. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5860. {
  5861. var validator = new VisaCommissionItemDtoValidator();
  5862. var validatorRes = await validator.ValidateAsync(_dto);
  5863. if (!validatorRes.IsValid)
  5864. {
  5865. StringBuilder sb = new StringBuilder();
  5866. foreach (var item in validatorRes.Errors)
  5867. {
  5868. sb.AppendLine(item.ErrorMessage);
  5869. }
  5870. return Ok(JsonView(false, sb.ToString()));
  5871. }
  5872. return Ok(await _visaCommissionRep.Item(_dto));
  5873. }
  5874. /// <summary>
  5875. /// 签证提成录入
  5876. /// Save
  5877. /// </summary>
  5878. /// <param name="_dto"></param>
  5879. /// <returns></returns>
  5880. [HttpPost]
  5881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5882. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  5883. {
  5884. //参数验证
  5885. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  5886. foreach (var item in _dto.Items)
  5887. {
  5888. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  5889. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  5890. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  5891. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  5892. }
  5893. return Ok(await _visaCommissionRep.Save(_dto));
  5894. }
  5895. /// <summary>
  5896. /// 签证提成录入
  5897. /// Create
  5898. /// </summary>
  5899. /// <param name="_dto"></param>
  5900. /// <returns></returns>
  5901. [HttpPost]
  5902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5903. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  5904. {
  5905. var validator = new VisaCommissionCreateDtoValidator();
  5906. var validatorRes = await validator.ValidateAsync(_dto);
  5907. if (!validatorRes.IsValid)
  5908. {
  5909. StringBuilder sb = new StringBuilder();
  5910. foreach (var item in validatorRes.Errors)
  5911. {
  5912. sb.AppendLine(item.ErrorMessage);
  5913. }
  5914. return Ok(JsonView(false, sb.ToString()));
  5915. }
  5916. return Ok(await _visaCommissionRep.Create(_dto));
  5917. }
  5918. /// <summary>
  5919. /// 签证提成录入
  5920. /// Put(编辑)
  5921. /// </summary>
  5922. /// <param name="id"></param>
  5923. /// <param name="_dto"></param>
  5924. /// <returns></returns>
  5925. [HttpPut]
  5926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5927. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  5928. {
  5929. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5930. var validator = new VisaCommissionCreateDtoValidator();
  5931. var validatorRes = await validator.ValidateAsync(_dto);
  5932. if (!validatorRes.IsValid)
  5933. {
  5934. StringBuilder sb = new StringBuilder();
  5935. foreach (var item in validatorRes.Errors)
  5936. {
  5937. sb.AppendLine(item.ErrorMessage);
  5938. }
  5939. return Ok(JsonView(false, sb.ToString()));
  5940. }
  5941. return Ok(await _visaCommissionRep.Edit(id, _dto));
  5942. }
  5943. /// <summary>
  5944. /// 签证提成录入
  5945. /// Del
  5946. /// </summary>
  5947. /// <param name="id"></param>
  5948. /// <param name="currUserId"></param>
  5949. /// <returns></returns>
  5950. [HttpPost]
  5951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5952. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  5953. {
  5954. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5955. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  5956. return Ok(await _visaCommissionRep.Del(id, currUserId));
  5957. }
  5958. #endregion
  5959. #region op费用录入
  5960. /// <summary>
  5961. /// 根据diid查询op费用列表
  5962. /// </summary>
  5963. /// <param name="dto"></param>
  5964. /// <returns></returns>
  5965. [HttpPost]
  5966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5967. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5968. {
  5969. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5970. if (groupData.Code != 0)
  5971. {
  5972. return Ok(JsonView(false, groupData.Msg));
  5973. }
  5974. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5975. }
  5976. /// <summary>
  5977. /// 根据op费用Id查询单条数据及c表数据
  5978. /// </summary>
  5979. /// <param name="dto"></param>
  5980. /// <returns></returns>
  5981. [HttpPost]
  5982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5983. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5984. {
  5985. try
  5986. {
  5987. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5988. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5989. var data = new
  5990. {
  5991. CarTouristGuideGround = _groupData,
  5992. CreditCardPayment = _creditCardPayment
  5993. };
  5994. return Ok(JsonView(true, "查询成功!", data));
  5995. }
  5996. catch (Exception ex)
  5997. {
  5998. return Ok(JsonView(false, "程序错误!"));
  5999. }
  6000. }
  6001. /// <summary>
  6002. /// op费用删除
  6003. /// </summary>
  6004. /// <param name="dto"></param>
  6005. /// <returns></returns>
  6006. [HttpPost]
  6007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6008. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6009. {
  6010. try
  6011. {
  6012. _sqlSugar.BeginTran();
  6013. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6014. if (!res)
  6015. {
  6016. return Ok(JsonView(false, "删除失败"));
  6017. }
  6018. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6019. {
  6020. IsDel = 1,
  6021. DeleteUserId = dto.DeleteUserId,
  6022. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6023. }).ExecuteCommandAsync();
  6024. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6025. {
  6026. IsDel = 1,
  6027. DeleteUserId = dto.DeleteUserId,
  6028. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6029. }).ExecuteCommandAsync();
  6030. #region 删除超支相关数据
  6031. //删除导入的超支数据
  6032. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6033. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6034. {
  6035. IsDel = 1,
  6036. DeleteUserId = dto.DeleteUserId,
  6037. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6038. }).ExecuteCommand();
  6039. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6040. {
  6041. IsDel = 1,
  6042. DeleteUserId = dto.DeleteUserId,
  6043. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6044. }).ExecuteCommand();
  6045. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6046. {
  6047. IsDel = 1,
  6048. DeleteUserId = dto.DeleteUserId,
  6049. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6050. }).ExecuteCommand();
  6051. #endregion
  6052. _sqlSugar.CommitTran();
  6053. return Ok(JsonView(true, "删除成功!"));
  6054. }
  6055. catch (Exception ex)
  6056. {
  6057. _sqlSugar.RollbackTran();
  6058. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6059. }
  6060. }
  6061. /// <summary>
  6062. /// op费用录入操作(Status:1.新增,2.修改)
  6063. /// </summary>
  6064. /// <param name="dto"></param>
  6065. /// <returns></returns>
  6066. [HttpPost]
  6067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6068. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6069. {
  6070. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6071. if (groupData.Code != 0)
  6072. {
  6073. return Ok(JsonView(false, groupData.Msg));
  6074. }
  6075. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6076. }
  6077. /// <summary>
  6078. /// 填写费用详细页面初始化绑定
  6079. /// </summary>
  6080. /// <param name="dto"></param>
  6081. /// <returns></returns>
  6082. [HttpPost]
  6083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6084. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6085. {
  6086. try
  6087. {
  6088. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6089. if (groupData.Code != 0)
  6090. {
  6091. return Ok(JsonView(false, groupData.Msg));
  6092. }
  6093. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6094. }
  6095. catch (Exception ex)
  6096. {
  6097. return Ok(JsonView(false, ex.Message));
  6098. }
  6099. }
  6100. /// <summary>
  6101. /// 根据op费用Id查询详细数据
  6102. /// </summary>
  6103. /// <param name="dto"></param>
  6104. /// <returns></returns>
  6105. [HttpPost]
  6106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6107. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6108. {
  6109. try
  6110. {
  6111. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6112. if (groupData.Code != 0)
  6113. {
  6114. return Ok(JsonView(false, groupData.Msg));
  6115. }
  6116. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6117. }
  6118. catch (Exception ex)
  6119. {
  6120. return Ok(JsonView(false, ex.Message));
  6121. }
  6122. }
  6123. /// <summary>
  6124. /// OP费用录入填写详情
  6125. /// </summary>
  6126. /// <param name="dto"></param>
  6127. /// <returns></returns>
  6128. [HttpPost]
  6129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6130. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6131. {
  6132. try
  6133. {
  6134. #region 参数校验
  6135. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6136. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6137. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6138. #endregion
  6139. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6140. if (groupData.Code != 0)
  6141. {
  6142. return Ok(JsonView(false, groupData.Msg));
  6143. }
  6144. //自动审核
  6145. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6146. #region 应用推送
  6147. try
  6148. {
  6149. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6150. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6151. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6152. }
  6153. catch (Exception ex)
  6154. {
  6155. }
  6156. #endregion
  6157. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6158. }
  6159. catch (Exception ex)
  6160. {
  6161. return Ok(JsonView(false, ex.Message));
  6162. }
  6163. }
  6164. /// <summary>
  6165. /// 获取三公详细所有城市
  6166. /// </summary>
  6167. /// <returns></returns>
  6168. [HttpGet]
  6169. public IActionResult OpCarCityResult()
  6170. {
  6171. var jw = JsonView(false);
  6172. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6173. {
  6174. x.Id,
  6175. x.Country,
  6176. x.City,
  6177. }).ToList();
  6178. if (data.Count > 0)
  6179. {
  6180. jw = JsonView(true, "获取成功!", data);
  6181. }
  6182. else
  6183. {
  6184. jw.Msg = "城市数据为空!";
  6185. jw.Data = new string[0];
  6186. }
  6187. return Ok(jw);
  6188. }
  6189. /// <summary>
  6190. /// 导出地接费用明细
  6191. /// </summary>
  6192. /// <param name="dto"></param>
  6193. /// <returns></returns>
  6194. [HttpPost]
  6195. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6196. {
  6197. var jw = JsonView(false);
  6198. if (dto.Diid < 1)
  6199. {
  6200. jw.Msg = "请输入正确的diid!";
  6201. return Ok(jw);
  6202. }
  6203. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6204. if (group == null)
  6205. {
  6206. jw.Msg = "未找到团组信息!";
  6207. return Ok(jw);
  6208. }
  6209. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6210. if (localGuideArr.Count == 0)
  6211. {
  6212. jw.Msg = "该团组暂无地接信息!";
  6213. return Ok(jw);
  6214. }
  6215. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6216. var overspendSoure = new Dictionary<int, int>
  6217. {
  6218. { 91, 982 }, //车
  6219. { 92 , 1059} ,//导游
  6220. { 994 , 1073}, //翻译
  6221. { 988 , 1074 }, //早餐
  6222. { 93 , 1075 }, //午餐
  6223. { 989 , 1076 }, //晚餐
  6224. };
  6225. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6226. foreach (var groupArr in localGroup)
  6227. {
  6228. var keyValue = groupArr.Key;
  6229. if (int.TryParse(keyValue, out int cityid))
  6230. {
  6231. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6232. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6233. }
  6234. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6235. foreach (var item in groupArr)
  6236. {
  6237. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6238. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6239. new Grp_CarTouristGuideGroundReservationsContentExtend
  6240. {
  6241. Count = a.Count,
  6242. CreateTime = a.CreateTime,
  6243. CreateUserId = a.CreateUserId,
  6244. CTGGRId = a.CTGGRId,
  6245. Currency = a.Currency,
  6246. DatePrice = a.DatePrice,
  6247. DeleteTime = a.DeleteTime,
  6248. DeleteUserId = a.DeleteUserId,
  6249. DiId = a.DiId,
  6250. Id = a.Id,
  6251. IsDel = a.IsDel,
  6252. Price = a.Price,
  6253. PriceContent = a.PriceContent,
  6254. Remark = a.Remark,
  6255. SId = a.SId,
  6256. SidName = b.Name,
  6257. Units = a.Units,
  6258. }
  6259. ).ToList();
  6260. if (content.Count > 0)
  6261. {
  6262. contentArr.Add(content);
  6263. }
  6264. }
  6265. //open excel
  6266. //set excel
  6267. //save excel
  6268. try
  6269. {
  6270. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6271. IWorkbook workbook;
  6272. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6273. {
  6274. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6275. }
  6276. else
  6277. {
  6278. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6279. }
  6280. ISheet sheet = workbook.GetSheetAt(0);
  6281. var rowStartIndex = 2;
  6282. var clounmCount = 10;
  6283. var initStyleRow = sheet.GetRow(2);
  6284. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6285. //var overspendArrDetail =
  6286. var existsId = new List<CarCompare>();
  6287. var lastElem = arr.Last();
  6288. var thisSid = -1;
  6289. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6290. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6291. {
  6292. Name = "未知币种!",
  6293. Remark = "未知币种!",
  6294. };
  6295. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6296. Action cloneRowFn = () =>
  6297. {
  6298. rowStartIndex++;
  6299. var cloneRow = sheet.CreateRow(rowStartIndex);
  6300. // 复制样式
  6301. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6302. {
  6303. ICell sourceCell = initStyleRow.GetCell(i);
  6304. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6305. // 确保单元格存在样式
  6306. if (sourceCell.CellStyle != null)
  6307. {
  6308. targetCell.CellStyle = sourceCell.CellStyle;
  6309. }
  6310. }
  6311. };
  6312. var mergeRow = () =>
  6313. {
  6314. for (int i = 2; i < sheet.LastRowNum; i++)
  6315. {
  6316. var row = sheet.GetRow(i);
  6317. var cellFirst = row.GetCell(0);
  6318. var thisIndex = i + 1;
  6319. while (thisIndex < sheet.LastRowNum)
  6320. {
  6321. var nextRow = sheet.GetRow(thisIndex);
  6322. var nextCellFirst = nextRow.GetCell(0);
  6323. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6324. {
  6325. thisIndex++;
  6326. }
  6327. else
  6328. {
  6329. break;
  6330. }
  6331. }
  6332. thisIndex--;
  6333. if (thisIndex != i)
  6334. {
  6335. //合并row
  6336. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6337. i, // 起始行索引(0-based)
  6338. thisIndex, // 结束行索引(0-based)
  6339. 0, // 起始列索引(0-based)
  6340. 0 // 结束列索引(0-based)
  6341. );
  6342. sheet.AddMergedRegion(cellRangeAddress);
  6343. i = thisIndex;
  6344. }
  6345. }
  6346. };
  6347. var chaoshiNumber = 0;
  6348. var totalNumber = 0.00M;
  6349. string lastStr = "";
  6350. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6351. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6352. {
  6353. b.IsAuditGM,
  6354. x.Id,
  6355. x.Area,
  6356. b.PayPercentage,
  6357. b.PayMoney,
  6358. }).ToList();
  6359. string yesPayment = "", noPayment = "";
  6360. foreach (var item in queryCarArrByCityAndDiid)
  6361. {
  6362. if (item.IsAuditGM == 1)
  6363. {
  6364. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6365. }
  6366. else
  6367. {
  6368. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6369. }
  6370. }
  6371. lastStr = yesPayment + noPayment;
  6372. foreach (var item in arr)
  6373. {
  6374. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6375. {
  6376. if (thisSid != item.SId)
  6377. {
  6378. if (thisSid == -1)
  6379. {
  6380. thisSid = item.SId;
  6381. }
  6382. else
  6383. {
  6384. //合并小计行
  6385. //创建合并区域的实例
  6386. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6387. rowStartIndex, // 起始行索引(0-based)
  6388. rowStartIndex, // 结束行索引(0-based)
  6389. 0, // 起始列索引(0-based)
  6390. 3 // 结束列索引(0-based)
  6391. );
  6392. sheet.AddMergedRegion(cellRangeAddress);
  6393. var CellStyle = workbook.CreateCellStyle();
  6394. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6395. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6396. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6397. for (int i = 0; i <= clounmCount; i++)
  6398. {
  6399. if (i > 6)
  6400. {
  6401. var CellStyle1 = workbook.CreateCellStyle();
  6402. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6403. IFont Font = workbook.CreateFont(); // 创建字体
  6404. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6405. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6406. CellStyle1.SetFont(Font);
  6407. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6408. }
  6409. else
  6410. {
  6411. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6412. }
  6413. }
  6414. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6415. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6416. //超时合计
  6417. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6418. //超时数
  6419. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6420. //超时合计费用
  6421. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6422. thisSid = item.SId;
  6423. cloneRowFn();
  6424. chaoshiNumber = 0;
  6425. totalNumber = 0;
  6426. }
  6427. }
  6428. IRow row = sheet.GetRow(rowStartIndex);
  6429. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6430. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6431. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6432. if (isOpenOverspendSoure)
  6433. {
  6434. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6435. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6436. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6437. }
  6438. for (int i = 0; i <= clounmCount; i++)
  6439. {
  6440. var cell = row.GetCell(i);
  6441. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6442. if (cell == null)
  6443. {
  6444. cell = row.CreateCell(i);
  6445. }
  6446. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6447. fontRed.CloneStyleFrom(cell.CellStyle);
  6448. IFont Font = workbook.CreateFont(); // 创建字体
  6449. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6450. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6451. fontRed.SetFont(Font);
  6452. byte[] rgb = new byte[3] { 255, 242, 204 };
  6453. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6454. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6455. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6456. if (workbook is XSSFWorkbook)
  6457. {
  6458. BackgroundColor255_242_204.FillForegroundColor = 0;
  6459. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6460. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6461. }
  6462. else
  6463. {
  6464. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6465. }
  6466. if (i == 1 || i > 6)
  6467. {
  6468. if (i > 6)
  6469. {
  6470. fontRed.FillForegroundColor = 0;
  6471. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6472. fontRed.FillPattern = FillPattern.SolidForeground;
  6473. }
  6474. cell.CellStyle = fontRed;
  6475. }
  6476. if (i > 2 && i < 7)
  6477. {
  6478. cell.CellStyle = BackgroundColor255_242_204;
  6479. }
  6480. cell.SetCellValue(setCellValue); //写入单元格
  6481. }
  6482. if (overspendSoure.ContainsKey(thisSid))
  6483. {
  6484. var overspendId = overspendSoure[thisSid];
  6485. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6486. }
  6487. cloneRowFn();
  6488. existsId.Add(new CarCompare
  6489. {
  6490. DataPrice = item.DatePrice.ObjToDate(),
  6491. Sid = item.SId
  6492. });
  6493. }
  6494. if (item.Equals(lastElem))
  6495. {
  6496. //合并小计行
  6497. //创建合并区域的实例
  6498. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6499. rowStartIndex, // 起始行索引(0-based)
  6500. rowStartIndex, // 结束行索引(0-based)
  6501. 0, // 起始列索引(0-based)
  6502. 3 // 结束列索引(0-based)
  6503. );
  6504. sheet.AddMergedRegion(cellRangeAddress);
  6505. var CellStyle = workbook.CreateCellStyle();
  6506. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6507. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6508. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6509. for (int i = 0; i <= clounmCount; i++)
  6510. {
  6511. if (i > 6)
  6512. {
  6513. var CellStyle1 = workbook.CreateCellStyle();
  6514. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6515. IFont Font = workbook.CreateFont(); // 创建字体
  6516. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6517. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6518. CellStyle1.SetFont(Font);
  6519. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6520. }
  6521. else
  6522. {
  6523. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6524. }
  6525. }
  6526. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6527. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6528. //超时合计
  6529. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6530. //超时数
  6531. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6532. //超时合计费用
  6533. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6534. cloneRowFn();
  6535. // 创建合并区域的实例
  6536. cellRangeAddress = new CellRangeAddress(
  6537. rowStartIndex, // 起始行索引(0-based)
  6538. rowStartIndex, // 结束行索引(0-based)
  6539. 0, // 起始列索引(0-based)
  6540. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6541. );
  6542. // 添加合并区域
  6543. sheet.AddMergedRegion(cellRangeAddress);
  6544. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6545. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6546. }
  6547. }
  6548. mergeRow();
  6549. // 保存修改后的Excel文件到新文件
  6550. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6551. // new FileStream(newFilePath, FileMode.CreateNew)
  6552. using (var stream = new MemoryStream())
  6553. {
  6554. workbook.Write(stream, true);
  6555. stream.Flush();
  6556. stream.Seek(0, SeekOrigin.Begin);
  6557. MemoryStream memoryStream = new MemoryStream();
  6558. stream.CopyTo(memoryStream);
  6559. memoryStream.Seek(0, SeekOrigin.Begin);
  6560. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6561. }
  6562. workbook.Close();
  6563. workbook.Dispose();
  6564. }
  6565. catch (Exception ex)
  6566. {
  6567. jw.Msg = "出现异常!" + ex.Message;
  6568. return Ok(jw);
  6569. }
  6570. }
  6571. if (Zips.Count > 0)
  6572. {
  6573. IOOperatorHelper io = new IOOperatorHelper();
  6574. var byts = io.ConvertZipStream(Zips);
  6575. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6576. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6577. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6578. }
  6579. else
  6580. {
  6581. jw.Msg = "暂无生成文件!";
  6582. }
  6583. return Ok(jw);
  6584. }
  6585. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6586. {
  6587. string outStr = string.Empty;
  6588. switch (i)
  6589. {
  6590. case 0:
  6591. outStr = arr[0].SidName;
  6592. break;
  6593. case 1:
  6594. outStr = arr[0].DataPriceStr;
  6595. break;
  6596. case 2:
  6597. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6598. break;
  6599. case 4:
  6600. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6601. break;
  6602. case 7:
  6603. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6604. {
  6605. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6606. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6607. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6608. }
  6609. break;
  6610. case 8:
  6611. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6612. {
  6613. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6614. }
  6615. break;
  6616. case 9:
  6617. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6618. {
  6619. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6620. }
  6621. break;
  6622. case 10:
  6623. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6624. {
  6625. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6626. }
  6627. break;
  6628. }
  6629. return outStr;
  6630. }
  6631. #region OP行程单
  6632. /// <summary>
  6633. /// OP行程单初始化
  6634. /// </summary>
  6635. /// <param name="dto"></param>
  6636. /// <returns></returns>
  6637. [HttpPost]
  6638. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6639. {
  6640. var jw = JsonView(false);
  6641. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6642. var group = groupList.First();
  6643. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6644. if (group == null)
  6645. {
  6646. jw.Msg = "暂无团组!";
  6647. return Ok(jw);
  6648. }
  6649. group = groupList.Find(x => x.Id == diid);
  6650. if (group == null)
  6651. {
  6652. jw.Msg = "请输入正确的团组ID!";
  6653. return Ok(jw);
  6654. }
  6655. string city = string.Empty;
  6656. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6657. if (blackCode.Count > 0)
  6658. {
  6659. var black = blackCode.First();
  6660. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6661. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6662. if (blackSp.Length > 0)
  6663. {
  6664. try
  6665. {
  6666. var cityArrCode = new List<string>(20);
  6667. foreach (var item in blackSp)
  6668. {
  6669. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6670. var IndexSelect = itemSp[2];
  6671. var cityArrCodeLength = cityArrCode.Count - 1;
  6672. var startCity = IndexSelect.Substring(0, 3);
  6673. if (cityArrCodeLength > 0)
  6674. {
  6675. var arrEndCity = cityArrCode[cityArrCodeLength];
  6676. if (arrEndCity != startCity)
  6677. {
  6678. cityArrCode.Add(startCity.ToUpper());
  6679. }
  6680. }
  6681. else
  6682. {
  6683. cityArrCode.Add(startCity.ToUpper());
  6684. }
  6685. var endCity = IndexSelect.Substring(3, 3);
  6686. cityArrCode.Add(endCity.ToUpper());
  6687. }
  6688. var cityThree = string.Empty;
  6689. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6690. cityThree = cityThree.TrimEnd(',');
  6691. if (string.IsNullOrWhiteSpace(cityThree))
  6692. {
  6693. throw new
  6694. Exception("error");
  6695. }
  6696. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6697. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6698. foreach (var item in cityArrCode)
  6699. {
  6700. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6701. if (find != null)
  6702. {
  6703. city += find.City + "/";
  6704. }
  6705. else
  6706. {
  6707. city += item + "三字码未收入/";
  6708. }
  6709. }
  6710. city = city.TrimEnd('/');
  6711. }
  6712. catch (Exception e)
  6713. {
  6714. city = "黑屏代码格式不正确!";
  6715. }
  6716. }
  6717. }
  6718. else
  6719. {
  6720. city = "未录入黑屏代码";
  6721. }
  6722. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6723. {
  6724. Date = x.Date,
  6725. Days = x.Days,
  6726. Diffgroup = x.Diffgroup,
  6727. Diid = x.Diid,
  6728. Traffic_First = x.Traffic_First,
  6729. Traffic_Second = x.Traffic_Second,
  6730. Trip = x.Trip,
  6731. WeekDay = x.WeekDay,
  6732. Id = x.Id
  6733. }).ToList();
  6734. jw.Data = new
  6735. {
  6736. groupList = groupList.Select(x => new
  6737. {
  6738. x.Id,
  6739. x.TeamName,
  6740. x.TourCode
  6741. }).ToList(),
  6742. groupInfo = new
  6743. {
  6744. group.VisitDays,
  6745. group.TourCode,
  6746. group.VisitPNumber,
  6747. group.TeamName,
  6748. city
  6749. },
  6750. OpTravelList
  6751. };
  6752. jw.Code = 200;
  6753. jw.Msg = "操作成功!";
  6754. return Ok(jw);
  6755. }
  6756. /// <summary>
  6757. /// 删除团组行程单
  6758. /// </summary>
  6759. /// <returns></returns>
  6760. [HttpPost]
  6761. public IActionResult DelTravel(DelOpTravelDto dto)
  6762. {
  6763. var jw = JsonView(false);
  6764. if (dto.UserId <= 0 || dto.Diid <= 0)
  6765. {
  6766. jw.Msg = "请输入正确的参数!";
  6767. return Ok(jw);
  6768. }
  6769. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6770. .SetColumns(x => new Grp_TravelList
  6771. {
  6772. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6773. DeleteUserId = dto.UserId,
  6774. IsDel = 1,
  6775. }).ExecuteCommand();
  6776. jw = JsonView(true);
  6777. return Ok(jw);
  6778. }
  6779. /// <summary>
  6780. /// 行程单保存
  6781. /// </summary>
  6782. /// <returns></returns>
  6783. [HttpPost]
  6784. public IActionResult TravelSave(TravelSaveDto dto)
  6785. {
  6786. var jw = JsonView(false);
  6787. if (dto.Arr.Count > 0)
  6788. {
  6789. try
  6790. {
  6791. _sqlSugar.BeginTran();
  6792. foreach (var item in dto.Arr)
  6793. {
  6794. if (item.Id == 0)
  6795. {
  6796. throw new Exception("请传入正确的Id");
  6797. }
  6798. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6799. .SetColumns(x => new Grp_TravelList
  6800. {
  6801. Trip = item.Trip
  6802. }).ExecuteCommand();
  6803. }
  6804. _sqlSugar.CommitTran();
  6805. jw = JsonView(true);
  6806. }
  6807. catch (Exception ex)
  6808. {
  6809. _sqlSugar.RollbackTran();
  6810. jw.Msg = "程序异常!" + ex.Message;
  6811. }
  6812. }
  6813. else
  6814. {
  6815. jw.Msg = "请传入正确的参数!";
  6816. }
  6817. return Ok(jw);
  6818. }
  6819. /// <summary>
  6820. /// 导出行程单
  6821. /// </summary>
  6822. /// <param name="dto"></param>
  6823. /// <returns></returns>
  6824. [HttpPost]
  6825. public IActionResult ExportTravel(ExportTravelDto dto)
  6826. {
  6827. var jw = JsonView(false);
  6828. jw.Data = "";
  6829. int diid = 0;
  6830. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6831. if (Find == null)
  6832. {
  6833. jw.Msg = "请选择正确的团组!";
  6834. return Ok(jw);
  6835. }
  6836. else
  6837. {
  6838. diid = Find.Id;
  6839. }
  6840. //数据源
  6841. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6842. DataTable dtBlack = null;
  6843. try
  6844. {
  6845. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6846. }
  6847. catch (Exception)
  6848. {
  6849. jw.Msg = "机票黑屏代码有误!";
  6850. return Ok(jw);
  6851. }
  6852. string CityStr = string.Empty;
  6853. if (dtBlack.Rows.Count == 0)
  6854. {
  6855. jw.Msg = "机票黑屏代码有误!";
  6856. return Ok(jw);
  6857. }
  6858. else
  6859. {
  6860. foreach (DataRow row in dtBlack.Rows)
  6861. {
  6862. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6863. {
  6864. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6865. return Ok(jw);
  6866. }
  6867. }
  6868. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6869. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6870. }
  6871. //创建数据源Table
  6872. DataTable dtSource = new DataTable();
  6873. dtSource.Columns.Add("Days", typeof(string));
  6874. dtSource.Columns.Add("Date", typeof(string));
  6875. dtSource.Columns.Add("Week", typeof(string));
  6876. dtSource.Columns.Add("Traffic", typeof(string));
  6877. dtSource.Columns.Add("Trip", typeof(string));
  6878. //获取数据,放到datatable
  6879. foreach (var item in _travelList)
  6880. {
  6881. DataRow dr = dtSource.NewRow();
  6882. dr["Days"] = item.Days;
  6883. dr["Date"] = item.Date;
  6884. dr["Week"] = item.WeekDay;
  6885. dr["Traffic"] = item.Traffic_First
  6886. + "\r\n"
  6887. + item.Traffic_Second;
  6888. dr["Trip"] = item.Trip;
  6889. dtSource.Rows.Add(dr);
  6890. }
  6891. Dictionary<string, string> dic = new Dictionary<string, string>();
  6892. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6893. dic.Add("City", CityStr);
  6894. dic.Add("Days", Find.VisitDays.ToString());
  6895. dic.Add("DeleCode", Find.TourCode);
  6896. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6897. //模板路径
  6898. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6899. //载入模板
  6900. Document doc = null;
  6901. DocumentBuilder builder = null;
  6902. try
  6903. {
  6904. //载入模板
  6905. doc = new Document(tempPath);
  6906. builder = new DocumentBuilder(doc);
  6907. }
  6908. catch (Exception)
  6909. {
  6910. jw.Msg = "模板位置不存在!";
  6911. return Ok(jw);
  6912. }
  6913. foreach (var key in dic.Keys)
  6914. {
  6915. Bookmark bookmark = doc.Range.Bookmarks[key];
  6916. if (bookmark != null)
  6917. {
  6918. builder.MoveToBookmark(key);
  6919. builder.Write(dic[key]);
  6920. }
  6921. }
  6922. //获取word里所有表格
  6923. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6924. //获取所填表格的序数
  6925. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6926. try
  6927. {
  6928. //循环赋值
  6929. for (int i = 0; i < dtSource.Rows.Count; i++)
  6930. {
  6931. builder.MoveToCell(0, i + 1, 0, 0);
  6932. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6933. builder.MoveToCell(0, i + 1, 1, 0);
  6934. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6935. builder.MoveToCell(0, i + 1, 2, 0);
  6936. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6937. var trip = dtSource.Rows[i]["Trip"].ToString();
  6938. builder.MoveToCell(0, i + 1, 3, 0);
  6939. builder.Write(trip);
  6940. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6941. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6942. // 获取特定索引的段落
  6943. Paragraph paragraph = (Paragraph)paragraphs[0];
  6944. Run run = paragraph.Runs[0];
  6945. Aspose.Words.Font font = run.Font;
  6946. font.Name = "黑体";
  6947. //设置双休红色
  6948. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6949. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6950. paragraph = (Paragraph)paragraphs[1];
  6951. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6952. {
  6953. run = paragraph.Runs[0];
  6954. font = run.Font;
  6955. font.Color = Color.Red;
  6956. }
  6957. }
  6958. }
  6959. catch (Exception ex)
  6960. {
  6961. }
  6962. //删除多余行
  6963. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6964. {
  6965. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6966. }
  6967. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6968. if (!Directory.Exists(savePath))
  6969. {
  6970. try
  6971. {
  6972. Directory.CreateDirectory(savePath);
  6973. }
  6974. catch
  6975. {
  6976. }
  6977. }
  6978. string path = savePath + Find.TeamName + "出访日程";
  6979. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6980. try
  6981. {
  6982. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6983. string postfix = ".docx";
  6984. if (dto.IsPDF == 1)
  6985. {
  6986. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6987. postfix = ".pdf";
  6988. }
  6989. doc.Save(path + postfix, saveFormat);
  6990. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6991. }
  6992. catch (Exception)
  6993. {
  6994. jw = JsonView(false);
  6995. }
  6996. return Ok(jw);
  6997. }
  6998. /// <summary>
  6999. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7000. /// </summary>
  7001. /// <param name="num"></param>
  7002. /// <returns></returns>
  7003. string GetNum(string num)
  7004. {
  7005. string str = "";
  7006. switch (num)
  7007. {
  7008. case "1":
  7009. str = "一";
  7010. break;
  7011. case "2":
  7012. str = "二";
  7013. break;
  7014. case "3":
  7015. str = "三";
  7016. break;
  7017. case "4":
  7018. str = "四";
  7019. break;
  7020. case "5":
  7021. str = "五";
  7022. break;
  7023. case "6":
  7024. str = "六";
  7025. break;
  7026. case "7":
  7027. str = "七";
  7028. break;
  7029. case "8":
  7030. str = "八";
  7031. break;
  7032. case "9":
  7033. str = "九";
  7034. break;
  7035. case "10":
  7036. str = "十";
  7037. break;
  7038. case "11":
  7039. str = "十一";
  7040. break;
  7041. case "12":
  7042. str = "十二";
  7043. break;
  7044. case "一":
  7045. str = "1";
  7046. break;
  7047. case "二":
  7048. str = "2";
  7049. break;
  7050. case "三":
  7051. str = "3";
  7052. break;
  7053. case "四":
  7054. str = "4";
  7055. break;
  7056. case "五":
  7057. str = "5";
  7058. break;
  7059. case "六":
  7060. str = "6";
  7061. break;
  7062. case "七":
  7063. str = "7";
  7064. break;
  7065. case "八":
  7066. str = "8";
  7067. break;
  7068. case "九":
  7069. str = "9";
  7070. break;
  7071. case "十":
  7072. str = "10";
  7073. break;
  7074. case "十一":
  7075. str = "11";
  7076. break;
  7077. case "十二":
  7078. str = "12";
  7079. break;
  7080. }
  7081. return str;
  7082. }
  7083. #endregion
  7084. #endregion
  7085. #region 团组成本
  7086. /// <summary>
  7087. /// 团组成本数据初始化
  7088. /// </summary>
  7089. /// <param name="dto"></param>
  7090. /// <returns></returns>
  7091. [HttpPost]
  7092. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7093. {
  7094. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7095. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7096. WHEN COUNT(*) >= 0 THEN 'True'
  7097. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7098. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7099. ").ToList(); //团组列表
  7100. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7101. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7102. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7103. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7104. if (groupinfoValue != null)
  7105. {
  7106. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7107. var spArr = new string[1] { countryArr };
  7108. if (countryArr.Contains("|"))
  7109. {
  7110. spArr = countryArr.Split("|");
  7111. }
  7112. else if (countryArr.Contains("、"))
  7113. {
  7114. spArr = countryArr.Split("、");
  7115. }
  7116. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7117. {
  7118. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7119. if (dbQueryCountry != null)
  7120. {
  7121. visaCountryInfoArr.Add(dbQueryCountry);
  7122. }
  7123. }
  7124. }
  7125. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7126. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7127. var create = _GroupCostRepository.
  7128. CreateGroupCostByBlackCode(dto.Diid);
  7129. if (groupCost.Count == 0 && create.Code == 0)
  7130. {
  7131. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7132. }
  7133. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7134. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7135. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7136. groupCostMap = groupCostMap.Select(x =>
  7137. {
  7138. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7139. {
  7140. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7141. }
  7142. return x;
  7143. }).ToList();
  7144. //GroupCostParameter.Add(new
  7145. // Grp_GroupCostParameter());
  7146. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7147. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7148. return Ok(JsonView(new
  7149. {
  7150. groupList,
  7151. groupInfo,
  7152. groupChecks,
  7153. groupCost = groupCostMap,
  7154. hotelNumber,
  7155. GroupCostParameter = GroupCostParameterMap,
  7156. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7157. {
  7158. x.VisaCountry,
  7159. x.VisaPrice,
  7160. x.Id,
  7161. }).ToList(),
  7162. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7163. blackCodeIsTrue = create.Code == 0 ? true : false,
  7164. hotelIsTrue = hotelIsTrue,
  7165. }));
  7166. }
  7167. /// <summary>
  7168. /// 团组成本信息保存
  7169. /// </summary>
  7170. /// <param name="dto"></param>
  7171. /// <returns></returns>
  7172. [HttpPost]
  7173. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7174. {
  7175. if (dto.Diid <= 0 || dto.Userid <= 0)
  7176. {
  7177. return Ok(JsonView(false));
  7178. }
  7179. JsonView jw = null;
  7180. bool isTrue = false;
  7181. #region 复制团组成本
  7182. //if (dto.Diid == 2581)
  7183. //{
  7184. // dto.Diid = 2599;
  7185. // dto.CheckBoxs.ForEach(x =>
  7186. // {
  7187. // x.Diid = 2599;
  7188. // });
  7189. // dto.GroupCosts.ForEach(x =>
  7190. // {
  7191. // x.Diid = 2599;
  7192. // });
  7193. // dto.CostTypeHotelNumbers.ForEach(x =>
  7194. // {
  7195. // x.Diid = 2599;
  7196. // });
  7197. // dto.GroupCostParameters.ForEach(x =>
  7198. // {
  7199. // x.DiId = 2599;
  7200. // });
  7201. //}
  7202. #endregion
  7203. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7204. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7205. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7206. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7207. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7208. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7209. try
  7210. {
  7211. _sqlSugar.BeginTran();
  7212. isTrue = await _GroupCostRepository.
  7213. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7214. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7215. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7216. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7217. _sqlSugar.CommitTran();
  7218. jw = JsonView(true, "保存成功!", isTrue);
  7219. }
  7220. catch (Exception)
  7221. {
  7222. _sqlSugar.RollbackTran();
  7223. jw = JsonView(false);
  7224. }
  7225. return Ok(jw);
  7226. }
  7227. /// <summary>
  7228. /// 司兼导数据
  7229. /// </summary>
  7230. /// <param name="dto"></param>
  7231. /// <returns></returns>
  7232. [HttpPost]
  7233. public IActionResult GetCarGuides(CarGuidesDto dto)
  7234. {
  7235. JsonView jw = null;
  7236. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7237. jw = JsonView(true, "获取成功!", Data);
  7238. return Ok(jw);
  7239. }
  7240. /// <summary>
  7241. /// 导游数据
  7242. /// </summary>
  7243. /// <param name="dto"></param>
  7244. /// <returns></returns>
  7245. [HttpPost]
  7246. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7247. {
  7248. JsonView jw = null;
  7249. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7250. // 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
  7251. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7252. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7253. jw = JsonView(true, "获取成功!", Data);
  7254. return Ok(jw);
  7255. }
  7256. /// <summary>
  7257. /// 成本车数据
  7258. /// </summary>
  7259. /// <param name="dto"></param>
  7260. /// <returns></returns>
  7261. [HttpPost]
  7262. public IActionResult GetCarInfo(CarGuidesDto dto)
  7263. {
  7264. JsonView jw = null;
  7265. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7266. jw = JsonView(true, "获取成功!", Data);
  7267. return Ok(jw);
  7268. }
  7269. /// <summary>
  7270. /// 景点数据
  7271. /// </summary>
  7272. /// <param name="dto"></param>
  7273. /// <returns></returns>
  7274. [HttpPost]
  7275. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7276. {
  7277. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7278. return Ok(JsonView(true, "获取成功!", Data));
  7279. }
  7280. /// <summary>
  7281. /// 成本通知
  7282. /// </summary>
  7283. /// <param name="dto"></param>
  7284. /// <returns></returns>
  7285. [HttpPost]
  7286. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7287. {
  7288. if (dto.Diid < 0)
  7289. {
  7290. return Ok(JsonView(false));
  7291. }
  7292. JsonView jw = null;
  7293. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7294. if (GroupCostParameter != null)
  7295. {
  7296. int IsShare = 0;
  7297. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7298. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7299. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7300. string msg = string.Empty;
  7301. if (isTrue)
  7302. {
  7303. if (IsShare == 0)
  7304. {
  7305. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7306. }
  7307. else
  7308. {
  7309. #region 企微通知对应岗位用户
  7310. try
  7311. {
  7312. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7313. }
  7314. catch (Exception ex)
  7315. {
  7316. }
  7317. #endregion
  7318. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7319. }
  7320. jw = JsonView(isTrue, msg, new { IsShare });
  7321. }
  7322. else
  7323. {
  7324. msg = "修改失败!";
  7325. jw = JsonView(isTrue, msg);
  7326. }
  7327. }
  7328. else
  7329. {
  7330. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7331. }
  7332. return Ok(jw);
  7333. }
  7334. /// <summary>
  7335. /// 导出报价单
  7336. /// </summary>
  7337. /// <param name="dto"></param>
  7338. /// <returns></returns>
  7339. [HttpPost]
  7340. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7341. {
  7342. if (dto.Diid == 0)
  7343. {
  7344. return Ok(JsonView(false, "请传递团组id"));
  7345. }
  7346. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7347. if (deleInfo.Code != 0)
  7348. {
  7349. return Ok(JsonView(false, "团组信息查询失败!"));
  7350. }
  7351. var di = deleInfo.Data as DelegationInfoWebView;
  7352. if (di != null)
  7353. {
  7354. di.TeamName = di.TeamName.Replace("|", "、");
  7355. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7356. //文件名
  7357. string strFileName = di.TeamName + "-收款账单.doc";
  7358. //获取模板
  7359. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7360. //载入模板
  7361. Document doc = new Document(tmppath);
  7362. decimal TotalPrice = 0.00M;
  7363. string itemStr = string.Empty;
  7364. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7365. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7366. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7367. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7368. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7369. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7370. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7371. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7372. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7373. foreach (var cost in groupCostType)
  7374. {
  7375. var List = cost.ToList();
  7376. if (cost.Key == "A")
  7377. {
  7378. foreach (var ListItem in List)
  7379. {
  7380. if (ListItem.number > 0)
  7381. {
  7382. if (ListItem.code.Contains("TBR"))
  7383. {
  7384. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7385. }
  7386. else
  7387. {
  7388. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7389. }
  7390. TotalPrice += (ListItem.number * ListItem.price);
  7391. }
  7392. }
  7393. }
  7394. else
  7395. {
  7396. itemStr = itemStr.Insert(0, "A段\r\n");
  7397. itemStr += "B段\r\n";
  7398. foreach (var ListItem in List)
  7399. {
  7400. if (ListItem.number > 0)
  7401. {
  7402. if (ListItem.code.Contains("TBR"))
  7403. {
  7404. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7405. }
  7406. else
  7407. {
  7408. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7409. }
  7410. TotalPrice += (ListItem.number * ListItem.price);
  7411. }
  7412. }
  7413. }
  7414. }
  7415. #region 替换Word模板书签内容
  7416. Dictionary<string, string> marks = new Dictionary<string, string>();
  7417. marks.Add("To", di.ClientUnit);//付款方
  7418. marks.Add("ToTel", di.TellPhone);//付款方电话
  7419. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7420. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7421. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7422. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7423. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7424. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7425. marks.Add("PayItemContent", itemStr);//详细信息
  7426. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7427. #endregion
  7428. ////注
  7429. //if (doc.Range.Bookmarks["Attention"] != null)
  7430. //{
  7431. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7432. // mark.Text = frList[0].Attention;
  7433. //}
  7434. foreach (var item in marks.Keys)
  7435. {
  7436. if (doc.Range.Bookmarks[item] != null)
  7437. {
  7438. Bookmark mark = doc.Range.Bookmarks[item];
  7439. mark.Text = marks[item];
  7440. }
  7441. }
  7442. byte[] bytes = null;
  7443. using (MemoryStream stream = new MemoryStream())
  7444. {
  7445. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7446. bytes = stream.ToArray();
  7447. }
  7448. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7449. return Ok(JsonView(true, "", new
  7450. {
  7451. Data = bytes,
  7452. strFileName,
  7453. }));
  7454. }
  7455. else
  7456. {
  7457. return Ok(JsonView(false, "团组信息不存在!"));
  7458. }
  7459. }
  7460. /// <summary>
  7461. /// 导出团组成本
  7462. /// </summary>
  7463. /// <param name="dto"></param>
  7464. /// <returns></returns>
  7465. [HttpPost]
  7466. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7467. {
  7468. var jw = JsonView(false);
  7469. if (dto.Diid == 0)
  7470. {
  7471. return Ok(JsonView(false, "请传递团组id"));
  7472. }
  7473. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7474. if (deleInfo.Code != 0)
  7475. {
  7476. return Ok(JsonView(false, "团组信息查询失败!"));
  7477. }
  7478. var di = deleInfo.Data as DelegationInfoWebView;
  7479. if (di == null)
  7480. {
  7481. return Ok(JsonView(false, "团组信息查询失败!"));
  7482. }
  7483. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7484. WorkbookDesigner designer = new WorkbookDesigner();
  7485. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7486. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7487. for (int i = 0; i < List_GC.Count; i++)
  7488. {
  7489. GroupCost_Excel gc = new GroupCost_Excel();
  7490. gc.Id = List_GC[i].Id;
  7491. gc.Diid = List_GC[i].Diid.ToString();
  7492. gc.DAY = List_GC[i].DAY;
  7493. string week = "";
  7494. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7495. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7496. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7497. gc.ITIN = List_GC[i].ITIN;
  7498. gc.CarType = List_GC[i].CarType;
  7499. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7500. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7501. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7502. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7503. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7504. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7505. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7506. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7507. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7508. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7509. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7510. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7511. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7512. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7513. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7514. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7515. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7516. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7517. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7518. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7519. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7520. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7521. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7522. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7523. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7524. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7525. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7526. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7527. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7528. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7529. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7530. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7531. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7532. List_GC1.Add(gc);
  7533. }
  7534. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7535. dt.TableName = "TB";
  7536. //报表标题等不用dt的值
  7537. designer.SetDataSource("TeamName", dto.title.TeamName);
  7538. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7539. designer.SetDataSource("Tax", dto.title.Tax);
  7540. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7541. designer.SetDataSource("Currency", dto.title.Currency);
  7542. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7543. designer.SetDataSource("Rate", dto.title.Rate);
  7544. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7545. var Aparams = hotels.Find(x => x.Type == "Default");
  7546. if (Aparams == null)
  7547. {
  7548. return Ok(jw);
  7549. }
  7550. //酒店数量
  7551. var txtSGRNumber = Aparams.SGR.ToString();
  7552. var txtTBRNumber = Aparams.TBR.ToString();
  7553. var txtJSESNumber = Aparams.JSES.ToString();
  7554. var txtSUITENumbe = Aparams.SUITE.ToString();
  7555. if (dto.costType == "B")
  7556. {
  7557. Aparams = hotels.Find(x => x.Type == "A");
  7558. var Bparams = hotels.Find(x => x.Type == "B");
  7559. if (Aparams == null || Bparams == null)
  7560. {
  7561. return Ok(jw);
  7562. }
  7563. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7564. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7565. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7566. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7567. }
  7568. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7569. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7570. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7571. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7572. var ws = designer.Workbook.Worksheets[0];
  7573. int Row = List_GC.Count;
  7574. int startIndex = 11;
  7575. int HideRows = 0;
  7576. List<int> hideRowsList = new List<int>();
  7577. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7578. #region A段left数据
  7579. var left = dto.leftInfo.Find(x => x.Type == "A");
  7580. if (left == null)
  7581. {
  7582. return Ok(jw);
  7583. }
  7584. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7585. if (leftBindData != null)
  7586. {
  7587. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7588. designer.SetDataSource("VisaRS", leftBindData.rs);
  7589. designer.SetDataSource("VisaXS", leftBindData.xs);
  7590. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7591. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7592. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7593. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7594. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7595. }
  7596. else
  7597. {
  7598. hideRowsList.Add(Row + startIndex + HideRows);
  7599. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7600. }
  7601. HideRows += 2;
  7602. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7603. if (leftBindData != null)
  7604. {
  7605. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7606. designer.SetDataSource("BXRS", leftBindData.rs);
  7607. designer.SetDataSource("BXXS", leftBindData.xs);
  7608. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7609. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7610. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7611. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7612. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7613. }
  7614. else
  7615. {
  7616. hideRowsList.Add(Row + startIndex + HideRows);
  7617. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7618. }
  7619. HideRows += 2;
  7620. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7621. if (leftBindData != null)
  7622. {
  7623. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7624. designer.SetDataSource("HSRS", leftBindData.rs);
  7625. designer.SetDataSource("HSXS", leftBindData.xs);
  7626. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7627. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7628. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7629. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7630. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7631. }
  7632. else
  7633. {
  7634. hideRowsList.Add(Row + startIndex + HideRows);
  7635. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7636. }
  7637. HideRows += 2;
  7638. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7639. if (leftBindData != null)
  7640. {
  7641. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7642. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7643. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7644. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7645. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7646. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7647. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7648. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7649. }
  7650. else
  7651. {
  7652. hideRowsList.Add(Row + startIndex + HideRows);
  7653. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7654. }
  7655. HideRows += 2;
  7656. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7657. if (leftBindData != null)
  7658. {
  7659. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7660. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7661. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7662. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7663. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7664. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7665. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7666. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7667. }
  7668. else
  7669. {
  7670. hideRowsList.Add(Row + startIndex + HideRows);
  7671. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7672. }
  7673. HideRows += 2;
  7674. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7675. if (leftBindData != null)
  7676. {
  7677. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7678. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7679. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7680. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7681. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7682. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7683. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7684. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7685. }
  7686. else
  7687. {
  7688. hideRowsList.Add(Row + startIndex + HideRows);
  7689. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7690. }
  7691. HideRows += 2;
  7692. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7693. if (leftBindData != null)
  7694. {
  7695. ////TBR
  7696. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7697. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7698. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7699. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7700. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7701. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7702. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7703. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7704. }
  7705. else
  7706. {
  7707. hideRowsList.Add(Row + startIndex + HideRows);
  7708. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7709. }
  7710. HideRows += 2;
  7711. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7712. if (leftBindData != null)
  7713. {
  7714. ////SGR
  7715. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7716. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7717. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7718. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7719. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7720. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7721. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7722. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7723. }
  7724. else
  7725. {
  7726. hideRowsList.Add(Row + startIndex + HideRows);
  7727. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7728. }
  7729. HideRows += 2;
  7730. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7731. if (leftBindData != null)
  7732. {
  7733. ////JS/ES
  7734. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7735. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7736. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7737. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7738. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7739. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7740. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7741. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7742. }
  7743. else
  7744. {
  7745. hideRowsList.Add(Row + startIndex + HideRows);
  7746. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7747. }
  7748. HideRows += 2;
  7749. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7750. if (leftBindData != null)
  7751. {
  7752. ////SUITE
  7753. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7754. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7755. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7756. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7757. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7758. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7759. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7760. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7761. }
  7762. else
  7763. {
  7764. hideRowsList.Add(Row + startIndex + HideRows);
  7765. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7766. }
  7767. HideRows += 2;
  7768. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7769. if (leftBindData != null)
  7770. {
  7771. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7772. designer.SetDataSource("DJRS", leftBindData.rs);
  7773. designer.SetDataSource("DJXS", leftBindData.xs);
  7774. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7775. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7776. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7777. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7778. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7779. }
  7780. else
  7781. {
  7782. hideRowsList.Add(Row + startIndex + HideRows);
  7783. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7784. }
  7785. HideRows += 2;
  7786. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7787. if (leftBindData != null)
  7788. {
  7789. designer.SetDataSource("HCPCB", leftBindData.cb);
  7790. designer.SetDataSource("HCPRS", leftBindData.rs);
  7791. designer.SetDataSource("HCPXS", leftBindData.xs);
  7792. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7793. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7794. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7795. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7796. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7797. }
  7798. else
  7799. {
  7800. hideRowsList.Add(Row + startIndex + HideRows);
  7801. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7802. }
  7803. HideRows += 2;
  7804. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7805. if (leftBindData != null)
  7806. {
  7807. designer.SetDataSource("CPCB", leftBindData.cb);
  7808. designer.SetDataSource("CPRS", leftBindData.rs);
  7809. designer.SetDataSource("CPXS", leftBindData.xs);
  7810. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7811. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7812. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7813. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7814. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7815. }
  7816. else
  7817. {
  7818. hideRowsList.Add(Row + startIndex + HideRows);
  7819. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7820. }
  7821. HideRows += 2;
  7822. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7823. if (leftBindData != null)
  7824. {
  7825. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7826. designer.SetDataSource("GWRS", leftBindData.rs);
  7827. designer.SetDataSource("GWXS", leftBindData.xs);
  7828. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7829. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7830. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7831. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7832. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7833. }
  7834. else
  7835. {
  7836. hideRowsList.Add(Row + startIndex + HideRows);
  7837. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7838. }
  7839. HideRows += 2;
  7840. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7841. if (leftBindData != null)
  7842. {
  7843. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7844. designer.SetDataSource("LYJRS", leftBindData.rs);
  7845. designer.SetDataSource("LYJXS", leftBindData.xs);
  7846. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7847. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7848. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7849. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7850. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7851. }
  7852. else
  7853. {
  7854. hideRowsList.Add(Row + startIndex + HideRows);
  7855. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7856. }
  7857. #endregion
  7858. #region A段Right信息
  7859. var right = dto.rightInfo.Find(x => x.Type == "A");
  7860. if (right == null)
  7861. {
  7862. return Ok(jw);
  7863. }
  7864. HideRows += 4;
  7865. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7866. if (rightBindData != null)
  7867. {
  7868. //经济舱 + 双人间 TBR
  7869. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7870. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7871. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7872. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7873. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7874. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7875. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7876. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7877. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7878. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7879. }
  7880. else
  7881. {
  7882. hideRowsList.Add(Row + startIndex + HideRows);
  7883. }
  7884. HideRows += 2;
  7885. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7886. if (rightBindData != null)
  7887. {
  7888. //经济舱 + 单人间 SGR
  7889. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7890. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7891. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7892. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7893. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7894. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7895. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7896. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7897. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7898. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7899. }
  7900. else
  7901. {
  7902. hideRowsList.Add(Row + startIndex + HideRows);
  7903. }
  7904. HideRows += 2;
  7905. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7906. if (rightBindData != null)
  7907. {
  7908. //公务舱 + 单人间 SGR
  7909. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7910. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7911. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7912. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7913. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7914. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7915. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7916. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7917. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7918. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7919. }
  7920. else
  7921. {
  7922. hideRowsList.Add(Row + startIndex + HideRows);
  7923. }
  7924. HideRows += 2;
  7925. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7926. if (rightBindData != null)
  7927. {
  7928. //公务舱 + 小套房 JSES
  7929. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7930. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7931. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7932. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7933. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7934. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7935. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7936. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7937. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7938. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7939. }
  7940. else
  7941. {
  7942. hideRowsList.Add(Row + startIndex + HideRows);
  7943. }
  7944. HideRows += 2;
  7945. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7946. if (rightBindData != null)
  7947. {
  7948. //公务舱 + 小套房 JSES
  7949. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7950. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7951. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7952. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7953. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7954. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7955. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7956. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7957. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7958. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7959. }
  7960. else
  7961. {
  7962. hideRowsList.Add(Row + startIndex + HideRows);
  7963. }
  7964. HideRows += 2;
  7965. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7966. if (rightBindData != null)
  7967. {
  7968. //经济舱 + 大套房
  7969. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7970. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7971. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7972. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7973. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7974. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7975. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7976. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7977. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7978. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7979. }
  7980. else
  7981. {
  7982. hideRowsList.Add(Row + startIndex + HideRows);
  7983. }
  7984. HideRows += 2;
  7985. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7986. if (rightBindData != null)
  7987. {
  7988. //头等舱 + 小套房 JSES
  7989. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7990. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7991. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7992. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7993. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7994. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7995. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7996. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7997. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7998. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7999. }
  8000. else
  8001. {
  8002. hideRowsList.Add(Row + startIndex + HideRows);
  8003. }
  8004. HideRows += 2;
  8005. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8006. if (rightBindData != null)
  8007. {
  8008. //头等舱 + 大套房
  8009. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8010. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8011. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8012. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8013. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8014. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8015. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8016. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8017. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8018. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8019. }
  8020. else
  8021. {
  8022. hideRowsList.Add(Row + startIndex + HideRows);
  8023. }
  8024. #endregion
  8025. #region B段标题清空
  8026. designer.SetDataSource("CostBDRCB", "");
  8027. designer.SetDataSource("CostBRS", "");
  8028. designer.SetDataSource("CostBXS", "");
  8029. designer.SetDataSource("CostBZCB", "");
  8030. designer.SetDataSource("CostBDRBJ", "");
  8031. designer.SetDataSource("CostBZBJ", "");
  8032. designer.SetDataSource("CostBDRLR", "");
  8033. designer.SetDataSource("CostBZLR", "");
  8034. designer.SetDataSource("CostBDRCBOM", "");
  8035. designer.SetDataSource("CostBRSOM", "");
  8036. designer.SetDataSource("CostBZCBOM", "");
  8037. designer.SetDataSource("CostBDRBJOM", "");
  8038. designer.SetDataSource("CostBZBJOM", "");
  8039. designer.SetDataSource("CostBDRLROM", "");
  8040. designer.SetDataSource("CostBZLROM", "");
  8041. #endregion
  8042. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8043. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8044. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8045. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8046. designer.SetDataSource("DJName", "地接(CNY)");
  8047. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8048. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8049. designer.SetDataSource("GWName", "公务(CNY)");
  8050. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8051. designer.SetDataSource("LYJName", "零用金(CNY)");
  8052. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8053. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8054. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8055. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8056. designer.SetDataSource("BXName", "保险(CNY)");
  8057. designer.SetDataSource("VisaName", "签证(CNY)");
  8058. #region B段基本数据
  8059. if (dto.costType == "B")
  8060. {
  8061. left = dto.leftInfo.Find(x => x.Type == "B");
  8062. if (left == null)
  8063. {
  8064. return Ok(jw);
  8065. }
  8066. #region B段left数据
  8067. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8068. if (leftBindData != null)
  8069. {
  8070. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8071. designer.SetDataSource("BHSRS", leftBindData.rs);
  8072. designer.SetDataSource("BHSXS", leftBindData.xs);
  8073. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8074. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8075. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8076. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8077. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8078. }
  8079. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8080. if (leftBindData != null)
  8081. {
  8082. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8083. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8084. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8085. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8086. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8087. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8088. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8089. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8090. }
  8091. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8092. if (leftBindData != null)
  8093. {
  8094. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8095. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8096. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8097. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8098. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8099. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8100. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8101. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8102. }
  8103. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8104. if (leftBindData != null)
  8105. {
  8106. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8107. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8108. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8109. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8110. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8111. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8112. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8113. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8114. }
  8115. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8116. if (leftBindData != null)
  8117. {
  8118. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8119. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8120. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8121. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8122. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8123. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8124. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8125. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8126. }
  8127. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8128. if (leftBindData != null)
  8129. {
  8130. designer.SetDataSource("BCPCB", leftBindData.cb);
  8131. designer.SetDataSource("BCPRS", leftBindData.rs);
  8132. designer.SetDataSource("BCPXS", leftBindData.xs);
  8133. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8134. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8135. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8136. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8137. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8138. }
  8139. //TBR
  8140. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8141. if (leftBindData != null)
  8142. {
  8143. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8144. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8145. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8146. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8147. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8148. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8149. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8150. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8151. }
  8152. //SGR
  8153. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8154. if (leftBindData != null)
  8155. {
  8156. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8157. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8158. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8159. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8160. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8161. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8162. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8163. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8164. }
  8165. //JS/ES
  8166. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8167. if (leftBindData != null)
  8168. {
  8169. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8170. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8171. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8172. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8173. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8174. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8175. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8176. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8177. }
  8178. //SUITE
  8179. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8180. if (leftBindData != null)
  8181. {
  8182. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8183. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8184. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8185. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8186. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8187. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8188. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8189. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8190. }
  8191. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8192. if (leftBindData != null)
  8193. {
  8194. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8195. designer.SetDataSource("BDJRS", leftBindData.rs);
  8196. designer.SetDataSource("BDJXS", leftBindData.xs);
  8197. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8198. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8199. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8200. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8201. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8202. }
  8203. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8204. if (leftBindData != null)
  8205. {
  8206. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8207. designer.SetDataSource("BGWRS", leftBindData.rs);
  8208. designer.SetDataSource("BGWXS", leftBindData.xs);
  8209. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8210. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8211. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8212. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8213. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8214. }
  8215. #region 优化方案
  8216. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8217. //excelBind.Add("零用金", new {
  8218. //cb="",
  8219. //rs="",
  8220. //xs ="",
  8221. //zcb = "",
  8222. //});
  8223. #endregion
  8224. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8225. if (leftBindData != null)
  8226. {
  8227. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8228. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8229. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8230. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8231. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8232. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8233. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8234. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8235. }
  8236. #endregion
  8237. #region B段Right信息
  8238. right = dto.rightInfo.Find(x => x.Type == "B");
  8239. if (right == null)
  8240. {
  8241. return Ok(jw);
  8242. }
  8243. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8244. if (rightBindData != null)
  8245. {
  8246. //经济舱 + 双人间 TBR
  8247. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8248. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8249. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8250. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8251. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8252. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8253. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8254. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8255. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8256. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8257. }
  8258. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8259. if (rightBindData != null)
  8260. {
  8261. //经济舱 + 单人间 SGR
  8262. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8263. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8264. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8265. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8266. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8267. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8268. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8269. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8270. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8271. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8272. }
  8273. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8274. if (rightBindData != null)
  8275. {
  8276. //公务舱 + 单人间 SGR
  8277. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8278. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8279. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8280. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8281. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8282. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8283. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8284. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8285. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8286. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8287. }
  8288. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8289. if (rightBindData != null)
  8290. {
  8291. //公务舱 + 小套房 JSES
  8292. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8293. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8294. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8295. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8296. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8297. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8298. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8299. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8300. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8301. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8302. }
  8303. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8304. if (rightBindData != null)
  8305. {
  8306. //公务舱 + 小套房 JSES
  8307. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8308. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8309. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8310. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8311. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8312. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8313. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8314. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8315. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8316. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8317. }
  8318. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8319. if (rightBindData != null)
  8320. {
  8321. //经济舱 + 大套房
  8322. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8323. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8324. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8325. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8326. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8327. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8328. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8329. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8330. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8331. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8332. }
  8333. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8334. if (rightBindData != null)
  8335. {
  8336. //头等舱 + 小套房 JSES
  8337. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8338. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8339. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8340. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8341. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8342. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8343. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8344. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8345. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8346. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8347. }
  8348. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8349. if (rightBindData != null)
  8350. {
  8351. //头等舱 + 大套房
  8352. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8353. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8354. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8355. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8356. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8357. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8358. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8359. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8360. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8361. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8362. }
  8363. #endregion
  8364. #region 标题
  8365. designer.SetDataSource("CostBDRCB", "单人成本");
  8366. designer.SetDataSource("CostBRS", "人数");
  8367. designer.SetDataSource("CostBXS", "系数");
  8368. designer.SetDataSource("CostBZCB", "总成本");
  8369. designer.SetDataSource("CostBDRBJ", "单人报价");
  8370. designer.SetDataSource("CostBZBJ", "总报价");
  8371. designer.SetDataSource("CostBDRLR", "单人利润");
  8372. designer.SetDataSource("CostBZLR", "总利润");
  8373. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8374. designer.SetDataSource("CostBRSOM", "人数");
  8375. designer.SetDataSource("CostBZCBOM", "总成本");
  8376. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8377. designer.SetDataSource("CostBZBJOM", "总报价");
  8378. designer.SetDataSource("CostBDRLROM", "单人利润");
  8379. designer.SetDataSource("CostBZLROM", "总利润");
  8380. #endregion
  8381. }
  8382. #endregion
  8383. designer.SetDataSource("TzZCB2", TzZCB2);
  8384. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8385. designer.SetDataSource("TzZLR2", TzZLR2);
  8386. string[] dataSourceKeys = new string[]
  8387. {
  8388. "VF",
  8389. "TGS",
  8390. "TGOF",
  8391. "TGM",
  8392. "TGA",
  8393. "TGTF",
  8394. "TGEF",
  8395. "CFM",
  8396. "CFOF",
  8397. "B",
  8398. "L",
  8399. "D",
  8400. "TBR",
  8401. "SGR",
  8402. "JSES",
  8403. "Suite",
  8404. "TV",
  8405. "1L",
  8406. "IF",
  8407. "EF",
  8408. "BRF",
  8409. "TE",
  8410. "TGT",
  8411. "DRVT",
  8412. "PC",
  8413. "TLF",
  8414. "ECT"
  8415. };
  8416. foreach (var item in dataSourceKeys)
  8417. {
  8418. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8419. if (find != null)
  8420. {
  8421. designer.SetDataSource(item, find.text);
  8422. }
  8423. else
  8424. {
  8425. designer.SetDataSource(item, 0);
  8426. }
  8427. }
  8428. designer.SetDataSource(dt);
  8429. //根据数据源处理生成报表内容
  8430. designer.Process();
  8431. designer.Workbook.Worksheets[0].Name = "清单";
  8432. Worksheet sheet = designer.Workbook.Worksheets[0];
  8433. foreach (var Rowindex in hideRowsList)
  8434. {
  8435. ws.Cells.HideRows(Rowindex, 2);
  8436. }
  8437. byte[] bytes = null;
  8438. string strFileName = di.TeamName + "-团组-成本.xls";
  8439. using (MemoryStream stream = new MemoryStream())
  8440. {
  8441. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8442. bytes = stream.ToArray();
  8443. }
  8444. return Ok(JsonView(true, "", new
  8445. {
  8446. Data = bytes,
  8447. strFileName,
  8448. }));
  8449. }
  8450. /// <summary>
  8451. /// 导出客户报表
  8452. /// </summary>
  8453. /// <returns></returns>
  8454. [HttpPost]
  8455. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8456. {
  8457. var jw = JsonView(false);
  8458. if (dto.Diid == 0)
  8459. {
  8460. return Ok(JsonView(false, "请传递团组id"));
  8461. }
  8462. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8463. if (deleInfo.Code != 0)
  8464. {
  8465. return Ok(JsonView(false, "团组信息查询失败!"));
  8466. }
  8467. var di = deleInfo.Data as DelegationInfoWebView;
  8468. if (di == null)
  8469. {
  8470. return Ok(JsonView(false, "团组信息查询失败!"));
  8471. }
  8472. //文件名
  8473. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8474. //获取模板
  8475. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8476. //载入模板
  8477. Document doc = new Document(tmppath);
  8478. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8479. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8480. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8481. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8482. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8483. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8484. if (AParameter == null)
  8485. {
  8486. return Ok(JsonView(false, "系数不存在!"));
  8487. }
  8488. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8489. , TzAirDesc, TzZCost;
  8490. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8491. = TzAirDesc = TzZCost = string.Empty;
  8492. TzNumber = AParameter.CostTypenumber.ToString();
  8493. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8494. CarGuides1 = dto.CarGuides1;
  8495. Meal = dto.Meal;
  8496. SubsidizedMeals = dto.SubsidizedMeals;
  8497. NightRepair = dto.NightRepair;
  8498. AttractionsTickets = dto.AttractionsTickets;
  8499. MiscellaneousFees = dto.MiscellaneousFees;
  8500. ATip = dto.ATip;
  8501. TzHotelDesc = "";
  8502. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8503. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8504. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8505. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8506. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8507. TzAirDesc = "";
  8508. TzZCost = dto.TzZCost;
  8509. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8510. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8511. var index = 1;
  8512. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8513. foreach (var item in TzHotelDescArr)
  8514. {
  8515. if (AinfoArr != null)
  8516. {
  8517. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8518. if (Ainfo != null)
  8519. {
  8520. if (int.Parse(Ainfo.rs) <= 0)
  8521. {
  8522. continue;
  8523. }
  8524. var hotelText = string.Empty;
  8525. switch (item)
  8526. {
  8527. case "SGR":
  8528. hotelText = "单人间";
  8529. break;
  8530. case "JSES":
  8531. hotelText = "小套房";
  8532. break;
  8533. case "SUITE":
  8534. hotelText = "套房";
  8535. break;
  8536. case "TBR":
  8537. hotelText = "双人间";
  8538. break;
  8539. }
  8540. if (item != "TBR")
  8541. {
  8542. 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";
  8543. }
  8544. else
  8545. {
  8546. 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";
  8547. }
  8548. index++;
  8549. }
  8550. }
  8551. }
  8552. index = 1;
  8553. foreach (var item in TzAirDescArr)
  8554. {
  8555. if (AinfoArr != null)
  8556. {
  8557. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8558. if (Ainfo != null)
  8559. {
  8560. if (int.Parse(Ainfo.rs) <= 0)
  8561. {
  8562. continue;
  8563. }
  8564. 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";
  8565. index++;
  8566. }
  8567. }
  8568. }
  8569. if (dto.costType == "B")
  8570. {
  8571. if (BParameter == null)
  8572. {
  8573. return Ok(JsonView(false, "B段系数不存在!"));
  8574. }
  8575. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8576. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8577. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8578. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8579. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8580. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8581. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8582. foreach (var item in TzHotelDescArr)
  8583. {
  8584. if (AinfoArr != null)
  8585. {
  8586. TzHotelDesc += "B段信息 \r\n";
  8587. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8588. if (Ainfo != null)
  8589. {
  8590. if (int.Parse(Ainfo.rs) <= 0)
  8591. {
  8592. continue;
  8593. }
  8594. var hotelText = string.Empty;
  8595. switch (item)
  8596. {
  8597. case "SGR":
  8598. hotelText = "单人间";
  8599. break;
  8600. case "JSES":
  8601. hotelText = "小套房";
  8602. break;
  8603. case "SUITE":
  8604. hotelText = "套房";
  8605. break;
  8606. case "TBR":
  8607. hotelText = "双人间";
  8608. break;
  8609. }
  8610. if (item != "TBR")
  8611. {
  8612. 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";
  8613. }
  8614. else
  8615. {
  8616. 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";
  8617. }
  8618. index++;
  8619. }
  8620. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8621. }
  8622. }
  8623. index = 1;
  8624. foreach (var item in TzAirDescArr)
  8625. {
  8626. if (AinfoArr != null)
  8627. {
  8628. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8629. if (Ainfo != null)
  8630. {
  8631. if (int.Parse(Ainfo.rs) <= 0)
  8632. {
  8633. continue;
  8634. }
  8635. 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";
  8636. index++;
  8637. }
  8638. }
  8639. }
  8640. }
  8641. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8642. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8643. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8644. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8645. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8646. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8647. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8648. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8649. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8650. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8651. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8652. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8653. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8654. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8655. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8656. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8657. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8658. DickeyValue.Add("TzZCost", TzZCost);
  8659. foreach (var key in DickeyValue.Keys)
  8660. {
  8661. if (doc.Range.Bookmarks[key] != null)
  8662. {
  8663. Bookmark mark = doc.Range.Bookmarks[key];
  8664. mark.Text = DickeyValue[key];
  8665. }
  8666. }
  8667. byte[] bytes = null;
  8668. string strFileName = di.TeamName + "-客户报价.doc";
  8669. using (MemoryStream stream = new MemoryStream())
  8670. {
  8671. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8672. bytes = stream.ToArray();
  8673. }
  8674. return Ok(JsonView(true, "", new
  8675. {
  8676. Data = bytes,
  8677. strFileName,
  8678. }));
  8679. }
  8680. /// <summary>
  8681. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8682. /// </summary>
  8683. /// <param name="dto"></param>
  8684. /// <returns></returns>
  8685. [HttpPost]
  8686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8687. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8688. {
  8689. try
  8690. {
  8691. #region 参数验证
  8692. if (dto.DiId < 0)
  8693. {
  8694. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8695. }
  8696. List<int> cTableIds = new List<int>() {
  8697. 76 ,//酒店预订
  8698. 77 ,//行程
  8699. 79 ,//车/导游地接
  8700. 80 ,//签证
  8701. 81 ,//邀请/公务活
  8702. 82 ,//团组客户保险
  8703. 85 ,//机票预订
  8704. 98 ,//其他款项
  8705. 285 ,//收款退还
  8706. 751 ,//酒店早餐
  8707. 1015 // 超支费用
  8708. };
  8709. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8710. {
  8711. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8712. }
  8713. #endregion
  8714. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8715. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8716. if (_GroupCostParameters.Count <= 0)
  8717. {
  8718. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8719. }
  8720. if (_GroupCostParameters[0].IsShare == 0)
  8721. {
  8722. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8723. }
  8724. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8725. //处理date为空问题
  8726. if (_GroupCosts.Count > 0)
  8727. {
  8728. for (int i = 0; i < _GroupCosts.Count; i++)
  8729. {
  8730. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8731. {
  8732. if (i > 0)
  8733. {
  8734. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8735. }
  8736. }
  8737. }
  8738. }
  8739. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8740. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8741. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8742. string currCode = "";
  8743. #region currCode 验证
  8744. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8745. if (isInt)
  8746. {
  8747. var currData = currDatas.Find(it => it.Id == intCurrency);
  8748. if (currData != null)
  8749. {
  8750. currCode = currData.Name;
  8751. }
  8752. }
  8753. else
  8754. {
  8755. currCode = _GroupCostParameters[0].Currency.Trim();
  8756. }
  8757. #endregion
  8758. //op,酒店单段模式存储
  8759. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8760. {
  8761. CurrencyCode = currCode,
  8762. Rate = _GroupCostParameters[0].Rate,
  8763. CostType = _GroupCostParameters[0].CostType,
  8764. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8765. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8766. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8767. };
  8768. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8769. if (_GroupCostParameters.Count == 2)
  8770. {
  8771. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8772. }
  8773. foreach (var item in _GroupCostParameters)
  8774. {
  8775. decimal _rate = 1;
  8776. decimal _rate1 = item.Rate;
  8777. decimal _scale = 1;
  8778. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8779. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8780. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8781. //if (userInfo != null)
  8782. //{
  8783. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8784. // {
  8785. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8786. // {
  8787. // _scale = 1.00M;
  8788. // }
  8789. // }
  8790. //}
  8791. #endregion
  8792. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8793. {
  8794. CurrencyCode = currCode,
  8795. Rate = _rate1,
  8796. CostType = item.CostType,
  8797. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8798. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8799. CostTypeNumber = item.CostTypenumber
  8800. };
  8801. if (_GroupCostParameters.Count > 1)
  8802. {
  8803. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8804. }
  8805. else
  8806. {
  8807. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8808. }
  8809. if (dto.CTable == 79)//
  8810. {
  8811. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8812. modulePromptInfo.TotalCost = item.DJCB;
  8813. }
  8814. List<string> costTypes = new List<string>() { "A", "B" };
  8815. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8816. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8817. if (_GroupCostsDuplicates.Count() == 1)
  8818. {
  8819. _GroupCostsTypeData = _GroupCosts;
  8820. }
  8821. else
  8822. {
  8823. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8824. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8825. }
  8826. /*
  8827. * 76 酒店预订
  8828. * 77 行程
  8829. * 79 车/导游地接
  8830. * 80 签证
  8831. * 81 邀请/公务活动
  8832. * 82 团组客户保险
  8833. * 85 机票预订
  8834. * 98 其他款项
  8835. * 285 收款退还
  8836. * 751 酒店早餐
  8837. * 1015 超支费用
  8838. */
  8839. switch (dto.CTable)
  8840. {
  8841. case 76: // 酒店预订
  8842. _ModuleSubPromptInfo.AddRange(
  8843. _GroupCostsTypeData.Select(it => new
  8844. {
  8845. it.DAY,
  8846. it.Date,
  8847. it.ACCON,
  8848. it.ITIN,
  8849. it.SGR,
  8850. it.TBR,
  8851. it.JS_ES,
  8852. it.Suite
  8853. })
  8854. );
  8855. break;
  8856. case 79: // 车/导游地接
  8857. _ModuleSubPromptInfo.AddRange(
  8858. _GroupCostsTypeData.Select(it => new
  8859. {
  8860. Date = it.Date, //日期
  8861. CarFee = it.CarCost * _rate * _scale, //车费用
  8862. CarType = it.CarType, //车型
  8863. DriverFee = it.CFS * _rate * _scale, //司机工资
  8864. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8865. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8866. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8867. GuideFee = it.TGS * _rate * _scale, //导游费用
  8868. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8869. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8870. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8871. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8872. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8873. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8874. Breakfast = it.B * _rate * _scale, //早餐费
  8875. Lunch = it.L * _rate * _scale, //午餐费
  8876. Dinner = it.D * _rate * _scale, //晚餐费
  8877. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8878. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8879. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8880. TicketFee = it.EF * _rate * _scale, //门票费
  8881. TicketRemark = it.EFR, //门票费描述
  8882. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8883. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8884. SpentCash = it.PC * _rate * _scale, //零用金
  8885. LeadersFee = it.TLF * _rate * _scale, //领队费
  8886. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8887. })
  8888. );
  8889. break;
  8890. case 85: // 机票
  8891. List<dynamic> datas = new List<dynamic>();
  8892. datas.Add(
  8893. new
  8894. {
  8895. AirType = "经济舱",
  8896. AirNum = item.JJCRS,
  8897. AirDRCB = item.JJCCB,
  8898. AirZCB = (item.JJCRS * item.JJCCB)
  8899. }
  8900. );
  8901. datas.Add(
  8902. new
  8903. {
  8904. AirType = "公务舱",
  8905. AirNum = item.GWCRS,
  8906. AirDRCB = item.GWCCB,
  8907. AirZCB = (item.GWCRS * item.GWCCB)
  8908. }
  8909. );
  8910. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8911. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8912. modulePromptInfo.Data = new
  8913. {
  8914. airFeeData = datas,
  8915. airInitData = initDatas
  8916. };
  8917. _ModulePromptInfos.Add(modulePromptInfo);
  8918. break;
  8919. default:
  8920. break;
  8921. }
  8922. }
  8923. if (dto.CTable != 85)
  8924. {
  8925. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8926. _ModulePromptInfos.Add(_ModulePromptInfo);
  8927. }
  8928. _view.ModulePromptInfos = _ModulePromptInfos;
  8929. return Ok(JsonView(true, "操作成功!", _view));
  8930. }
  8931. catch (Exception ex)
  8932. {
  8933. return Ok(JsonView(false, ex.Message));
  8934. }
  8935. }
  8936. /// <summary>
  8937. /// 根据黑屏代码重新生成行程
  8938. /// </summary>
  8939. /// <param name="dto"></param>
  8940. /// <returns></returns>
  8941. [HttpPost]
  8942. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8943. {
  8944. var jw = JsonView(false);
  8945. var Create = _GroupCostRepository.
  8946. CreateGroupCostByBlackCode(dto.Diid);
  8947. jw.Msg = Create.Msg;
  8948. if (Create.Code == 0)
  8949. {
  8950. jw.Code = 200;
  8951. jw.Data = new
  8952. {
  8953. groupCost = Create.Data,
  8954. blackCodeIsTrue = true
  8955. };
  8956. }
  8957. else
  8958. {
  8959. jw.Code = 400;
  8960. jw.Data = new
  8961. {
  8962. groupCost = Create.Data,
  8963. blackCodeIsTrue = false,
  8964. };
  8965. }
  8966. return Ok(jw);
  8967. }
  8968. /// <summary>
  8969. /// 成本获取OP历史车费用
  8970. /// </summary>
  8971. /// <param name="dto"></param>
  8972. /// <returns></returns>
  8973. [HttpPost]
  8974. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8975. {
  8976. var jw = JsonView(false);
  8977. try
  8978. {
  8979. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8980. //获取现有所有车的数据
  8981. if (!dto.Param.IsNullOrWhiteSpace())
  8982. {
  8983. string sql = $@"
  8984. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8985. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8986. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8987. 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
  8988. AND gctggr.ServiceEndTime is not NULL
  8989. ORDER by gctggrc.id DESC
  8990. ";
  8991. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8992. var numeberResult = await Task.Run(() =>
  8993. {
  8994. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8995. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8996. return numberArr;
  8997. });
  8998. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8999. foreach (var item in numeberResult)
  9000. {
  9001. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9002. {
  9003. Country = "数据异常!",
  9004. City = string.Empty,
  9005. };
  9006. item.Area = find.Country + " " + find.City;
  9007. }
  9008. dbResult.AddRange(numeberResult);
  9009. if (dto.Param.Contains("、"))
  9010. {
  9011. var sp = dto.Param.Split("、");
  9012. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9013. .Where(x =>
  9014. {
  9015. return System.Array.Exists(sp, e =>
  9016. {
  9017. bool where = false;
  9018. if (x.Area != null)
  9019. {
  9020. where = x.Area.Contains(e);
  9021. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9022. {
  9023. return false;
  9024. }
  9025. }
  9026. if (x.PriceName != null && !where)
  9027. {
  9028. where = x.PriceName.Contains(e);
  9029. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9030. {
  9031. return false;
  9032. }
  9033. }
  9034. return where;
  9035. });
  9036. }).ToList();
  9037. }
  9038. else
  9039. {
  9040. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9041. .Where(x =>
  9042. {
  9043. bool where = false;
  9044. if (x.Area != null)
  9045. {
  9046. where = x.Area.Contains(dto.Param);
  9047. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9048. {
  9049. return false;
  9050. }
  9051. }
  9052. if (x.PriceName != null && !where)
  9053. {
  9054. where = x.PriceName.Contains(dto.Param);
  9055. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9056. {
  9057. return false;
  9058. }
  9059. }
  9060. return where;
  9061. }
  9062. )
  9063. .ToList();
  9064. }
  9065. }
  9066. var view = dbResult.Select(x =>
  9067. {
  9068. decimal dp = 0.00M;
  9069. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9070. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9071. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9072. {
  9073. if (startB && endB)
  9074. {
  9075. var timesp = endD.Subtract(startD);
  9076. if ((timesp.Days + 1) != 0)
  9077. {
  9078. dp = x.Price / (timesp.Days + 1);
  9079. }
  9080. }
  9081. }
  9082. else
  9083. {
  9084. dp = x.Price;
  9085. }
  9086. return new
  9087. {
  9088. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9089. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9090. x.Area,
  9091. x.id,
  9092. price = x.Price.ToString("F2"),
  9093. x.PriceName,
  9094. x.PriceContent,
  9095. x.TeamName,
  9096. x.DatePrice,
  9097. dayPrice = dp.ToString("F2"),
  9098. };
  9099. }).OrderByDescending(x => x.id).ToList();
  9100. jw = JsonView(true, "获取成功!", view);
  9101. }
  9102. catch (Exception e)
  9103. {
  9104. jw = JsonView(false, e.Message);
  9105. }
  9106. return Ok(jw);
  9107. }
  9108. #endregion
  9109. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9110. /// <summary>
  9111. /// 酒店预订
  9112. /// 酒店费用列表 根据团组Id查询
  9113. /// </summary>
  9114. /// <param name="_dto"></param>
  9115. /// <returns></returns>
  9116. [HttpPost]
  9117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9118. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9119. {
  9120. #region 参数验证
  9121. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9122. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9123. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9124. #region 团组操作权限验证 76 酒店预定模块
  9125. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9126. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9127. #endregion
  9128. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9129. #region 页面操作权限验证
  9130. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9131. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9132. #endregion
  9133. #endregion
  9134. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9135. }
  9136. /// <summary>
  9137. /// 酒店预订
  9138. /// 基础数据
  9139. /// </summary>
  9140. /// <param name="_dto"></param>
  9141. /// <returns></returns>
  9142. [HttpPost]
  9143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9144. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9145. {
  9146. #region 参数验证
  9147. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9148. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9149. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9151. #region 页面操作权限验证
  9152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9153. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9154. #endregion
  9155. #region 团组操作权限验证 76 酒店预定模块
  9156. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9157. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9158. #endregion
  9159. #endregion
  9160. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9161. }
  9162. /// <summary>
  9163. /// 酒店预订
  9164. /// 创建 入住卷号码
  9165. /// </summary>
  9166. /// <param name="_dto"></param>
  9167. /// <returns></returns>
  9168. [HttpPost]
  9169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9170. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9171. {
  9172. #region 参数验证
  9173. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9174. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9175. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9176. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9177. #region 页面操作权限验证
  9178. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9179. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9180. #endregion
  9181. #region 团组操作权限验证 76 酒店预定模块
  9182. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9183. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9184. #endregion
  9185. #endregion
  9186. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9187. if (data.Code != 0)
  9188. {
  9189. return Ok(JsonView(false, data.Msg));
  9190. }
  9191. return Ok(JsonView(true, data.Msg, data.Data));
  9192. }
  9193. /// <summary>
  9194. /// 酒店预订
  9195. /// 详情
  9196. /// </summary>
  9197. /// <param name="_dto"></param>
  9198. /// <returns></returns>
  9199. [HttpPost]
  9200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9201. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9202. {
  9203. #region 参数验证
  9204. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9205. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9206. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9207. #region 团组操作权限验证 76 酒店预定模块
  9208. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9209. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9210. #endregion
  9211. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9212. #region 页面操作权限验证
  9213. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9214. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9215. #endregion
  9216. #endregion
  9217. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9218. }
  9219. /// <summary>
  9220. /// 酒店预订
  9221. /// Add Or Edit
  9222. /// </summary>
  9223. /// <param name="_dto"></param>
  9224. /// <returns></returns>
  9225. [HttpPost]
  9226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9227. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9228. {
  9229. #region 参数验证
  9230. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9231. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9232. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9233. #region 团组操作权限验证 76 酒店预定模块
  9234. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9235. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9236. #endregion
  9237. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9238. #region 页面操作权限验证
  9239. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9240. if (_dto.Id == 0) // Add
  9241. {
  9242. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9243. }
  9244. else if (_dto.Id > 1) // Edit
  9245. {
  9246. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9247. }
  9248. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9249. #endregion
  9250. #endregion
  9251. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9252. if (_view.Code != 200)
  9253. {
  9254. return Ok(_view);
  9255. }
  9256. #region 应用推送
  9257. try
  9258. {
  9259. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9260. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9261. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9262. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9263. //自动审核
  9264. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9265. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9266. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9267. }
  9268. catch (Exception ex)
  9269. {
  9270. }
  9271. #endregion
  9272. return Ok(_view);
  9273. }
  9274. /// <summary>
  9275. /// 酒店自动审核测试
  9276. /// Add Or Edit
  9277. /// </summary>
  9278. /// <param name="_dto"></param>
  9279. /// <returns></returns>
  9280. [HttpPost]
  9281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9282. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9283. {
  9284. #region 应用推送
  9285. try
  9286. {
  9287. //自动审核
  9288. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9289. }
  9290. catch (Exception ex)
  9291. {
  9292. return Ok(JsonView(false, "操作失败"));
  9293. }
  9294. #endregion
  9295. return Ok(JsonView(false, "操作成功"));
  9296. }
  9297. /// <summary>
  9298. /// 酒店预订
  9299. /// Del
  9300. /// </summary>
  9301. /// <param name="_dto"></param>
  9302. /// <returns></returns>
  9303. [HttpPost]
  9304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9305. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9306. {
  9307. #region 参数验证
  9308. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9309. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9310. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9311. #region 团组操作权限验证 76 酒店预定模块
  9312. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9313. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9314. #endregion
  9315. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9316. #region 页面操作权限验证
  9317. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9318. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9319. #endregion
  9320. #endregion
  9321. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9322. }
  9323. /// <summary>
  9324. /// 酒店预订
  9325. /// 生成VOUCHER
  9326. /// 2024.05.06 之前版本
  9327. /// </summary>
  9328. /// <param name="_dto"></param>
  9329. /// <returns></returns>
  9330. [HttpPost]
  9331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9332. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9333. {
  9334. try
  9335. {
  9336. #region 参数验证
  9337. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9338. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9339. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9340. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9341. #region 团组操作权限验证 76 酒店预定模块
  9342. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9343. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9344. #endregion
  9345. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9346. #region 页面操作权限验证
  9347. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9348. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9349. #endregion
  9350. #endregion
  9351. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9352. //判断数据是否完整
  9353. if (hr != null)
  9354. {
  9355. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9356. {
  9357. string strFileName = "HotelStatement/";
  9358. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9359. if (dele != null)
  9360. strFileName += dele.TourCode;
  9361. //载入模板
  9362. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9363. Document doc = new Document(sss);
  9364. DocumentBuilder builder = new DocumentBuilder(doc);
  9365. #region 替换Word模板书签内容
  9366. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9367. //入住卷预定号码
  9368. if (doc.Range.Bookmarks["VNO"] != null)
  9369. {
  9370. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9371. mark.Text = hr.CheckNumber;
  9372. }
  9373. //酒店时间
  9374. if (doc.Range.Bookmarks["Date"] != null)
  9375. {
  9376. Bookmark mark = doc.Range.Bookmarks["Date"];
  9377. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9378. }
  9379. //团号
  9380. if (doc.Range.Bookmarks["TNo"] != null)
  9381. {
  9382. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9383. mark.Text = dele.TourCode;
  9384. }
  9385. //预定号码
  9386. if (doc.Range.Bookmarks["BookingId"] != null)
  9387. {
  9388. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9389. mark.Text = hr.ReservationsNo;
  9390. }
  9391. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9392. {
  9393. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9394. mark.Text = hr.DetermineNo;
  9395. }
  9396. //酒店城市
  9397. if (doc.Range.Bookmarks["City"] != null)
  9398. {
  9399. Bookmark mark = doc.Range.Bookmarks["City"];
  9400. mark.Text = hr.City;
  9401. }
  9402. //酒店名称
  9403. if (doc.Range.Bookmarks["HName"] != null)
  9404. {
  9405. Bookmark mark = doc.Range.Bookmarks["HName"];
  9406. mark.Text = hr.HotelName;
  9407. }
  9408. //酒店地址
  9409. if (doc.Range.Bookmarks["Address"] != null)
  9410. {
  9411. Bookmark mark = doc.Range.Bookmarks["Address"];
  9412. mark.Text = hr.HotelAddress;
  9413. }
  9414. //酒店电话
  9415. if (doc.Range.Bookmarks["Tel"] != null)
  9416. {
  9417. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9418. mark.Text = hr.HotelTel;
  9419. }
  9420. //酒店传真
  9421. if (doc.Range.Bookmarks["Fax"] != null)
  9422. {
  9423. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9424. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9425. {
  9426. mark.Text = hr.HotelFax;
  9427. }
  9428. }
  9429. //入住时间
  9430. if (doc.Range.Bookmarks["CIn"] != null)
  9431. {
  9432. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9433. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9434. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9435. }
  9436. //退房时间
  9437. if (doc.Range.Bookmarks["COut"] != null)
  9438. {
  9439. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9440. Bookmark mark = doc.Range.Bookmarks["COut"];
  9441. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9442. }
  9443. //客户名称
  9444. if (doc.Range.Bookmarks["GName"] != null)
  9445. {
  9446. string guestName = "";
  9447. string[] clients = new string[] { };
  9448. if (hr.GuestName.Contains(","))
  9449. {
  9450. clients = hr.GuestName.Split(",");
  9451. }
  9452. else
  9453. {
  9454. clients = new string[] { hr.GuestName };
  9455. }
  9456. List<int> clientIds_int = new List<int>();
  9457. if (clients.Length > 0)
  9458. {
  9459. foreach (var item in clients)
  9460. {
  9461. if (item.IsNumeric())
  9462. {
  9463. clientIds_int.Add(int.Parse(item));
  9464. }
  9465. }
  9466. }
  9467. if (clientIds_int.Count > 0)
  9468. {
  9469. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9470. foreach (var client in _clientDatas)
  9471. {
  9472. //男
  9473. if (client.Sex == 0) guestName += $"Mr.";
  9474. //女
  9475. else if (client.Sex == 1) guestName += $"Ms.";
  9476. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9477. {
  9478. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9479. }
  9480. //guestName += $"{client.Pinyin},";
  9481. }
  9482. if (guestName.Length > 0)
  9483. {
  9484. guestName = guestName.Substring(0, guestName.Length - 1);
  9485. }
  9486. }
  9487. else
  9488. {
  9489. guestName = hr.GuestName;
  9490. }
  9491. Bookmark mark = doc.Range.Bookmarks["GName"];
  9492. mark.Text = guestName;
  9493. }
  9494. //房间介绍
  9495. if (doc.Range.Bookmarks["ROOM"] != null)
  9496. {
  9497. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9498. mark.Text = hr.RoomExplanation;
  9499. }
  9500. //报价描述
  9501. if (doc.Range.Bookmarks["NOTE"] != null)
  9502. {
  9503. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9504. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9505. if (ss != null)
  9506. mark.Text = ss.Name;
  9507. }
  9508. //入住时间
  9509. if (doc.Range.Bookmarks["CheckIn"] != null)
  9510. {
  9511. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9512. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9513. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9514. }
  9515. //退房时间
  9516. if (doc.Range.Bookmarks["CheckOut"] != null)
  9517. {
  9518. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9519. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9520. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9521. }
  9522. //日期
  9523. if (doc.Range.Bookmarks["DT"] != null)
  9524. {
  9525. Bookmark mark = doc.Range.Bookmarks["DT"];
  9526. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9527. }
  9528. //名称
  9529. if (doc.Range.Bookmarks["VName"] != null)
  9530. {
  9531. Bookmark mark = doc.Range.Bookmarks["VName"];
  9532. mark.Text = hr.HotelName;
  9533. }
  9534. //号码
  9535. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9536. {
  9537. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9538. mark.Text = hr.CheckNumber;
  9539. }
  9540. #endregion
  9541. strFileName += "VOUCHER.doc";
  9542. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9543. doc.Save(fileDir);
  9544. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9545. return Ok(JsonView(true, "操作成功!", Url));
  9546. }
  9547. else
  9548. {
  9549. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9550. }
  9551. }
  9552. else
  9553. {
  9554. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9555. }
  9556. }
  9557. catch (Exception ex)
  9558. {
  9559. return Ok(JsonView(false, ex.Message));
  9560. }
  9561. }
  9562. /// <summary>
  9563. /// 酒店预订
  9564. /// 生成VOUCHER
  9565. /// 2024.05.06 之后版本
  9566. /// </summary>
  9567. /// <param name="_dto"></param>
  9568. /// <returns></returns>
  9569. [HttpPost]
  9570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9571. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9572. {
  9573. #region 参数验证
  9574. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9575. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9576. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9577. #region 团组操作权限验证 76 酒店预定模块
  9578. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9579. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9580. #endregion
  9581. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9582. #region 页面操作权限验证
  9583. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9584. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9585. #endregion
  9586. #endregion
  9587. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9588. //判断数据是否完整
  9589. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9590. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9591. string strFileName = "HotelStatement/";
  9592. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9593. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9594. #region 数据处理
  9595. List<int> guestIds = new List<int>();
  9596. int index = 0;
  9597. foreach (var item in hrDtas)
  9598. {
  9599. if (item.GuestName.Contains(","))
  9600. {
  9601. string[] guestIdArr = item.GuestName.Split(',');
  9602. foreach (var guestIdStr in guestIdArr)
  9603. {
  9604. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9605. if (guestBool)
  9606. {
  9607. guestIds.Add(guestId);
  9608. }
  9609. }
  9610. }
  9611. else guestNames += item.GuestName;
  9612. var voucherInfo = new HotelVoucherInfoView()
  9613. {
  9614. HotelName = item.HotelName,
  9615. CheckInDate = item.CheckInDate,
  9616. CheckOutDate = item.CheckOutDate,
  9617. ConfirmationNumber = item.DetermineNo.Trim(),
  9618. RoomType = item.RoomExplanation
  9619. };
  9620. vouchers.Add(voucherInfo);
  9621. }
  9622. if (guestIds.Count > 0)
  9623. {
  9624. guestIds = guestIds.Distinct().ToList();
  9625. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9626. if (guestDatas.Count > 0)
  9627. {
  9628. guestNames = "";
  9629. foreach (var guest in guestDatas)
  9630. {
  9631. string guestName = "";
  9632. if (guest.Sex == 0) guestName += @"MR.";
  9633. else if (guest.Sex == 1) guestName += @"MS.";
  9634. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9635. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9636. guestNames += @$"{guestName.Trim()}、";
  9637. }
  9638. if (guestNames.Length > 0)
  9639. {
  9640. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9641. }
  9642. }
  9643. }
  9644. #endregion
  9645. //载入模板
  9646. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9647. Document doc = new Document(sss);
  9648. DocumentBuilder builder = new DocumentBuilder(doc);
  9649. if (doc.Range.Bookmarks["GuestName"] != null)
  9650. {
  9651. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9652. mark.Text = guestNames;
  9653. }
  9654. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9655. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9656. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9657. for (int i = 1; i <= vouchers.Count; i++)
  9658. {
  9659. HotelVoucherInfoView hviv = vouchers[i - 1];
  9660. builder.MoveToCell(0, i, 0, 0);
  9661. builder.Write(hviv.HotelName);
  9662. builder.MoveToCell(0, i, 1, 0);
  9663. builder.Write(hviv.CheckInDate);
  9664. builder.MoveToCell(0, i, 2, 0);
  9665. builder.Write(hviv.CheckOutDate);
  9666. builder.MoveToCell(0, i, 3, 0);
  9667. builder.Write(hviv.RoomType);
  9668. builder.MoveToCell(0, i, 4, 0);
  9669. builder.Write(hviv.ConfirmationNumber);
  9670. }
  9671. //删除多余行
  9672. int currRowIndex = vouchers.Count + 1;
  9673. int delRows = 21 - currRowIndex;
  9674. if (delRows > 0)
  9675. {
  9676. for (int i = 0; i < delRows; i++)
  9677. {
  9678. table.Rows.RemoveAt(currRowIndex);
  9679. //cultivateRowIndex++;
  9680. }
  9681. }
  9682. strFileName += "VOUCHER.docx";
  9683. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9684. doc.Save(fileDir);
  9685. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9686. return Ok(JsonView(true, "操作成功!", Url));
  9687. }
  9688. /// <summary>
  9689. /// 酒店预订
  9690. /// 生成VOUCHER 批量生成
  9691. /// New
  9692. /// </summary>
  9693. /// <param name="_dto"></param>
  9694. /// <returns></returns>
  9695. [HttpPost]
  9696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9697. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9698. {
  9699. #region 参数验证
  9700. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9701. if (_dto.PageId < 1) _dto.PageId = 28;
  9702. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9703. #region 团组操作权限验证 76 酒店预定模块
  9704. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9705. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9706. #endregion
  9707. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9708. #region 页面操作权限验证
  9709. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9710. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9711. #endregion
  9712. #endregion
  9713. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9714. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9715. .OrderBy(x => x.CheckInDate)
  9716. .ToListAsync();
  9717. //判断数据是否完整
  9718. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9719. string strFileName = "HotelStatement/";
  9720. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9721. if (dele != null)
  9722. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9723. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9724. for (int i = 0; i < hrDtas.Count; i++)
  9725. {
  9726. string guestNames = string.Empty;
  9727. List<int> guestIds = new List<int>();
  9728. var item = hrDtas[i];
  9729. //处理客户姓名
  9730. if (item.GuestName.Contains(","))
  9731. {
  9732. string[] guestIdArr = item.GuestName.Split(',');
  9733. foreach (var guestIdStr in guestIdArr)
  9734. if (int.TryParse(guestIdStr, out int guestId))
  9735. guestIds.Add(guestId);
  9736. }
  9737. else
  9738. {
  9739. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  9740. if (guestIdBool)
  9741. {
  9742. guestIds.Add(guestId);
  9743. }
  9744. //NaN
  9745. if (item.GuestName.Contains("NaN"))
  9746. {
  9747. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9748. }
  9749. }
  9750. if (guestIds.Count > 0)
  9751. {
  9752. guestIds = guestIds.Distinct().ToList();
  9753. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9754. if (guestDatas1.Count > 0)
  9755. {
  9756. guestNames = "";
  9757. foreach (var guest in guestDatas1)
  9758. {
  9759. string guestName = "";
  9760. if (guest.Sex == 0) guestName += @"MR.";
  9761. else if (guest.Sex == 1) guestName += @"MS.";
  9762. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9763. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9764. guestNames += @$"{guestName.Trim()}、";
  9765. }
  9766. if (guestNames.Length > 0)
  9767. {
  9768. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9769. }
  9770. }
  9771. }
  9772. //if (!string.IsNullOrEmpty(guestNames))
  9773. //{
  9774. hrDtas[i].GuestName = guestNames;
  9775. //}
  9776. }
  9777. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9778. Document doc = new Document();
  9779. DocumentBuilder builder = new DocumentBuilder(doc);
  9780. try
  9781. {
  9782. builder.MoveToDocumentStart();
  9783. foreach (var item in hrDtas)
  9784. {
  9785. //标题
  9786. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9787. builder.ParagraphFormat.LineSpacing = 1;
  9788. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9789. builder.ParagraphFormat.Style.Font.Size = 9;
  9790. builder.ParagraphFormat.Style.Font.Bold = true;
  9791. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9792. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9793. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9794. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9795. builder.ParagraphFormat.LineSpacing = 1;
  9796. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9797. builder.ParagraphFormat.Style.Font.Size = 9;
  9798. builder.ParagraphFormat.Style.Font.Bold = true;
  9799. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9800. builder.StartTable();
  9801. // 设置边框颜色
  9802. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9803. //设置边框样式
  9804. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9805. //表格
  9806. #region 第一行
  9807. builder.InsertCell();
  9808. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9809. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9810. //builder.CellFormat.AllowAutoFit = false;
  9811. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9812. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9813. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9814. builder.CellFormat.WrapText = true; //自动换行
  9815. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9816. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  9817. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9818. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9819. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9820. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9821. builder.Write("TOUR NO:");
  9822. builder.InsertCell();
  9823. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9824. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9825. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9826. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9827. builder.ParagraphFormat.Style.Font.Bold = false;
  9828. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9829. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9830. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9831. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9832. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9833. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9834. builder.Write($"{dele?.TourCode ?? "-"}");
  9835. builder.InsertCell();
  9836. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9837. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9838. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9839. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9840. builder.ParagraphFormat.Style.Font.Bold = false;
  9841. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9842. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9843. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9844. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9845. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9846. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9847. builder.Write($"CITY:");
  9848. builder.InsertCell();
  9849. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9850. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9851. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9852. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9853. builder.ParagraphFormat.Style.Font.Bold = false;
  9854. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9855. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9856. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9857. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9858. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9859. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9860. builder.Write($"{item.City}");
  9861. builder.EndRow();
  9862. #endregion
  9863. #region 第二行
  9864. builder.InsertCell();
  9865. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9866. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9867. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9868. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9869. builder.ParagraphFormat.Style.Font.Bold = false;
  9870. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9871. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9872. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9873. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9874. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9875. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9876. builder.Write("CONFIRMATION NO:");
  9877. builder.InsertCell();
  9878. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9879. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9880. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9881. builder.ParagraphFormat.Style.Font.Bold = false;
  9882. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9883. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9884. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9885. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9886. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9887. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9888. builder.CellFormat.VerticalMerge = CellMerge.None;
  9889. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9890. builder.Write($"{item.DetermineNo}");
  9891. builder.InsertCell();
  9892. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9893. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9894. builder.InsertCell();
  9895. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9896. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9897. builder.EndRow();
  9898. #endregion
  9899. #region 第三行
  9900. builder.InsertCell();
  9901. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9902. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9903. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9904. builder.ParagraphFormat.Style.Font.Bold = false;
  9905. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9906. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9907. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9908. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9909. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9910. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9911. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9912. builder.Write($"HOTEL NAME:");
  9913. builder.InsertCell();
  9914. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9915. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9916. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9917. builder.ParagraphFormat.Style.Font.Bold = false;
  9918. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9919. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9920. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9921. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9922. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9923. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9924. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9925. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9926. builder.Write($"{item.HotelName}");
  9927. builder.InsertCell();
  9928. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9929. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9930. builder.InsertCell();
  9931. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9932. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9933. builder.EndRow();
  9934. #endregion
  9935. #region 第四行
  9936. builder.InsertCell();
  9937. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9938. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9939. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9940. builder.ParagraphFormat.Style.Font.Bold = false;
  9941. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9942. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9943. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9944. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9945. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9946. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9947. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9948. builder.Write($"HOTEL ADDRESS:");
  9949. builder.InsertCell();
  9950. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9951. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9952. builder.ParagraphFormat.Style.Font.Size = 8;
  9953. builder.ParagraphFormat.Style.Font.Bold = false;
  9954. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9955. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9956. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9957. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9958. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9959. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9960. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9961. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9962. builder.Write($"{item.HotelAddress}");
  9963. builder.InsertCell();
  9964. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9965. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9966. builder.InsertCell();
  9967. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9968. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9969. builder.EndRow();
  9970. #endregion
  9971. #region 第五行
  9972. builder.InsertCell();
  9973. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9974. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9975. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9976. builder.ParagraphFormat.Style.Font.Bold = false;
  9977. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9978. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9979. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9980. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9981. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9982. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9983. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9984. builder.Write("TEL:");
  9985. builder.InsertCell();
  9986. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9987. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9988. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9989. builder.ParagraphFormat.Style.Font.Bold = false;
  9990. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9991. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9992. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9993. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9994. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9995. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9996. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9997. builder.Write($"{item.HotelTel}");
  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($"FAX:");
  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.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10020. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10021. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10022. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10023. builder.Write($"{item.HotelFax}");
  10024. builder.EndRow();
  10025. #endregion
  10026. #region 第六行
  10027. builder.InsertCell();
  10028. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10029. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10030. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10031. builder.ParagraphFormat.Style.Font.Bold = false;
  10032. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10033. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10034. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10035. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10036. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10037. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10038. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10039. builder.Write("CHECK IN:");
  10040. builder.InsertCell();
  10041. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10042. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10043. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10044. builder.ParagraphFormat.Style.Font.Bold = false;
  10045. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10046. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10047. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10048. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10049. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10050. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10051. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10052. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10053. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10054. builder.Write($"{checkInStr}");
  10055. builder.InsertCell();
  10056. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10057. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10058. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10059. builder.ParagraphFormat.Style.Font.Bold = false;
  10060. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10061. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10062. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10063. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10064. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10065. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10066. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10067. builder.Write($"CHECK OUT:");
  10068. builder.InsertCell();
  10069. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10070. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10071. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10072. builder.ParagraphFormat.Style.Font.Bold = false;
  10073. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10074. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10075. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10076. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10077. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10078. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10079. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10080. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10081. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10082. builder.Write($"{checkOutStr}");
  10083. builder.EndRow();
  10084. #endregion
  10085. #region 第七行
  10086. builder.InsertCell();
  10087. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10088. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10089. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10090. builder.ParagraphFormat.Style.Font.Bold = false;
  10091. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10092. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10093. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10094. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10095. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10096. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10097. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10098. builder.Write($"GUEST NAME:");
  10099. builder.InsertCell();
  10100. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10101. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10102. builder.ParagraphFormat.Style.Font.Size = 8;
  10103. builder.ParagraphFormat.Style.Font.Bold = false;
  10104. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10105. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10106. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10107. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10108. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10109. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10110. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10111. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10112. builder.Write($"{item.GuestName}");
  10113. builder.InsertCell();
  10114. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10115. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10116. builder.InsertCell();
  10117. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10118. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10119. builder.EndRow();
  10120. #endregion
  10121. #region 第八行
  10122. builder.InsertCell();
  10123. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10124. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10125. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10126. builder.ParagraphFormat.Style.Font.Bold = false;
  10127. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10128. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10129. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10130. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10131. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10132. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10133. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10134. builder.Write($"ROOM TYPE:");
  10135. builder.InsertCell();
  10136. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10137. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10138. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10139. builder.ParagraphFormat.Style.Font.Bold = false;
  10140. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10141. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10142. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10143. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10144. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10145. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10146. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10147. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10148. builder.Write($"{item.RoomExplanation}");
  10149. builder.InsertCell();
  10150. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10151. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10152. builder.InsertCell();
  10153. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10154. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10155. builder.EndRow();
  10156. #endregion
  10157. #region 第九行
  10158. builder.InsertCell();
  10159. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10160. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10161. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10162. builder.ParagraphFormat.Style.Font.Bold = false;
  10163. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10164. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10165. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10166. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10167. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10168. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10169. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10170. builder.Write($"NOTE:");
  10171. builder.InsertCell();
  10172. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10173. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10174. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10175. builder.ParagraphFormat.Style.Font.Bold = false;
  10176. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10177. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10178. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10179. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10180. 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.");
  10181. builder.InsertCell();
  10182. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10183. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10184. builder.InsertCell();
  10185. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10186. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10187. builder.EndRow();
  10188. #endregion
  10189. builder.EndTable();
  10190. //换行
  10191. builder.Writeln("");
  10192. builder.Writeln("");
  10193. }
  10194. #region 获取文档中的所有表格 设置文字自适应
  10195. // 获取文档中的所有表格。
  10196. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10197. {
  10198. // 遍历表格中的所有行。
  10199. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10200. {
  10201. foreach (Cell cell in row.Cells)
  10202. {
  10203. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10204. cellFormat.Width = 0;
  10205. }
  10206. }
  10207. }
  10208. #endregion
  10209. #region 设置页眉
  10210. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10211. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10212. if (System.IO.File.Exists(voucherHeaderPath))
  10213. {
  10214. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10215. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10216. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10217. Shape shape = builder.InsertImage(imageBytes);
  10218. // 调整图片位置
  10219. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10220. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10221. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10222. shape.Left = 0; // 将图片距离页面左边缘的距离
  10223. shape.Width = 81; // 设置图片宽度
  10224. shape.Height = 36; // 设置图片高度
  10225. }
  10226. //靠右
  10227. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10228. //// 设置页脚上下边距
  10229. //builder.PageSetup.HeaderDistance = 42;
  10230. // 添加页眉线
  10231. Aspose.Words.Border borderHeader = null;
  10232. try
  10233. {
  10234. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10235. }
  10236. catch (Exception e)
  10237. {
  10238. // TODO Auto-generated catch block
  10239. //e.printStackTrace();
  10240. }
  10241. borderHeader.Shadow = true;
  10242. borderHeader.DistanceFromText = 2;
  10243. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10244. #endregion
  10245. }
  10246. catch (Exception ex)
  10247. {
  10248. }
  10249. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10250. doc.Save(fileDir);
  10251. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10252. return Ok(JsonView(true, "操作成功!", Url));
  10253. }
  10254. /// <summary>
  10255. /// 酒店预订
  10256. /// 生成 预定成本 Excel
  10257. /// </summary>
  10258. /// <param name="_dto"></param>
  10259. /// <returns></returns>
  10260. [HttpPost]
  10261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10262. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10263. {
  10264. #region 参数验证
  10265. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10266. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10267. if (!vadalitorRes.IsValid)
  10268. {
  10269. var errors = new StringBuilder();
  10270. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10271. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10272. }
  10273. #region 团组操作权限验证 76 酒店预定模块
  10274. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10275. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10276. #endregion
  10277. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10278. #region 页面操作权限验证
  10279. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10280. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10281. #endregion
  10282. #endregion
  10283. decimal _rate = 1.00M;
  10284. string _currency = "";
  10285. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10286. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10287. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10288. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10289. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10290. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10291. {
  10292. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10293. }
  10294. _currency = _GroupCostParameter.Currency;
  10295. bool isIntType = int.TryParse(_currency, out int currId);
  10296. if (isIntType)
  10297. {
  10298. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10299. }
  10300. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10301. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10302. if (currInfo == null)
  10303. {
  10304. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10305. }
  10306. if (!_currency.ToUpper().Equals("CNY"))
  10307. {
  10308. _rate = _GroupCostParameter.Rate;
  10309. }
  10310. _rate = currInfo.Rate;
  10311. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10312. string strFileName = "HotelStatement/";
  10313. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10314. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10315. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10316. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10317. #region 数据处理
  10318. foreach (var item in hrDtas)
  10319. {
  10320. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10321. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10322. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10323. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10324. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10325. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10326. string singleRoomFeeStr = string.Empty,
  10327. doubleRoomFeeStr = string.Empty,
  10328. suiteRoomFeeStr = string.Empty,
  10329. otherRoomFeeStr = string.Empty,
  10330. payMoneyStr = string.Empty,
  10331. cardPriceStr = string.Empty;
  10332. if (roomCurr.Equals(_currency))
  10333. {
  10334. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10335. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10336. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10337. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10338. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10339. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10340. }
  10341. else
  10342. {
  10343. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10344. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10345. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10346. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10347. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10348. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10349. }
  10350. string breakfastPriceStr = string.Empty,
  10351. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10352. governmentRentStr = string.Empty,
  10353. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10354. cityTaxStrStr = string.Empty,
  10355. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10356. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10357. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10358. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10359. int payDId = roomInfo?.PayDId ?? 0;
  10360. pcfds.Add(new HotelReservations_PCFD_View()
  10361. {
  10362. City = item.City,
  10363. HotelName = item.HotelName,
  10364. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10365. // SingleRoomCount = item.SingleRoomCount,
  10366. SingleRoomPrice = singleRoomFeeStr,
  10367. // DoubleRoomCount = item.DoubleRoomCount,
  10368. DoubleRoomPrice = doubleRoomFeeStr,
  10369. //SuiteRoomCount = item.SuiteRoomCount,
  10370. SuiteRoomPrice = suiteRoomFeeStr,
  10371. OtherRoomPrice = otherRoomFeeStr,
  10372. //OtherRoomCount = item.OtherRoomCount,
  10373. BreakfastPrice = breakfastPriceStr,
  10374. GovernmentRent = governmentRentStr,
  10375. CityTax = cityTaxStrStr,
  10376. RoomExplanation = item.RoomExplanation,
  10377. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10378. PayTime = roomInfo?.ConsumptionDate,
  10379. BankNo = roomInfo?.BankNo,
  10380. PayMoney = payMoneyStr,
  10381. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10382. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10383. CardPrice = cardPriceStr,
  10384. Remark = ccpInfo.Remark
  10385. });
  10386. }
  10387. #endregion
  10388. //载入模板
  10389. WorkbookDesigner designer = new WorkbookDesigner();
  10390. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10391. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10392. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10393. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10394. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10395. designer.SetDataSource("Opertor", userInfo.CnName);
  10396. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10397. dt.TableName = "ViewMyHotelReservations";
  10398. designer.SetDataSource(dt);
  10399. designer.Process();
  10400. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10401. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10402. designer.Workbook.Save(serverPath);
  10403. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10404. #region 删除指定行
  10405. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10406. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10407. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10408. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10409. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10410. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10411. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10412. cssIndex = dt.Columns["CityTax"].Ordinal,
  10413. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10414. remarkIndex = dt.Columns["Remark"].Ordinal;
  10415. //删除指定列
  10416. foreach (DataRow item in dt.Rows)
  10417. {
  10418. string singleStr = item["SingleRoomPrice"].ToString();
  10419. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10420. if (containsDigitButNotZero1) singleDel = false;
  10421. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10422. string doubleStr = item["DoubleRoomPrice"].ToString();
  10423. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10424. if (containsDigitButNotZero2) doubleDel = false;
  10425. string suiteStr = item["SuiteRoomPrice"].ToString();
  10426. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10427. if (containsDigitButNotZero3) suiteDel = false;
  10428. string otherStr = item["OtherRoomPrice"].ToString();
  10429. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10430. if (containsDigitButNotZero4) otherDel = false;
  10431. string zcStr = item["BreakfastPrice"].ToString();
  10432. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10433. if (containsDigitButNotZero5) zcDel = false;
  10434. string dsStr = item["GovernmentRent"].ToString();
  10435. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10436. if (containsDigitButNotZero6) dsDel = false;
  10437. string cssStr = item["CityTax"].ToString();
  10438. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10439. if (containsDigitButNotZero7) cssDel = false;
  10440. string cpStr = item["ConsumptionPatterns"].ToString();
  10441. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10442. string remarkStr = item["Remark"].ToString();
  10443. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10444. }
  10445. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10446. DeleteColumn(serverPath, cpIndex, cpDel);
  10447. DeleteColumn(serverPath, dsIndex, dsDel);
  10448. DeleteColumn(serverPath, cssIndex, cssDel);
  10449. DeleteColumn(serverPath, zcIndex, zcDel);
  10450. DeleteColumn(serverPath, otherIndex, otherDel);
  10451. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10452. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10453. DeleteColumn(serverPath, singleIndex, singleDel);
  10454. #endregion
  10455. //只保留第一个表格
  10456. DeleteSheet(serverPath);
  10457. return Ok(JsonView(true, "操作成功", url = rst));
  10458. }
  10459. /// <summary>
  10460. /// 删除指定列
  10461. /// </summary>
  10462. /// <param name="file"></param>
  10463. /// <param name="columnIndex"></param>
  10464. /// <param name="isDel"></param>
  10465. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10466. {
  10467. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10468. //wb.Save(file);
  10469. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10470. if (sheet1 != null)
  10471. {
  10472. if (isDel)
  10473. {
  10474. Cells cells = sheet1.Cells;
  10475. cells.DeleteColumn(columnIndex);
  10476. }
  10477. }
  10478. wb.Save(file);
  10479. }
  10480. /// <summary>
  10481. /// 删除sheet
  10482. /// </summary>
  10483. /// <param name="file"></param>
  10484. /// <param name="sheetName"></param>
  10485. private void DeleteSheet(string file, string sheetName = "")
  10486. {
  10487. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10488. //wb.Save(file);
  10489. List<string> sheets = new List<string>();
  10490. foreach (var item in wb.Worksheets)
  10491. {
  10492. sheets.Add(item.Name);
  10493. }
  10494. if (sheets.Count > 0)
  10495. {
  10496. sheets.RemoveAt(0);//不删除第一个sheet
  10497. foreach (var item in sheets)
  10498. {
  10499. wb.Worksheets.RemoveAt(item);
  10500. }
  10501. }
  10502. wb.Save(file);
  10503. }
  10504. /// <summary>
  10505. /// 酒店预订
  10506. /// 确认单
  10507. /// </summary>
  10508. /// <param name="_dto"></param>
  10509. /// <returns></returns>
  10510. [HttpPost]
  10511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10512. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10513. {
  10514. try
  10515. {
  10516. #region 参数验证
  10517. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10518. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10519. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10520. #region 团组操作权限验证 76 酒店预定模块
  10521. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10522. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10523. #endregion
  10524. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10525. #region 页面操作权限验证
  10526. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10527. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10528. #endregion
  10529. #endregion
  10530. //团组信息
  10531. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10532. //酒店数据
  10533. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10534. if (listhoteldata.Count < 0)
  10535. {
  10536. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10537. }
  10538. //利datatable存储
  10539. DataTable dt = new DataTable();
  10540. dt.Columns.Add("CheckInDate", typeof(string));
  10541. dt.Columns.Add("City", typeof(string));
  10542. dt.Columns.Add("Hotel", typeof(string));
  10543. dt.Columns.Add("Room", typeof(string));
  10544. for (int i = 0; i < listhoteldata.Count; i++)
  10545. {
  10546. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10547. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10548. while (dayStart < dayEnd)
  10549. {
  10550. string temp = "";
  10551. DataRow row = dt.NewRow();
  10552. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10553. row["City"] = listhoteldata[i].City;
  10554. row["Hotel"] = listhoteldata[i].HotelName;
  10555. if (listhoteldata[i].SingleRoomCount > 0)
  10556. {
  10557. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10558. }
  10559. if (listhoteldata[i].DoubleRoomCount > 0)
  10560. {
  10561. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10562. }
  10563. if (listhoteldata[i].SuiteRoomCount > 0)
  10564. {
  10565. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10566. }
  10567. if (listhoteldata[i].OtherRoomCount > 0)
  10568. {
  10569. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10570. }
  10571. row["Room"] = temp;
  10572. dt.Rows.Add(row);
  10573. dayStart = dayStart.AddDays(1);
  10574. }
  10575. }
  10576. Dictionary<string, string> dic = new Dictionary<string, string>();
  10577. dic.Add("Dele", di.TeamName);
  10578. dic.Add("City", di.VisitCountry);
  10579. //模板路径
  10580. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10581. //载入模板
  10582. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10583. DocumentBuilder builder = new DocumentBuilder(doc);
  10584. foreach (var key in dic.Keys)
  10585. {
  10586. builder.MoveToBookmark(key);
  10587. builder.Write(dic[key]);
  10588. }
  10589. //获取word里所有表格
  10590. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10591. //获取所填表格的序数
  10592. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10593. var rowStart = tableOne.Rows[0]; //获取第1行
  10594. //循环赋值
  10595. for (int i = 0; i < dt.Rows.Count; i++)
  10596. {
  10597. builder.MoveToCell(0, i + 1, 0, 0);
  10598. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10599. builder.MoveToCell(0, i + 1, 1, 0);
  10600. builder.Write(dt.Rows[i]["City"].ToString());
  10601. builder.MoveToCell(0, i + 1, 2, 0);
  10602. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10603. builder.MoveToCell(0, i + 1, 3, 0);
  10604. builder.Write(dt.Rows[i]["Room"].ToString());
  10605. }
  10606. //删除多余行
  10607. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10608. {
  10609. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10610. }
  10611. string strFileName = di.TeamName + "酒店确认单.doc";
  10612. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10613. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10614. return Ok(JsonView(true, "成功", url));
  10615. }
  10616. catch (Exception ex)
  10617. {
  10618. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10619. }
  10620. }
  10621. #endregion
  10622. #region 团组状态
  10623. /// <summary>
  10624. /// 团组状态列表 Page
  10625. /// </summary>
  10626. /// <param name="dto">团组列表请求dto</param>
  10627. /// <returns></returns>
  10628. [HttpPost]
  10629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10630. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10631. {
  10632. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10633. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10634. {
  10635. string sqlWhere = string.Empty;
  10636. if (dto.IsSure == 0) //未完成
  10637. {
  10638. sqlWhere += string.Format(@" And IsSure = 0");
  10639. }
  10640. else if (dto.IsSure == 1) //已完成
  10641. {
  10642. sqlWhere += string.Format(@" And IsSure = 1");
  10643. }
  10644. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10645. {
  10646. string tj = dto.SearchCriteria;
  10647. 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}%')",
  10648. tj, tj, tj, tj, tj);
  10649. }
  10650. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10651. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10652. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10653. From (
  10654. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10655. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10656. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10657. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10658. From Grp_DelegationInfo gdi
  10659. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10660. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10661. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10662. Where gdi.IsDel = 0 {0}
  10663. ) temp ", sqlWhere);
  10664. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10665. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10666. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10667. }
  10668. else
  10669. {
  10670. return Ok(JsonView(false, "查询失败"));
  10671. }
  10672. }
  10673. /// <summary>
  10674. /// 团组状态
  10675. /// 设置操作完成
  10676. /// </summary>
  10677. /// <param name="dto">团组列表请求dto</param>
  10678. /// <returns></returns>
  10679. [HttpPost]
  10680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10681. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10682. {
  10683. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10684. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10685. {
  10686. Id = dto.Id,
  10687. IsSure = 1
  10688. };
  10689. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10690. .UpdateColumns(it => new { it.IsSure })
  10691. .WhereColumns(it => new { it.Id })
  10692. .ExecuteCommandAsync();
  10693. if (result > 0)
  10694. {
  10695. return Ok(JsonView(true, "操作完成!"));
  10696. }
  10697. return Ok(JsonView(false, "操作失败!"));
  10698. }
  10699. #endregion
  10700. #region 保险费用录入
  10701. /// <summary>
  10702. /// 根据团组Id查询保险费用列表
  10703. /// </summary>
  10704. /// <param name="dto"></param>
  10705. /// <returns></returns>
  10706. [HttpPost]
  10707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10708. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10709. {
  10710. try
  10711. {
  10712. Result groupData = await _customersRep.CustomersByDiId(dto);
  10713. if (groupData.Code != 0)
  10714. {
  10715. return Ok(JsonView(false, groupData.Msg));
  10716. }
  10717. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10718. }
  10719. catch (Exception ex)
  10720. {
  10721. return Ok(JsonView(false, ex.Message));
  10722. }
  10723. }
  10724. /// <summary>
  10725. /// 根据保险费用Id查询保险费用详细
  10726. /// </summary>
  10727. /// <param name="dto"></param>
  10728. /// <returns></returns>
  10729. [HttpPost]
  10730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10731. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10732. {
  10733. try
  10734. {
  10735. Result groupData = await _customersRep.CustomersById(dto);
  10736. if (groupData.Code != 0)
  10737. {
  10738. return Ok(JsonView(false, groupData.Msg));
  10739. }
  10740. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10741. }
  10742. catch (Exception ex)
  10743. {
  10744. return Ok(JsonView(false, ex.Message));
  10745. }
  10746. }
  10747. /// <summary>
  10748. /// 保险费用录入页面初始化绑定
  10749. /// </summary>
  10750. /// <param name="dto"></param>
  10751. /// <returns></returns>
  10752. [HttpPost]
  10753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10754. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10755. {
  10756. try
  10757. {
  10758. Result groupData = await _customersRep.CustomersInitialize(dto);
  10759. if (groupData.Code != 0)
  10760. {
  10761. return Ok(JsonView(false, groupData.Msg));
  10762. }
  10763. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10764. }
  10765. catch (Exception ex)
  10766. {
  10767. return Ok(JsonView(false, ex.Message));
  10768. }
  10769. }
  10770. /// <summary>
  10771. /// 保险费用操作(Status:1.新增,2.修改)
  10772. /// </summary>
  10773. /// <param name="dto"></param>
  10774. /// <returns></returns>
  10775. [HttpPost]
  10776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10777. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10778. {
  10779. Result groupData = await _customersRep.OpCustomers(dto);
  10780. if (groupData.Code != 0)
  10781. {
  10782. return Ok(JsonView(false, groupData.Msg));
  10783. }
  10784. #region 应用推送
  10785. try
  10786. {
  10787. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10788. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10789. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10790. }
  10791. catch (Exception ex)
  10792. {
  10793. }
  10794. #endregion
  10795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10796. }
  10797. /// <summary>
  10798. /// 保险文件上传
  10799. /// </summary>
  10800. /// <param name="file"></param>
  10801. /// <returns></returns>
  10802. [HttpPost]
  10803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10804. public async Task<IActionResult> UploadCus(IFormFile file)
  10805. {
  10806. try
  10807. {
  10808. if (file != null)
  10809. {
  10810. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10811. //文件名称
  10812. string projectFileName = file.FileName;
  10813. //上传的文件的路径
  10814. string filePath = "";
  10815. if (!Directory.Exists(fileDir))
  10816. {
  10817. Directory.CreateDirectory(fileDir);
  10818. }
  10819. //上传的文件的路径
  10820. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10821. using (FileStream fs = System.IO.File.Create(filePath))
  10822. {
  10823. file.CopyTo(fs);
  10824. fs.Flush();
  10825. }
  10826. return Ok(JsonView(true, "上传成功!", projectFileName));
  10827. }
  10828. else
  10829. {
  10830. return Ok(JsonView(false, "上传失败!"));
  10831. }
  10832. }
  10833. catch (Exception ex)
  10834. {
  10835. return Ok(JsonView(false, "程序错误!"));
  10836. throw;
  10837. }
  10838. }
  10839. /// <summary>
  10840. /// 保险删除指定文件
  10841. /// </summary>
  10842. /// <param name="dto"></param>
  10843. /// <returns></returns>
  10844. [HttpPost]
  10845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10846. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10847. {
  10848. try
  10849. {
  10850. string filePath = "";
  10851. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10852. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10853. //int id = 0;
  10854. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10855. // 删除该文件
  10856. try
  10857. {
  10858. System.IO.File.Delete(filePath);
  10859. 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()
  10860. {
  10861. Attachment = "",
  10862. }).ExecuteCommandAsync();
  10863. if (result != 0)
  10864. {
  10865. return Ok(JsonView(true, "成功!"));
  10866. }
  10867. else
  10868. {
  10869. return Ok(JsonView(false, "失败!"));
  10870. }
  10871. }
  10872. catch (Exception)
  10873. {
  10874. 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()
  10875. {
  10876. Attachment = "",
  10877. }).ExecuteCommandAsync();
  10878. if (result != 0)
  10879. {
  10880. return Ok(JsonView(true, "成功!"));
  10881. }
  10882. else
  10883. {
  10884. return Ok(JsonView(false, "失败!"));
  10885. }
  10886. }
  10887. }
  10888. catch (Exception ex)
  10889. {
  10890. return Ok(JsonView(false, "程序错误!"));
  10891. throw;
  10892. }
  10893. }
  10894. /// <summary>
  10895. /// 保险费用操作(删除)
  10896. /// </summary>
  10897. /// <param name="dto"></param>
  10898. /// <returns></returns>
  10899. [HttpPost]
  10900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10901. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10902. {
  10903. try
  10904. {
  10905. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10906. if (!res)
  10907. {
  10908. return Ok(JsonView(false, "删除失败"));
  10909. }
  10910. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10911. {
  10912. IsDel = 1,
  10913. DeleteUserId = dto.DeleteUserId,
  10914. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10915. }).ExecuteCommandAsync();
  10916. return Ok(JsonView(true, "删除成功!"));
  10917. }
  10918. catch (Exception ex)
  10919. {
  10920. return Ok(JsonView(false, "程序错误!"));
  10921. throw;
  10922. }
  10923. }
  10924. #endregion
  10925. #region 接团客户名单 PageId 104
  10926. /// <summary>
  10927. /// 接团客户名单
  10928. /// 迁移数据(慎用!)
  10929. /// </summary>
  10930. /// <param name="dto"></param>
  10931. /// <returns></returns>
  10932. [HttpPost]
  10933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10934. public async Task<IActionResult> PostTourClientListChange()
  10935. {
  10936. try
  10937. {
  10938. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10939. //var groupClinetData1
  10940. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10941. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10942. int updateCount = 0;
  10943. if (oldOAClientList.Count > 0)
  10944. {
  10945. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10946. _sqlSugar.BeginTran();
  10947. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10948. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10949. foreach (var item in oldOAClientList)
  10950. {
  10951. int comId = 0;
  10952. string format = "yyyy-MM-dd HH:mm:ss";
  10953. string data11 = "1990-01-01 00:00";
  10954. var data1 = IsValidDate(item.OPdate, format);
  10955. if (data1) data11 = item.OPdate;
  10956. //客户公司验证
  10957. if (!string.IsNullOrEmpty(item.Company))
  10958. {
  10959. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10960. if (clientComInfo == null) // add
  10961. {
  10962. var addInfo = new Crm_CustomerCompany()
  10963. {
  10964. CompanyAbbreviation = "",
  10965. CompanyFullName = item.Company,
  10966. Address = "",
  10967. PostCodes = "",
  10968. LastedOpUserId = item.OPer,
  10969. LastedOpDt = Convert.ToDateTime(data11),
  10970. CreateUserId = item.OPer,
  10971. CreateTime = Convert.ToDateTime(data11),
  10972. IsDel = 0
  10973. };
  10974. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10975. if (comId1 > 0) comId = comId1;
  10976. }
  10977. else comId = clientComInfo.Id;
  10978. }
  10979. //客户人员验证
  10980. int clientId = 0;
  10981. string name = item.LastName + item.Name;
  10982. if (!string.IsNullOrEmpty(name))
  10983. {
  10984. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10985. if (clientInfo == null)
  10986. {
  10987. DateTime? dateTime = null;
  10988. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10989. if (isDt) dateTime = birthDayDt;
  10990. var addInfo1 = new Crm_DeleClient()
  10991. {
  10992. CrmCompanyId = comId,
  10993. DiId = -1,
  10994. LastName = item.LastName,
  10995. FirstName = item.Name,
  10996. OldName = "",
  10997. Pinyin = item.Pinyin,
  10998. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10999. Marriage = 0,
  11000. Phone = item.Phone,
  11001. Job = item.Job,
  11002. BirthDay = dateTime
  11003. };
  11004. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11005. if (clientId1 > 0) clientId = clientId1;
  11006. }
  11007. else clientId = clientInfo.Id;
  11008. }
  11009. if (clientId < 1)
  11010. {
  11011. continue;
  11012. }
  11013. int airType = 0;
  11014. if (item.AirType == "超经舱") airType = 459;
  11015. else if (item.AirType == "公务舱") airType = 458;
  11016. else if (item.AirType == "经济舱") airType = 460;
  11017. else if (item.AirType == "其他") airType = 565;
  11018. else if (item.AirType == "头等舱") airType = 457;
  11019. var _TourClientListEntity = new Grp_TourClientList()
  11020. {
  11021. DiId = item.Diid,
  11022. ClientId = clientId,
  11023. CreateUserId = item.OPer,
  11024. CreateTime = Convert.ToDateTime(data11),
  11025. Remark = item.Remark,
  11026. IsDel = item.Isdel,
  11027. ShippingSpaceTypeId = airType,
  11028. ShippingSpaceSpecialNeeds = item.AirRemark,
  11029. HotelSpecialNeeds = item.RoomType
  11030. };
  11031. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11032. if (_TourClientList > 0)
  11033. {
  11034. updateCount++;
  11035. }
  11036. }
  11037. _sqlSugar.CommitTran();
  11038. }
  11039. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11040. }
  11041. catch (Exception ex)
  11042. {
  11043. _sqlSugar.RollbackTran();
  11044. return Ok(JsonView(false, ex.Message));
  11045. }
  11046. return Ok(JsonView(true));
  11047. }
  11048. private bool IsValidDate(string dateString, string format)
  11049. {
  11050. DateTime dateValue;
  11051. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11052. return valid;
  11053. }
  11054. /// <summary>
  11055. /// 接团客户名单
  11056. /// 根据团组Id查询List
  11057. /// </summary>
  11058. /// <param name="dto"></param>
  11059. /// <returns></returns>
  11060. [HttpPost]
  11061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11062. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11063. {
  11064. #region 参数验证
  11065. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11066. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11067. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11068. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11069. #region 页面操作权限验证
  11070. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11071. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11072. #endregion
  11073. #endregion
  11074. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11075. if (viewData.Code != 0)
  11076. {
  11077. return Ok(JsonView(false, viewData.Msg));
  11078. }
  11079. return Ok(JsonView(viewData.Data));
  11080. }
  11081. /// <summary>
  11082. /// 接团客户名单
  11083. /// 基础数据 Init
  11084. /// </summary>
  11085. /// <param name="_dto"></param>
  11086. /// <returns></returns>
  11087. [HttpPost]
  11088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11089. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11090. {
  11091. #region 参数验证
  11092. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11093. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11094. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11095. #region 页面操作权限验证
  11096. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11097. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11098. #endregion
  11099. #endregion
  11100. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11101. }
  11102. /// <summary>
  11103. /// 接团客户名单
  11104. /// 根据 Id查询 Details
  11105. /// </summary>
  11106. /// <param name="_dto"></param>
  11107. /// <returns></returns>
  11108. [HttpPost]
  11109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11110. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11111. {
  11112. #region 参数验证
  11113. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11114. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11115. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11116. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11117. #region 页面操作权限验证
  11118. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11119. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11120. #endregion
  11121. #endregion
  11122. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11123. if (viewData.Code != 0)
  11124. {
  11125. return Ok(JsonView(false, viewData.Msg));
  11126. }
  11127. return Ok(JsonView(viewData.Data));
  11128. }
  11129. /// <summary>
  11130. /// 接团客户名单
  11131. /// Add Or Edit
  11132. /// </summary>
  11133. /// <param name="_dto"></param>
  11134. /// <returns></returns>
  11135. [HttpPost]
  11136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11137. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11138. {
  11139. #region 参数验证
  11140. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11141. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11142. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11143. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11144. #region 页面操作权限验证
  11145. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11146. if (_dto.Id == 0) //添加
  11147. {
  11148. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11149. }
  11150. else if (_dto.Id >= 0) //修改
  11151. {
  11152. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11153. }
  11154. #endregion
  11155. #endregion
  11156. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11157. if (viewData.Code != 0)
  11158. {
  11159. return Ok(JsonView(false, viewData.Msg));
  11160. }
  11161. return Ok(JsonView(true));
  11162. }
  11163. /// <summary>
  11164. /// 接团客户名单
  11165. /// AddMultiple(添加多个)
  11166. /// </summary>
  11167. /// <param name="_dto"></param>
  11168. /// <returns></returns>
  11169. [HttpPost]
  11170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11171. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11172. {
  11173. #region 参数验证
  11174. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11175. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11176. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11177. #region 页面操作权限验证
  11178. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11179. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11180. #endregion
  11181. #endregion
  11182. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11183. if (viewData.Code != 0)
  11184. {
  11185. return Ok(JsonView(false, viewData.Msg));
  11186. }
  11187. return Ok(JsonView(true));
  11188. }
  11189. /// <summary>
  11190. /// 接团客户名单
  11191. /// Del
  11192. /// </summary>
  11193. /// <param name="_dto"></param>
  11194. /// <returns></returns>
  11195. [HttpPost]
  11196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11197. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11198. {
  11199. #region 参数验证
  11200. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11201. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11202. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11203. #region 页面操作权限验证
  11204. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11205. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11206. #endregion
  11207. #endregion
  11208. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11209. if (viewData.Code != 0)
  11210. {
  11211. return Ok(JsonView(false, viewData.Msg));
  11212. }
  11213. return Ok(JsonView(true));
  11214. }
  11215. /// <summary>
  11216. /// 接团客户名单
  11217. /// 文件下载 客户名单
  11218. /// </summary>
  11219. /// <param name="_dto"></param>
  11220. /// <returns></returns>
  11221. [HttpPost]
  11222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11223. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11224. {
  11225. #region 参数验证
  11226. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11227. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11228. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11229. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11230. #region 页面操作权限验证
  11231. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11232. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11233. #endregion
  11234. #endregion
  11235. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11236. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11237. From Grp_TourClientList tcl
  11238. Left Join
  11239. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11240. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11241. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11242. From Crm_DeleClient dc
  11243. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11244. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11245. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11246. Where dc.IsDel = 0) temp
  11247. On temp.DcId =tcl.ClientId
  11248. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11249. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11250. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11251. //载入模板
  11252. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11253. if (_dto.Language == 1)
  11254. {
  11255. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11256. }
  11257. //载入模板
  11258. var doc = new Document(tempPath);
  11259. DocumentBuilder builder = new DocumentBuilder(doc);
  11260. //获取word里所有表格
  11261. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11262. //获取所填表格的序数
  11263. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11264. var rowStart = tableOne.Rows[0]; //获取第1行
  11265. if (_dto.Language == 0)
  11266. {
  11267. //循环赋值
  11268. for (int i = 0; i < DcList.Count; i++)
  11269. {
  11270. builder.MoveToCell(0, i + 1, 0, 0);
  11271. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11272. builder.MoveToCell(0, i + 1, 1, 0);
  11273. int sex = DcList[i].Sex;
  11274. string sexStr = string.Empty;
  11275. if (sex == 0) sexStr = "男";
  11276. else if (sex == 1) sexStr = "女";
  11277. else sexStr = "未设置";
  11278. builder.Write(sexStr);
  11279. builder.MoveToCell(0, i + 1, 2, 0);
  11280. string birthDay = DcList[i].BirthDay;
  11281. string birthDayStr = string.Empty;
  11282. if (!string.IsNullOrEmpty(birthDay))
  11283. {
  11284. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11285. }
  11286. builder.Write(birthDayStr);
  11287. builder.MoveToCell(0, i + 1, 3, 0);
  11288. string company = "";
  11289. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11290. {
  11291. company = DcList[i].CompanyFullName.ToString();
  11292. }
  11293. builder.Write(company);
  11294. builder.MoveToCell(0, i + 1, 4, 0);
  11295. builder.Write(DcList[i].Job);
  11296. }
  11297. }
  11298. else if (_dto.Language == 1)
  11299. {
  11300. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11301. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11302. List<string> transArrayStr = new List<string>();
  11303. string transStrRes1 = "";
  11304. for (int i = 0; i < DcList.Count; i++)
  11305. {
  11306. var dc = DcList[i];
  11307. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11308. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11309. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11310. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11311. else transStrRes1 += $"{str1}|";
  11312. }
  11313. //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";
  11314. string transStrRes = "";
  11315. if (transStrRes1.Length > 0)
  11316. {
  11317. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11318. }
  11319. //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
  11320. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11321. //List<string> transArray = new List<string> { };
  11322. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11323. if (transStrRes.Contains("|"))
  11324. {
  11325. string[] transArray1 = transStrRes.Split('|');
  11326. if (transArray1.Length > 0)
  11327. {
  11328. foreach (var item in transArray1)
  11329. {
  11330. if (item.Contains("&"))
  11331. {
  11332. string[] transArray2 = item.Split('&');
  11333. int index = 0;
  11334. string companyName = "", job = "";
  11335. if (transArray2.Length > 0)
  11336. {
  11337. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11338. if (1 < transArray2.Length) companyName = transArray2[1];
  11339. if (2 < transArray2.Length) job = transArray2[2];
  11340. }
  11341. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11342. }
  11343. }
  11344. }
  11345. }
  11346. //循环赋值
  11347. for (int i = 0; i < DcList.Count; i++)
  11348. {
  11349. string PYName = "";
  11350. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11351. {
  11352. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11353. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11354. PYName = PY_First + " " + PY_Last;
  11355. }
  11356. else
  11357. {
  11358. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11359. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11360. PYName = PY_First + " " + PY_Last;
  11361. }
  11362. builder.MoveToCell(0, i + 1, 0, 0);
  11363. builder.Write(PYName);
  11364. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11365. builder.MoveToCell(0, i + 1, 1, 0);
  11366. builder.Write(sex);
  11367. DateTime birthDt;
  11368. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11369. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11370. builder.MoveToCell(0, i + 1, 2, 0);
  11371. builder.Write(birthday);
  11372. string company = string.Empty, job = string.Empty;
  11373. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11374. if (dcTransInfo != null)
  11375. {
  11376. company = dcTransInfo.CompanyName;
  11377. job = dcTransInfo.Job;
  11378. }
  11379. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11380. {
  11381. //查询对照表
  11382. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11383. if (tempCec != null)
  11384. {
  11385. company = tempCec.enName;
  11386. }
  11387. //翻译
  11388. else
  11389. {
  11390. }
  11391. }
  11392. builder.MoveToCell(0, i + 1, 3, 0);
  11393. builder.Write(company);
  11394. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11395. {
  11396. //查询对照表
  11397. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11398. if (tempPec != null)
  11399. {
  11400. job = tempPec.enName;
  11401. }
  11402. //翻译
  11403. else
  11404. {
  11405. }
  11406. }
  11407. builder.MoveToCell(0, i + 1, 4, 0);
  11408. builder.Write(job);
  11409. }
  11410. }
  11411. //删除多余行
  11412. while (tableOne.Rows.Count > DcList.Count + 1)
  11413. {
  11414. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11415. }
  11416. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11417. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11418. doc.Save(fileDir);
  11419. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11420. return Ok(JsonView(true, "操作成功!", Url));
  11421. }
  11422. private class TranslateInfo
  11423. {
  11424. public int Index { get; set; }
  11425. public string CompanyName { get; set; }
  11426. public string Job { get; set; }
  11427. }
  11428. #endregion
  11429. #region 团组倒推表
  11430. /// <summary>
  11431. /// 倒推表基础数据
  11432. /// Init
  11433. /// </summary>
  11434. /// <param name="dto"></param>
  11435. /// <returns></returns>
  11436. [HttpPost]
  11437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11438. public async Task<IActionResult> PostInvertedListInit()
  11439. {
  11440. var viewData = await _invertedListRep._Init();
  11441. if (viewData.Code != 0)
  11442. {
  11443. return Ok(JsonView(false, viewData.Msg));
  11444. }
  11445. return Ok(JsonView(viewData.Data));
  11446. }
  11447. /// <summary>
  11448. /// 倒推表
  11449. /// Info
  11450. /// </summary>
  11451. /// <param name="dto"></param>
  11452. /// <returns></returns>
  11453. [HttpPost]
  11454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11455. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11456. {
  11457. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11458. if (viewData.Code != 0)
  11459. {
  11460. return Ok(JsonView(false, viewData.Msg));
  11461. }
  11462. return Ok(JsonView(viewData.Data));
  11463. }
  11464. /// <summary>
  11465. /// 倒推表
  11466. /// Create
  11467. /// </summary>
  11468. /// <param name="dto"></param>
  11469. /// <returns></returns>
  11470. [HttpPost]
  11471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11472. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11473. {
  11474. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11475. if (viewData.Code != 0)
  11476. {
  11477. return Ok(JsonView(false, viewData.Msg));
  11478. }
  11479. return Ok(JsonView(viewData.Data));
  11480. }
  11481. /// <summary>
  11482. /// 倒推表
  11483. /// Update
  11484. /// </summary>
  11485. /// <param name="dto"></param>
  11486. /// <returns></returns>
  11487. [HttpPost]
  11488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11489. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11490. {
  11491. var viewData = await _invertedListRep._Update(dto);
  11492. if (viewData.Code != 0)
  11493. {
  11494. return Ok(JsonView(false, viewData.Msg));
  11495. }
  11496. return Ok(JsonView(viewData.Data));
  11497. }
  11498. /// <summary>
  11499. /// 倒推表
  11500. /// File Download
  11501. /// </summary>
  11502. /// <param name="dto"></param>
  11503. /// <returns></returns>
  11504. [HttpPost]
  11505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11506. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11507. {
  11508. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11509. if (info2.Code != 0)
  11510. {
  11511. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11512. }
  11513. var info1 = info2.Data as InvertedListInfoView;
  11514. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11515. string teamName = "";
  11516. if (info != null) teamName = info.TeamName;
  11517. //载入模板
  11518. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11519. DocumentBuilder builder = new DocumentBuilder(doc);
  11520. //利用键值对存放数据
  11521. Dictionary<string, string> dic = new Dictionary<string, string>();
  11522. dic.Add("TeamName", teamName);
  11523. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11524. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11525. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11526. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11527. dic.Add("SQRemark", info1.ApprovalRemark);
  11528. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11529. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11530. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11531. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11532. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11533. dic.Add("QZRemark", info1.VisaInformationRemark);
  11534. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11535. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11536. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11537. dic.Add("CQRemark", info1.IssueVisaRemark);
  11538. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11539. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11540. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11541. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11542. #region 填充word模板书签内容
  11543. foreach (var key in dic.Keys)
  11544. {
  11545. builder.MoveToBookmark(key);
  11546. builder.Write(dic[key]);
  11547. }
  11548. #endregion
  11549. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11550. string fileName = $"{teamName}团出行准备流程表.doc";
  11551. string filePath = fileDir + $@"InvertedList/{fileName}";
  11552. doc.Save(filePath);
  11553. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11554. return Ok(JsonView(true, "操作成功!", Url));
  11555. }
  11556. #endregion
  11557. #region 三公签证费用(签证费、代办费)
  11558. /// <summary>
  11559. /// 三公签证费用(签证费、代办费)
  11560. /// List
  11561. /// </summary>
  11562. /// <returns></returns>
  11563. [HttpPost]
  11564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11565. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11566. {
  11567. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11568. if (_view.Code != 0)
  11569. {
  11570. return Ok(JsonView(false, _view.Msg));
  11571. }
  11572. return Ok(JsonView(true, "操作成功!", _view.Data));
  11573. }
  11574. /// <summary>
  11575. /// 三公签证费用(签证费、代办费)
  11576. /// Add Or Update
  11577. /// </summary>
  11578. /// <returns></returns>
  11579. [HttpPost]
  11580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11581. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11582. {
  11583. var _view = await _visaFeeInfoRep._Update(_dto);
  11584. if (_view.Code != 0)
  11585. {
  11586. return Ok(JsonView(false, _view.Msg));
  11587. }
  11588. return Ok(JsonView(true, _view.Msg));
  11589. }
  11590. #endregion
  11591. #region 酒店询价
  11592. /// <summary>
  11593. /// 酒店询价
  11594. /// Init
  11595. /// </summary>
  11596. /// <param name="dto"></param>
  11597. /// <returns></returns>
  11598. [HttpPost]
  11599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11600. public async Task<IActionResult> PostHotelInquiryInit()
  11601. {
  11602. var res = await _hotelInquiryRep._Init();
  11603. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11604. return Ok(JsonView(true, res.Msg, res.Data));
  11605. }
  11606. /// <summary>
  11607. /// 酒店询价
  11608. /// page Item
  11609. /// </summary>
  11610. /// <param name="_dto"></param>
  11611. /// <returns></returns>
  11612. [HttpPost]
  11613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11614. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11615. {
  11616. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11617. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11618. var view = res.Data as PageDataViewBase;
  11619. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11620. }
  11621. /// <summary>
  11622. /// 酒店询价
  11623. /// info
  11624. /// </summary>
  11625. /// <param name="_dto"></param>
  11626. /// <returns></returns>
  11627. [HttpPost]
  11628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11629. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11630. {
  11631. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11632. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11633. return Ok(JsonView(true, res.Msg, res.Data));
  11634. }
  11635. /// <summary>
  11636. /// 酒店询价
  11637. /// Add Or Edit
  11638. /// </summary>
  11639. /// <param name="_dto"></param>
  11640. /// <returns></returns>
  11641. [HttpPost]
  11642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11643. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11644. {
  11645. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11646. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11647. return Ok(JsonView(true, res.Msg, res.Data));
  11648. }
  11649. /// <summary>
  11650. /// 酒店询价
  11651. /// Del
  11652. /// </summary>
  11653. /// <param name="_dto"></param>
  11654. /// <returns></returns>
  11655. [HttpPost]
  11656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11657. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11658. {
  11659. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11660. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11661. return Ok(JsonView(true, res.Msg, res.Data));
  11662. }
  11663. #endregion
  11664. #region 下载匹配op行程单
  11665. /// <summary>
  11666. /// 匹配op行程单
  11667. /// Init
  11668. /// </summary>
  11669. /// <param name="dto">团组列表请求dto</param>
  11670. /// <returns></returns>
  11671. [HttpPost]
  11672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11673. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11674. {
  11675. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11676. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11677. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11678. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11679. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11680. .Where(it => it.IsDel == 0)
  11681. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11682. .OrderByDescending(it => it.CreateUserId)
  11683. .ToList();
  11684. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11685. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11686. var diids = groupInfos.Select(it => it.Id).ToList();
  11687. List<string> countrys = new List<string>();
  11688. foreach (var item in country)
  11689. {
  11690. var data = _groupRepository.FormartTeamName(item);
  11691. var dataArray = _groupRepository.GroupSplitCountry(data);
  11692. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11693. }
  11694. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11695. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11696. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11697. foreach (var item in areaItem)
  11698. {
  11699. string areaStr = item.Value;
  11700. if (!string.IsNullOrEmpty(areaStr))
  11701. {
  11702. string[] str1 = areaStr.Split("-");
  11703. if (str1.Length > 0)
  11704. {
  11705. areaArray.AddRange(str1);
  11706. }
  11707. }
  11708. }
  11709. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11710. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11711. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11712. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11713. .ToList();
  11714. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11715. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11716. .Where(it => countriesIds.Contains(it.Id))
  11717. .Select(it => new { it.Id, Name = it.Name_CN })
  11718. .ToList();
  11719. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11720. .Select(it => it.TeamName).ToList();
  11721. stopwatch.Stop();
  11722. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11723. }
  11724. ///// <summary>
  11725. ///// 匹配op行程单
  11726. ///// Init 查询区域数据
  11727. ///// </summary>
  11728. ///// <param name="dto">团组列表请求dto</param>
  11729. ///// <returns></returns>
  11730. //[HttpPost]
  11731. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11732. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11733. //{
  11734. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11735. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11736. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11737. // if (string.IsNullOrEmpty(countriesDataStr))
  11738. // {
  11739. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11740. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11741. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11742. // }
  11743. // else
  11744. // {
  11745. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11746. // }
  11747. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11748. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11749. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11750. // List<dynamic> childList = new List<dynamic>();
  11751. // int parentId = dto.CountriesId;
  11752. // if (provinceData.Count > 1)
  11753. // {
  11754. // foreach (var item1 in provinceData)
  11755. // {
  11756. // List<dynamic> childList1 = new List<dynamic>();
  11757. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11758. // foreach (var item2 in citiesData1)
  11759. // {
  11760. // List<dynamic> childList2 = new List<dynamic>();
  11761. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11762. // foreach (var item3 in countiesData1)
  11763. // {
  11764. // childList2.Add(new
  11765. // {
  11766. // id = item3.Id,
  11767. // parentId = item2.Id,
  11768. // level = "district",
  11769. // name = item3.Name_CN,
  11770. // });
  11771. // }
  11772. // childList1.Add(new
  11773. // {
  11774. // id = item2.Id,
  11775. // parentId = item1.Id,
  11776. // level = "city",
  11777. // name = item2.Name_CN,
  11778. // childList = childList2
  11779. // });
  11780. // }
  11781. // childList.Add(new
  11782. // {
  11783. // id = item1.Id,
  11784. // parentId = parentId,
  11785. // level = "province",
  11786. // name = item1.Name_CN,
  11787. // childList = childList1
  11788. // });
  11789. // }
  11790. // //城市
  11791. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11792. // foreach (var item2 in citiesData2)
  11793. // {
  11794. // List<dynamic> childList22 = new List<dynamic>();
  11795. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11796. // foreach (var item3 in countiesData1)
  11797. // {
  11798. // childList22.Add(new
  11799. // {
  11800. // id = item3.Id,
  11801. // parentId = item2.Id,
  11802. // level = "district",
  11803. // name = item3.Name_CN,
  11804. // });
  11805. // }
  11806. // childList.Add(new
  11807. // {
  11808. // id = item2.Id,
  11809. // parentId = parentId,
  11810. // level = "city",
  11811. // name = item2.Name_CN,
  11812. // childList = childList22
  11813. // });
  11814. // }
  11815. // }
  11816. // else
  11817. // {
  11818. // foreach (var item2 in citiesData)
  11819. // {
  11820. // string cname = item2.Name_CN;
  11821. // List<dynamic> childList1 = new List<dynamic>();
  11822. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11823. // foreach (var item3 in countiesData1)
  11824. // {
  11825. // childList1.Add(new
  11826. // {
  11827. // Id = item3.Id,
  11828. // parentId = item2.Id,
  11829. // level = "district",
  11830. // name = item3.Name_CN
  11831. // });
  11832. // }
  11833. // childList.Add(new
  11834. // {
  11835. // id = item2.Id,
  11836. // parentId = parentId,
  11837. // level = "city",
  11838. // name = item2.Name_CN,
  11839. // childList = childList1
  11840. // });
  11841. // }
  11842. // }
  11843. // stopwatch.Stop();
  11844. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11845. //}
  11846. /// <summary>
  11847. /// 匹配op行程单
  11848. /// 接团信息列表 Page
  11849. /// </summary>
  11850. /// <param name="dto">团组列表请求dto</param>
  11851. /// <returns></returns>
  11852. [HttpPost]
  11853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11854. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11855. {
  11856. var swatch = new Stopwatch();
  11857. swatch.Start();
  11858. #region 参数验证
  11859. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11860. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11861. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11862. #region 页面操作权限验证
  11863. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11864. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11865. #endregion
  11866. #endregion
  11867. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11868. {
  11869. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11870. string sqlWhere = "";
  11871. if (!string.IsNullOrEmpty(dto.Country))
  11872. {
  11873. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11874. }
  11875. if (!string.IsNullOrEmpty(dto.Area))
  11876. {
  11877. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11878. }
  11879. if (!string.IsNullOrEmpty(dto.TeamName))
  11880. {
  11881. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11882. }
  11883. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11884. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11885. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11886. swatch.Stop();
  11887. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11888. }
  11889. else
  11890. {
  11891. return Ok(JsonView(false, "查询失败"));
  11892. }
  11893. }
  11894. /// <summary>
  11895. /// 匹配op行程单
  11896. /// 行程单下载
  11897. /// </summary>
  11898. /// <param name="dto">团组列表请求dto</param>
  11899. /// <returns></returns>
  11900. [HttpPost]
  11901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11902. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11903. {
  11904. #region 参数验证
  11905. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11906. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11907. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11908. #region 页面操作权限验证
  11909. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11910. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11911. #endregion
  11912. #endregion
  11913. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11914. {
  11915. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11916. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11917. }
  11918. else
  11919. {
  11920. return Ok(JsonView(false, "下载失败!"));
  11921. }
  11922. }
  11923. #endregion
  11924. #region 国家信息 数据 注释
  11925. //[HttpPost]
  11926. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11927. //{
  11928. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11929. // foreach (var item in dto)
  11930. // {
  11931. // infos.Add(new Grp_GroupsTaskAssignment()
  11932. // {
  11933. // DIId = item,
  11934. // CTId = 82,
  11935. // UId = 248,
  11936. // IsEnable = 1,
  11937. // CreateUserId = 233,
  11938. // CreateTime = DateTime.Now,
  11939. // IsDel = 0
  11940. // });
  11941. // infos.Add(new Grp_GroupsTaskAssignment()
  11942. // {
  11943. // DIId = item,
  11944. // CTId = 82,
  11945. // UId = 286,
  11946. // IsEnable = 1,
  11947. // CreateUserId = 233,
  11948. // CreateTime = DateTime.Now,
  11949. // IsDel = 0
  11950. // });
  11951. // }
  11952. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11953. // return Ok("操作成功");
  11954. //}
  11955. //public class paramJsonDto
  11956. //{
  11957. // public List<CountriesInfo> str { get; set; }
  11958. //}
  11959. //[HttpPost]
  11960. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11961. //{
  11962. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11963. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11964. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11965. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11966. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11967. // _sqlSugar.BeginTran();
  11968. // int countitiesIndex = 0;
  11969. // foreach (var item in dto.str)
  11970. // {
  11971. // dynamic data = item.c;
  11972. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11973. // if (data != null)
  11974. // {
  11975. // countitiesIndex++;
  11976. // foreach (var item1 in data)
  11977. // {
  11978. // string cnname = item1.cn;
  11979. // string enname = item1.en;
  11980. // Sys_Cities provinceInfo = new Sys_Cities()
  11981. // {
  11982. // CountriesId = countriesId,
  11983. // Name_CN = cnname,
  11984. // Name_EN = enname,
  11985. // ParentId = 0,
  11986. // IsCapital = 1,
  11987. // CreateUserId = 208,
  11988. // CreateTime = DateTime.Now,
  11989. // IsDel = 0
  11990. // };
  11991. // if (item1.lv == "province") //省份
  11992. // {
  11993. // provinceInfo.Level = 1;
  11994. // int provinceId = 0;
  11995. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11996. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11997. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11998. // var data1 = item1.c;
  11999. // foreach (var item2 in data1)
  12000. // {
  12001. // if (item2.lv == "city")
  12002. // {
  12003. // string citycnname = item2.cn;
  12004. // string cityenname = item2.en;
  12005. // Sys_Cities cityInfo = new Sys_Cities()
  12006. // {
  12007. // CountriesId = countriesId,
  12008. // ParentId = provinceId,
  12009. // Level = 2,
  12010. // Name_CN = citycnname,
  12011. // Name_EN = cityenname,
  12012. // IsCapital = 1,
  12013. // CreateUserId = 208,
  12014. // CreateTime = DateTime.Now,
  12015. // IsDel = 0
  12016. // };
  12017. // if (item2.c != null)
  12018. // {
  12019. // int cityId = 0;
  12020. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12021. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12022. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12023. // foreach (var item3 in item2.c)
  12024. // {
  12025. // if (item3.lv == "district")
  12026. // {
  12027. // var districtInfo = new Sys_Cities()
  12028. // {
  12029. // CountriesId = countriesId,
  12030. // Name_CN = item3.cn,
  12031. // Name_EN = item3.en,
  12032. // Level = 3,
  12033. // ParentId = cityId,
  12034. // IsCapital = 1,
  12035. // CreateUserId = 208,
  12036. // CreateTime = DateTime.Now,
  12037. // IsDel = 0
  12038. // };
  12039. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12040. // //{
  12041. // districts.Add(districtInfo);
  12042. // //}
  12043. // }
  12044. // }
  12045. // }
  12046. // else
  12047. // {
  12048. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12049. // //{
  12050. // cities.Add(cityInfo);
  12051. // //}
  12052. // }
  12053. // }
  12054. // }
  12055. // }
  12056. // else if (item1.lv == "city")//城市
  12057. // {
  12058. // provinceInfo.Level = 2;
  12059. // if (item1.c != null)
  12060. // {
  12061. // int cityId = 0;
  12062. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12063. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12064. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12065. // foreach (var item3 in item1.c)
  12066. // {
  12067. // if (item3.lv == "district")
  12068. // {
  12069. // var districtInfo = new Sys_Cities()
  12070. // {
  12071. // CountriesId = countriesId,
  12072. // Name_CN = item3.cn,
  12073. // Name_EN = item3.en,
  12074. // Level = 3,
  12075. // ParentId = cityId,
  12076. // IsCapital = 1,
  12077. // CreateUserId = 208,
  12078. // CreateTime = DateTime.Now,
  12079. // IsDel = 0
  12080. // };
  12081. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12082. // //{
  12083. // districts.Add(districtInfo);
  12084. // //}
  12085. // }
  12086. // }
  12087. // }
  12088. // else
  12089. // {
  12090. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12091. // //{
  12092. // cities.Add(provinceInfo);
  12093. // //}
  12094. // }
  12095. // }
  12096. // }
  12097. // }
  12098. // }
  12099. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12100. // cities = cities.Distinct().ToList();
  12101. // districts = districts.Distinct().ToList();
  12102. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12103. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12104. // cities.AddRange(districts);
  12105. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12106. // //_sqlSugar.RollbackTran();
  12107. // _sqlSugar.CommitTran();
  12108. // return Ok(JsonView(false, "操作成功!"));
  12109. //}
  12110. //[HttpPost]
  12111. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12112. //{
  12113. // List<CountitiesInfo> infos = dto.MyProperty;
  12114. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12115. // _sqlSugar.BeginTran();
  12116. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12117. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12118. // foreach (var item in infos)
  12119. // {
  12120. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12121. // if (countryInfo != null)
  12122. // {
  12123. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12124. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12125. // if (cityInfo1 != null)
  12126. // {
  12127. // cityInfo1.IsCapital = 0;
  12128. // cityInfos.Add(cityInfo1);
  12129. // }
  12130. // }
  12131. // }
  12132. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12133. // .UpdateColumns(it => it.IsCapital)
  12134. // .WhereColumns(it => it.Id)
  12135. // .ExecuteCommand();
  12136. // //_sqlSugar.RollbackTran();
  12137. // _sqlSugar.CommitTran();
  12138. // return Ok(JsonView(false, "操作成功!"));
  12139. //}
  12140. //public class CounrtiesDto
  12141. //{
  12142. // public List<CountitiesInfo> MyProperty { get; set; }
  12143. //}
  12144. //public class CountitiesInfo
  12145. //{
  12146. // /// <summary>
  12147. // /// 圣约翰
  12148. // /// </summary>
  12149. // public string capital_name_chinese { get; set; }
  12150. // /// <summary>
  12151. // ///
  12152. // /// </summary>
  12153. // public string capital_name { get; set; }
  12154. // /// <summary>
  12155. // ///
  12156. // /// </summary>
  12157. // public string country_type { get; set; }
  12158. // /// <summary>
  12159. // /// 安提瓜和巴布达
  12160. // /// </summary>
  12161. // public string country_name_chinese { get; set; }
  12162. // /// <summary>
  12163. // /// 安提瓜和巴布达
  12164. // /// </summary>
  12165. // public string country_name_chinese_short { get; set; }
  12166. // /// <summary>
  12167. // /// 安提瓜和巴布达
  12168. // /// </summary>
  12169. // public string country_name_chinese_UN { get; set; }
  12170. // /// <summary>
  12171. // ///
  12172. // /// </summary>
  12173. // public string country_name_english_abbreviation { get; set; }
  12174. // /// <summary>
  12175. // ///
  12176. // /// </summary>
  12177. // public string country_name_english_formal { get; set; }
  12178. // /// <summary>
  12179. // ///
  12180. // /// </summary>
  12181. // public string country_name_english_UN { get; set; }
  12182. // /// <summary>
  12183. // ///
  12184. // /// </summary>
  12185. // public string continent_name { get; set; }
  12186. // /// <summary>
  12187. // ///
  12188. // /// </summary>
  12189. // public string subregion_name { get; set; }
  12190. // /// <summary>
  12191. // ///
  12192. // /// </summary>
  12193. // public string country_code2 { get; set; }
  12194. // /// <summary>
  12195. // ///
  12196. // /// </summary>
  12197. // public string country_code3 { get; set; }
  12198. // /// <summary>
  12199. // ///
  12200. // /// </summary>
  12201. // public string phone_code { get; set; }
  12202. //}
  12203. //public class CountriesInfo : BasicInfo
  12204. //{
  12205. // public List<CitiesInfo> c { get; set; }
  12206. //}
  12207. //public class CitiesInfo : BasicInfo
  12208. //{
  12209. // public List<AreaInfo> c { get; set; }
  12210. //}
  12211. //public class AreaInfo : BasicInfo
  12212. //{
  12213. // public List<AreaInfo> c { get; set; }
  12214. //}
  12215. //public class BasicInfo
  12216. //{
  12217. // public string code { get; set; }
  12218. // public string cn { get; set; }
  12219. // public string lv { get; set; }
  12220. // public string en { get; set; }
  12221. //}
  12222. #endregion
  12223. #region 查看邀请方
  12224. /// <summary>
  12225. /// 查看邀请方
  12226. /// 邀请方信息 Init
  12227. /// </summary>
  12228. /// <param name="dto"></param>
  12229. /// <returns></returns>
  12230. [HttpPost]
  12231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12232. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12233. {
  12234. string sqlWhere = string.Empty;
  12235. if (!string.IsNullOrEmpty(dto.Search))
  12236. {
  12237. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12238. }
  12239. string sql = string.Format($@"Select
  12240. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12241. Id,
  12242. UnitName
  12243. From Res_InvitationOfficialActivityData
  12244. Where IsDel = 0
  12245. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12246. RefAsync<int> total = 0;
  12247. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12248. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12249. }
  12250. /// <summary>
  12251. /// 查看邀请方
  12252. /// 国家信息 Init
  12253. /// </summary>
  12254. /// <param name="dto"></param>
  12255. /// <returns></returns>
  12256. [HttpPost]
  12257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12258. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12259. {
  12260. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12261. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12262. var diids = groupInfos.Select(it => it.Id).ToList();
  12263. List<string> countrys = new List<string>();
  12264. foreach (var item in country)
  12265. {
  12266. var data = _groupRepository.FormartTeamName(item);
  12267. var dataArray = _groupRepository.GroupSplitCountry(data);
  12268. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12269. }
  12270. countrys = countrys.Distinct().ToList();
  12271. for (int i = 0; i < countrys.Count; i++)
  12272. {
  12273. string item = countrys[i];
  12274. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12275. {
  12276. countrys.Remove(item);
  12277. i--;
  12278. }
  12279. }
  12280. RefAsync<int> total = 0;
  12281. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12282. .Where(it => countrys.Contains(it.Name_CN))
  12283. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12284. .Select(it => new { id = it.Id, name = it.Name_CN })
  12285. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12286. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12287. }
  12288. /// <summary>
  12289. /// 查看邀请方
  12290. /// 城市信息 Init
  12291. /// </summary>
  12292. /// <param name="dto"></param>
  12293. /// <returns></returns>
  12294. [HttpPost]
  12295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12296. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12297. {
  12298. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12299. RefAsync<int> total = 0;
  12300. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12301. .Where(it => it.CountriesId == dto.CountiesId)
  12302. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12303. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12304. .Select(it => new { id = it.Id, name = it.Name_CN })
  12305. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12306. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12307. }
  12308. /// <summary>
  12309. /// 查看邀请方
  12310. /// 团组名称 Init
  12311. /// </summary>
  12312. /// <param name="dto"></param>
  12313. /// <returns></returns>
  12314. [HttpPost]
  12315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12316. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12317. {
  12318. var watch = new Stopwatch();
  12319. watch.Start();
  12320. RefAsync<int> total = 0;
  12321. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12322. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12323. .Where((oa, di) => oa.IsDel == 0)
  12324. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12325. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12326. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12327. .Distinct()
  12328. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12329. watch.Stop();
  12330. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12331. }
  12332. /// <summary>
  12333. /// 查看邀请方
  12334. /// 团组 & 邀请方信息
  12335. /// </summary>
  12336. /// <param name="dto"></param>
  12337. /// <returns></returns>
  12338. [HttpPost]
  12339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12340. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12341. {
  12342. var watch = new Stopwatch();
  12343. watch.Start();
  12344. RefAsync<int> total = 0;
  12345. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12346. .AS("Grp_DelegationInfo")
  12347. .Includes(x => x.InvitingInfos)
  12348. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12349. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12350. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12351. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12352. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12353. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12354. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12355. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12356. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12357. infos.ForEach(x =>
  12358. {
  12359. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12360. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12361. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12362. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12363. });
  12364. watch.Stop();
  12365. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12366. }
  12367. #endregion
  12368. #region 报批行程
  12369. /// <summary>
  12370. /// 报批行程初始化
  12371. /// </summary>
  12372. /// <param name="dto"></param>
  12373. /// <returns></returns>
  12374. [HttpPost]
  12375. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12376. {
  12377. const int chiNumber = 5;
  12378. var jw = JsonView(false);
  12379. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12380. var group = groupList.First();
  12381. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12382. group = groupList.First(x => x.Id == diid);
  12383. if (group == null)
  12384. {
  12385. jw.Msg = "暂无团组!";
  12386. return Ok(jw);
  12387. }
  12388. var data = new
  12389. {
  12390. groupList = groupList.Select(x => new
  12391. {
  12392. x.TeamName,
  12393. x.Id
  12394. }),
  12395. content = new ArrayList(),
  12396. groupInfo = new
  12397. {
  12398. group.VisitDays,
  12399. group.TourCode,
  12400. group.VisitPNumber,
  12401. group.TeamName,
  12402. group.Id,
  12403. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12404. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12405. },
  12406. };
  12407. var resultArr = new ArrayList();
  12408. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12409. if (content.Count == 0)
  12410. {
  12411. var stay = "-";
  12412. var cityPath = "-";
  12413. //添加城市路径以及住宿地
  12414. //黑屏代码数据
  12415. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12416. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12417. {
  12418. jw = JsonView(true, "黑屏代码有误!", data);
  12419. return Ok(jw);
  12420. }
  12421. foreach (DataRow row in dtBlack.Rows)
  12422. {
  12423. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12424. {
  12425. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12426. return Ok(jw);
  12427. }
  12428. }
  12429. //黑屏代码获取时间区间
  12430. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12431. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12432. _sqlSugar.BeginTran();
  12433. for (int i = 0; i < timeArr.Count; i++)
  12434. {
  12435. stay = "-";
  12436. cityPath = "-";
  12437. DateTime NewData = DateTime.Parse(timeArr[i]);
  12438. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12439. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12440. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12441. if (tbSelect.Length > 0)
  12442. {
  12443. List<string> threeCodeStr = new List<string>();
  12444. foreach (var item in tbSelect)
  12445. {
  12446. var threeCode = item["Three"].ToString() ?? "";
  12447. if (threeCode.Length == 6)
  12448. {
  12449. var start = threeCode.Substring(0, 3);
  12450. var end = threeCode.Substring(3, 3);
  12451. if (threeCodeStr.Count == 0)
  12452. {
  12453. threeCodeStr.Add(start);
  12454. threeCodeStr.Add(end);
  12455. }
  12456. else
  12457. {
  12458. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12459. {
  12460. threeCodeStr.Add(end);
  12461. }
  12462. else
  12463. {
  12464. threeCodeStr.Add(start);
  12465. threeCodeStr.Add(end);
  12466. }
  12467. }
  12468. }
  12469. }
  12470. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12471. var last = threeCodeStr.Last();
  12472. foreach (var item in threeCodeStr)
  12473. {
  12474. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12475. if (item.Equals(last))
  12476. {
  12477. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12478. }
  12479. }
  12480. cityPath = cityPath.Trim('-');
  12481. }
  12482. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12483. appro.Diid = diid ?? -1;
  12484. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12485. appro.Id = thisId;
  12486. appro.CreateUserId = dto.UserId;
  12487. appro.CreateTime = DateTime.Now;
  12488. content.Add(appro);
  12489. }
  12490. _sqlSugar.CommitTran();
  12491. }
  12492. foreach (var x in content)
  12493. {
  12494. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12495. if (chiList.Count < chiNumber)
  12496. {
  12497. for (int i = chiList.Count; i < chiNumber; i++)
  12498. {
  12499. chiList.Add(new Grp_ApprovalTravelDetails());
  12500. }
  12501. }
  12502. resultArr.Add(new
  12503. {
  12504. x.Id,
  12505. x.Date,
  12506. x.Diid,
  12507. chiList = chiList.Select(x1 => new
  12508. {
  12509. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12510. x1.Details,
  12511. x1.ParentId,
  12512. x1.Id
  12513. })
  12514. });
  12515. }
  12516. data = data with
  12517. {
  12518. content = resultArr,
  12519. };
  12520. jw = JsonView(true, "获取成功!", data);
  12521. return Ok(jw);
  12522. }
  12523. /// <summary>
  12524. /// 报批行程删除
  12525. /// </summary>
  12526. /// <param name="dto"></param>
  12527. /// <returns></returns>
  12528. [HttpPost]
  12529. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12530. {
  12531. var jw = JsonView(false);
  12532. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12533. if (group == null)
  12534. {
  12535. jw.Msg = "团组参数有误!";
  12536. return Ok(jw);
  12537. }
  12538. try
  12539. {
  12540. _sqlSugar.BeginTran();
  12541. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12542. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12543. {
  12544. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12545. DeleteUserId = dto.uesrId,
  12546. IsDel = 1
  12547. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12548. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12549. {
  12550. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12551. DeleteUserId = dto.uesrId,
  12552. IsDel = 1
  12553. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12554. _sqlSugar.CommitTran();
  12555. jw = JsonView(true, "删除成功");
  12556. }
  12557. catch (Exception ex)
  12558. {
  12559. jw = JsonView(false, ex.Message);
  12560. }
  12561. return Ok(jw);
  12562. }
  12563. /// <summary>
  12564. /// 报批行程保存
  12565. /// </summary>
  12566. /// <param name="dto"></param>
  12567. /// <returns></returns>
  12568. [HttpPost]
  12569. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12570. {
  12571. var jw = JsonView(false);
  12572. var Find = dto.Arr.Find(x => x.id == 0);
  12573. if (Find != null)
  12574. {
  12575. jw.Msg = "生成的ID为0!";
  12576. return Ok(jw);
  12577. }
  12578. foreach (var item in dto.Arr)
  12579. {
  12580. foreach (var chi in item.chiList)
  12581. {
  12582. if (chi.parentId == 0)
  12583. {
  12584. chi.parentId = item.id;
  12585. }
  12586. }
  12587. }
  12588. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12589. _sqlSugar.BeginTran();
  12590. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12591. {
  12592. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12593. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12594. {
  12595. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12596. DeleteUserId = dto.UserId,
  12597. IsDel = 1
  12598. }).ExecuteCommand();
  12599. }
  12600. try
  12601. {
  12602. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12603. {
  12604. CreateTime = DateTime.Now,
  12605. CreateUserId = dto.UserId,
  12606. Details = x.details,
  12607. ParentId = x.parentId,
  12608. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12609. Remark = "",
  12610. IsDel = 0
  12611. }).ToList()).ExecuteCommand();
  12612. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12613. {
  12614. Id = x.id,
  12615. Details = x.details,
  12616. ParentId = x.parentId,
  12617. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12618. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12619. {
  12620. Details = x.Details,
  12621. ParentId = x.ParentId,
  12622. Time = x.Time
  12623. }).ExecuteCommand();
  12624. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12625. {
  12626. Id = x.id,
  12627. Date = x.date,
  12628. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12629. {
  12630. Date = x.Date
  12631. }).ExecuteCommand();
  12632. _sqlSugar.CommitTran();
  12633. jw = JsonView(true, "保存成功!");
  12634. }
  12635. catch (Exception ex)
  12636. {
  12637. _sqlSugar.RollbackTran();
  12638. jw = JsonView(false, "保存失败!" + ex.Message);
  12639. }
  12640. return Ok(jw);
  12641. }
  12642. /// <summary>
  12643. /// 报批行程生成
  12644. /// </summary>
  12645. /// <param name="dto"></param>
  12646. /// <returns></returns>
  12647. [HttpPost]
  12648. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12649. {
  12650. var jw = JsonView(false);
  12651. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12652. if (group == null)
  12653. {
  12654. jw.Msg = "暂无该团组!";
  12655. return Ok(jw);
  12656. }
  12657. //黑屏代码数据
  12658. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12659. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12660. {
  12661. jw.Msg = "黑屏代码有误!";
  12662. return Ok(jw);
  12663. }
  12664. foreach (DataRow row in dtBlack.Rows)
  12665. {
  12666. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12667. {
  12668. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12669. return Ok(jw);
  12670. }
  12671. }
  12672. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12673. var resultArr = new ArrayList();
  12674. if (officialActivitiesArr.Count == 0)
  12675. {
  12676. jw.Msg = "暂无公务出访信息!";
  12677. return Ok(jw);
  12678. }
  12679. try
  12680. {
  12681. _sqlSugar.BeginTran();
  12682. DeleteApprovalJourney(new
  12683. Domain.Dtos.Groups.DeleteApprovalJourney
  12684. {
  12685. Diid = dto.Diid,
  12686. uesrId = dto.Userid
  12687. });
  12688. var stay = "-";
  12689. var cityPath = "-";
  12690. //添加城市路径以及住宿地
  12691. //黑屏代码获取时间区间
  12692. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12693. var empty = "【未收入该三字码!请机票同事录入】";
  12694. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12695. for (int i = 0; i < timeArr.Count; i++)
  12696. {
  12697. stay = "-";
  12698. cityPath = "-";
  12699. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12700. DateTime NewData = DateTime.Parse(timeArr[i]);
  12701. 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();
  12702. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12703. if (tbSelect.Length > 0)
  12704. {
  12705. List<string> threeCodeStr = new List<string>();
  12706. bool isTrade = false;
  12707. string trip = string.Empty;
  12708. var rowLast = tbSelect.Last();
  12709. var rowFirst = tbSelect.First();
  12710. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12711. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12712. var takeOffTime = DateTime.Parse(timeArr[i]);
  12713. var fallToTime = DateTime.Parse(timeArr[i]);
  12714. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12715. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12716. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12717. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12718. foreach (var item in tbSelect)
  12719. {
  12720. var start = string.Empty;
  12721. var end = string.Empty;
  12722. var threeCode = item["Three"].ToString() ?? "";
  12723. if (threeCode.Length == 6)
  12724. {
  12725. start = threeCode.Substring(0, 3);
  12726. end = threeCode.Substring(3, 3);
  12727. if (threeCodeStr.Count == 0)
  12728. {
  12729. threeCodeStr.Add(start);
  12730. threeCodeStr.Add(end);
  12731. }
  12732. else
  12733. {
  12734. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12735. {
  12736. threeCodeStr.Add(end);
  12737. }
  12738. else
  12739. {
  12740. threeCodeStr.Add(start);
  12741. threeCodeStr.Add(end);
  12742. }
  12743. }
  12744. }
  12745. //处理机票信息
  12746. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12747. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12748. if (start_Object == null)
  12749. {
  12750. start_Object = new Res_ThreeCode()
  12751. {
  12752. AirPort = empty,
  12753. AirPort_En = empty,
  12754. City = empty,
  12755. Country = empty,
  12756. Four = empty,
  12757. Three = empty,
  12758. };
  12759. }
  12760. if (end_Object == null)
  12761. {
  12762. end_Object = new Res_ThreeCode()
  12763. {
  12764. AirPort = empty,
  12765. AirPort_En = empty,
  12766. City = empty,
  12767. Country = empty,
  12768. Four = empty,
  12769. Three = empty,
  12770. };
  12771. }
  12772. //机型判断
  12773. string airModel = item["AirModel"].ToString();
  12774. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12775. string flightTime = item["FlightTime"].ToString();
  12776. if (flightTime!.Contains(":"))
  12777. {
  12778. flightTime = flightTime.Replace(":", "小时");
  12779. flightTime += "分钟";
  12780. }
  12781. if (flightTime.Contains("H"))
  12782. {
  12783. flightTime = flightTime.Replace("H", "小时");
  12784. }
  12785. if (flightTime.Contains("M"))
  12786. {
  12787. flightTime = flightTime.Replace("M", "分钟");
  12788. }
  12789. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12790. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12791. {
  12792. flightTime = flightDataTime.Hour > 0
  12793. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12794. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12795. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12796. }
  12797. //航班号
  12798. string flightcode = item["Fliagtcode"].ToString();
  12799. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12800. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12801. if (aircompany == null)
  12802. {
  12803. aircompany = new Res_AirCompany
  12804. {
  12805. CnName = hsEmpty,
  12806. EnName = hsEmpty,
  12807. ShortCode = hsEmpty,
  12808. };
  12809. }
  12810. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12811. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12812. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12813. if (isTrade)
  12814. {
  12815. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12816. }
  12817. else
  12818. {
  12819. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12820. }
  12821. }
  12822. chiarr.Add(new Grp_ApprovalTravelDetails
  12823. {
  12824. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12825. CreateTime = DateTime.Now,
  12826. CreateUserId = dto.Userid,
  12827. ParentId = 0,
  12828. Details = trip
  12829. });
  12830. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12831. var last = threeCodeStr.Last();
  12832. foreach (var item in threeCodeStr)
  12833. {
  12834. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12835. if (item.Equals(last))
  12836. {
  12837. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12838. }
  12839. }
  12840. cityPath = cityPath.Trim('-');
  12841. }
  12842. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12843. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12844. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12845. appro.Diid = dto.Diid;
  12846. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12847. appro.Id = thisId;
  12848. appro.CreateUserId = dto.Userid;
  12849. appro.CreateTime = DateTime.Now;
  12850. foreach (var item in gwinfo)
  12851. {
  12852. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12853. chi.Details = "拜访" + item.Client;
  12854. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12855. {
  12856. chi.Details += "," + item.ReqSample;
  12857. }
  12858. chi.ParentId = thisId;
  12859. chi.Time = item.Time;
  12860. chiarr.Add(chi);
  12861. }
  12862. if (chiarr.Count < 5)
  12863. {
  12864. for (int j = chiarr.Count; j < 5; j++)
  12865. {
  12866. chiarr.Add(new
  12867. Grp_ApprovalTravelDetails());
  12868. }
  12869. }
  12870. resultArr.Add(new
  12871. {
  12872. appro.Id,
  12873. appro.Date,
  12874. appro.Diid,
  12875. chiList = chiarr.Select(x1 => new
  12876. {
  12877. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12878. x1.Details,
  12879. x1.ParentId,
  12880. x1.Id
  12881. })
  12882. });
  12883. }
  12884. _sqlSugar.CommitTran();
  12885. jw = JsonView(true, "生成成功!", resultArr);
  12886. }
  12887. catch (Exception ex)
  12888. {
  12889. jw.Code = 400;
  12890. jw.Msg = "生成失败!" + ex.Message;
  12891. }
  12892. return Ok(jw);
  12893. }
  12894. /// <summary>
  12895. /// 报批行程word导出
  12896. /// </summary>
  12897. /// <param name="dto"></param>
  12898. /// <returns></returns>
  12899. [HttpPost]
  12900. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12901. {
  12902. var jw = JsonView(false);
  12903. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12904. if (group == null)
  12905. {
  12906. jw.Msg = "暂无该团组!";
  12907. return Ok(jw);
  12908. }
  12909. //模板路径
  12910. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12911. //载入模板
  12912. Document doc = new Document(tempPath);
  12913. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12914. //获取所填表格的序数
  12915. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12916. Aspose.Words.Tables.Row titleRowClone = null;
  12917. Aspose.Words.Tables.Row CenterRowClone = null;
  12918. int index = 0;
  12919. int indexChi = 0;
  12920. int SetIndex = 0;
  12921. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12922. //获取数据,放到datatable
  12923. foreach (var item in ApprovalTravelArr)
  12924. {
  12925. if (index > 0)
  12926. {
  12927. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12928. tableOne.AppendChild(titleRowClone);
  12929. }
  12930. var textTime = item.Date;
  12931. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12932. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12933. SetIndex++;
  12934. if (ChiRep.Count > 0)
  12935. {
  12936. foreach (var itemChi in ChiRep)
  12937. {
  12938. var txtTime = itemChi.Time;
  12939. var txtDetail = itemChi.Details;
  12940. if (indexChi > 0)
  12941. {
  12942. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12943. tableOne.AppendChild(CenterRowClone);
  12944. }
  12945. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12946. {
  12947. SetCells(tableOne, doc, SetIndex, 0, "");
  12948. SetCells(tableOne, doc, SetIndex, 1, "");
  12949. indexChi++;
  12950. SetIndex++;
  12951. break;
  12952. }
  12953. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12954. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12955. indexChi++;
  12956. SetIndex++;
  12957. }
  12958. }
  12959. else
  12960. {
  12961. if (indexChi > 0)
  12962. {
  12963. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12964. tableOne.AppendChild(CenterRowClone);
  12965. }
  12966. SetCells(tableOne, doc, SetIndex, 0, "");
  12967. SetCells(tableOne, doc, SetIndex, 1, "");
  12968. indexChi++;
  12969. SetIndex++;
  12970. }
  12971. index++;
  12972. }
  12973. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12974. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12975. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12976. jw.Code = 200;
  12977. jw.Msg = "";
  12978. return Ok(jw);
  12979. }
  12980. private string intToString(int numberVal)
  12981. {
  12982. string numberval = numberVal.ToString();
  12983. Dictionary<char, string> Number = new Dictionary<char, string>();
  12984. Number.Add('1', "一");
  12985. Number.Add('2', "二");
  12986. Number.Add('3', "三");
  12987. Number.Add('4', "四");
  12988. Number.Add('5', "五");
  12989. Number.Add('6', "六");
  12990. Number.Add('7', "七");
  12991. Number.Add('8', "八");
  12992. Number.Add('9', "九");
  12993. string stringNumberVal = string.Empty;
  12994. for (int i = 0; i < numberval.Length; i++)
  12995. {
  12996. if (i == 0)
  12997. {
  12998. stringNumberVal += Number[numberval[i]];
  12999. }
  13000. else if (i >= 1)
  13001. {
  13002. if (numberval[i] == '0')
  13003. {
  13004. stringNumberVal = "十";
  13005. }
  13006. else
  13007. {
  13008. stringNumberVal += "十" + Number[numberval[i]];
  13009. }
  13010. }
  13011. }
  13012. return stringNumberVal;
  13013. }
  13014. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13015. {
  13016. //获取table中的某个单元格,从0开始
  13017. Cell lshCell = table.Rows[rows].Cells[cells];
  13018. //将单元格中段落移除
  13019. foreach (Node item in lshCell.Paragraphs)
  13020. {
  13021. lshCell.Paragraphs.Remove(item);
  13022. }
  13023. if (val.Contains("\r\n"))
  13024. {
  13025. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13026. foreach (var item in spArr)
  13027. {
  13028. //新建一个段落
  13029. Paragraph p = new Paragraph(doc);
  13030. var r = new Run(doc, item);
  13031. //把设置的值赋给之前新建的段落
  13032. p.AppendChild(r);
  13033. //将此段落加到单元格内
  13034. lshCell.AppendChild(p);
  13035. }
  13036. }
  13037. else
  13038. {
  13039. //新建一个段落
  13040. Paragraph p = new Paragraph(doc);
  13041. var r = new Run(doc, val);
  13042. //把设置的值赋给之前新建的段落
  13043. p.AppendChild(r);
  13044. //将此段落加到单元格内
  13045. lshCell.AppendChild(p);
  13046. }
  13047. }
  13048. [HttpPost]
  13049. public async Task<IActionResult> ServerHttp(string paramStr)
  13050. {
  13051. paramStr = paramStr.TrimEnd('\'');
  13052. paramStr = paramStr.TrimStart('\'');
  13053. JsonView jw = JsonView(false);
  13054. JObject param = JObject.Parse(paramStr);
  13055. if (!param.ContainsKey("url"))
  13056. {
  13057. jw.Msg = "url null";
  13058. return Ok(jw);
  13059. }
  13060. string url = param["url"]!.ToString();
  13061. var methon = "get";
  13062. Dictionary<string, string> bodyValues = null;
  13063. Dictionary<string, string> headValues = null;
  13064. if (param.ContainsKey("methon"))
  13065. {
  13066. methon = param["methon"]!.ToString().ToLower();
  13067. }
  13068. if (param.ContainsKey("header"))
  13069. {
  13070. var header = param["header"]!.ToString();
  13071. JObject headerJobject = JObject.Parse(header);
  13072. headValues = new Dictionary<string, string>();
  13073. foreach (JProperty item in headerJobject.Properties())
  13074. {
  13075. var value = item.Value.ToString();
  13076. var head = item.Path;
  13077. headValues.Add(head, value);
  13078. }
  13079. }
  13080. if (param.ContainsKey("body"))
  13081. {
  13082. var body = param["body"]!.ToString();
  13083. bodyValues = new Dictionary<string, string>();
  13084. JObject bodyJobject = JObject.Parse(body);
  13085. foreach (JProperty item in bodyJobject.Properties())
  13086. {
  13087. var value = item.Value.ToString();
  13088. var head = item.Path;
  13089. bodyValues.Add(head, value);
  13090. }
  13091. }
  13092. HttpClient client = new HttpClient();
  13093. string responseString = string.Empty;
  13094. if (headValues != null)
  13095. {
  13096. foreach (var item in headValues.Keys)
  13097. {
  13098. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13099. }
  13100. }
  13101. try
  13102. {
  13103. if (methon == "get")
  13104. {
  13105. responseString = await client.GetStringAsync(url);
  13106. }
  13107. else if (methon == "post")
  13108. {
  13109. if (bodyValues == null)
  13110. {
  13111. jw.Msg = "methon post body null";
  13112. return Ok(jw);
  13113. }
  13114. // 数据转化为 key=val 格式
  13115. var content = new FormUrlEncodedContent(bodyValues);
  13116. var response = await client.PostAsync(url, content);
  13117. // 获取数据
  13118. responseString = await response.Content.ReadAsStringAsync();
  13119. }
  13120. else
  13121. {
  13122. responseString = "methon error";
  13123. }
  13124. jw = JsonView(true, "success", responseString);
  13125. }
  13126. catch (Exception ex)
  13127. {
  13128. jw.Msg = "error " + ex.Message;
  13129. jw.Data = ex.StackTrace;
  13130. }
  13131. finally
  13132. {
  13133. client.Dispose();
  13134. }
  13135. return Ok(jw);
  13136. }
  13137. #endregion
  13138. // /// <summary>
  13139. // ///
  13140. // /// </summary>
  13141. // /// <param name="_dto"></param>
  13142. // /// <returns></returns>
  13143. // [HttpPost]
  13144. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13145. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13146. // {
  13147. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13148. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13149. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13150. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13151. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13152. // dic_psg.Add("客人", 974);
  13153. // dic_psg.Add("司机", 975);
  13154. // dic_psg.Add("导游", 976);
  13155. // dic_psg.Add("公司内部人员", 977);
  13156. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13157. // foreach (var item in list_visa)
  13158. // {
  13159. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13160. // temp.Id = item.Id;
  13161. // temp.DIId = item.DIId;
  13162. // temp.VisaClient = item.VisaClient;
  13163. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13164. // temp.VisaCurrency = item.VisaCurrency;
  13165. // temp.IsThird = item.IsThird;
  13166. // if (dic_psg.ContainsKey(item.PassengerType))
  13167. // {
  13168. // temp.PassengerType = dic_psg[item.PassengerType];
  13169. // }
  13170. // else {
  13171. // temp.PassengerType = -1;
  13172. // }
  13173. // temp.VisaNumber = item.VisaNumber;
  13174. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13175. // temp.CreateUserId = item.Operators;
  13176. // DateTime dt_ct;
  13177. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13178. // if (b_ct)
  13179. // {
  13180. // temp.CreateTime = dt_ct;
  13181. // }
  13182. // else
  13183. // {
  13184. // temp.CreateTime = DateTime.Now;
  13185. // }
  13186. // temp.DeleteTime = "";
  13187. // temp.DeleteUserId = 0;
  13188. // temp.Remark = item.Remark;
  13189. // if (string.IsNullOrEmpty(temp.Remark)) {
  13190. // temp.Remark = "";
  13191. // }
  13192. // temp.IsDel = item.IsDel;
  13193. // temp.VisaDescription = item.VisaAttachment;
  13194. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13195. //([Id]
  13196. // ,[DIId]
  13197. // ,[VisaClient]
  13198. // ,[VisaPrice]
  13199. // ,[VisaCurrency]
  13200. // ,[IsThird]
  13201. // ,[PassengerType]
  13202. // ,[VisaNumber]
  13203. // ,[VisaFreeNumber]
  13204. // ,[CreateUserId]
  13205. // ,[CreateTime]
  13206. // ,[DeleteTime]
  13207. // ,[DeleteUserId]
  13208. // ,[Remark]
  13209. // ,[IsDel]
  13210. // ,[visaDescription])
  13211. // VALUES
  13212. // ({0},{1},'{2}',{3},{4}
  13213. //,{5},{6},{7},{8},{9}
  13214. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13215. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13216. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13217. //);
  13218. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13219. // }
  13220. // return Ok(JsonView(true, "操作成功!"));
  13221. // }
  13222. /// <summary>
  13223. /// 123132123
  13224. /// </summary>
  13225. /// <param name="_dto"></param>
  13226. /// <returns></returns>
  13227. [HttpPost]
  13228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13229. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13230. {
  13231. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13232. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13233. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13234. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13235. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13236. dicDetail.Add(789, 1034);
  13237. dicDetail.Add(790, 1035);
  13238. dicDetail.Add(791, 1036);
  13239. dicDetail.Add(792, 1037);
  13240. dicDetail.Add(793, 1038);
  13241. dicDetail.Add(794, 1039);
  13242. dicDetail.Add(795, 1040);
  13243. dicDetail.Add(796, 1041);
  13244. dicDetail.Add(797, 1042);
  13245. dicDetail.Add(798, 1043);
  13246. dicDetail.Add(801, 1044);
  13247. dicDetail.Add(802, 1045);
  13248. dicDetail.Add(803, 1046);
  13249. Dictionary<int, int> dic = new Dictionary<int, int>();
  13250. dic.Add(806, 1027);
  13251. dic.Add(807, 1028);
  13252. dic.Add(808, 1029);
  13253. dic.Add(809, 1030);
  13254. dic.Add(810, 1031);
  13255. dic.Add(811, 1032);
  13256. dic.Add(812, 1033);
  13257. foreach (var item in list_visa)
  13258. {
  13259. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13260. temp.Coefficient = item.coefficient;
  13261. DateTime dtCrt;
  13262. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13263. if (b1)
  13264. {
  13265. temp.CreateTime = dtCrt;
  13266. }
  13267. else
  13268. {
  13269. temp.CreateTime = DateTime.Now;
  13270. }
  13271. temp.CreateUserId = item.Operators;
  13272. temp.DeleteTime = "";
  13273. temp.DeleteUserId = 0;
  13274. temp.DiId = int.Parse(item.DIID);
  13275. temp.FilePath = item.FilePath;
  13276. temp.IsDel = item.IsDel;
  13277. temp.Price = item.Price;
  13278. temp.PriceCount = 1;
  13279. temp.PriceCurrency = item.Currency;
  13280. int detailId = 0;
  13281. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13282. {
  13283. detailId = dicDetail[item.PriceTypeDetail];
  13284. }
  13285. temp.PriceDetailType = detailId;
  13286. temp.PriceDt = DateTime.Now;
  13287. temp.PriceName = item.PriceName;
  13288. temp.PriceSum = item.Price;
  13289. int tid = 0;
  13290. if (dic.ContainsKey(item.PriceType))
  13291. {
  13292. tid = dic[item.PriceType];
  13293. }
  13294. temp.PriceType = tid;
  13295. temp.Remark = item.Remark;
  13296. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13297. }
  13298. return Ok(JsonView(true, "操作成功!"));
  13299. }
  13300. }
  13301. }