GroupsController.cs 686 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835
  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 NPOI.HSSF.UserModel;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.OAMethodLib;
  11. using OASystem.API.OAMethodLib.File;
  12. using OASystem.API.OAMethodLib.Hub.HubClients;
  13. using OASystem.API.OAMethodLib.Hub.Hubs;
  14. using OASystem.API.OAMethodLib.JuHeAPI;
  15. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  16. using OASystem.Domain.Dtos.CRM;
  17. using OASystem.Domain.Dtos.FileDto;
  18. using OASystem.Domain.Dtos.Groups;
  19. using OASystem.Domain.Entities.Customer;
  20. using OASystem.Domain.Entities.Financial;
  21. using OASystem.Domain.Entities.Groups;
  22. using OASystem.Domain.ViewModels.Groups;
  23. using OASystem.Infrastructure.Repositories.Groups;
  24. using Quartz.Util;
  25. using SqlSugar.Extensions;
  26. using System.Collections;
  27. using System.Data;
  28. using System.Diagnostics;
  29. using System.Globalization;
  30. using System.Reflection.PortableExecutable;
  31. using Ubiety.Dns.Core;
  32. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  33. using Bookmark = Aspose.Words.Bookmark;
  34. using Cell = Aspose.Words.Tables.Cell;
  35. using Table = Aspose.Words.Tables.Table;
  36. namespace OASystem.API.Controllers
  37. {
  38. /// <summary>
  39. /// 团组相关
  40. /// </summary>
  41. //[Authorize]
  42. [Route("api/[controller]/[action]")]
  43. public class GroupsController : ControllerBase
  44. {
  45. private readonly ILogger<GroupsController> _logger;
  46. private readonly GrpScheduleRepository _grpScheduleRep;
  47. private readonly IMapper _mapper;
  48. private readonly DelegationInfoRepository _groupRepository;
  49. private readonly TaskAssignmentRepository _taskAssignmentRep;
  50. private readonly AirTicketResRepository _airTicketResRep;
  51. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  52. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  53. private readonly DelegationEnDataRepository _delegationEnDataRep;
  54. private readonly DelegationVisaRepository _delegationVisaRep;
  55. private readonly VisaPriceRepository _visaPriceRep;
  56. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  57. private readonly HotelPriceRepository _hotelPriceRep;
  58. private readonly CustomersRepository _customersRep;
  59. private readonly MessageRepository _message;
  60. private readonly SqlSugarClient _sqlSugar;
  61. private readonly TourClientListRepository _tourClientListRep;
  62. private readonly TeamRateRepository _teamRateRep;
  63. #region 成本相关
  64. private readonly CheckBoxsRepository _checkBoxs;
  65. private readonly GroupCostRepository _GroupCostRepository;
  66. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  67. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  68. #endregion
  69. private readonly SetDataRepository _setDataRep;
  70. private string url;
  71. private string path;
  72. private readonly EnterExitCostRepository _enterExitCostRep;
  73. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  74. private readonly UsersRepository _usersRep;
  75. private readonly IJuHeApiService _juHeApi;
  76. private readonly InvertedListRepository _invertedListRep;
  77. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  78. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  79. private readonly ThreeCodeRepository _threeCodeRepository;
  80. private readonly HotelInquiryRepository _hotelInquiryRep;
  81. private readonly FeeAuditRepository _feeAuditRep;
  82. private readonly VisaCommissionRepository _visaCommissionRep;
  83. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  84. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  85. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  86. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  87. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  88. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  89. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  90. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  91. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep)
  92. {
  93. _logger = logger;
  94. _mapper = mapper;
  95. _grpScheduleRep = grpScheduleRep;
  96. _groupRepository = groupRepository;
  97. _taskAssignmentRep = taskAssignmentRep;
  98. _airTicketResRep = airTicketResRep;
  99. _sqlSugar = sqlSugar;
  100. url = AppSettingsHelper.Get("ExcelBaseUrl");
  101. path = AppSettingsHelper.Get("ExcelBasePath");
  102. if (!System.IO.Directory.Exists(path))
  103. {
  104. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  105. }
  106. _decreasePaymentsRep = decreasePaymentsRep;
  107. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  108. _delegationEnDataRep = delegationEnDataRep;
  109. _enterExitCostRep = enterExitCostRep;
  110. _delegationVisaRep = delegationVisaRep;
  111. _message = message;
  112. _visaPriceRep = visaPriceRep;
  113. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  114. _checkBoxs = checkBoxs;
  115. _GroupCostRepository = GroupCostRepository;
  116. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  117. _GroupCostParameterRepository = GroupCostParameterRepository;
  118. _hotelPriceRep = hotelPriceRep;
  119. _customersRep = customersRep;
  120. _setDataRep = setDataRep;
  121. _tourClientListRep = tourClientListRep;
  122. _teamRateRep = teamRateRep;
  123. _hubContext = hubContext;
  124. _usersRep = usersRep;
  125. _juHeApi = juHeApi;
  126. _invertedListRep = invertedListRep;
  127. _visaFeeInfoRep = visaFeeInfoRep;
  128. _ticketBlackCodeRep = ticketBlackCodeRep;
  129. _hotelInquiryRep = hotelInquiryRep;
  130. _threeCodeRepository = threeCodeRepository;
  131. _feeAuditRep = feeAuditRep;
  132. _visaCommissionRep = visaCommissionRep;
  133. }
  134. #region 流程管控
  135. /// <summary>
  136. /// 获取团组流程管控信息
  137. /// </summary>
  138. /// <param name="paras">参数Json字符串</param>
  139. /// <returns></returns>
  140. [HttpPost]
  141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  142. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  143. {
  144. if (string.IsNullOrEmpty(_jsonDto.Paras))
  145. {
  146. return Ok(JsonView(false, "参数为空"));
  147. }
  148. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  149. if (_ScheduleDto != null)
  150. {
  151. if (_ScheduleDto.SearchType == 2)//获取列表
  152. {
  153. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  154. return Ok(JsonView(_grpScheduleViewList));
  155. }
  156. else//获取对象
  157. {
  158. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  159. if (_grpScheduleView != null)
  160. {
  161. return Ok(JsonView(_grpScheduleView));
  162. }
  163. }
  164. }
  165. else
  166. {
  167. return Ok(JsonView(false, "参数反序列化失败"));
  168. }
  169. return Ok(JsonView(false, "暂无数据!"));
  170. }
  171. /// <summary>
  172. /// 修改团组流程管控详细表数据
  173. /// </summary>
  174. /// <param name="paras"></param>
  175. /// <returns></returns>
  176. [HttpPost]
  177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  178. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  179. {
  180. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  181. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  182. .SetColumns(it => it.Duty == _detail.Duty)
  183. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  184. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  185. .SetColumns(it => it.JobContent == _detail.JobContent)
  186. .SetColumns(it => it.Remark == _detail.Remark)
  187. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  188. .Where(s => s.Id == dto.Id)
  189. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  190. .ExecuteCommandAsync();
  191. if (result > 0)
  192. {
  193. return Ok(JsonView(true, "保存成功!"));
  194. }
  195. return Ok(JsonView(false, "保存失败!"));
  196. }
  197. /// <summary>
  198. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  199. /// </summary>
  200. /// <param name="dto"></param>
  201. /// <returns></returns>
  202. [HttpPost]
  203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  204. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  205. {
  206. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  207. _detail.IsDel = 1;
  208. _detail.DeleteUserId = dto.Duty;
  209. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  210. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  211. .SetColumns(it => it.IsDel == _detail.IsDel)
  212. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  213. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  214. .Where(it => it.Id == dto.Id)
  215. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  216. //.WhereColumns(s => s.Id == dto.Id)
  217. .ExecuteCommandAsync();
  218. if (result > 0)
  219. {
  220. return Ok(JsonView(true, "删除成功!"));
  221. }
  222. return Ok(JsonView(false, "删除失败!"));
  223. }
  224. /// <summary>
  225. /// 增加团组流程管控详细表数据
  226. /// </summary>
  227. /// <param name="dto"></param>
  228. /// <returns></returns>
  229. [HttpPost]
  230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  231. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  232. {
  233. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  234. if (DateTime.Now < _detail.ExpectBeginDt)
  235. {
  236. _detail.StepStatus = 0;
  237. }
  238. else
  239. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  240. _detail.StepStatus = 1;
  241. }
  242. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  243. if (result > 0)
  244. {
  245. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  246. return Ok(JsonView(true, "添加成功!", _result));
  247. }
  248. return Ok(JsonView(false, "添加失败!"));
  249. }
  250. #endregion
  251. #region 团组基本信息
  252. /// <summary>
  253. /// 接团信息列表
  254. /// </summary>
  255. /// <param name="dto">团组列表请求dto</param>
  256. /// <returns></returns>
  257. [HttpPost]
  258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  259. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  260. {
  261. var groupData = await _groupRepository.GetGroupList(dto);
  262. if (groupData.Code != 0)
  263. {
  264. return Ok(JsonView(false, groupData.Msg));
  265. }
  266. return Ok(JsonView(groupData.Data));
  267. }
  268. /// <summary>
  269. /// 分页查询团组列表
  270. /// </summary>
  271. /// <param name="dto"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  276. {
  277. var watch = new Stopwatch();
  278. watch.Start();
  279. RefAsync<int> total = 0;
  280. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  281. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  282. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  283. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  284. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  285. .Distinct()
  286. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  287. watch.Stop();
  288. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  289. }
  290. /// <summary>
  291. /// 接团信息列表 Page
  292. /// </summary>
  293. /// <param name="dto">团组列表请求dto</param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  298. {
  299. #region 参数验证
  300. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  301. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  302. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  303. #region 页面操作权限验证
  304. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  305. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  306. #endregion
  307. #endregion
  308. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  309. {
  310. string sqlWhere = string.Empty;
  311. if (dto.IsSure == 0) //未完成
  312. {
  313. sqlWhere += string.Format(@" And IsSure = 0");
  314. }
  315. else if (dto.IsSure == 1) //已完成
  316. {
  317. sqlWhere += string.Format(@" And IsSure = 1");
  318. }
  319. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  320. {
  321. string tj = dto.SearchCriteria;
  322. 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}%')",
  323. tj, tj, tj, tj, tj);
  324. }
  325. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  326. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  327. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  328. JietuanOperator,IsSure,CreateTime,IsBid
  329. From (
  330. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  331. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  332. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  333. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  334. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  335. From Grp_DelegationInfo gdi
  336. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  337. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  338. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  339. Where gdi.IsDel = 0 {0}
  340. ) temp", sqlWhere);
  341. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  342. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  343. #region 处理所属部门
  344. /*
  345. * 1.sq 和 gyy 等显示 市场部
  346. * 2.王鸽和主管及张总还有管理员号统一国交部
  347. * 2-1. 4 管理员 ,21 张海麟
  348. */
  349. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  350. List<int> userIds1 = new List<int>() { 4, 21 };
  351. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  352. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  353. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  354. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  355. .ToList();
  356. foreach (var item in _DelegationList)
  357. {
  358. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  359. }
  360. #endregion
  361. var _view = new
  362. {
  363. PageFuncAuth = pageFunAuthView,
  364. Data = _DelegationList
  365. };
  366. return Ok(JsonView(true, "查询成功!", _view, total));
  367. }
  368. else
  369. {
  370. return Ok(JsonView(false, "查询失败"));
  371. }
  372. }
  373. /// <summary>
  374. /// 团组列表
  375. /// </summary>
  376. /// <returns></returns>
  377. [HttpPost]
  378. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  379. {
  380. #region 参数验证
  381. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  382. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  383. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  384. #region 页面操作权限验证
  385. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  386. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  387. #endregion
  388. #endregion
  389. if (dto.PortType != 1 && dto.PortType != 2)
  390. {
  391. return Ok(JsonView(false, "查询失败!"));
  392. }
  393. string orderbyStr = "order by gdi.CreateTime Desc";
  394. string sqlWhere = string.Empty;
  395. if (dto.IsSure == 0) //未完成
  396. {
  397. sqlWhere += string.Format(@" And IsSure = 0");
  398. }
  399. else if (dto.IsSure == 1) //已完成
  400. {
  401. sqlWhere += string.Format(@" And IsSure = 1");
  402. }
  403. //团组类型
  404. if (dto.TeamDid > 0)
  405. {
  406. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  407. }
  408. //团组名称
  409. if (!string.IsNullOrEmpty(dto.TeamName))
  410. {
  411. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  412. }
  413. //客户名称
  414. if (!string.IsNullOrEmpty(dto.ClientName))
  415. {
  416. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  417. }
  418. //客户单位
  419. if (!string.IsNullOrEmpty(dto.ClientUnit))
  420. {
  421. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  422. }
  423. //出访时间
  424. if (!string.IsNullOrEmpty(dto.visitDataTime))
  425. {
  426. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  427. orderbyStr = "order by gdi.VisitDate";
  428. }
  429. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  430. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  431. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  432. JietuanOperator,IsSure,CreateTime
  433. From (
  434. Select row_number() over({0}) as Row_Number,
  435. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  436. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  437. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  438. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  439. From Grp_DelegationInfo gdi
  440. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  441. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  442. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  443. Where gdi.IsDel = 0 {1}
  444. ) temp ", orderbyStr, sqlWhere);
  445. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  446. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  447. #region 处理所属部门
  448. /*
  449. * 1.sq 和 gyy 等显示 市场部
  450. * 2.王鸽和主管及张总还有管理员号统一国交部
  451. * 2-1. 4 管理员 ,21 张海麟
  452. */
  453. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  454. List<int> userIds1 = new List<int>() { 4, 21 };
  455. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  456. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  457. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  458. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  459. .ToList();
  460. foreach (var item in _DelegationList)
  461. {
  462. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  463. }
  464. #endregion
  465. var _view = new
  466. {
  467. PageFuncAuth = pageFunAuthView,
  468. Data = _DelegationList
  469. };
  470. return Ok(JsonView(true, "查询成功!", _view, total));
  471. }
  472. /// <summary>
  473. /// 接团信息详情
  474. /// </summary>
  475. /// <param name="dto">团组info请求dto</param>
  476. /// <returns></returns>
  477. [HttpPost]
  478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  479. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  480. {
  481. var groupData = await _groupRepository.GetGroupInfo(dto);
  482. if (groupData.Code != 0)
  483. {
  484. return Ok(JsonView(false, groupData.Msg));
  485. }
  486. return Ok(JsonView(groupData.Data));
  487. }
  488. /// <summary>
  489. /// 接团信息 编辑添加
  490. /// 基础信息数据源
  491. /// </summary>
  492. /// <param name="dto"></param>
  493. /// <returns></returns>
  494. [HttpPost]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  497. {
  498. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  499. if (groupData.Code != 0)
  500. {
  501. return Ok(JsonView(false, groupData.Msg));
  502. }
  503. return Ok(JsonView(groupData.Data));
  504. }
  505. /// <summary>
  506. /// 接团信息 操作(增改)
  507. /// </summary>
  508. /// <param name="dto"></param>
  509. /// <returns></returns>
  510. [HttpPost]
  511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  512. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  513. {
  514. try
  515. {
  516. var groupData = await _groupRepository.GroupOperation(dto);
  517. if (groupData.Code != 0)
  518. {
  519. return Ok(JsonView(false, groupData.Msg));
  520. }
  521. int diId = 0;
  522. //添加时 默认加入团组汇率
  523. if (dto.Status == 1) //添加
  524. {
  525. diId = groupData.Data;
  526. //添加默认币种
  527. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  528. //默认分配权限
  529. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  530. //消息提示 王鸽 主管号
  531. List<int> _managerIds = new List<int>() { 22, 32 };
  532. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  533. if (userIds.Count > 0)
  534. {
  535. userIds.Add(208);
  536. //创建团组管控
  537. GroupStepForDelegation.CreateWorkStep(diId);
  538. //发送消息
  539. string groupName = dto.TeamName;
  540. string createGroupUser = string.Empty;
  541. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  542. if (userInfo != null) createGroupUser = userInfo.CnName;
  543. string title = $"系统通知";
  544. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  545. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  546. }
  547. //默认创建倒推表
  548. await _invertedListRep._Create(dto.UserId, diId);
  549. }
  550. else if (dto.Status == 2)
  551. {
  552. diId = dto.Id;
  553. }
  554. return Ok(JsonView(true, "操作成功!", diId));
  555. }
  556. catch (Exception ex)
  557. {
  558. Logs("[response]" + JsonConvert.SerializeObject(dto));
  559. Logs(ex.Message);
  560. return Ok(JsonView(false, ex.Message));
  561. }
  562. }
  563. /// <summary>
  564. /// 接团流程操作(增改)
  565. /// 安卓端使用 建团时添加客户名单
  566. /// </summary>
  567. /// <param name="dto"></param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  572. {
  573. try
  574. {
  575. #region 参数验证
  576. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  577. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  578. #region 页面操作权限验证
  579. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  580. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  581. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  582. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  583. #endregion
  584. #endregion
  585. _sqlSugar.BeginTran();
  586. var _dto = new GroupOperationDto();
  587. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  588. var groupData = await _groupRepository.GroupOperation(_dto);
  589. if (groupData.Code != 0)
  590. {
  591. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  592. }
  593. int diId = 0;
  594. //添加时 默认加入团组汇率
  595. if (dto.Status == 1) //添加
  596. {
  597. diId = groupData.Data;
  598. //添加默认币种
  599. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  600. //默认分配权限
  601. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  602. //消息提示 王鸽 主管号
  603. List<int> _managerIds = new List<int>() { 22, 32 };
  604. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  605. if (userIds.Count > 0)
  606. {
  607. userIds.Add(208);
  608. //创建团组管控
  609. GroupStepForDelegation.CreateWorkStep(diId);
  610. //发送消息
  611. string groupName = dto.TeamName;
  612. string createGroupUser = string.Empty;
  613. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  614. if (userInfo != null) createGroupUser = userInfo.CnName;
  615. string title = $"系统通知";
  616. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  617. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  618. }
  619. }
  620. if (dto.Status == 2)
  621. {
  622. diId = dto.Id;
  623. if (diId == 0)
  624. {
  625. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  626. }
  627. }
  628. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  629. if (viewData.Code != 0)
  630. {
  631. _sqlSugar.RollbackTran();
  632. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  633. }
  634. _sqlSugar.CommitTran();
  635. return Ok(JsonView(true, "添加成功"));
  636. }
  637. catch (Exception ex)
  638. {
  639. _sqlSugar.RollbackTran();
  640. return Ok(JsonView(false, ex.Message));
  641. }
  642. }
  643. /// <summary>
  644. /// 接团信息 操作(删除)
  645. /// </summary>
  646. /// <param name="dto"></param>
  647. /// <returns></returns>
  648. [HttpPost]
  649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  650. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  651. {
  652. try
  653. {
  654. var groupData = await _groupRepository.GroupDel(dto);
  655. if (groupData.Code != 0)
  656. {
  657. return Ok(JsonView(false, groupData.Msg));
  658. }
  659. return Ok(JsonView(true));
  660. }
  661. catch (Exception ex)
  662. {
  663. Logs("[response]" + JsonConvert.SerializeObject(dto));
  664. Logs(ex.Message);
  665. return Ok(JsonView(false, ex.Message));
  666. }
  667. }
  668. /// <summary>
  669. /// 获取团组销售报价号
  670. /// 团组添加时 使用
  671. /// </summary>
  672. /// <returns></returns>
  673. [HttpPost]
  674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  675. public async Task<IActionResult> GetGroupSalesQuoteNo()
  676. {
  677. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  678. if (groupData.Code != 0)
  679. {
  680. return Ok(JsonView(false, groupData.Msg));
  681. }
  682. object salesQuoteNo = new
  683. {
  684. SalesQuoteNo = groupData.Data
  685. };
  686. return Ok(JsonView(salesQuoteNo));
  687. }
  688. /// <summary>
  689. /// 设置确认出团
  690. /// </summary>
  691. /// <param name="dto"></param>
  692. /// <returns></returns>
  693. [HttpPost]
  694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  695. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  696. {
  697. var groupData = await _groupRepository.ConfirmationGroup(dto);
  698. if (groupData.Code != 0)
  699. {
  700. return Ok(JsonView(false, groupData.Msg));
  701. }
  702. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  703. #region OA消息推送
  704. try
  705. {
  706. string groupName = groupInfo.TeamName;
  707. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  708. List<int> userIds = new List<int>();
  709. listUser.ForEach(s => userIds.Add(s.Id));
  710. string title = $"系统通知";
  711. string content = $"团组[{groupName}]已确认出团!";
  712. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  713. }
  714. catch (Exception ex)
  715. {
  716. }
  717. #endregion
  718. #region 应用推送
  719. try
  720. {
  721. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  722. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  723. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  724. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  725. {
  726. List<string> userList = new List<string>() { users.QiyeChatUserId };
  727. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  728. }
  729. }
  730. catch (Exception ex)
  731. {
  732. }
  733. #endregion
  734. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  735. return Ok(JsonView(true, "操作成功!", groupData.Data));
  736. }
  737. /// <summary>
  738. /// 获取团组名称data And 签证国别Data
  739. /// </summary>
  740. /// <param name="dto"></param>
  741. /// <returns></returns>
  742. [HttpPost]
  743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  744. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  745. {
  746. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  747. if (groupData.Code != 0)
  748. {
  749. return Ok(JsonView(false, groupData.Msg));
  750. }
  751. return Ok(JsonView(groupData.Data));
  752. }
  753. /// <summary>
  754. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  755. /// </summary>
  756. /// <returns></returns>
  757. [HttpPost]
  758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  759. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  760. {
  761. try
  762. {
  763. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  764. if (groupData.Code != 0)
  765. {
  766. return Ok(JsonView(false, groupData.Msg));
  767. }
  768. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  769. }
  770. catch (Exception ex)
  771. {
  772. return Ok(JsonView(false, "程序错误!"));
  773. throw;
  774. }
  775. }
  776. #endregion
  777. #region 团组&签证
  778. /// <summary>
  779. /// 根据团组Id获取签证客户信息List
  780. /// </summary>
  781. /// <param name="dto">请求dto</param>
  782. /// <returns></returns>
  783. [HttpPost]
  784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  785. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  786. {
  787. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  788. if (groupData.Code != 0)
  789. {
  790. return Ok(JsonView(false, groupData.Msg));
  791. }
  792. return Ok(JsonView(groupData.Data));
  793. }
  794. /// <summary>
  795. /// IOS获取团组签证拍照上传进度01(团组列表)
  796. /// </summary>
  797. /// <param name="dto">请求dto</param>
  798. /// <returns></returns>
  799. [HttpPost]
  800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  801. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  802. {
  803. if (dto == null)
  804. {
  805. return Ok(JsonView(false, "参数为空"));
  806. }
  807. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  808. return Ok(JsonView(visaList));
  809. }
  810. /// <summary>
  811. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  812. /// </summary>
  813. /// <returns></returns>
  814. [HttpPost]
  815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  816. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  817. {
  818. if (dto == null)
  819. {
  820. return Ok(JsonView(false, "请求错误:"));
  821. }
  822. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  823. return Ok(JsonView(list));
  824. }
  825. /// <summary>
  826. /// IOS获取团组签证拍照上传进度03(相册)
  827. /// </summary>
  828. /// <returns></returns>
  829. [HttpPost]
  830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  831. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  832. {
  833. if (dto == null)
  834. {
  835. return Ok(JsonView(false, "请求错误:"));
  836. }
  837. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  838. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  839. list.ForEach(s => s.url = url);
  840. return Ok(JsonView(list));
  841. }
  842. /// <summary>
  843. /// IOS获取团组签证拍照上传进度04(图片上传)
  844. /// </summary>
  845. /// <param name="dto"></param>
  846. /// <returns></returns>
  847. [HttpPost]
  848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  849. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  850. {
  851. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  852. //if (!string.IsNullOrEmpty(result))
  853. //{
  854. //}
  855. //else {
  856. // return Ok(JsonView(false, "上传失败"));
  857. //}
  858. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  859. int sucNum = 0;
  860. try
  861. {
  862. foreach (var item in dto.base64DataList)
  863. {
  864. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  865. string result = decodeBase64ToImage(item, imageName);
  866. if (!string.IsNullOrEmpty(result))
  867. {
  868. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  869. pic.CreateUserId = dto.CreateUserId;
  870. pic.PicName = imageName;
  871. pic.PicPath = result;
  872. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  873. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  874. if (insertResult > 0)
  875. {
  876. sucNum++;
  877. }
  878. }
  879. }
  880. }
  881. catch (Exception ex)
  882. {
  883. return Ok(JsonView(false, ex.Message));
  884. }
  885. string msg = string.Format(@"成功上传{0}张", sucNum);
  886. return Ok(JsonView(true, msg));
  887. }
  888. private string decodeBase64ToImage(string base64DataURL, string imgName)
  889. {
  890. string filename = "";//声明一个string类型的相对路径
  891. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  892. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  893. try//会有异常抛出,try,catch一下
  894. {
  895. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  896. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  897. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  898. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  899. //文件名称
  900. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  901. //上传的文件的路径
  902. string filePath = "";
  903. if (!Directory.Exists(fileDir))
  904. {
  905. Directory.CreateDirectory(fileDir);
  906. }
  907. //上传的文件的路径
  908. filePath = fileDir + filename;
  909. //string url = HttpRuntime.AppDomainAppPath.ToString();
  910. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  911. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  912. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  913. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  914. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  915. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  916. ms.Close();//关闭当前流,并释放所有与之关联的资源
  917. bitmap.Dispose();
  918. }
  919. catch (Exception e)
  920. {
  921. string massage = e.Message;
  922. Logs("IOS图片上传Error:" + massage);
  923. //filename = e.Message;
  924. }
  925. return filename;//返回相对路径
  926. }
  927. /// <summary>
  928. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  929. /// </summary>
  930. /// <param name="dto"></param>
  931. /// <returns></returns>
  932. [HttpPost]
  933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  934. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  935. {
  936. if (dto == null)
  937. {
  938. return Ok(JsonView(false, "请求错误:"));
  939. }
  940. string msg = "参数错误";
  941. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  942. {
  943. try
  944. {
  945. //_delegationVisaRep.BeginTran();
  946. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  947. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  948. .Where(s => s.Id == dto.visaProgressCustomerId)
  949. .ExecuteCommandAsync();
  950. if (updCount > 0 && dto.publishCode == 1)
  951. {
  952. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  953. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  954. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  955. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  956. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  957. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  958. if (groupData == null)
  959. {
  960. _delegationVisaRep.RollbackTran();
  961. }
  962. string title = string.Format(@"[签证进度更新]");
  963. string content = string.Format(@"测试文本");
  964. bool rst = await _message.AddMsg(new MessageDto()
  965. {
  966. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  967. IssuerId = dto.publisher,
  968. Title = title,
  969. Content = content,
  970. ReleaseTime = DateTime.Now,
  971. UIdList = new List<int> {
  972. 234
  973. }
  974. });
  975. if (rst)
  976. {
  977. return Ok(JsonView(true, "发送通知成功"));
  978. }
  979. }
  980. //_delegationVisaRep.CommitTran();
  981. }
  982. catch (Exception)
  983. {
  984. //_delegationVisaRep.RollbackTran();
  985. }
  986. }
  987. return Ok(JsonView(true, msg));
  988. }
  989. #endregion
  990. #region 团组任务分配
  991. /// <summary>
  992. /// 团组任务分配初始化
  993. /// </summary>
  994. /// <param name="dto"></param>
  995. /// <returns></returns>
  996. [HttpPost]
  997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  998. public async Task<IActionResult> GetTaskAssignmen()
  999. {
  1000. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1001. if (groupData.Code != 0)
  1002. {
  1003. return Ok(JsonView(false, groupData.Msg));
  1004. }
  1005. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1006. }
  1007. /// <summary>
  1008. /// 团组任务分配查询
  1009. /// </summary>
  1010. /// <param name="dto"></param>
  1011. /// <returns></returns>
  1012. [HttpPost]
  1013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1014. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1015. {
  1016. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1017. if (groupData.Code != 0)
  1018. {
  1019. return Ok(JsonView(false, groupData.Msg));
  1020. }
  1021. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1022. }
  1023. /// <summary>
  1024. /// 团组任务分配操作
  1025. /// </summary>
  1026. /// <param name="dto"></param>
  1027. /// <returns></returns>
  1028. [HttpPost]
  1029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1030. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1031. {
  1032. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1033. if (groupData.Code != 0)
  1034. {
  1035. return Ok(JsonView(false, groupData.Msg));
  1036. }
  1037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1038. }
  1039. /// <summary>
  1040. /// 团组任务分配
  1041. /// 批量分配
  1042. /// 查询团组
  1043. /// </summary>
  1044. /// <param name="dto"></param>
  1045. /// <returns></returns>
  1046. [HttpPost]
  1047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1048. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1049. {
  1050. //参数验证
  1051. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1052. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1053. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1054. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1055. }
  1056. /// <summary>
  1057. /// 团组任务分配
  1058. /// 批量分配
  1059. /// </summary>
  1060. /// <param name="dto"></param>
  1061. /// <returns></returns>
  1062. [HttpPost]
  1063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1064. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1065. {
  1066. //参数验证
  1067. if (dto.UserId < 1 ) return Ok(JsonView(false, MsgTips.UserId));
  1068. if (dto.OperateId < 1) return Ok(JsonView(false, MsgTips.OperateId));
  1069. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请传入有效的GroupIds数组参数!"));
  1070. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1071. }
  1072. #endregion
  1073. #region 团组费用审核
  1074. /// <summary>
  1075. /// 费用审核
  1076. /// 团组列表 Page
  1077. /// </summary>
  1078. /// <param name="_dto">团组列表请求dto</param>
  1079. /// <returns></returns>
  1080. [HttpPost]
  1081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1082. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1083. {
  1084. #region 参数验证
  1085. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1086. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1087. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1088. #region 页面操作权限验证
  1089. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1090. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1091. #endregion
  1092. #endregion
  1093. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1094. {
  1095. string sqlWhere = string.Empty;
  1096. if (_dto.IsSure == 0) //未完成
  1097. {
  1098. sqlWhere += string.Format(@" And IsSure = 0");
  1099. }
  1100. else if (_dto.IsSure == 1) //已完成
  1101. {
  1102. sqlWhere += string.Format(@" And IsSure = 1");
  1103. }
  1104. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1105. {
  1106. string tj = _dto.SearchCriteria;
  1107. 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}%')",
  1108. tj, tj, tj, tj, tj);
  1109. }
  1110. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1111. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1112. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1113. From (
  1114. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1115. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1116. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1117. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1118. From Grp_DelegationInfo gdi
  1119. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1120. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1121. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1122. Where gdi.IsDel = 0 {0}
  1123. ) temp ", sqlWhere);
  1124. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1125. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1126. var _view = new
  1127. {
  1128. PageFuncAuth = pageFunAuthView,
  1129. Data = _DelegationList
  1130. };
  1131. return Ok(JsonView(true, "查询成功!", _view, total));
  1132. }
  1133. else
  1134. {
  1135. return Ok(JsonView(false, "查询失败"));
  1136. }
  1137. }
  1138. /// <summary>
  1139. /// 获取团组费用审核
  1140. /// </summary>
  1141. /// <param name="paras">参数Json字符串</param>
  1142. /// <returns></returns>
  1143. [HttpPost]
  1144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1145. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1146. {
  1147. try
  1148. {
  1149. #region 参数验证
  1150. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1151. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1152. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1153. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1154. #region 页面操作权限验证
  1155. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1156. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1157. #endregion
  1158. #endregion
  1159. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1160. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1161. #region 费用清单
  1162. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1163. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1164. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1165. List<Grp_CreditCardPayment> entityList = _groupRepository
  1166. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1167. .Where(exp.ToExpression())
  1168. .ToList();
  1169. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1170. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1171. /*
  1172. * 76://酒店预订
  1173. */
  1174. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1175. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1178. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1179. .ToListAsync();
  1180. /*
  1181. * 79://车/导游地接
  1182. */
  1183. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1184. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1187. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1188. .ToListAsync();
  1189. /*
  1190. * 80: //签证
  1191. */
  1192. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1193. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1194. .ToListAsync();
  1195. /*
  1196. *81: //邀请/公务活动
  1197. */
  1198. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1199. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1200. .ToListAsync();
  1201. /*
  1202. * 82: //团组客户保险
  1203. */
  1204. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1205. /*
  1206. * Lable = 85 机票预订
  1207. */
  1208. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1209. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1210. .ToListAsync();
  1211. /*
  1212. * 85 机票预定
  1213. */
  1214. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1215. /*
  1216. * 98 其他款项
  1217. */
  1218. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1219. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1220. .ToListAsync();
  1221. /*
  1222. * 285:收款退还
  1223. */
  1224. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1225. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1226. .ToListAsync();
  1227. /*
  1228. * 1015: //超支费用
  1229. */
  1230. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1231. /*
  1232. * 币种信息
  1233. */
  1234. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1235. /*
  1236. * 车/导游地接 费用类型
  1237. */
  1238. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1239. /*
  1240. * 车/导游地接 费用类型
  1241. */
  1242. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1243. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1244. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1245. /*
  1246. * 用户信息
  1247. */
  1248. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1249. /*
  1250. * 费用模块
  1251. */
  1252. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1253. string priceModule = string.Empty;
  1254. if (sdPriceName != null)
  1255. {
  1256. priceModule = sdPriceName.Name;
  1257. }
  1258. /*
  1259. * 成本信息
  1260. */
  1261. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1262. decimal _groupRate = 0.0000M;
  1263. string _groupCurrencyCode = "-";
  1264. if (groupCost != null)
  1265. {
  1266. _groupRate = groupCost.Rate;
  1267. if (int.TryParse(groupCost.Currency, out int _currency))
  1268. {
  1269. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1270. }
  1271. else _groupCurrencyCode = groupCost.Currency;
  1272. }
  1273. string costContentSql = $"Select * From Grp_GroupCost";
  1274. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1275. //处理日期为空的天数
  1276. for (int i = 0; i < groupCostDetails.Count; i++)
  1277. if (i != 0)
  1278. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1279. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1280. /*
  1281. * 处理详情数据
  1282. */
  1283. foreach (var entity in entityList)
  1284. {
  1285. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1286. _detail.Id = entity.Id;
  1287. _detail.PriceName = priceModule;
  1288. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1289. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1290. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1291. /*
  1292. * 应付款金额
  1293. */
  1294. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1295. string PaymentCurrency_WaitPay = "Unknown";
  1296. string hotelCurrncyCode = "Unknown";
  1297. string hotelCurrncyName = "Unknown";
  1298. if (sdPaymentCurrency_WaitPay != null)
  1299. {
  1300. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1301. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1302. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1303. if (hotelCurrncyCode.Equals("CNY"))
  1304. {
  1305. entity.DayRate = 1.0000M;
  1306. }
  1307. }
  1308. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1309. /*
  1310. * 此次付款金额
  1311. */
  1312. decimal CurrPayStr = 0;
  1313. if (entity.PayPercentage == 0)
  1314. {
  1315. if (entity.PayThenMoney != 0)
  1316. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1317. }
  1318. else
  1319. {
  1320. if (entity.PayMoney != 0)
  1321. {
  1322. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1323. }
  1324. }
  1325. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1326. /*
  1327. * 剩余尾款
  1328. */
  1329. decimal BalanceStr = 0;
  1330. if (CurrPayStr != 0)
  1331. {
  1332. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1333. BalanceStr = 0;
  1334. else
  1335. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1336. }
  1337. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1338. /*
  1339. * Bus名称
  1340. */
  1341. _detail.BusName = "待增加";
  1342. /*
  1343. *费用所属
  1344. */
  1345. switch (entity.CTable)
  1346. {
  1347. case 76://酒店预订
  1348. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1349. if (hotelReservations != null)
  1350. {
  1351. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1352. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1353. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1354. string roomFeeStr = "", roomFeestr1 = "";
  1355. //是否比较房型价格
  1356. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1357. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1358. roomFeeStr += $"<br/>";
  1359. if (hotelReservations.SingleRoomPrice > 0)
  1360. {
  1361. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1362. __isSingle = true;
  1363. }
  1364. if (hotelReservations.DoubleRoomPrice > 0)
  1365. {
  1366. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1367. __isDouble = true;
  1368. }
  1369. if (hotelReservations.SuiteRoomPrice > 0)
  1370. {
  1371. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1372. __isSuite = true;
  1373. }
  1374. if (hotelReservations.OtherRoomPrice > 0)
  1375. {
  1376. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1377. __isOther = true;
  1378. }
  1379. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1380. else roomFeeStr += " 0.00 * 0";
  1381. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1382. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1383. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1384. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1385. /*
  1386. * 费用类型
  1387. * 1:房费
  1388. * 2:早餐
  1389. * 3:地税
  1390. * 4:城市税
  1391. * </summary>
  1392. */
  1393. //地税
  1394. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1395. if (governmentRentData != null)
  1396. {
  1397. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1398. governmentRentFee = governmentRentData.Price;
  1399. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1400. if (governmentRentCurrData != null)
  1401. {
  1402. governmentRentCode = governmentRentCurrData.Name;
  1403. governmentRentName = $"({governmentRentCurrData.Remark})";
  1404. }
  1405. }
  1406. //城市税
  1407. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1408. if (cityTaxData != null)
  1409. {
  1410. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1411. cityTaxFee = cityTaxData.Price;
  1412. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1413. if (cityTaxCurrData != null)
  1414. {
  1415. cityTaxCode = cityTaxCurrData.Name;
  1416. cityTaxName = $"({cityTaxCurrData.Remark})";
  1417. }
  1418. }
  1419. //酒店早餐
  1420. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1421. if (breakfastData != null)
  1422. {
  1423. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1424. breakfastFee = breakfastData.Price;
  1425. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1426. if (breakfastCurrData != null)
  1427. {
  1428. breakfastCode = breakfastCurrData.Name;
  1429. breakfastName = $"({breakfastCurrData.Remark})";
  1430. }
  1431. }
  1432. //房间费用
  1433. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1434. if (roomData != null)
  1435. {
  1436. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1437. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1438. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1439. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1440. roomFee = roomData.Price;
  1441. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1442. if (roomCurrData != null)
  1443. {
  1444. roomCode = roomCurrData.Name;
  1445. roomName = $"({roomCurrData.Remark})";
  1446. }
  1447. }
  1448. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1449. string hotelCostStr = "";
  1450. decimal hotelCsotTotal = 0.00M;
  1451. if (groupCost != null)
  1452. {
  1453. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1454. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1455. }
  1456. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1457. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1458. string hotelCost_day = "";
  1459. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1460. foreach (var item in hotelCostDetails1)
  1461. {
  1462. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1463. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1464. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1465. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1466. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1467. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1468. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1469. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1470. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1471. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1472. hotelCost_day += @$"</br>";
  1473. }
  1474. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1475. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1476. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1477. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1478. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1479. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1480. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1481. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1482. $"房间说明: {hotelReservations.Remark} <br/>" +
  1483. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1484. $"{hotelBreakfastStr}" +
  1485. $"{hotelGovernmentRentStr}" +
  1486. $"{hotelCityTaxStr}";
  1487. _detail.PriceNameContent = hotelReservations.HotelName;
  1488. }
  1489. break;
  1490. case 79://车/导游地接
  1491. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1492. if (touristGuideGroundReservations != null)
  1493. {
  1494. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1495. {
  1496. _detail.BusName = touristGuideGroundReservations.BusName;
  1497. }
  1498. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1499. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1500. //if (isInt)
  1501. //{
  1502. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1503. // if (cityInfo != null)
  1504. // {
  1505. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1506. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1507. // if (carFeeItem != null)
  1508. // {
  1509. // nameContent += $@"({carFeeItem.Name})";
  1510. // }
  1511. // _detail.PriceNameContent = nameContent;
  1512. // }
  1513. //}
  1514. //else
  1515. //{
  1516. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1517. //}
  1518. var touristGuideGroundReservationsContents =
  1519. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1520. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1521. foreach (var item in touristGuideGroundReservationsContents)
  1522. {
  1523. string typeName = "Unknown";
  1524. string carCurrencyCode = "Unknown";
  1525. string carCurrencyName = "Unknown";
  1526. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1527. if (carTypeData != null) typeName = carTypeData.Name;
  1528. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1529. if (currencyData != null)
  1530. {
  1531. carCurrencyCode = currencyData.Name;
  1532. carCurrencyName = currencyData.Remark;
  1533. }
  1534. //op、成本 币种是否一致
  1535. bool IsCurrencyAgreement = false;
  1536. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1537. string opCostStr = string.Empty;
  1538. decimal opCostTypePrice = 0.00M;
  1539. #region 处理成本各项费用
  1540. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1541. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1542. if (opCost.Count > 0)
  1543. {
  1544. switch (item.SId)
  1545. {
  1546. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1547. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1548. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1549. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1550. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1551. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1552. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1553. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1554. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1555. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1556. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1557. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1558. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1559. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1560. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1561. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1562. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1563. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1564. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1565. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1566. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1567. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1568. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1569. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1570. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1571. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1572. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1573. }
  1574. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1575. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1576. }
  1577. #endregion
  1578. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1579. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1580. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1581. $"{opTypeStr} {opCostStr}<br/>" +
  1582. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1583. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1584. }
  1585. _detail.PriceMsgContent = priceMsg;
  1586. }
  1587. break;
  1588. case 80: //签证
  1589. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1590. if (visaInfo != null)
  1591. {
  1592. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1593. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1594. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1595. }
  1596. break;
  1597. case 81: //邀请/公务活动
  1598. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1599. if (_ioa != null)
  1600. {
  1601. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1602. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1603. sendCurrName = "Unknown", //快递费用币种 Name
  1604. sendCurrCode = "Unknown", //快递费用币种 Code
  1605. eventsCurrName = "Unknown", //公务活动费币种 Name
  1606. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1607. translateCurrName = "Unknown", //公务翻译费 Name
  1608. translateCurrCode = "Unknown"; //公务翻译费 Code
  1609. #region 处理费用币种
  1610. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1611. if (inviteCurrData != null)
  1612. {
  1613. inviteCurrName = inviteCurrData.Remark;
  1614. inviteCurrCode = inviteCurrData.Name;
  1615. }
  1616. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1617. if (sendCurrData != null)
  1618. {
  1619. sendCurrName = sendCurrData.Remark;
  1620. sendCurrCode = sendCurrData.Name;
  1621. }
  1622. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1623. if (eventsCurrData != null)
  1624. {
  1625. eventsCurrName = eventsCurrData.Remark;
  1626. eventsCurrCode = eventsCurrData.Name;
  1627. }
  1628. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1629. if (translateCurrData != null)
  1630. {
  1631. translateCurrName = translateCurrData.Remark;
  1632. translateCurrCode = translateCurrData.Name;
  1633. }
  1634. #endregion
  1635. _detail.PriceNameContent = _ioa.InviterArea;
  1636. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1637. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1638. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1639. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1640. $@"备注:" + _ioa.Remark + "<br/>";
  1641. }
  1642. break;
  1643. case 82: //团组客户保险
  1644. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1645. if (customers != null)
  1646. {
  1647. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1648. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1649. }
  1650. break;
  1651. case 85: //机票预订
  1652. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1653. if (jpRes != null)
  1654. {
  1655. string FlightsDescription = jpRes.FlightsDescription;
  1656. string PriceDescription = jpRes.PriceDescription;
  1657. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1658. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1659. }
  1660. break;
  1661. case 98://其他款项
  1662. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1663. if (gdpRes != null)
  1664. {
  1665. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1666. _detail.PriceNameContent = gdpRes.PriceName;
  1667. }
  1668. break;
  1669. case 285://收款退还
  1670. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1671. if (refundAndOtherMoney != null)
  1672. {
  1673. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1674. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1675. }
  1676. break;
  1677. case 751://酒店早餐
  1678. break;
  1679. case 1015://超支费用
  1680. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1681. if (groupExtraCost != null)
  1682. {
  1683. _detail.PriceNameContent = groupExtraCost.PriceName;
  1684. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1685. }
  1686. break;
  1687. default:
  1688. break;
  1689. }
  1690. /*
  1691. * 申请人
  1692. */
  1693. string operatorName = " - ";
  1694. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1695. if (_opUser != null)
  1696. {
  1697. operatorName = _opUser.CnName;
  1698. }
  1699. _detail.OperatorName = operatorName;
  1700. /*
  1701. * 审核人
  1702. */
  1703. string auditOperatorName = "Unknown";
  1704. if (entity.AuditGMOperate == 0)
  1705. auditOperatorName = " - ";
  1706. else if (entity.AuditGMOperate == 4)
  1707. auditOperatorName = "自动审核";
  1708. else
  1709. {
  1710. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1711. if (_adUser != null)
  1712. {
  1713. auditOperatorName = _adUser.CnName;
  1714. }
  1715. }
  1716. _detail.AuditOperatorName = auditOperatorName;
  1717. /*
  1718. * 超预算比例
  1719. */
  1720. string overBudgetStr = "";
  1721. if (entity.ExceedBudget == -1)
  1722. overBudgetStr = sdPriceName.Name + "尚无预算";
  1723. else if (entity.ExceedBudget == 0)
  1724. {
  1725. if (entity.CTable == 76 || entity.CTable == 79)
  1726. {
  1727. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1728. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1729. }
  1730. else
  1731. {
  1732. overBudgetStr = "未超预算";
  1733. }
  1734. }
  1735. else
  1736. overBudgetStr = entity.ExceedBudget.ToString("P");
  1737. _detail.OverBudget = overBudgetStr;
  1738. /*
  1739. * 费用总计
  1740. */
  1741. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1742. {
  1743. CurrencyId = entity.PaymentCurrency,
  1744. CurrencyName = PaymentCurrency_WaitPay,
  1745. AmountPayable = entity.PayMoney,
  1746. ThisPayment = CurrPayStr,
  1747. BalancePayment = BalanceStr,
  1748. AuditedFunds = CurrPayStr
  1749. });
  1750. _detail.IsAuditGM = entity.IsAuditGM;
  1751. detailList.Add(_detail);
  1752. }
  1753. #endregion
  1754. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1755. /*
  1756. * 下方描述处理
  1757. */
  1758. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1759. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1760. if (ccpCurrencyPrice != null)
  1761. {
  1762. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1763. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1764. }
  1765. else
  1766. {
  1767. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1768. }
  1769. string amountPayableStr = string.Format(@"应付款总金额: ");
  1770. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1771. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1772. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1773. foreach (var item in nonDuplicat)
  1774. {
  1775. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1776. if (strs.Count > 0)
  1777. {
  1778. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1779. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1780. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1781. //单独处理此次付款金额
  1782. if (item.CurrencyId == 836) //人民币
  1783. {
  1784. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1785. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1786. }
  1787. else
  1788. {
  1789. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1790. }
  1791. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1792. //单独处理已审核费用
  1793. if (item.CurrencyId == 836) //人民币
  1794. {
  1795. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1796. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1797. }
  1798. else
  1799. {
  1800. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1801. }
  1802. }
  1803. }
  1804. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1805. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1806. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1807. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1808. var _view1 = new
  1809. {
  1810. PageFuncAuth = pageFunAuthView,
  1811. Data = _view
  1812. };
  1813. return Ok(JsonView(_view1));
  1814. }
  1815. catch (Exception ex)
  1816. {
  1817. return Ok(JsonView(false, ex.Message));
  1818. }
  1819. }
  1820. /// <summary>
  1821. /// 费用审核
  1822. /// 修改团组费用审核状态
  1823. /// </summary>
  1824. /// <param name="_dto">参数Json字符串</param>
  1825. /// <returns></returns>
  1826. [HttpPost]
  1827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1828. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1829. {
  1830. #region 参数验证
  1831. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1832. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1833. #endregion
  1834. #region 页面操作权限验证
  1835. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1836. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1837. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1838. #endregion
  1839. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1840. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1841. DateTime dtNow = DateTime.Now;
  1842. _groupRepository.BeginTran();
  1843. int rst = 0;
  1844. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1845. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1846. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1847. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1848. List<dynamic> msgDatas = new List<dynamic>();
  1849. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1850. foreach (var item in idList)
  1851. {
  1852. int CreditId = int.Parse(item);
  1853. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1854. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1855. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1856. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1857. .Where(s => s.Id == CreditId)
  1858. .ExecuteCommandAsync();
  1859. if (result < 1)
  1860. {
  1861. rst = -1;
  1862. _groupRepository.RollbackTran();
  1863. return Ok(JsonView(false, "操作失败并回滚!"));
  1864. }
  1865. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1866. if (creditData != null)
  1867. {
  1868. #region 应用通知配置
  1869. try
  1870. {
  1871. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1872. }
  1873. catch (Exception ex)
  1874. {
  1875. }
  1876. #endregion
  1877. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1878. string groupNameStr = string.Empty;
  1879. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1880. if (groupData != null) groupNameStr = groupData.TeamName;
  1881. string creditTypeStr = string.Empty;
  1882. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1883. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1884. string creditCurrency = string.Empty;
  1885. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1886. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1887. if (creditCurrency.Equals("CNY"))
  1888. {
  1889. creditData.DayRate = 1.0000M;
  1890. }
  1891. if (creditData.PayPercentage == 0.00M)
  1892. {
  1893. creditData.PayPercentage = 100M;
  1894. }
  1895. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1896. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1897. string msgContent = "";
  1898. if (creditCurrency.Equals("CNY"))
  1899. {
  1900. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1901. }
  1902. else
  1903. {
  1904. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1905. }
  1906. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1907. }
  1908. }
  1909. if (rst == 0)
  1910. {
  1911. _groupRepository.CommitTran();
  1912. foreach (var item in msgDatas)
  1913. {
  1914. //发送消息
  1915. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1916. }
  1917. #region 应用推送
  1918. try
  1919. {
  1920. foreach (var ccpId in dic_ccp_user.Keys)
  1921. {
  1922. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1923. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1924. }
  1925. }
  1926. catch (Exception)
  1927. {
  1928. }
  1929. #endregion
  1930. return Ok(JsonView(true, "操作成功!"));
  1931. }
  1932. return Ok(JsonView(false, "操作失败!"));
  1933. }
  1934. #endregion
  1935. #region 机票费用录入
  1936. /// <summary>
  1937. /// 机票录入当前登录人可操作团组
  1938. /// </summary>
  1939. /// <param name="dto"></param>
  1940. /// <returns></returns>
  1941. [HttpPost]
  1942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1943. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1944. {
  1945. try
  1946. {
  1947. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1948. if (groupData.Code != 0)
  1949. {
  1950. return Ok(JsonView(false, groupData.Msg));
  1951. }
  1952. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1953. }
  1954. catch (Exception ex)
  1955. {
  1956. return Ok(JsonView(false, "程序错误!"));
  1957. throw;
  1958. }
  1959. }
  1960. /// <summary>
  1961. /// 机票费用录入列表
  1962. /// </summary>
  1963. /// <param name="dto"></param>
  1964. /// <returns></returns>
  1965. [HttpPost]
  1966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1967. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1968. {
  1969. try
  1970. {
  1971. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1972. if (groupData.Code != 0)
  1973. {
  1974. return Ok(JsonView(false, groupData.Msg));
  1975. }
  1976. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1977. }
  1978. catch (Exception ex)
  1979. {
  1980. return Ok(JsonView(false, ex.Message));
  1981. throw;
  1982. }
  1983. }
  1984. /// <summary>
  1985. /// 根据id查询费用录入信息
  1986. /// </summary>
  1987. /// <param name="dto"></param>
  1988. /// <returns></returns>
  1989. [HttpPost]
  1990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1991. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1992. {
  1993. try
  1994. {
  1995. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1996. if (groupData.Code != 0)
  1997. {
  1998. return Ok(JsonView(false, groupData.Msg));
  1999. }
  2000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2001. }
  2002. catch (Exception ex)
  2003. {
  2004. return Ok(JsonView(false, "程序错误!"));
  2005. throw;
  2006. }
  2007. }
  2008. /// <summary>
  2009. /// 机票费用录入操作(Status:1.新增,2.修改)
  2010. /// </summary>
  2011. /// <param name="dto"></param>
  2012. /// <returns></returns>
  2013. [HttpPost]
  2014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2015. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2016. {
  2017. try
  2018. {
  2019. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2020. if (groupData.Code != 0)
  2021. {
  2022. return Ok(JsonView(false, groupData.Msg));
  2023. }
  2024. #region 应用推送
  2025. try
  2026. {
  2027. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2028. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2029. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2030. }
  2031. catch (Exception ex)
  2032. {
  2033. }
  2034. #endregion
  2035. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2036. }
  2037. catch (Exception ex)
  2038. {
  2039. return Ok(JsonView(false, "程序错误!"));
  2040. throw;
  2041. }
  2042. }
  2043. /// <summary>
  2044. /// 根据舱位类型查询接团客户名单信息
  2045. /// </summary>
  2046. /// <param name="dto"></param>
  2047. /// <returns></returns>
  2048. [HttpPost]
  2049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2050. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2051. {
  2052. try
  2053. {
  2054. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2055. if (crm_Groups.Count != 0)
  2056. {
  2057. List<dynamic> Customer = new List<dynamic>();
  2058. foreach (var item in crm_Groups)
  2059. {
  2060. var data = new
  2061. {
  2062. Id = item.Id,
  2063. Pinyin = item.Pinyin,
  2064. Name = item.LastName + item.FirstName
  2065. };
  2066. Customer.Add(data);
  2067. }
  2068. return Ok(JsonView(true, "查询成功!", Customer));
  2069. }
  2070. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2071. }
  2072. catch (Exception ex)
  2073. {
  2074. return Ok(JsonView(false, "程序错误!"));
  2075. throw;
  2076. }
  2077. }
  2078. /// <summary>
  2079. /// 根据团号获取客户信息
  2080. /// </summary>
  2081. /// <param name="dto"></param>
  2082. /// <returns></returns>
  2083. [HttpPost]
  2084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2085. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2086. {
  2087. var jw = JsonView(false);
  2088. if (dto.DIID < 1)
  2089. {
  2090. jw.Msg += "请输入正确的diid";
  2091. return Ok(jw);
  2092. }
  2093. var arr = getSimplClientList(dto.DIID);
  2094. jw = JsonView(true, "获取成功!", arr);
  2095. return Ok(jw);
  2096. }
  2097. private List<SimplClientInfo> getSimplClientList(int diId)
  2098. {
  2099. 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);
  2100. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2101. return arr;
  2102. }
  2103. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2104. {
  2105. string result = origin;
  2106. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2107. {
  2108. string[] temparr = origin.Split(',');
  2109. string fistrStr = temparr[0];
  2110. int count = temparr.Count();
  2111. int tempId;
  2112. bool success = int.TryParse(fistrStr, out tempId);
  2113. if (success)
  2114. {
  2115. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2116. if (tempInfo != null)
  2117. {
  2118. if (count > 1)
  2119. {
  2120. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2121. }
  2122. else
  2123. {
  2124. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2125. }
  2126. }
  2127. }
  2128. }
  2129. return result;
  2130. }
  2131. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2132. {
  2133. string result = origin;
  2134. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2135. {
  2136. string[] temparr = origin.Split(',');
  2137. result = "";
  2138. foreach (var item in temparr)
  2139. {
  2140. int tempId;
  2141. bool success = int.TryParse(item, out tempId);
  2142. if (success)
  2143. {
  2144. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2145. if (tempInfo != null)
  2146. {
  2147. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2148. }
  2149. }
  2150. }
  2151. }
  2152. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2153. return result;
  2154. }
  2155. /// <summary>
  2156. /// 机票费用录入,删除
  2157. /// </summary>
  2158. /// <param name="dto"></param>
  2159. /// <returns></returns>
  2160. [HttpPost]
  2161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2162. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2163. {
  2164. try
  2165. {
  2166. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2167. if (res)
  2168. {
  2169. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2170. {
  2171. IsDel = 1,
  2172. DeleteUserId = dto.DeleteUserId,
  2173. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2174. }).ExecuteCommandAsync();
  2175. return Ok(JsonView(true, "删除成功!"));
  2176. }
  2177. return Ok(JsonView(false, "删除失败!"));
  2178. }
  2179. catch (Exception ex)
  2180. {
  2181. return Ok(JsonView(false, "程序错误!"));
  2182. throw;
  2183. }
  2184. }
  2185. /// <summary>
  2186. /// 导出机票录入报表
  2187. /// </summary>
  2188. /// <param name="dto"></param>
  2189. /// <returns></returns>
  2190. [HttpPost]
  2191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2192. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2193. {
  2194. try
  2195. {
  2196. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2197. if (groupData.Code != 0)
  2198. {
  2199. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2200. }
  2201. else
  2202. {
  2203. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2204. if (AirTicketReservations.Count != 0)
  2205. {
  2206. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2207. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2208. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2209. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2210. WorkbookDesigner designer = new WorkbookDesigner();
  2211. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2212. decimal countCost = 0;
  2213. foreach (var item in AirTicketReservations)
  2214. {
  2215. #region 处理客人姓名
  2216. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2217. item.ClientName = clientNames;
  2218. #endregion
  2219. if (item.BankType == "其他")
  2220. {
  2221. item.BankNo = "--";
  2222. }
  2223. else
  2224. {
  2225. if (!string.IsNullOrEmpty(item.BankType))
  2226. {
  2227. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2228. }
  2229. }
  2230. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2231. item.Price = System.Decimal.Round(item.Price, 2);
  2232. countCost += Convert.ToDecimal(item.Price);
  2233. }
  2234. designer.SetDataSource("Export", AirTicketReservations);
  2235. designer.SetDataSource("ExportDiCode", diCode);
  2236. designer.SetDataSource("ExportDiName", diName);
  2237. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2238. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2239. designer.Process();
  2240. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2241. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2242. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2243. return Ok(JsonView(true, "成功", url = rst));
  2244. }
  2245. else
  2246. {
  2247. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2248. }
  2249. }
  2250. }
  2251. catch (Exception ex)
  2252. {
  2253. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2254. throw;
  2255. }
  2256. }
  2257. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2258. /// <summary>
  2259. /// 行程单导出
  2260. /// </summary>
  2261. /// <param name="dto"></param>
  2262. /// <returns></returns>
  2263. [HttpPost]
  2264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2265. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2266. {
  2267. try
  2268. {
  2269. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2270. if (groupData.Code != 0)
  2271. {
  2272. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2273. }
  2274. else
  2275. {
  2276. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2277. if (dto.Language == "CN")
  2278. {
  2279. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2280. DocumentBuilder builder = new DocumentBuilder(doc);
  2281. int tableIndex = 0;//表格索引
  2282. //得到文档中的第一个表格
  2283. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2284. foreach (var item in _AirTicketReservations)
  2285. {
  2286. #region 处理固定数据
  2287. string[] FlightsCode = item.FlightsCode.Split('/');
  2288. if (FlightsCode.Length != 0)
  2289. {
  2290. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2291. if (_AirCompany != null)
  2292. {
  2293. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2294. }
  2295. else
  2296. {
  2297. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2298. }
  2299. }
  2300. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2301. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2302. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2303. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2304. string name = "";
  2305. foreach (string clientName in nameArray)
  2306. {
  2307. if (!name.Contains(clientName))
  2308. {
  2309. name += clientName + ",";
  2310. }
  2311. }
  2312. if (!string.IsNullOrWhiteSpace(name))
  2313. {
  2314. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2315. }
  2316. else
  2317. {
  2318. table.Range.Bookmarks["ClientName"].Text = "--";
  2319. }
  2320. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2321. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2322. table.Range.Bookmarks["JointTicket"].Text = "--";
  2323. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2324. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2325. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2326. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2327. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2328. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2329. #endregion
  2330. #region 循环数据处理
  2331. List<AirInfo> airs = new List<AirInfo>();
  2332. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2333. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2334. for (int i = 0; i < FlightsCode.Length; i++)
  2335. {
  2336. AirInfo air = new AirInfo();
  2337. string[] tempstr = DayArray[i]
  2338. .Replace("\r\n", string.Empty)
  2339. .Replace("\\r\\n", string.Empty)
  2340. .TrimStart().TrimEnd()
  2341. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2342. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2343. string starCity = "";
  2344. if (star_Three != null)
  2345. {
  2346. starCity = star_Three.AirPort;
  2347. }
  2348. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2349. string EndCity = "";
  2350. if (End_Three != null)
  2351. {
  2352. EndCity = End_Three.AirPort;
  2353. }
  2354. air.Destination = starCity + "/" + EndCity;
  2355. air.Flight = FlightsCode[i];
  2356. air.SeatingClass = item.CTypeName;
  2357. string dateTime = tempstr[2];
  2358. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2359. air.FlightDate = DateTemp;
  2360. air.DepartureTime = tempstr[5];
  2361. air.LandingTime = tempstr[6];
  2362. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2363. air.TicketStatus = "--";
  2364. air.Luggage = "--";
  2365. air.DepartureTerminal = "--";
  2366. air.LandingTerminal = "--";
  2367. airs.Add(air);
  2368. }
  2369. int row = 13;
  2370. for (int i = 0; i < airs.Count; i++)
  2371. {
  2372. if (airs.Count > 2)
  2373. {
  2374. for (int j = 0; j < airs.Count - 2; j++)
  2375. {
  2376. var CopyRow = table.Rows[12].Clone(true);
  2377. table.Rows.Add(CopyRow);
  2378. }
  2379. }
  2380. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2381. int index = 0;
  2382. foreach (PropertyInfo property in properties)
  2383. {
  2384. string value = property.GetValue(airs[i]).ToString();
  2385. Cell ishcel0 = table.Rows[row].Cells[index];
  2386. Paragraph p = new Paragraph(doc);
  2387. string s = value;
  2388. p.AppendChild(new Run(doc, s));
  2389. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2390. ishcel0.AppendChild(p);
  2391. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2392. index++;
  2393. }
  2394. row++;
  2395. }
  2396. #endregion
  2397. Paragraph lastParagraph = new Paragraph(doc);
  2398. //第一个表格末尾加段落
  2399. table.ParentNode.InsertAfter(lastParagraph, table);
  2400. //复制第一个表格
  2401. Table cloneTable = (Table)table.Clone(true);
  2402. //在文档末尾段落后面加入复制的表格
  2403. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2404. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2405. {
  2406. int rownewsIndex = 13;
  2407. for (int i = 0; i < 2; i++)
  2408. {
  2409. var CopyRow = table.Rows[12].Clone(true);
  2410. table.Rows.RemoveAt(13);
  2411. table.Rows.Add(CopyRow);
  2412. rownewsIndex++;
  2413. }
  2414. }
  2415. else
  2416. {
  2417. table.Rows.RemoveAt(12);
  2418. }
  2419. cloneTable.Rows.RemoveAt(12);
  2420. }
  2421. if (_AirTicketReservations.Count != 0)
  2422. {
  2423. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2424. if (FlightsCode.Length != 0)
  2425. {
  2426. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2427. if (_AirCompany != null)
  2428. {
  2429. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2430. }
  2431. else
  2432. {
  2433. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2434. }
  2435. }
  2436. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2437. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2438. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2439. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2440. string name = "";
  2441. foreach (string clientName in nameArray)
  2442. {
  2443. if (!name.Contains(clientName))
  2444. {
  2445. name += clientName + ",";
  2446. }
  2447. }
  2448. if (!string.IsNullOrWhiteSpace(name))
  2449. {
  2450. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2451. }
  2452. else
  2453. {
  2454. table.Range.Bookmarks["ClientName"].Text = "--";
  2455. }
  2456. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2457. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2458. table.Range.Bookmarks["JointTicket"].Text = "--";
  2459. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2460. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2461. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2462. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2463. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2464. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2465. }
  2466. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2467. //保存合并后的文档
  2468. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2469. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2470. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2471. return Ok(JsonView(true, "成功!", rst));
  2472. }
  2473. else
  2474. {
  2475. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2476. DocumentBuilder builder = new DocumentBuilder(doc);
  2477. int tableIndex = 0;//表格索引
  2478. //得到文档中的第一个表格
  2479. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2480. List<string> texts = new List<string>();
  2481. foreach (var item in _AirTicketReservations)
  2482. {
  2483. string[] FlightsCode = item.FlightsCode.Split('/');
  2484. if (FlightsCode.Length != 0)
  2485. {
  2486. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2487. if (_AirCompany != null)
  2488. {
  2489. if (!transDic.ContainsKey(_AirCompany.CnName))
  2490. {
  2491. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2492. }
  2493. }
  2494. else
  2495. {
  2496. if (!transDic.ContainsKey("--"))
  2497. {
  2498. transDic.Add("--", "--");
  2499. }
  2500. }
  2501. }
  2502. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2503. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2504. string name = "";
  2505. foreach (string clientName in nameArray)
  2506. {
  2507. name += clientName + ",";
  2508. }
  2509. if (!texts.Contains(name))
  2510. {
  2511. texts.Add(name);
  2512. }
  2513. List<AirInfo> airs = new List<AirInfo>();
  2514. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2515. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2516. for (int i = 0; i < FlightsCode.Length; i++)
  2517. {
  2518. AirInfo air = new AirInfo();
  2519. string[] tempstr = DayArray[i]
  2520. .Replace("\r\n", string.Empty)
  2521. .Replace("\\r\\n", string.Empty)
  2522. .TrimStart().TrimEnd()
  2523. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2524. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2525. if (star_Three != null)
  2526. {
  2527. if (!transDic.ContainsKey(star_Three.AirPort))
  2528. {
  2529. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2530. }
  2531. }
  2532. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2533. if (End_Three != null)
  2534. {
  2535. if (!transDic.ContainsKey(End_Three.AirPort))
  2536. {
  2537. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2538. }
  2539. }
  2540. if (!texts.Contains(item.CTypeName))
  2541. {
  2542. texts.Add(item.CTypeName);
  2543. }
  2544. }
  2545. }
  2546. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2547. if (transData.Count > 0)
  2548. {
  2549. foreach (TranslateResult item in transData)
  2550. {
  2551. if (!transDic.ContainsKey(item.Query))
  2552. {
  2553. transDic.Add(item.Query, item.Translation);
  2554. }
  2555. }
  2556. }
  2557. foreach (var item in _AirTicketReservations)
  2558. {
  2559. #region 处理固定数据
  2560. string[] FlightsCode = item.FlightsCode.Split('/');
  2561. if (FlightsCode.Length != 0)
  2562. {
  2563. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2564. if (_AirCompany != null)
  2565. {
  2566. string str = "--";
  2567. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2568. if (!string.IsNullOrEmpty(translateResult))
  2569. {
  2570. str = translateResult;
  2571. str = _airTicketResRep.Processing(str);
  2572. }
  2573. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2574. }
  2575. else
  2576. {
  2577. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2578. }
  2579. }
  2580. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2581. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2582. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2583. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2584. string names = "";
  2585. foreach (string clientName in nameArray)
  2586. {
  2587. names += clientName + ",";
  2588. }
  2589. if (!string.IsNullOrWhiteSpace(names))
  2590. {
  2591. string str = "--";
  2592. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2593. if (!string.IsNullOrEmpty(translateResult))
  2594. {
  2595. str = translateResult;
  2596. str = _airTicketResRep.Processing(str);
  2597. }
  2598. table.Range.Bookmarks["ClientName"].Text = str;
  2599. }
  2600. else
  2601. {
  2602. table.Range.Bookmarks["ClientName"].Text = "--";
  2603. }
  2604. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2605. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2606. table.Range.Bookmarks["JointTicket"].Text = "--";
  2607. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2608. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2609. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2610. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2611. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2612. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2613. #endregion
  2614. #region 循环数据处理
  2615. List<AirInfo> airs = new List<AirInfo>();
  2616. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2617. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2618. for (int i = 0; i < FlightsCode.Length; i++)
  2619. {
  2620. AirInfo air = new AirInfo();
  2621. string[] tempstr = DayArray[i]
  2622. .Replace("\r\n", string.Empty)
  2623. .Replace("\\r\\n", string.Empty)
  2624. .TrimStart().TrimEnd()
  2625. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2626. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2627. string starCity = "";
  2628. if (star_Three != null)
  2629. {
  2630. string str2 = "--";
  2631. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2632. if (!string.IsNullOrEmpty(translateResult2))
  2633. {
  2634. str2 = translateResult2;
  2635. str2 = _airTicketResRep.Processing(str2);
  2636. }
  2637. starCity = str2;
  2638. }
  2639. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2640. string EndCity = "";
  2641. if (End_Three != null)
  2642. {
  2643. string str1 = "--";
  2644. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2645. if (!string.IsNullOrEmpty(translateResult1))
  2646. {
  2647. str1 = translateResult1;
  2648. str1 = _airTicketResRep.Processing(str1);
  2649. }
  2650. EndCity = str1;
  2651. }
  2652. air.Destination = starCity + "/" + EndCity;
  2653. air.Flight = FlightsCode[i];
  2654. string str = "--";
  2655. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2656. if (!string.IsNullOrEmpty(translateResult))
  2657. {
  2658. str = translateResult;
  2659. str = _airTicketResRep.Processing(str);
  2660. }
  2661. air.SeatingClass = str;
  2662. string dateTime = tempstr[2];
  2663. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2664. air.FlightDate = DateTemp;
  2665. air.DepartureTime = tempstr[5];
  2666. air.LandingTime = tempstr[6];
  2667. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2668. air.TicketStatus = "--";
  2669. air.Luggage = "--";
  2670. air.DepartureTerminal = "--";
  2671. air.LandingTerminal = "--";
  2672. airs.Add(air);
  2673. }
  2674. int row = 13;
  2675. for (int i = 0; i < airs.Count; i++)
  2676. {
  2677. if (airs.Count > 2)
  2678. {
  2679. for (int j = 0; j < airs.Count - 2; j++)
  2680. {
  2681. var CopyRow = table.Rows[12].Clone(true);
  2682. table.Rows.Add(CopyRow);
  2683. }
  2684. }
  2685. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2686. int index = 0;
  2687. foreach (PropertyInfo property in properties)
  2688. {
  2689. string value = property.GetValue(airs[i]).ToString();
  2690. Cell ishcel0 = table.Rows[row].Cells[index];
  2691. Paragraph p = new Paragraph(doc);
  2692. string s = value;
  2693. p.AppendChild(new Run(doc, s));
  2694. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2695. ishcel0.AppendChild(p);
  2696. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2697. //ishcel0.CellFormat.VerticalAlignment=
  2698. index++;
  2699. }
  2700. row++;
  2701. }
  2702. #endregion
  2703. Paragraph lastParagraph = new Paragraph(doc);
  2704. //第一个表格末尾加段落
  2705. table.ParentNode.InsertAfter(lastParagraph, table);
  2706. //复制第一个表格
  2707. Table cloneTable = (Table)table.Clone(true);
  2708. //在文档末尾段落后面加入复制的表格
  2709. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2710. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2711. {
  2712. int rownewsIndex = 13;
  2713. for (int i = 0; i < 2; i++)
  2714. {
  2715. var CopyRow = table.Rows[12].Clone(true);
  2716. table.Rows.RemoveAt(13);
  2717. table.Rows.Add(CopyRow);
  2718. rownewsIndex++;
  2719. }
  2720. }
  2721. else
  2722. {
  2723. table.Rows.RemoveAt(12);
  2724. }
  2725. cloneTable.Rows.RemoveAt(12);
  2726. }
  2727. if (_AirTicketReservations.Count != 0)
  2728. {
  2729. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2730. if (FlightsCode.Length != 0)
  2731. {
  2732. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2733. if (_AirCompany != null)
  2734. {
  2735. string str = "--";
  2736. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2737. if (!string.IsNullOrEmpty(translateResult))
  2738. {
  2739. str = translateResult;
  2740. str = _airTicketResRep.Processing(str);
  2741. }
  2742. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2743. }
  2744. else
  2745. {
  2746. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2747. }
  2748. }
  2749. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2750. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2751. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2752. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2753. string names = "";
  2754. foreach (string clientName in nameArray)
  2755. {
  2756. names += clientName + ",";
  2757. }
  2758. if (!string.IsNullOrWhiteSpace(names))
  2759. {
  2760. string str = "--";
  2761. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2762. if (!string.IsNullOrEmpty(translateResult))
  2763. {
  2764. str = translateResult;
  2765. str = _airTicketResRep.Processing(str);
  2766. }
  2767. table.Range.Bookmarks["ClientName"].Text = str;
  2768. }
  2769. else
  2770. {
  2771. table.Range.Bookmarks["ClientName"].Text = "--";
  2772. }
  2773. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2774. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2775. table.Range.Bookmarks["JointTicket"].Text = "--";
  2776. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2777. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2778. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2779. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2780. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2781. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2782. }
  2783. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2784. //保存合并后的文档
  2785. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2786. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2787. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2788. return Ok(JsonView(true, "成功!", rst));
  2789. }
  2790. }
  2791. }
  2792. catch (Exception ex)
  2793. {
  2794. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2795. throw;
  2796. }
  2797. }
  2798. #endregion
  2799. #region 团组增减款项 --> 其他款项
  2800. /// <summary>
  2801. /// 团组增减款项下拉框绑定
  2802. /// </summary>
  2803. /// <param name="dto"></param>
  2804. /// <returns></returns>
  2805. [HttpPost]
  2806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2807. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2808. {
  2809. #region 参数验证
  2810. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2811. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2812. #endregion
  2813. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2814. }
  2815. /// <summary>
  2816. /// 根据团组Id查询团组增减款项
  2817. /// </summary>
  2818. /// <param name="dto"></param>
  2819. /// <returns></returns>
  2820. [HttpPost]
  2821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2822. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2823. {
  2824. #region 参数验证
  2825. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2826. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2827. #endregion
  2828. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2829. }
  2830. /// <summary>
  2831. /// 团组增减款项操作(Status:1.新增,2.修改)
  2832. /// </summary>
  2833. /// <param name="dto"></param>
  2834. /// <returns></returns>
  2835. [HttpPost]
  2836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2837. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2838. {
  2839. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2840. if (groupData.Code != 200)
  2841. {
  2842. return Ok(JsonView(false, groupData.Msg));
  2843. }
  2844. #region 应用推送
  2845. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2846. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2847. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2848. #endregion
  2849. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2850. }
  2851. /// <summary>
  2852. /// 团组增减款项操作 删除
  2853. /// </summary>
  2854. /// <param name="dto"></param>
  2855. /// <returns></returns>
  2856. [HttpPost]
  2857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2858. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2859. {
  2860. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2861. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2862. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2863. if (res.Code == 0)
  2864. {
  2865. return Ok(JsonView(true, "删除成功!"));
  2866. }
  2867. return Ok(JsonView(false, "删除失败!"));
  2868. }
  2869. /// <summary>
  2870. /// 根据团组增减款项Id查询
  2871. /// </summary>
  2872. /// <param name="dto"></param>
  2873. /// <returns></returns>
  2874. [HttpPost]
  2875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2876. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2877. {
  2878. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2879. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2880. }
  2881. /// <summary>
  2882. /// 查询供应商名称
  2883. /// </summary>
  2884. /// <param name="dto"></param>
  2885. /// <returns></returns>
  2886. [HttpPost]
  2887. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2888. {
  2889. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2890. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2891. ?? new List<Grp_DecreasePayments>();
  2892. dbResult = dbResult.Distinct(new
  2893. ProductComparer()).ToList();
  2894. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2895. {
  2896. x.Id,
  2897. x.SupplierAddress,
  2898. x.SupplierArea,
  2899. x.SupplierContact,
  2900. x.SupplierContactNumber,
  2901. x.SupplierEmail,
  2902. x.SupplierName,
  2903. x.SupplierSocialAccount,
  2904. x.SupplierTypeId,
  2905. }).ToList());
  2906. return Ok(jw);
  2907. }
  2908. #endregion
  2909. #region 文件上传、删除
  2910. /// <summary>
  2911. /// region 文件上传 可以带参数
  2912. /// </summary>
  2913. /// <param name="file"></param>
  2914. /// <returns></returns>
  2915. [HttpPost]
  2916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2917. public async Task<IActionResult> UploadProject(IFormFile file)
  2918. {
  2919. try
  2920. {
  2921. var TypeName = Request.Headers["TypeName"].ToString();
  2922. if (file != null)
  2923. {
  2924. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2925. //文件名称
  2926. string projectFileName = file.FileName;
  2927. //上传的文件的路径
  2928. string filePath = "";
  2929. if (TypeName == "A")//A代表团组增减款项
  2930. {
  2931. if (!Directory.Exists(fileDir))
  2932. {
  2933. Directory.CreateDirectory(fileDir);
  2934. }
  2935. //上传的文件的路径
  2936. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2937. }
  2938. else if (TypeName == "B")//B代表商邀相关文件
  2939. {
  2940. if (!Directory.Exists(fileDir))
  2941. {
  2942. Directory.CreateDirectory(fileDir);
  2943. }
  2944. //上传的文件的路径
  2945. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2946. }
  2947. using (FileStream fs = System.IO.File.Create(filePath))
  2948. {
  2949. file.CopyTo(fs);
  2950. fs.Flush();
  2951. }
  2952. return Ok(JsonView(true, "上传成功!", projectFileName));
  2953. }
  2954. else
  2955. {
  2956. return Ok(JsonView(false, "上传失败!"));
  2957. }
  2958. }
  2959. catch (Exception ex)
  2960. {
  2961. return Ok(JsonView(false, "程序错误!"));
  2962. throw;
  2963. }
  2964. }
  2965. /// <summary>
  2966. /// 删除指定文件
  2967. /// </summary>
  2968. /// <param name="dto"></param>
  2969. /// <returns></returns>
  2970. [HttpPost]
  2971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2972. public async Task<IActionResult> DelFile(DelFileDto dto)
  2973. {
  2974. try
  2975. {
  2976. var TypeName = Request.Headers["TypeName"].ToString();
  2977. string filePath = "";
  2978. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2979. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2980. int id = 0;
  2981. if (TypeName == "A")
  2982. {
  2983. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2984. // 删除该文件
  2985. System.IO.File.Delete(filePath);
  2986. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2987. }
  2988. else if (TypeName == "B")
  2989. {
  2990. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2991. // 删除该文件
  2992. System.IO.File.Delete(filePath);
  2993. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2994. }
  2995. if (id != 0)
  2996. {
  2997. return Ok(JsonView(true, "成功!"));
  2998. }
  2999. else
  3000. {
  3001. return Ok(JsonView(false, "失败!"));
  3002. }
  3003. }
  3004. catch (Exception ex)
  3005. {
  3006. return Ok(JsonView(false, "程序错误!"));
  3007. throw;
  3008. }
  3009. }
  3010. #endregion
  3011. #region 商邀费用录入
  3012. /// <summary>
  3013. /// 根据团组Id查询商邀费用列表
  3014. /// </summary>
  3015. /// <param name="dto"></param>
  3016. /// <returns></returns>
  3017. [HttpPost]
  3018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3019. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3020. {
  3021. try
  3022. {
  3023. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3024. if (groupData.Code != 0)
  3025. {
  3026. return Ok(JsonView(false, groupData.Msg));
  3027. }
  3028. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3029. }
  3030. catch (Exception ex)
  3031. {
  3032. return Ok(JsonView(false, "程序错误!"));
  3033. throw;
  3034. }
  3035. }
  3036. //
  3037. /// <summary>
  3038. /// 商邀费用 Info Page 基础数据源
  3039. /// </summary>
  3040. /// <param name="dto"></param>
  3041. /// <returns></returns>
  3042. [HttpPost]
  3043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3044. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3045. {
  3046. try
  3047. {
  3048. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3049. if (groupData.Code != 0)
  3050. {
  3051. return Ok(JsonView(false, groupData.Msg));
  3052. }
  3053. return Ok(JsonView(true, "操作成功", groupData.Data));
  3054. }
  3055. catch (Exception ex)
  3056. {
  3057. return Ok(JsonView(false, ex.Message));
  3058. throw;
  3059. }
  3060. }
  3061. /// <summary>
  3062. /// 根据商邀费用ID查询C表和商邀费用数据
  3063. /// </summary>
  3064. /// <param name="dto"></param>
  3065. /// <returns></returns>
  3066. [HttpPost]
  3067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3068. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3069. {
  3070. try
  3071. {
  3072. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3073. if (groupData.Code != 0)
  3074. {
  3075. return Ok(JsonView(false, groupData.Msg));
  3076. }
  3077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3078. }
  3079. catch (Exception ex)
  3080. {
  3081. return Ok(JsonView(false, ex.Message));
  3082. throw;
  3083. }
  3084. }
  3085. /// <summary>
  3086. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3087. /// </summary>
  3088. /// <param name="dto"></param>
  3089. /// <returns></returns>
  3090. [HttpPost]
  3091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3092. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3093. {
  3094. try
  3095. {
  3096. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3097. if (groupData.Code != 0)
  3098. {
  3099. return Ok(JsonView(false, groupData.Msg));
  3100. }
  3101. #region 应用推送
  3102. try
  3103. {
  3104. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3105. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3106. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3107. }
  3108. catch (Exception ex)
  3109. {
  3110. }
  3111. #endregion
  3112. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3113. }
  3114. catch (Exception ex)
  3115. {
  3116. return Ok(JsonView(false, "程序错误!"));
  3117. throw;
  3118. }
  3119. }
  3120. /// <summary>
  3121. /// 商邀删除
  3122. /// </summary>
  3123. /// <param name="dto"></param>
  3124. /// <returns></returns>
  3125. [HttpPost]
  3126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3127. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3128. {
  3129. try
  3130. {
  3131. _sqlSugar.BeginTran();
  3132. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3133. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3134. {
  3135. IsDel = 1,
  3136. DeleteUserId = dto.DeleteUserId,
  3137. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3138. })
  3139. .Where(it => it.Id == dto.Id)
  3140. .ExecuteCommand();
  3141. if (res1 > 0)
  3142. {
  3143. int _diId = 0;
  3144. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3145. if (_ioaInfo != null)
  3146. {
  3147. _diId = _ioaInfo.DiId;
  3148. }
  3149. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3150. .SetColumns(a => new Grp_CreditCardPayment()
  3151. {
  3152. IsDel = 1,
  3153. DeleteUserId = dto.DeleteUserId,
  3154. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3155. })
  3156. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3157. .ExecuteCommand();
  3158. if (res2 > 0)
  3159. {
  3160. _sqlSugar.CommitTran();
  3161. return Ok(JsonView(true, "删除成功!"));
  3162. }
  3163. }
  3164. _sqlSugar.RollbackTran();
  3165. return Ok(JsonView(false, "删除失败"));
  3166. }
  3167. catch (Exception ex)
  3168. {
  3169. _sqlSugar.RollbackTran();
  3170. return Ok(JsonView(false, ex.Message));
  3171. }
  3172. }
  3173. /// <summary>
  3174. /// 团组模块文件上传
  3175. /// </summary>
  3176. /// <param name="dto"></param>
  3177. /// <returns></returns>
  3178. [HttpPost]
  3179. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3180. {
  3181. var jw = JsonView(false);
  3182. long M = 1024 * 1024;
  3183. if (dto.Files == null || dto.Files.Count == 0)
  3184. {
  3185. jw.Msg = "无文件信息!";
  3186. return Ok(jw);
  3187. }
  3188. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3189. {
  3190. jw.Msg = "文件大小超过20M!";
  3191. return Ok(jw);
  3192. }
  3193. //var nameSp = dto.File.FileName.Split(".");
  3194. //if (nameSp.Length < 2)
  3195. //{
  3196. // jw.Msg = "拓展名称有误!";
  3197. // return Ok(jw);
  3198. //}
  3199. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3200. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3201. //{
  3202. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3203. // return Ok(jw);
  3204. //}
  3205. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3206. if (Ctable == null)
  3207. {
  3208. jw.Msg = "Ctable指向有误!";
  3209. return Ok(jw);
  3210. }
  3211. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3212. if (groupInfo == null)
  3213. {
  3214. jw.Msg = "团组信息不存在!";
  3215. return Ok(jw);
  3216. }
  3217. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3218. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3219. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3220. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3221. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3222. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3223. try
  3224. {
  3225. if (!Directory.Exists(fileBase))
  3226. {
  3227. Directory.CreateDirectory(fileBase);
  3228. }
  3229. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3230. foreach (var fileStream in dto.Files)
  3231. {
  3232. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3233. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3234. {
  3235. Cid = dto.Cid,
  3236. CreateTime = DateTime.Now,
  3237. CreateUserId = dto.Userid,
  3238. Ctable = dto.Ctable,
  3239. Diid = dto.Diid,
  3240. IsDel = 0,
  3241. FilePath = saveFilePath,
  3242. FileName = fileStream.FileName
  3243. };
  3244. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3245. {
  3246. fileStream.CopyTo(fs);
  3247. fs.Flush();
  3248. }
  3249. saveArr.Add(file);
  3250. }
  3251. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3252. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3253. jw = JsonView(true, "保存成功!", new
  3254. {
  3255. count = addResult,
  3256. filesName = saveArr.Select(x => x.FileName)
  3257. }) ;
  3258. }
  3259. catch (Exception ex)
  3260. {
  3261. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3262. {
  3263. count = 0,
  3264. filesName = new string[0],
  3265. }) ;
  3266. }
  3267. return Ok(jw);
  3268. }
  3269. /// <summary>
  3270. /// 查询各模块已保存文件
  3271. /// </summary>
  3272. /// <param name="dto"></param>
  3273. /// <returns></returns>
  3274. [HttpPost]
  3275. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3276. {
  3277. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3278. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3279. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3280. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3281. {
  3282. expression = Expressionable.Create<Grp_GroupModelFile>()
  3283. .And(x=>visaIds.Contains(x.CreateUserId));
  3284. }
  3285. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3286. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3287. .Where(expression.ToExpression())
  3288. .ToList();
  3289. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3290. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3291. {
  3292. x.FileName,
  3293. x.Id,
  3294. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3295. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3296. })));
  3297. }
  3298. /// <summary>
  3299. /// 下载该团组下的所有文件
  3300. /// </summary>
  3301. /// <param name="dto"></param>
  3302. /// <returns></returns>
  3303. [HttpPost]
  3304. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3305. {
  3306. var jw = JsonView(false);
  3307. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3308. if (groupInfo == null)
  3309. {
  3310. jw.Msg = "团组信息不存在!";
  3311. return Ok(jw);
  3312. }
  3313. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3314. var isModule = Convert.ToBoolean(dto.isModule);
  3315. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3316. IOOperatorHelper io = new IOOperatorHelper();
  3317. if (isModule)
  3318. {
  3319. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3320. foreach (var moduleArr in moduleGroup)
  3321. {
  3322. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3323. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3324. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3325. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3326. foreach (var item in moduleArr)
  3327. {
  3328. if (System.IO.File.Exists(item.FilePath))
  3329. {
  3330. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3331. {
  3332. byte[] bytes = new byte[fileStream.Length];
  3333. fileStream.Read(bytes, 0, bytes.Length);
  3334. fileStream.Close();
  3335. Stream stream = new MemoryStream(bytes);
  3336. chiZips.Add(item.FileName, stream);
  3337. }
  3338. }
  3339. }
  3340. if (chiZips.Count > 0)
  3341. {
  3342. var byts = io.ConvertZipStream(chiZips);
  3343. Stream stream = new MemoryStream(byts);
  3344. Zips.Add(key.Name+"_.zip", stream);
  3345. }
  3346. }
  3347. }
  3348. else
  3349. {
  3350. foreach (var item in dbQuery)
  3351. {
  3352. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3353. {
  3354. byte[] bytes = new byte[fileStream.Length];
  3355. fileStream.Read(bytes, 0, bytes.Length);
  3356. fileStream.Close();
  3357. Stream stream = new MemoryStream(bytes);
  3358. while (Zips.Keys.Contains(item.FileName))
  3359. {
  3360. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3361. }
  3362. Zips.Add(item.FileName, stream);
  3363. }
  3364. }
  3365. }
  3366. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3367. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3368. if (Zips.Count > 0)
  3369. {
  3370. var byts = io.ConvertZipStream(Zips);
  3371. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3372. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3373. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3374. }
  3375. else
  3376. {
  3377. jw.Msg = "暂无生成文件!";
  3378. }
  3379. return Ok(jw);
  3380. }
  3381. /// <summary>
  3382. /// 下载该团组下此模块的所有文件
  3383. /// </summary>
  3384. /// <param name="dto"></param>
  3385. /// <returns></returns>
  3386. [HttpPost]
  3387. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3388. {
  3389. var jw = JsonView(false);
  3390. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3391. if (groupInfo == null)
  3392. {
  3393. jw.Msg = "团组信息不存在!";
  3394. return Ok(jw);
  3395. }
  3396. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3397. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3398. && x.IsDel == 0);
  3399. if (key == null)
  3400. {
  3401. jw.Msg = "Ctable指向错误!";
  3402. return Ok(jw);
  3403. }
  3404. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3405. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3406. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3407. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3408. IOOperatorHelper io = new IOOperatorHelper();
  3409. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3410. foreach (var item in dbQuery)
  3411. {
  3412. if (System.IO.File.Exists(item.FilePath))
  3413. {
  3414. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3415. {
  3416. byte[] bytes = new byte[fileStream.Length];
  3417. fileStream.Read(bytes, 0, bytes.Length);
  3418. fileStream.Close();
  3419. Stream stream = new MemoryStream(bytes);
  3420. while (Zips.Keys.Contains(item.FileName))
  3421. {
  3422. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3423. }
  3424. Zips.Add(item.FileName, stream);
  3425. }
  3426. }
  3427. }
  3428. if (Zips.Count > 0)
  3429. {
  3430. var byts = io.ConvertZipStream(Zips);
  3431. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3432. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3433. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3434. }
  3435. else
  3436. {
  3437. jw.Msg = "暂无生成文件!";
  3438. }
  3439. return Ok(jw);
  3440. }
  3441. /// <summary>
  3442. /// 删除该团组下的指定文件
  3443. /// </summary>
  3444. /// <param name="dto"></param>
  3445. /// <returns></returns>
  3446. [HttpPost]
  3447. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3448. {
  3449. var jw = JsonView(false);
  3450. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3451. if (sing == null)
  3452. {
  3453. jw.Msg = "暂无";
  3454. return Ok(jw);
  3455. }
  3456. if (System.IO.File.Exists(sing.FilePath))
  3457. {
  3458. try
  3459. {
  3460. System.IO.File.Delete(sing.FilePath);
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. jw.Msg = "删除失败!" + ex.Message;
  3465. return Ok(jw);
  3466. }
  3467. }
  3468. sing.IsDel = 1;
  3469. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3470. sing.DeleteUserId = dto.UserId;
  3471. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3472. jw = JsonView(true, "删除成功!");
  3473. return Ok(jw);
  3474. }
  3475. #endregion
  3476. #region 团组英文资料
  3477. /// <summary>
  3478. /// 查询团组英文所有资料
  3479. /// </summary>
  3480. /// <param name="dto"></param>
  3481. /// <returns></returns>
  3482. [HttpPost]
  3483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3484. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3485. {
  3486. try
  3487. {
  3488. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3489. if (groupData.Code != 0)
  3490. {
  3491. return Ok(JsonView(false, groupData.Msg));
  3492. }
  3493. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3494. }
  3495. catch (Exception ex)
  3496. {
  3497. return Ok(JsonView(false, "程序错误!"));
  3498. throw;
  3499. }
  3500. }
  3501. /// <summary>
  3502. /// 团组英文资料操作(Status:1.新增,2.修改)
  3503. /// </summary>
  3504. /// <param name="dto"></param>
  3505. /// <returns></returns>
  3506. [HttpPost]
  3507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3508. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3509. {
  3510. try
  3511. {
  3512. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3513. if (groupData.Code != 0)
  3514. {
  3515. return Ok(JsonView(false, groupData.Msg));
  3516. }
  3517. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3518. }
  3519. catch (Exception ex)
  3520. {
  3521. return Ok(JsonView(false, "程序错误!"));
  3522. throw;
  3523. }
  3524. }
  3525. /// <summary>
  3526. /// 团组英文资料Id查询数据
  3527. /// </summary>
  3528. /// <param name="dto"></param>
  3529. /// <returns></returns>
  3530. [HttpPost]
  3531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3532. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3533. {
  3534. try
  3535. {
  3536. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3537. if (_DelegationEnData != null)
  3538. {
  3539. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3540. }
  3541. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3542. }
  3543. catch (Exception ex)
  3544. {
  3545. return Ok(JsonView(false, "程序错误!"));
  3546. throw;
  3547. }
  3548. }
  3549. /// <summary>
  3550. /// 团组英文资料删除
  3551. /// </summary>
  3552. /// <param name="dto"></param>
  3553. /// <returns></returns>
  3554. [HttpPost]
  3555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3556. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3557. {
  3558. try
  3559. {
  3560. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3561. if (!res)
  3562. {
  3563. return Ok(JsonView(false, "删除失败"));
  3564. }
  3565. return Ok(JsonView(true, "删除成功!"));
  3566. }
  3567. catch (Exception ex)
  3568. {
  3569. return Ok(JsonView(false, "程序错误!"));
  3570. throw;
  3571. }
  3572. }
  3573. #endregion
  3574. #region 导出邀请函
  3575. /// <summary>
  3576. /// 导出邀请函页面初始化
  3577. /// </summary>
  3578. /// <param name="dto"></param>
  3579. /// <returns></returns>
  3580. [HttpPost]
  3581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3582. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3583. {
  3584. try
  3585. {
  3586. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3587. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3588. if (dto.DiId == 0)
  3589. {
  3590. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3591. }
  3592. else
  3593. {
  3594. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3595. }
  3596. return Ok(JsonView(true, "查询成功!", new
  3597. {
  3598. deleClient = crm_Deles,
  3599. delegations = grp_Delegations
  3600. }));
  3601. }
  3602. catch (Exception ex)
  3603. {
  3604. return Ok(JsonView(false, "程序错误!"));
  3605. throw;
  3606. }
  3607. }
  3608. /// <summary>
  3609. /// 导出邀请函
  3610. /// </summary>
  3611. /// <param name="dto"></param>
  3612. /// <returns></returns>
  3613. [HttpPost]
  3614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3615. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3616. {
  3617. #region 参数验证
  3618. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3619. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3620. #endregion
  3621. try
  3622. {
  3623. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3624. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3625. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3626. From Grp_TourClientList tcl
  3627. Left Join
  3628. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3629. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3630. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3631. From Crm_DeleClient dc
  3632. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3633. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3634. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3635. Where dc.IsDel = 0) temp
  3636. On temp.DcId =tcl.ClientId
  3637. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3638. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3639. List<string> texts = new List<string>();
  3640. if (datas.Count != 0)
  3641. {
  3642. foreach (TourClientListDetailsView item in datas)
  3643. {
  3644. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3645. {
  3646. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3647. }
  3648. else
  3649. {
  3650. string name = item.LastName + item.FirstName;
  3651. texts.Add(name);
  3652. }
  3653. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3654. {
  3655. if (!transDic.ContainsKey(item.Job))
  3656. {
  3657. texts.Add(item.Job);
  3658. }
  3659. }
  3660. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3661. {
  3662. texts.Add(item.CompanyFullName);
  3663. }
  3664. }
  3665. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3666. if (transData.Count > 0)
  3667. {
  3668. foreach (TranslateResult item in transData)
  3669. {
  3670. if (!transDic.ContainsKey(item.Query))
  3671. {
  3672. transDic.Add(item.Query, item.Translation);
  3673. }
  3674. }
  3675. }
  3676. List<GuestList> list = new List<GuestList>();
  3677. foreach (TourClientListDetailsView dele in datas)
  3678. {
  3679. GuestList guestList = new GuestList();
  3680. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3681. {
  3682. guestList.Name = dele.Pinyin;
  3683. }
  3684. else
  3685. {
  3686. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3687. guestList.Name = Name;
  3688. }
  3689. if (dele.Sex == 0)
  3690. {
  3691. guestList.Sex = "Male";
  3692. }
  3693. else if (dele.Sex == 1)
  3694. {
  3695. guestList.Sex = "Female";
  3696. }
  3697. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3698. if (!string.IsNullOrEmpty(dele.Job))
  3699. {
  3700. guestList.Job = dele.Job;
  3701. }
  3702. list.Add(guestList);
  3703. }
  3704. //载入模板
  3705. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3706. DocumentBuilder builder = new DocumentBuilder(doc);
  3707. //获取word里所有表格
  3708. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3709. //获取所填表格的序数
  3710. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3711. var rowStart = tableOne.Rows[0]; //获取第1行
  3712. //循环赋值
  3713. for (int i = 0; i < list.Count; i++)
  3714. {
  3715. builder.MoveToCell(0, i + 1, 0, 0);
  3716. builder.Write(list[i].Name.ToString());
  3717. builder.MoveToCell(0, i + 1, 1, 0);
  3718. builder.Write(list[i].Sex.ToString());
  3719. builder.MoveToCell(0, i + 1, 2, 0);
  3720. builder.Write(list[i].DOB.ToString());
  3721. builder.MoveToCell(0, i + 1, 3, 0);
  3722. builder.Write(list[i].Job.ToString());
  3723. }
  3724. //删除多余行
  3725. while (tableOne.Rows.Count > list.Count + 1)
  3726. {
  3727. tableOne.Rows.RemoveAt(list.Count + 1);
  3728. }
  3729. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3730. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3731. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3732. doc.Save(filePath);
  3733. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3734. return Ok(JsonView(true, "操作成功!", Url));
  3735. }
  3736. else
  3737. {
  3738. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3739. }
  3740. }
  3741. catch (Exception ex)
  3742. {
  3743. return Ok(JsonView(false, ex.Message));
  3744. throw;
  3745. }
  3746. }
  3747. #endregion
  3748. #region 团组经理模块 出入境费用
  3749. ///// <summary>
  3750. ///// 团组模块 - 出入境费用
  3751. ///// </summary>
  3752. ///// <returns></returns>
  3753. //[HttpPost]
  3754. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3755. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3756. //{
  3757. // try
  3758. // {
  3759. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3760. // if (data.Code != 0)
  3761. // {
  3762. // return Ok(JsonView(false, data.Msg));
  3763. // }
  3764. // return Ok(JsonView(true, "查询成功!"));
  3765. // }
  3766. // catch (Exception ex)
  3767. // {
  3768. // return Ok(JsonView(false, ex.Message));
  3769. // throw;
  3770. // }
  3771. //}
  3772. /// <summary>
  3773. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3774. /// </summary>
  3775. /// <returns></returns>
  3776. [HttpPost]
  3777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3778. public async Task<IActionResult> SetDayAndCostAreaChange()
  3779. {
  3780. try
  3781. {
  3782. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3783. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3784. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3785. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3786. foreach (var item in unite) //处理交集数据
  3787. {
  3788. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3789. }
  3790. foreach (var item in merge) //处理差集数据
  3791. {
  3792. int nationalTravelFeeId = 0;
  3793. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3794. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3795. else
  3796. {
  3797. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3798. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3799. }
  3800. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3801. }
  3802. //只更新dayAndCost 的 nationalTravelFeeId;
  3803. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3804. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3805. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3806. }
  3807. catch (Exception ex)
  3808. {
  3809. return Ok(JsonView(false, ex.Message));
  3810. throw;
  3811. }
  3812. }
  3813. /// <summary>
  3814. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3815. /// </summary>
  3816. /// <returns></returns>
  3817. [HttpPost]
  3818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3819. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3820. {
  3821. try
  3822. {
  3823. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3824. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3825. //SetDataInfoView
  3826. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3827. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3828. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3829. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3830. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3831. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3832. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3833. //默认币种显示
  3834. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3835. {
  3836. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3837. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3838. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3839. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3840. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3841. };
  3842. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3843. if (_currencyRate.Count > 0)
  3844. {
  3845. foreach (var item in _currencyInfos)
  3846. {
  3847. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3848. if (rateInfo != null)
  3849. {
  3850. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3851. rate1 *= 1.035M;
  3852. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3853. }
  3854. }
  3855. }
  3856. return Ok(JsonView(true, "查询成功!", new
  3857. {
  3858. GroupNameData = groupNameData.Data,
  3859. CurrencyData = _CurrencyData,
  3860. WordTypeData = _WordTypeData,
  3861. ExcelTypeData = _ExcelTypeData,
  3862. CurrencyInit = _currencyInfos
  3863. }));
  3864. }
  3865. catch (Exception ex)
  3866. {
  3867. return Ok(JsonView(false, ex.Message));
  3868. throw;
  3869. }
  3870. }
  3871. /// <summary>
  3872. /// 团组模块 - 出入境费用
  3873. /// 实时汇率 tips
  3874. /// 签证费用 tips
  3875. /// </summary>
  3876. /// <returns></returns>
  3877. [HttpPost]
  3878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3879. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3880. {
  3881. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3882. //默认币种显示
  3883. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3884. {
  3885. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3886. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3887. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3888. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3889. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3890. };
  3891. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3892. List<dynamic> reteInfos = new List<dynamic>();
  3893. if (_currencyRate.Count > 0)
  3894. {
  3895. foreach (var item in _currencyInfos)
  3896. {
  3897. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3898. if (rateInfo != null)
  3899. {
  3900. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3901. decimal rate1 = item.Rate;
  3902. rate1 *= 1.03M;
  3903. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3904. reteInfos.Add(new
  3905. {
  3906. currCode = item.CurrencyCode,
  3907. currName = item.CurrencyName,
  3908. rate = rate2,
  3909. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3910. });
  3911. }
  3912. }
  3913. }
  3914. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3915. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3916. return Ok(JsonView(true, "查询成功!", new
  3917. {
  3918. //GroupNameData = groupNameData.Data,
  3919. visaData = visaData.Data,
  3920. airData = airData.Data,
  3921. reteInfos = reteInfos
  3922. }));
  3923. }
  3924. /// <summary>
  3925. /// 团组模块 - 出入境费用 - Info
  3926. /// </summary>
  3927. /// <returns></returns>
  3928. [HttpPost]
  3929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3930. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3931. {
  3932. try
  3933. {
  3934. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3935. if (data.Code != 0)
  3936. {
  3937. return Ok(JsonView(false, data.Msg));
  3938. }
  3939. return Ok(JsonView(true, "查询成功!", data.Data));
  3940. }
  3941. catch (Exception ex)
  3942. {
  3943. return Ok(JsonView(false, ex.Message));
  3944. }
  3945. }
  3946. /// <summary>
  3947. /// 团组模块 - 出入境费用 - Add And Update
  3948. /// </summary>
  3949. /// <returns></returns>
  3950. [HttpPost]
  3951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3952. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3953. {
  3954. try
  3955. {
  3956. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3957. if (data.Code != 0)
  3958. {
  3959. return Ok(JsonView(false, data.Msg));
  3960. }
  3961. //生成默认文件pdf并且通知人员
  3962. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3963. {
  3964. DiId = dto.DiId,
  3965. ExportType = 1,
  3966. SubTypeId = 1005
  3967. }, "pdf");
  3968. //发送通知
  3969. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3970. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3971. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3972. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3973. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3974. return Ok(JsonView(true, data.Msg, data.Data));
  3975. }
  3976. catch (Exception ex)
  3977. {
  3978. return Ok(JsonView(false, ex.Message));
  3979. }
  3980. }
  3981. /// <summary>
  3982. /// 团组模块 - 出入境费用 - Confirm 费用
  3983. /// </summary>
  3984. /// <returns></returns>
  3985. [HttpPost]
  3986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3987. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3988. {
  3989. //TODO:测试完毕需把对应的用户ID更改
  3990. //1、数据表添加字段
  3991. //2、更改字段接口()
  3992. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3993. //3、确认成功 给财务发送消息
  3994. if (_view.Code == 200)
  3995. {
  3996. if (dto.Type == 1)
  3997. {
  3998. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3999. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4000. }
  4001. }
  4002. return Ok(_view);
  4003. }
  4004. /// <summary>
  4005. /// 团组模块 - 出入境费用 - File downlaod
  4006. /// </summary>
  4007. /// <param name="dto"></param>
  4008. /// <returns></returns>
  4009. [HttpPost]
  4010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4011. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4012. {
  4013. try
  4014. {
  4015. if (dto.DiId < 1)
  4016. {
  4017. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4018. }
  4019. if (dto.ExportType < 1)
  4020. {
  4021. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4022. }
  4023. if (dto.SubTypeId < 1)
  4024. {
  4025. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4026. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4027. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4028. 3 团组成员名单 1 团组成员名单"));
  4029. }
  4030. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4031. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4032. if (_EnterExitCosts == null)
  4033. {
  4034. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4035. }
  4036. //数据源
  4037. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4038. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4039. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4040. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4041. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4042. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4043. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4044. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4045. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4046. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4047. .Select((tcl, dc, cc) => new
  4048. {
  4049. Name = dc.LastName + dc.FirstName,
  4050. Sex = dc.Sex,
  4051. Birthday = dc.BirthDay,
  4052. Company = cc.CompanyFullName,
  4053. Job = dc.Job
  4054. })
  4055. .ToList();
  4056. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4057. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4058. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4059. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4060. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4061. if (dto.ExportType == 1) //明细表
  4062. {
  4063. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4064. {
  4065. //获取模板
  4066. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4067. //载入模板
  4068. Document doc = new Document(tempPath);
  4069. DocumentBuilder builder = new DocumentBuilder(doc);
  4070. //利用键值对存放数据
  4071. Dictionary<string, string> dic = new Dictionary<string, string>();
  4072. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4073. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4074. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4075. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4076. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4077. //境内费用(其他费用)
  4078. if (_EnterExitCosts.ChoiceOne == 1)
  4079. {
  4080. string row1_1 = "";
  4081. if (_EnterExitCosts.Visa > 0)
  4082. {
  4083. //insidePayTotal += _EnterExitCosts.Visa;
  4084. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4085. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4086. {
  4087. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4088. }
  4089. }
  4090. string row1_2 = "";
  4091. if (_EnterExitCosts.YiMiao > 0)
  4092. {
  4093. //insidePayTotal += _EnterExitCosts.YiMiao;
  4094. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4095. }
  4096. if (_EnterExitCosts.HeSuan > 0)
  4097. {
  4098. //insidePayTotal += _EnterExitCosts.HeSuan;
  4099. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4100. }
  4101. if (_EnterExitCosts.Service > 0)
  4102. {
  4103. //insidePayTotal += _EnterExitCosts.Service;
  4104. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4105. }
  4106. string row1_3 = "";
  4107. if (_EnterExitCosts.Safe > 0)
  4108. {
  4109. //insidePayTotal += _EnterExitCosts.Safe;
  4110. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4111. }
  4112. if (_EnterExitCosts.Ticket > 0)
  4113. {
  4114. //insidePayTotal += _EnterExitCosts.Ticket;
  4115. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4116. }
  4117. string row1 = "";
  4118. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4119. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4120. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4121. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4122. dic.Add("Row1Str", row1);
  4123. }
  4124. string airTotalStr = string.Empty,
  4125. airPriceStr = string.Empty;
  4126. //经济舱
  4127. if (_EnterExitCosts.SumJJC == 1)
  4128. {
  4129. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4130. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4131. }
  4132. //公务舱
  4133. if (_EnterExitCosts.SumGWC == 1)
  4134. {
  4135. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4136. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4137. }
  4138. //头等舱
  4139. if (_EnterExitCosts.SumTDC == 1)
  4140. {
  4141. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4142. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4143. }
  4144. dic.Add("AirTotalStr", airTotalStr);
  4145. dic.Add("AirPriceStr", airPriceStr);
  4146. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4147. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4148. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4149. int table1Row = 0,
  4150. table2Row = 0,
  4151. table3Row = 0,
  4152. table4Row = 0;
  4153. //住宿费
  4154. if (_EnterExitCosts.ChoiceThree == 1)
  4155. {
  4156. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4157. table1Row = dac1.Count;
  4158. #region 填充word表格内容
  4159. for (int i = 0; i < dac1.Count; i++)
  4160. {
  4161. Grp_DayAndCost dac = dac1[i];
  4162. if (dac == null) continue;
  4163. builder.MoveToCell(0, i, 0, 0);
  4164. builder.Write("第" + dac.Days.ToString() + "晚:");
  4165. builder.MoveToCell(0, i, 1, 0);
  4166. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4167. //builder.Write(dac.Place == null ? "" : dac.Place);
  4168. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4169. builder.MoveToCell(0, i, 2, 0);
  4170. builder.Write("费用标准:");
  4171. string curr = "";
  4172. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4173. if (currData != null)
  4174. {
  4175. curr = currData.Name;
  4176. }
  4177. builder.MoveToCell(0, i, 3, 0);
  4178. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4179. builder.MoveToCell(0, i, 4, 0);
  4180. builder.Write("费用小计:");
  4181. builder.MoveToCell(0, i, 5, 0);
  4182. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4183. }
  4184. #endregion
  4185. }else dic.Add("SubZS","0.00");
  4186. //删除多余行
  4187. while (table1.Rows.Count > table1Row)
  4188. {
  4189. table1.Rows.RemoveAt(table1Row);
  4190. }
  4191. //伙食费
  4192. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4193. if (_EnterExitCosts.ChoiceFour == 1)
  4194. {
  4195. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4196. table2Row = dac2.Count;
  4197. #region 填充word表格内容
  4198. for (int i = 0; i < dac2.Count; i++)
  4199. {
  4200. Grp_DayAndCost dac = dac2[i];
  4201. if (dac == null) continue;
  4202. builder.MoveToCell(1, i, 0, 0);
  4203. builder.Write("第" + dac.Days.ToString() + "天:");
  4204. builder.MoveToCell(1, i, 1, 0);
  4205. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4206. builder.MoveToCell(1, i, 2, 0);
  4207. builder.Write("费用标准:");
  4208. string curr = "";
  4209. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4210. if (currData != null)
  4211. {
  4212. curr = currData.Name;
  4213. }
  4214. builder.MoveToCell(1, i, 3, 0);
  4215. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4216. builder.MoveToCell(1, i, 4, 0);
  4217. builder.Write("费用小计:");
  4218. builder.MoveToCell(1, i, 5, 0);
  4219. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4220. }
  4221. #endregion
  4222. }else dic.Add("SubHS","0.00");
  4223. //删除多余行
  4224. while (table2.Rows.Count > table2Row)
  4225. {
  4226. table2.Rows.RemoveAt(table2Row);
  4227. }
  4228. //公杂费
  4229. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4230. if (_EnterExitCosts.ChoiceFive == 1)
  4231. {
  4232. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4233. table3Row = dac3.Count;
  4234. #region 填充word表格内容
  4235. for (int i = 0; i < dac3.Count; i++)
  4236. {
  4237. Grp_DayAndCost dac = dac3[i];
  4238. if (dac == null) continue;
  4239. builder.MoveToCell(2, i, 0, 0);
  4240. builder.Write("第" + dac.Days.ToString() + "天:");
  4241. builder.MoveToCell(2, i, 1, 0);
  4242. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4243. builder.MoveToCell(2, i, 2, 0);
  4244. builder.Write("费用标准:");
  4245. string curr = "";
  4246. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4247. if (currData != null)
  4248. {
  4249. curr = currData.Name;
  4250. }
  4251. builder.MoveToCell(2, i, 3, 0);
  4252. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4253. builder.MoveToCell(2, i, 4, 0);
  4254. builder.Write("费用小计:");
  4255. builder.MoveToCell(2, i, 5, 0);
  4256. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4257. }
  4258. //删除多余行
  4259. while (table3.Rows.Count > table3Row)
  4260. {
  4261. table3.Rows.RemoveAt(table3Row);
  4262. }
  4263. #endregion
  4264. }else dic.Add("SubGZF", "0.00");
  4265. //删除多余行
  4266. while (table3.Rows.Count > table3Row)
  4267. {
  4268. table3.Rows.RemoveAt(table3Row);
  4269. }
  4270. //培训费
  4271. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4272. if (_EnterExitCosts.ChoiceSix == 1)
  4273. {
  4274. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4275. dic.Add("SubPX", pxStr);
  4276. table4Row = dac4.Count;
  4277. #region 填充word表格内容
  4278. for (int i = 0; i < dac4.Count; i++)
  4279. {
  4280. Grp_DayAndCost dac = dac4[i];
  4281. if (dac == null) continue;
  4282. builder.MoveToCell(3, i, 0, 0);
  4283. builder.Write("第" + dac.Days.ToString() + "天:");
  4284. builder.MoveToCell(3, i, 1, 0);
  4285. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4286. builder.MoveToCell(3, i, 2, 0);
  4287. builder.Write("费用标准:");
  4288. string curr = "";
  4289. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4290. if (currData != null)
  4291. {
  4292. curr = currData.Name;
  4293. }
  4294. builder.MoveToCell(3, i, 3, 0);
  4295. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4296. builder.MoveToCell(3, i, 4, 0);
  4297. builder.Write("费用小计:");
  4298. builder.MoveToCell(3, i, 5, 0);
  4299. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4300. }
  4301. #endregion
  4302. }
  4303. //else dic.Add("SubPX","0.00");
  4304. //删除多余行
  4305. while (table4.Rows.Count > table4Row)
  4306. {
  4307. table4.Rows.RemoveAt(table4Row);
  4308. }
  4309. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4310. decimal subJJC = 0.00M,
  4311. subGWC = 0.00M,
  4312. subTDC = 0.00M;
  4313. //经济舱
  4314. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4315. //公务舱
  4316. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4317. //头等舱
  4318. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4319. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4320. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4321. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4322. #region 填充word模板书签内容
  4323. foreach (var key in dic.Keys)
  4324. {
  4325. builder.MoveToBookmark(key);
  4326. builder.Write(dic[key]);
  4327. }
  4328. #endregion
  4329. //文件名
  4330. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4331. AsposeHelper.removewatermark_v2180();
  4332. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4333. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4334. return Ok(JsonView(true, "成功", new { Url = url }));
  4335. }
  4336. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4337. {
  4338. //获取模板
  4339. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4340. //载入模板
  4341. Document doc = new Document(tempPath);
  4342. DocumentBuilder builder = new DocumentBuilder(doc);
  4343. Dictionary<string, string> dic = new Dictionary<string, string>();
  4344. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4345. {
  4346. List<string> list = new List<string>();
  4347. try
  4348. {
  4349. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4350. foreach (var item in spilitArr)
  4351. {
  4352. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4353. var depCode = spDotandEmpty[2].Substring(0, 3);
  4354. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4355. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4356. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4357. list.Add(depName);
  4358. list.Add(arrName);
  4359. }
  4360. list = list.Distinct().ToList();
  4361. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4362. }
  4363. catch (Exception)
  4364. {
  4365. dic.Add("ReturnCode", "行程录入不正确!");
  4366. }
  4367. }
  4368. else
  4369. {
  4370. dic.Add("ReturnCode", "未录入行程!");
  4371. }
  4372. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4373. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4374. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4375. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4376. {
  4377. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4378. dic.Add("Day", sp.Days.ToString());
  4379. }
  4380. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4381. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4382. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4383. //dic.Add("Names", Names);
  4384. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4385. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4386. decimal dac1totalPrice = 0.00M;
  4387. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4388. foreach (var dac in dac1)
  4389. {
  4390. if (dac.SubTotal == 0.00M)
  4391. {
  4392. continue;
  4393. }
  4394. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4395. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4396. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4397. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4398. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4399. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4400. builder.Write(currency);//币种
  4401. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4402. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4403. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4404. builder.Write("");//人数
  4405. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4406. builder.Write("");//天数
  4407. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4408. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4409. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4410. decimal rate = 0.00M;
  4411. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4412. builder.Write(rate.ToString("#0.0000"));//汇率
  4413. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4414. decimal rbmPrice = dac.SubTotal;
  4415. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4416. accommodationStartIndex++;
  4417. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4418. }
  4419. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4420. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4421. {
  4422. table1.Rows.RemoveAt(i - 1);
  4423. foodandotherStartIndex--;
  4424. }
  4425. if (dac2.Count == dac3.Count)//国家 币种 金额
  4426. {
  4427. for (int i = 0; i < dac2.Count; i++)
  4428. {
  4429. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4430. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4431. }
  4432. }
  4433. decimal dac2totalPrice = 0.00M;
  4434. foreach (var dac in dac2)
  4435. {
  4436. if (dac.SubTotal == 0)
  4437. {
  4438. continue;
  4439. }
  4440. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4441. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4442. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4443. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4444. builder.Write(currency);//币种
  4445. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4446. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4447. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4448. builder.Write("");//人数
  4449. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4450. builder.Write("");//天数
  4451. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4452. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4453. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4454. decimal rate = 0.00M;
  4455. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4456. builder.Write(rate.ToString("#0.0000"));//汇率
  4457. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4458. decimal rbmPrice = dac.SubTotal;
  4459. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4460. foodandotherStartIndex++;
  4461. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4462. }
  4463. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4464. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4465. {
  4466. table1.Rows.RemoveAt(i - 1);
  4467. }
  4468. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4469. string otherFeeStr = "";
  4470. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4471. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4472. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4473. if (otherFeeStr.Length > 0)
  4474. {
  4475. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4476. otherFeeStr = $"({otherFeeStr})";
  4477. dic.Add("OtherFeeStr", otherFeeStr);
  4478. }
  4479. //总计
  4480. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4481. //国际旅费
  4482. string outsideAir = string.Empty;
  4483. string allPriceAir = string.Empty;
  4484. if (_EnterExitCosts.SumJJC == 1)
  4485. {
  4486. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4487. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4488. }
  4489. if (_EnterExitCosts.SumGWC == 1)
  4490. {
  4491. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4492. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4493. }
  4494. if (_EnterExitCosts.SumTDC == 1)
  4495. {
  4496. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4497. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4498. }
  4499. dic.Add("InTravelPrice", $"({outsideAir})");
  4500. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4501. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4502. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4503. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4504. foreach (var key in dic.Keys)
  4505. {
  4506. builder.MoveToBookmark(key);
  4507. builder.Write(dic[key]);
  4508. }
  4509. //模板文件名
  4510. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4511. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4512. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4513. return Ok(JsonView(true, "成功", new { Url = url }));
  4514. }
  4515. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4516. {
  4517. //获取模板
  4518. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4519. //载入模板
  4520. WorkbookDesigner designer = new WorkbookDesigner();
  4521. designer.Workbook = new Workbook(tempPath);
  4522. Dictionary<string, string> dic = new Dictionary<string, string>();
  4523. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4524. {
  4525. List<string> list = new List<string>();
  4526. try
  4527. {
  4528. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4529. foreach (var item in spilitArr)
  4530. {
  4531. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4532. var depCode = spDotandEmpty[2].Substring(0, 3);
  4533. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4534. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4535. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4536. list.Add(depName);
  4537. list.Add(arrName);
  4538. }
  4539. list = list.Distinct().ToList();
  4540. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4541. }
  4542. catch (Exception)
  4543. {
  4544. dic.Add("ReturnCode", "行程录入不正确!");
  4545. }
  4546. }
  4547. else
  4548. {
  4549. dic.Add("ReturnCode", "未录入行程!");
  4550. }
  4551. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4552. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4553. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4554. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4555. {
  4556. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4557. dic.Add("Day", sp.Days.ToString());
  4558. }
  4559. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4560. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4561. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4562. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4563. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4564. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4565. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4566. designer.SetDataSource("Name", Names);
  4567. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4568. designer.SetDataSource("Day", dic["Day"] + "天");
  4569. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4570. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4571. int startIndex = 10;
  4572. const int startIndexcopy = 10;
  4573. if (dac2.Count == dac3.Count)//国家 币种 金额
  4574. {
  4575. for (int i = 0; i < dac2.Count; i++)
  4576. {
  4577. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4578. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4579. }
  4580. }
  4581. DataTable dtdac1 = new DataTable();
  4582. List<string> place = new List<string>();
  4583. dtdac1.Columns.AddRange(new DataColumn[] {
  4584. new DataColumn(){ ColumnName = "city"},
  4585. new DataColumn(){ ColumnName = "curr"},
  4586. new DataColumn(){ ColumnName = "criterion"},
  4587. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4588. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4589. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4590. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4591. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4592. });
  4593. DataTable dtdac2 = new DataTable();
  4594. dtdac2.Columns.AddRange(new DataColumn[] {
  4595. new DataColumn(){ ColumnName = "city"},
  4596. new DataColumn(){ ColumnName = "curr"},
  4597. new DataColumn(){ ColumnName = "criterion"},
  4598. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4599. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4600. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4601. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4602. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4603. });
  4604. dtdac1.TableName = "tb1";
  4605. dtdac2.TableName = "tb2";
  4606. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4607. foreach (var item in dac1)
  4608. {
  4609. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4610. if (place.Contains(item.Place))
  4611. {
  4612. continue;
  4613. }
  4614. DataRow row = dtdac1.NewRow();
  4615. row["city"] = item.Place;
  4616. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4617. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4618. row["curr"] = currency;
  4619. row["rate"] = rate.ToString("#0.0000");
  4620. row["criterion"] = item.Cost.ToString("#0.00");
  4621. row["number"] = 1;
  4622. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4623. //row["costRMB"] = rbmPrice;
  4624. dtdac1.Rows.Add(row);
  4625. place.Add(item.Place);
  4626. }
  4627. place = new List<string>();
  4628. foreach (var item in dac2)
  4629. {
  4630. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4631. if (place.Contains(item.Place))
  4632. {
  4633. continue;
  4634. }
  4635. DataRow row = dtdac2.NewRow();
  4636. row["city"] = item.Place;
  4637. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4638. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4639. row["curr"] = currency;
  4640. row["rate"] = rate.ToString("#0.0000");
  4641. row["criterion"] = item.Cost.ToString("#0.00");
  4642. row["number"] = 1;
  4643. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4644. //row["cost"] = item.SubTotal;
  4645. //row["costRMB"] = rbmPrice;
  4646. dtdac2.Rows.Add(row);
  4647. place.Add(item.Place);
  4648. //dac2totalPrice += rbmPrice;
  4649. }
  4650. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4651. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4652. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4653. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4654. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4655. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4656. string cell4Str1 = string.Empty;
  4657. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4658. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4659. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4660. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4661. string cellStr = $" 5.其他费用(";
  4662. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4663. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4664. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4665. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4666. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4667. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4668. if (cellStr.Length > 8)
  4669. {
  4670. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4671. }
  4672. cellStr += ")";
  4673. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4674. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4675. decimal pxFee = dac4.Sum(it => it.Cost);
  4676. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4677. string celllastStr1 = "";
  4678. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4679. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4680. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4681. celllastStr1 += $",国际旅费 元";
  4682. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4683. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4684. designer.SetDataSource("cell4Str", cell4Str);
  4685. designer.SetDataSource("cellStr", cellStr);
  4686. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4687. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4688. designer.SetDataSource("celllastStr", celllastStr);
  4689. Workbook wb = designer.Workbook;
  4690. var sheet = wb.Worksheets[0];
  4691. //绑定datatable数据集
  4692. designer.SetDataSource(dtdac1);
  4693. designer.SetDataSource(dtdac2);
  4694. designer.Process();
  4695. var rowStart = dtdac1.Rows.Count;
  4696. while (rowStart > 0)
  4697. {
  4698. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4699. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4700. startIndex++;
  4701. rowStart--;
  4702. }
  4703. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4704. startIndex += 1; //总计行
  4705. rowStart = dtdac2.Rows.Count;
  4706. while (rowStart > 0)
  4707. {
  4708. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4709. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4710. startIndex++;
  4711. rowStart--;
  4712. }
  4713. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4714. wb.CalculateFormula(true);
  4715. //模板文件名
  4716. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4717. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4718. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4719. return Ok(JsonView(true, "成功", new { Url = url }));
  4720. }
  4721. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4722. {
  4723. //获取模板
  4724. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4725. //载入模板
  4726. Document doc = new Document(tempPath);
  4727. DocumentBuilder builder = new DocumentBuilder(doc);
  4728. Dictionary<string, string> dic = new Dictionary<string, string>();
  4729. dic.Add("GroupName", _DelegationInfo.TeamName);
  4730. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4731. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4732. string missionLeaderJob = "";//负责人job
  4733. int groupNumber = 0; //团人数
  4734. if (DeleClientList.Count > 0)
  4735. {
  4736. missionLeader = DeleClientList[0]?.Name ?? "";
  4737. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4738. }
  4739. dic.Add("MissionLeader", missionLeader); //团负责人
  4740. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4741. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4742. #region MyRegion
  4743. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4744. //{
  4745. // List<string> list = new List<string>();
  4746. // try
  4747. // {
  4748. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4749. // foreach (var item in spilitArr)
  4750. // {
  4751. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4752. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4753. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4754. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4755. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4756. // list.Add(depName);
  4757. // list.Add(arrName);
  4758. // }
  4759. // list = list.Distinct().ToList();
  4760. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4761. // }
  4762. // catch (Exception)
  4763. // {
  4764. // dic.Add("ReturnCode", "行程录入不正确!");
  4765. // }
  4766. //}
  4767. //else
  4768. //{
  4769. // dic.Add("ReturnCode", "未录入行程!");
  4770. //}
  4771. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4772. dic.Add("ReturnCode", string.Join("、", countrys));
  4773. #endregion
  4774. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4775. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4776. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4777. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4778. //{
  4779. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4780. // dic.Add("Day", sp.Days.ToString());
  4781. //}
  4782. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4783. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4784. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4785. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4786. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4787. //培训人员名单
  4788. int cultivateRowIndex = 7;
  4789. foreach (var item in DeleClientList)
  4790. {
  4791. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4792. builder.Write(item.Name);
  4793. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4794. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4795. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4796. string birthDay = "";
  4797. if (item.Birthday != null)
  4798. {
  4799. DateTime dt = Convert.ToDateTime(item.Birthday);
  4800. birthDay = $"{dt.Year}.{dt.Month}";
  4801. }
  4802. builder.Write(birthDay);
  4803. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4804. builder.Write(item.Company);
  4805. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4806. builder.Write(item.Job);
  4807. cultivateRowIndex++;
  4808. }
  4809. //删除多余行
  4810. //cultivateRowIndex -= 2;
  4811. int delRows = 10 + 7 - cultivateRowIndex;
  4812. if (delRows > 0)
  4813. {
  4814. for (int i = 0; i < delRows; i++)
  4815. {
  4816. table1.Rows.RemoveAt(cultivateRowIndex);
  4817. //cultivateRowIndex++;
  4818. }
  4819. }
  4820. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4821. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4822. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4823. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4824. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4825. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4826. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4827. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4828. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4829. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4830. //其他费用
  4831. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4832. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4833. //其他费用合计
  4834. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4835. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4836. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4837. //公务舱合计
  4838. //国际旅费
  4839. string outsideJJ = "";
  4840. string allPriceJJ = "";
  4841. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4842. {
  4843. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4844. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4845. }
  4846. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4847. {
  4848. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4849. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4850. }
  4851. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4852. {
  4853. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4854. dic.Add("AirFeeTotal", airFeeTotalStr);
  4855. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4856. dic.Add("FeeTotal", feeTotalStr);
  4857. }
  4858. foreach (var key in dic.Keys)
  4859. {
  4860. builder.MoveToBookmark(key);
  4861. builder.Write(dic[key]);
  4862. }
  4863. //模板文件名
  4864. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4865. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4866. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4867. return Ok(JsonView(true, "成功", new { Url = url }));
  4868. }
  4869. }
  4870. else if (dto.ExportType == 2) //表格
  4871. {
  4872. //利用键值对存放数据
  4873. Dictionary<string, string> dic = new Dictionary<string, string>();
  4874. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4875. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4876. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4877. dic.Add("Day", sp.Days.ToString());
  4878. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4879. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4880. {
  4881. //获取模板
  4882. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4883. //载入模板
  4884. Document doc = new Document(tempPath);
  4885. DocumentBuilder builder = new DocumentBuilder(doc);
  4886. dic.Add("TeamName", _DelegationInfo.TeamName);
  4887. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4888. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4889. string missionLeaderName = "",
  4890. missionLeaderJob = "";
  4891. if (DeleClientList.Count > 0)
  4892. {
  4893. missionLeaderName = DeleClientList[0].Name;
  4894. missionLeaderJob = DeleClientList[0].Job;
  4895. }
  4896. dic.Add("MissionLeaderName", missionLeaderName);
  4897. dic.Add("MissionLeaderJob", missionLeaderJob);
  4898. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4899. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4900. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4901. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4902. int rowCount = 10;//总人数行
  4903. int startRowIndex = 7; //起始行
  4904. for (int i = 0; i < DeleClientList.Count; i++)
  4905. {
  4906. builder.MoveToCell(0, startRowIndex, 0, 0);
  4907. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4908. builder.MoveToCell(0, startRowIndex, 1, 0);
  4909. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4910. builder.Write(sex);//性别
  4911. builder.MoveToCell(0, startRowIndex, 2, 0);
  4912. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4913. builder.MoveToCell(0, startRowIndex, 3, 0);
  4914. builder.Write(DeleClientList[i].Company);//工作单位
  4915. builder.MoveToCell(0, startRowIndex, 4, 0);
  4916. builder.Write(DeleClientList[i].Job);//职务及级别
  4917. builder.MoveToCell(0, startRowIndex, 5, 0);
  4918. builder.Write("");//人员属性
  4919. builder.MoveToCell(0, startRowIndex, 6, 0);
  4920. builder.Write("");//上次出国时间
  4921. startRowIndex++;
  4922. }
  4923. int nullRow = rowCount - DeleClientList.Count;//空行
  4924. for (int i = 0; i < nullRow; i++)
  4925. {
  4926. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4927. }
  4928. foreach (var key in dic.Keys)
  4929. {
  4930. builder.MoveToBookmark(key);
  4931. builder.Write(dic[key]);
  4932. }
  4933. //模板文件名
  4934. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4935. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4936. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4937. return Ok(JsonView(true, "成功", new { Url = url }));
  4938. }
  4939. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4940. {
  4941. //获取模板
  4942. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4943. //载入模板
  4944. Document doc = new Document(tempPath);
  4945. DocumentBuilder builder = new DocumentBuilder(doc);
  4946. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4947. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4948. dic.Add("Names", Names);
  4949. int accommodationRows = 12, foodandotherRows = 12;
  4950. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4951. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4952. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4953. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4954. int accommodationStartIndex = 6;
  4955. decimal dac1totalPrice = 0.00M;
  4956. foreach (var dac in dac1)
  4957. {
  4958. if (dac.SubTotal == 0)
  4959. {
  4960. continue;
  4961. }
  4962. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4963. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4964. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4965. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4966. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4967. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4968. builder.Write(currency);//币种
  4969. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4970. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4971. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4972. builder.Write("");//人数
  4973. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4974. builder.Write("");//天数
  4975. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4976. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4977. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4978. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4979. builder.Write(rate.ToString("#0.0000"));//汇率
  4980. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4981. decimal rbmPrice = rate * dac.SubTotal;
  4982. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4983. accommodationStartIndex++;
  4984. dac1totalPrice += rbmPrice;
  4985. }
  4986. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4987. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4988. builder.Write("小计");
  4989. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4990. builder.Write(dac1totalPrice.ToString("#0.00"));
  4991. accommodationStartIndex++;
  4992. int nullRow = accommodationRows - dac1.Count;
  4993. //删除空行
  4994. //if (nullRow > 0)
  4995. //{
  4996. // int rowIndex = accommodationStartIndex;
  4997. // for (int i = 0; i < nullRow; i++)
  4998. // {
  4999. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5000. // row.Remove();
  5001. // rowIndex++;
  5002. // }
  5003. //}
  5004. if (dac2.Count == dac3.Count)//国家 币种 金额
  5005. {
  5006. for (int i = 0; i < dac2.Count; i++)
  5007. {
  5008. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5009. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5010. }
  5011. }
  5012. int foodandotherStartIndex = 19;//
  5013. decimal dac2totalPrice = 0.00M;
  5014. foreach (var dac in dac2)
  5015. {
  5016. if (dac.SubTotal == 0)
  5017. {
  5018. continue;
  5019. }
  5020. //foodandotherStartIndex = 12;
  5021. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5022. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5023. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5024. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5025. builder.Write(currency);//币种
  5026. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5027. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5028. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5029. builder.Write("");//人数
  5030. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5031. builder.Write("");//天数
  5032. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5033. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5034. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5035. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5036. builder.Write(rate.ToString("#0.0000"));//汇率
  5037. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5038. decimal rbmPrice = rate * dac.SubTotal;
  5039. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5040. foodandotherStartIndex++;
  5041. dac2totalPrice += rbmPrice;
  5042. }
  5043. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5044. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5045. //删除空行
  5046. //if (dac2.Count < foodandotherRows)
  5047. //{
  5048. // while (table2.Rows.Count > dac2.Count)
  5049. // {
  5050. // table2.Rows.RemoveAt(dac2.Count);
  5051. // }
  5052. //}
  5053. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5054. string otherFeeStr = "";
  5055. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5056. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5057. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5058. if (otherFeeStr.Length > 0)
  5059. {
  5060. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5061. otherFeeStr = $"({otherFeeStr})";
  5062. dic.Add("OtherFeeStr", otherFeeStr);
  5063. }
  5064. foreach (var key in dic.Keys)
  5065. {
  5066. builder.MoveToBookmark(key);
  5067. builder.Write(dic[key]);
  5068. }
  5069. //模板文件名
  5070. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5071. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5072. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5073. return Ok(JsonView(true, "成功", new { Url = url }));
  5074. }
  5075. }
  5076. else if (dto.ExportType == 3)
  5077. {
  5078. if (dto.SubTypeId == 1) //团组成员名单
  5079. {
  5080. if (DeleClientList.Count < 1)
  5081. {
  5082. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5083. }
  5084. //获取模板
  5085. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5086. //载入模板
  5087. Document doc = new Document(tempPath);
  5088. DocumentBuilder builder = new DocumentBuilder(doc);
  5089. //获取word里所有表格
  5090. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5091. //获取所填表格的序数
  5092. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5093. var rowStart = tableOne.Rows[0]; //获取第1行
  5094. //循环赋值
  5095. for (int i = 0; i < DeleClientList.Count; i++)
  5096. {
  5097. builder.MoveToCell(0, i + 1, 0, 0);
  5098. builder.Write(DeleClientList[i].Name);
  5099. builder.MoveToCell(0, i + 1, 1, 0);
  5100. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5101. builder.Write(sex);
  5102. builder.MoveToCell(0, i + 1, 2, 0);
  5103. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5104. builder.MoveToCell(0, i + 1, 3, 0);
  5105. builder.Write(DeleClientList[i].Company);
  5106. builder.MoveToCell(0, i + 1, 4, 0);
  5107. builder.Write(DeleClientList[i].Job);
  5108. }
  5109. //删除多余行
  5110. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5111. {
  5112. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5113. }
  5114. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5115. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5116. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5117. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5118. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5119. return Ok(JsonView(true, "成功", new { Url = url }));
  5120. }
  5121. }
  5122. return Ok(JsonView(false, "操作失败!"));
  5123. }
  5124. catch (Exception ex)
  5125. {
  5126. return Ok(JsonView(false, ex.Message));
  5127. }
  5128. }
  5129. /// <summary>
  5130. /// 获取三公费用标准city
  5131. /// </summary>
  5132. /// <param name="placeData"></param>
  5133. /// <param name="nationalTravelFeeId"></param>
  5134. /// <returns></returns>
  5135. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5136. {
  5137. string _city = string.Empty;
  5138. if (placeData.Count < 1) return _city;
  5139. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5140. if (data == null) return _city;
  5141. string country = data.Country;
  5142. string city = data.City;
  5143. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5144. else _city = city;
  5145. return _city;
  5146. }
  5147. /// <summary>
  5148. /// 团组模块 - 出入境费用 - 明细表导出
  5149. /// </summary>
  5150. /// <returns></returns>
  5151. [HttpPost]
  5152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5153. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5154. {
  5155. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5156. if (data.Code != 0)
  5157. {
  5158. return Ok(JsonView(false, data.Msg));
  5159. }
  5160. return Ok(JsonView(true, data.Msg, data.Data));
  5161. }
  5162. /// <summary>
  5163. /// 团组模块 - 出入境费用 - 一键清空
  5164. /// </summary>
  5165. /// <returns></returns>
  5166. [HttpPost]
  5167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5168. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5169. {
  5170. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5171. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5172. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5173. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5174. if (_view.Code == 0)
  5175. {
  5176. return Ok(JsonView(true, "操作成功"));
  5177. }
  5178. return Ok(JsonView(false, "操作失败"));
  5179. }
  5180. /// <summary>
  5181. /// 团组模块 - 出入境费用 - 子项删除
  5182. /// </summary>
  5183. /// <returns></returns>
  5184. [HttpPost]
  5185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5186. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5187. {
  5188. try
  5189. {
  5190. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5191. if (data.Code != 0)
  5192. {
  5193. return Ok(JsonView(false, data.Msg));
  5194. }
  5195. return Ok(JsonView(true, "操作成功!", data.Data));
  5196. }
  5197. catch (Exception ex)
  5198. {
  5199. return Ok(JsonView(false, ex.Message));
  5200. }
  5201. }
  5202. /// <summary>
  5203. /// 团组模块 - 出入境国家费用标准 List
  5204. /// </summary>
  5205. /// <returns></returns>
  5206. [HttpPost]
  5207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5208. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5209. {
  5210. try
  5211. {
  5212. Stopwatch sw = new Stopwatch();
  5213. sw.Start();
  5214. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5215. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5216. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5217. Where gntf.Isdel = 0");
  5218. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5219. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5220. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5221. //foreach (var item in nationalTravel)
  5222. //{
  5223. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5224. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5225. // if (otherData != null)
  5226. // {
  5227. // cityData.Remove(otherData);
  5228. // cityData.Add(otherData);
  5229. // }
  5230. // nationalTravelFeeData1.Add(new
  5231. // {
  5232. // Country = item.Country,
  5233. // CityData = cityData
  5234. // });
  5235. //}
  5236. sw.Stop();
  5237. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5238. }
  5239. catch (Exception ex)
  5240. {
  5241. return Ok(JsonView(false, ex.Message));
  5242. throw;
  5243. }
  5244. }
  5245. /// <summary>
  5246. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5247. /// </summary>
  5248. /// <returns></returns>
  5249. [HttpPost]
  5250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5251. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5252. {
  5253. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5254. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5255. List<string> countryData = new List<string>();
  5256. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5257. countryData = countryData.Distinct().ToList();
  5258. List<dynamic> dataSource = new List<dynamic>();
  5259. foreach (var item in countryData)
  5260. {
  5261. List<string> cityData1 = new List<string>();
  5262. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5263. var countryData2 = new
  5264. {
  5265. CountryName = item,
  5266. CityData = cityData1
  5267. };
  5268. dataSource.Add(countryData2);
  5269. }
  5270. return Ok(JsonView(true, "查询成功!", dataSource));
  5271. }
  5272. /// <summary>
  5273. /// 团组模块 - 出入境国家费用标准 Page List
  5274. /// </summary>
  5275. /// <returns></returns>
  5276. [HttpPost]
  5277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5278. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5279. {
  5280. int portId = dto.PortType;
  5281. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5282. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5283. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5284. string whereSql = string.Empty;
  5285. if (!string.IsNullOrEmpty(dto.Country))
  5286. {
  5287. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5288. }
  5289. if (!string.IsNullOrEmpty(dto.City))
  5290. {
  5291. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5292. }
  5293. string pageSql = string.Format(@"Select * From (
  5294. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5295. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5296. From Grp_NationalTravelFee gntf
  5297. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5298. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5299. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5300. RefAsync<int> total = 0;
  5301. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5302. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5303. }
  5304. /// <summary>
  5305. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5306. /// </summary>
  5307. /// <returns></returns>
  5308. [HttpPost]
  5309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5310. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5311. {
  5312. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5313. int portId = dto.PortType;
  5314. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5315. string whereSql = string.Empty;
  5316. if (!string.IsNullOrEmpty(dto.Country))
  5317. {
  5318. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5319. }
  5320. if (!string.IsNullOrEmpty(dto.City))
  5321. {
  5322. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5323. }
  5324. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5325. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5326. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5327. From Grp_NationalTravelFee gntf
  5328. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5329. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5330. Where gntf.Isdel = 0 {0} ", whereSql);
  5331. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5332. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5333. }
  5334. /// <summary>
  5335. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5336. /// </summary>
  5337. /// <returns></returns>
  5338. [HttpPost]
  5339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5340. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5341. {
  5342. try
  5343. {
  5344. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5345. if (data.Code != 0)
  5346. {
  5347. return Ok(JsonView(false, data.Msg));
  5348. }
  5349. return Ok(JsonView(true, "操作成功!", data.Data));
  5350. }
  5351. catch (Exception ex)
  5352. {
  5353. return Ok(JsonView(false, ex.Message));
  5354. }
  5355. }
  5356. /// <summary>
  5357. /// 团组模块 - 出入境国家费用标准 - Del
  5358. /// </summary>
  5359. /// <returns></returns>
  5360. [HttpPost]
  5361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5362. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5363. {
  5364. try
  5365. {
  5366. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5367. {
  5368. Id = dto.Id,
  5369. DeleteUserId = dto.DeleteUserId,
  5370. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5371. IsDel = 1
  5372. };
  5373. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5374. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5375. .WhereColumns(it => new { it.Id })
  5376. .ExecuteCommandAsync();
  5377. if (delStatus <= 0)
  5378. {
  5379. return Ok(JsonView(false, "删除失败!"));
  5380. }
  5381. return Ok(JsonView(true, "操作成功!"));
  5382. }
  5383. catch (Exception ex)
  5384. {
  5385. return Ok(JsonView(false, ex.Message));
  5386. }
  5387. }
  5388. #endregion
  5389. #region 签证费用录入
  5390. /// <summary>
  5391. /// 根据diid查询签证费用列表
  5392. /// </summary>
  5393. /// <param name="dto"></param>
  5394. /// <returns></returns>
  5395. [HttpPost]
  5396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5397. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5398. {
  5399. try
  5400. {
  5401. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5402. if (groupData.Code != 0)
  5403. {
  5404. return Ok(JsonView(false, groupData.Msg));
  5405. }
  5406. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5407. }
  5408. catch (Exception ex)
  5409. {
  5410. return Ok(JsonView(false, ex.Message));
  5411. }
  5412. }
  5413. /// <summary>
  5414. /// 根据签证费用Id查询单条数据及c表数据
  5415. /// </summary>
  5416. /// <param name="dto"></param>
  5417. /// <returns></returns>
  5418. [HttpPost]
  5419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5420. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5421. {
  5422. try
  5423. {
  5424. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5425. if (groupData.Code != 0)
  5426. {
  5427. return Ok(JsonView(false, groupData.Msg));
  5428. }
  5429. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5430. }
  5431. catch (Exception ex)
  5432. {
  5433. return Ok(JsonView(false, ex.Message));
  5434. }
  5435. }
  5436. /// <summary>
  5437. /// 签证费用删除
  5438. /// </summary>
  5439. /// <param name="dto"></param>
  5440. /// <returns></returns>
  5441. [HttpPost]
  5442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5443. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5444. {
  5445. _sqlSugar.BeginTran();
  5446. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5447. if (!res)
  5448. {
  5449. _sqlSugar.RollbackTran();
  5450. return Ok(JsonView(false, "删除失败"));
  5451. }
  5452. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5453. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5454. .SetColumns(a => new Grp_CreditCardPayment()
  5455. {
  5456. IsDel = 1,
  5457. DeleteUserId = dto.DeleteUserId,
  5458. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5459. }).ExecuteCommand();
  5460. if (resSub < 1)
  5461. {
  5462. _sqlSugar.RollbackTran();
  5463. return Ok(JsonView(false, "删除失败"));
  5464. }
  5465. _sqlSugar.CommitTran();
  5466. return Ok(JsonView(true, "删除成功!"));
  5467. }
  5468. /// <summary>
  5469. /// 签证费用录入下拉框初始化
  5470. /// </summary>
  5471. /// <returns></returns>
  5472. [HttpPost]
  5473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5474. public async Task<IActionResult> VisaPriceAddSelect()
  5475. {
  5476. try
  5477. {
  5478. //支付方式
  5479. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5480. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5481. //币种
  5482. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5483. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5484. //乘客类型
  5485. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5486. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5487. //卡类型
  5488. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5489. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5490. var data = new
  5491. {
  5492. Payment = _Payment,
  5493. CurrencyList = _CurrencyList,
  5494. PassengerType = _PassengerType,
  5495. BankCard = _BankCard
  5496. };
  5497. return Ok(JsonView(true, "查询成功!", data));
  5498. }
  5499. catch (Exception ex)
  5500. {
  5501. return Ok(JsonView(false, "程序错误!"));
  5502. throw;
  5503. }
  5504. }
  5505. /// <summary>
  5506. /// 签证费用录入操作(Status:1.新增,2.修改)
  5507. /// </summary>
  5508. /// <param name="dto"></param>
  5509. /// <returns></returns>
  5510. [HttpPost]
  5511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5512. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5513. {
  5514. try
  5515. {
  5516. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5517. if (groupData.Code != 0)
  5518. {
  5519. return Ok(JsonView(false, groupData.Msg));
  5520. }
  5521. #region 应用推送
  5522. try
  5523. {
  5524. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5525. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5526. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5527. }
  5528. catch (Exception ex)
  5529. {
  5530. }
  5531. #endregion
  5532. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5533. }
  5534. catch (Exception ex)
  5535. {
  5536. return Ok(JsonView(false, ex.Message));
  5537. }
  5538. }
  5539. #endregion
  5540. #region 签证提成录入
  5541. /// <summary>
  5542. /// 签证提成录入
  5543. /// 基础数据
  5544. /// </summary>
  5545. /// <param name="_dto"></param>
  5546. /// <returns></returns>
  5547. [HttpGet]
  5548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5549. public async Task<IActionResult> VisaCommissionInit()
  5550. {
  5551. return Ok(await _visaCommissionRep._Init());
  5552. }
  5553. /// <summary>
  5554. /// 签证提成录入
  5555. /// Item
  5556. /// </summary>
  5557. /// <param name="_dto"></param>
  5558. /// <returns></returns>
  5559. [HttpGet]
  5560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5561. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto dto)
  5562. {
  5563. var validator = new VisaCommissionItemDtoValidator();
  5564. var validatorRes = await validator.ValidateAsync(dto);
  5565. if (!validatorRes.IsValid)
  5566. {
  5567. StringBuilder sb = new StringBuilder();
  5568. foreach (var item in validatorRes.Errors)
  5569. {
  5570. sb.AppendLine(item.ErrorMessage);
  5571. }
  5572. return Ok(JsonView(false, sb.ToString()));
  5573. }
  5574. return Ok(await _visaCommissionRep._Init());
  5575. }
  5576. #endregion
  5577. #region op费用录入
  5578. /// <summary>
  5579. /// 根据diid查询op费用列表
  5580. /// </summary>
  5581. /// <param name="dto"></param>
  5582. /// <returns></returns>
  5583. [HttpPost]
  5584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5585. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5586. {
  5587. try
  5588. {
  5589. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5590. if (groupData.Code != 0)
  5591. {
  5592. return Ok(JsonView(false, groupData.Msg));
  5593. }
  5594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5595. }
  5596. catch (Exception ex)
  5597. {
  5598. return Ok(JsonView(false, ex.Message));
  5599. }
  5600. }
  5601. /// <summary>
  5602. /// 根据op费用Id查询单条数据及c表数据
  5603. /// </summary>
  5604. /// <param name="dto"></param>
  5605. /// <returns></returns>
  5606. [HttpPost]
  5607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5608. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5609. {
  5610. try
  5611. {
  5612. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5613. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5614. var data = new
  5615. {
  5616. CarTouristGuideGround = _groupData,
  5617. CreditCardPayment = _creditCardPayment
  5618. };
  5619. return Ok(JsonView(true, "查询成功!", data));
  5620. }
  5621. catch (Exception ex)
  5622. {
  5623. return Ok(JsonView(false, "程序错误!"));
  5624. }
  5625. }
  5626. /// <summary>
  5627. /// op费用删除
  5628. /// </summary>
  5629. /// <param name="dto"></param>
  5630. /// <returns></returns>
  5631. [HttpPost]
  5632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5633. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5634. {
  5635. try
  5636. {
  5637. _sqlSugar.BeginTran();
  5638. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5639. if (!res)
  5640. {
  5641. return Ok(JsonView(false, "删除失败"));
  5642. }
  5643. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5644. {
  5645. IsDel = 1,
  5646. DeleteUserId = dto.DeleteUserId,
  5647. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5648. }).ExecuteCommandAsync();
  5649. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5650. {
  5651. IsDel = 1,
  5652. DeleteUserId = dto.DeleteUserId,
  5653. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5654. }).ExecuteCommandAsync();
  5655. #region 删除超支相关数据
  5656. //删除导入的超支数据
  5657. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5658. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5659. {
  5660. IsDel = 1,
  5661. DeleteUserId = dto.DeleteUserId,
  5662. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5663. }).ExecuteCommand();
  5664. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5665. {
  5666. IsDel = 1,
  5667. DeleteUserId = dto.DeleteUserId,
  5668. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5669. }).ExecuteCommand() ;
  5670. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5671. {
  5672. IsDel = 1,
  5673. DeleteUserId = dto.DeleteUserId,
  5674. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5675. }).ExecuteCommand();
  5676. #endregion
  5677. _sqlSugar.CommitTran();
  5678. return Ok(JsonView(true, "删除成功!"));
  5679. }
  5680. catch (Exception ex)
  5681. {
  5682. _sqlSugar.RollbackTran();
  5683. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5684. }
  5685. }
  5686. /// <summary>
  5687. /// op费用录入操作(Status:1.新增,2.修改)
  5688. /// </summary>
  5689. /// <param name="dto"></param>
  5690. /// <returns></returns>
  5691. [HttpPost]
  5692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5693. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5694. {
  5695. try
  5696. {
  5697. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5698. if (groupData.Code != 0)
  5699. {
  5700. return Ok(JsonView(false, groupData.Msg));
  5701. }
  5702. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5703. }
  5704. catch (Exception ex)
  5705. {
  5706. return Ok(JsonView(false, ex.Message));
  5707. }
  5708. }
  5709. /// <summary>
  5710. /// 填写费用详细页面初始化绑定
  5711. /// </summary>
  5712. /// <param name="dto"></param>
  5713. /// <returns></returns>
  5714. [HttpPost]
  5715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5716. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5717. {
  5718. try
  5719. {
  5720. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5721. if (groupData.Code != 0)
  5722. {
  5723. return Ok(JsonView(false, groupData.Msg));
  5724. }
  5725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5726. }
  5727. catch (Exception ex)
  5728. {
  5729. return Ok(JsonView(false, ex.Message));
  5730. }
  5731. }
  5732. /// <summary>
  5733. /// 根据op费用Id查询详细数据
  5734. /// </summary>
  5735. /// <param name="dto"></param>
  5736. /// <returns></returns>
  5737. [HttpPost]
  5738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5739. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5740. {
  5741. try
  5742. {
  5743. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5744. if (groupData.Code != 0)
  5745. {
  5746. return Ok(JsonView(false, groupData.Msg));
  5747. }
  5748. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5749. }
  5750. catch (Exception ex)
  5751. {
  5752. return Ok(JsonView(false, ex.Message));
  5753. }
  5754. }
  5755. /// <summary>
  5756. /// OP费用录入填写详情
  5757. /// </summary>
  5758. /// <param name="dto"></param>
  5759. /// <returns></returns>
  5760. [HttpPost]
  5761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5762. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5763. {
  5764. try
  5765. {
  5766. #region 参数校验
  5767. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5768. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5769. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5770. #endregion
  5771. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5772. if (groupData.Code != 0)
  5773. {
  5774. return Ok(JsonView(false, groupData.Msg));
  5775. }
  5776. //自动审核
  5777. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5778. #region 应用推送
  5779. try
  5780. {
  5781. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5782. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5783. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5784. }
  5785. catch (Exception ex)
  5786. {
  5787. }
  5788. #endregion
  5789. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5790. }
  5791. catch (Exception ex)
  5792. {
  5793. return Ok(JsonView(false, ex.Message));
  5794. }
  5795. }
  5796. /// <summary>
  5797. /// 获取三公详细所有城市
  5798. /// </summary>
  5799. /// <returns></returns>
  5800. [HttpGet]
  5801. public IActionResult OpCarCityResult()
  5802. {
  5803. var jw = JsonView(false);
  5804. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5805. {
  5806. x.Id,
  5807. x.Country,
  5808. x.City,
  5809. }).ToList();
  5810. if (data.Count > 0)
  5811. {
  5812. jw = JsonView(true, "获取成功!", data);
  5813. }
  5814. else
  5815. {
  5816. jw.Msg = "城市数据为空!";
  5817. jw.Data = new string[0];
  5818. }
  5819. return Ok(jw);
  5820. }
  5821. /// <summary>
  5822. /// 导出地接费用明细
  5823. /// </summary>
  5824. /// <param name="dto"></param>
  5825. /// <returns></returns>
  5826. [HttpPost]
  5827. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5828. {
  5829. var jw = JsonView(false);
  5830. if (dto.Diid < 1)
  5831. {
  5832. jw.Msg = "请输入正确的diid!";
  5833. return Ok(jw);
  5834. }
  5835. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5836. if (group == null)
  5837. {
  5838. jw.Msg = "未找到团组信息!";
  5839. return Ok(jw);
  5840. }
  5841. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5842. if (localGuideArr.Count == 0)
  5843. {
  5844. jw.Msg = "该团组暂无地接信息!";
  5845. return Ok(jw);
  5846. }
  5847. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5848. var overspendSoure = new Dictionary<int, int>
  5849. {
  5850. { 91, 982 }, //车
  5851. { 92 , 1059} ,//导游
  5852. { 994 , 1073}, //翻译
  5853. { 988 , 1074 }, //早餐
  5854. { 93 , 1075 }, //午餐
  5855. { 989 , 1076 }, //晚餐
  5856. };
  5857. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5858. foreach (var groupArr in localGroup)
  5859. {
  5860. var keyValue = groupArr.Key;
  5861. if (int.TryParse(keyValue, out int cityid))
  5862. {
  5863. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5864. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5865. }
  5866. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5867. foreach (var item in groupArr)
  5868. {
  5869. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5870. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5871. new Grp_CarTouristGuideGroundReservationsContentExtend
  5872. {
  5873. Count = a.Count,
  5874. CreateTime = a.CreateTime,
  5875. CreateUserId = a.CreateUserId,
  5876. CTGGRId = a.CTGGRId,
  5877. Currency = a.Currency,
  5878. DatePrice = a.DatePrice,
  5879. DeleteTime = a.DeleteTime,
  5880. DeleteUserId = a.DeleteUserId,
  5881. DiId = a.DiId,
  5882. Id = a.Id,
  5883. IsDel = a.IsDel,
  5884. Price = a.Price,
  5885. PriceContent = a.PriceContent,
  5886. Remark = a.Remark,
  5887. SId = a.SId,
  5888. SidName = b.Name,
  5889. Units = a.Units,
  5890. }
  5891. ).ToList();
  5892. if (content.Count > 0)
  5893. {
  5894. contentArr.Add(content);
  5895. }
  5896. }
  5897. //open excel
  5898. //set excel
  5899. //save excel
  5900. try
  5901. {
  5902. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5903. IWorkbook workbook;
  5904. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5905. {
  5906. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5907. }
  5908. else
  5909. {
  5910. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5911. }
  5912. ISheet sheet = workbook.GetSheetAt(0);
  5913. var rowStartIndex = 2;
  5914. var clounmCount = 10;
  5915. var initStyleRow = sheet.GetRow(2);
  5916. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5917. //var overspendArrDetail =
  5918. var existsId = new List<CarCompare>();
  5919. var lastElem = arr.Last();
  5920. var thisSid = -1;
  5921. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5922. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5923. {
  5924. Name = "未知币种!",
  5925. Remark = "未知币种!",
  5926. };
  5927. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5928. Action cloneRowFn = () =>
  5929. {
  5930. rowStartIndex++;
  5931. var cloneRow = sheet.CreateRow(rowStartIndex);
  5932. // 复制样式
  5933. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5934. {
  5935. ICell sourceCell = initStyleRow.GetCell(i);
  5936. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5937. // 确保单元格存在样式
  5938. if (sourceCell.CellStyle != null)
  5939. {
  5940. targetCell.CellStyle = sourceCell.CellStyle;
  5941. }
  5942. }
  5943. };
  5944. var mergeRow = () =>
  5945. {
  5946. for (int i = 2; i < sheet.LastRowNum; i++)
  5947. {
  5948. var row = sheet.GetRow(i);
  5949. var cellFirst = row.GetCell(0);
  5950. var thisIndex = i + 1;
  5951. while (thisIndex < sheet.LastRowNum)
  5952. {
  5953. var nextRow = sheet.GetRow(thisIndex);
  5954. var nextCellFirst = nextRow.GetCell(0);
  5955. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5956. {
  5957. thisIndex++;
  5958. }
  5959. else
  5960. {
  5961. break;
  5962. }
  5963. }
  5964. thisIndex--;
  5965. if (thisIndex != i)
  5966. {
  5967. //合并row
  5968. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5969. i, // 起始行索引(0-based)
  5970. thisIndex, // 结束行索引(0-based)
  5971. 0, // 起始列索引(0-based)
  5972. 0 // 结束列索引(0-based)
  5973. );
  5974. sheet.AddMergedRegion(cellRangeAddress);
  5975. i = thisIndex;
  5976. }
  5977. }
  5978. };
  5979. var chaoshiNumber = 0;
  5980. var totalNumber = 0.00M;
  5981. string lastStr = "";
  5982. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5983. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5984. {
  5985. b.IsAuditGM,
  5986. x.Id,
  5987. x.Area,
  5988. b.PayPercentage,
  5989. b.PayMoney,
  5990. }).ToList();
  5991. string yesPayment = "", noPayment = "";
  5992. foreach (var item in queryCarArrByCityAndDiid)
  5993. {
  5994. if (item.IsAuditGM == 1)
  5995. {
  5996. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5997. }
  5998. else
  5999. {
  6000. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6001. }
  6002. }
  6003. lastStr = yesPayment + noPayment;
  6004. foreach (var item in arr)
  6005. {
  6006. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6007. {
  6008. if (thisSid != item.SId)
  6009. {
  6010. if (thisSid == -1)
  6011. {
  6012. thisSid = item.SId;
  6013. }
  6014. else
  6015. {
  6016. //合并小计行
  6017. //创建合并区域的实例
  6018. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6019. rowStartIndex, // 起始行索引(0-based)
  6020. rowStartIndex, // 结束行索引(0-based)
  6021. 0, // 起始列索引(0-based)
  6022. 3 // 结束列索引(0-based)
  6023. );
  6024. sheet.AddMergedRegion(cellRangeAddress);
  6025. var CellStyle = workbook.CreateCellStyle();
  6026. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6027. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6028. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6029. for (int i = 0; i <= clounmCount; i++)
  6030. {
  6031. if (i > 6)
  6032. {
  6033. var CellStyle1 = workbook.CreateCellStyle();
  6034. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6035. IFont Font = workbook.CreateFont(); // 创建字体
  6036. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6037. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6038. CellStyle1.SetFont(Font);
  6039. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6040. }
  6041. else
  6042. {
  6043. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6044. }
  6045. }
  6046. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6047. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6048. //超时合计
  6049. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6050. //超时数
  6051. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6052. //超时合计费用
  6053. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6054. thisSid = item.SId;
  6055. cloneRowFn();
  6056. chaoshiNumber = 0;
  6057. totalNumber = 0;
  6058. }
  6059. }
  6060. IRow row = sheet.GetRow(rowStartIndex);
  6061. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6062. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6063. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6064. if (isOpenOverspendSoure)
  6065. {
  6066. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6067. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6068. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6069. }
  6070. for (int i = 0; i <= clounmCount; i++)
  6071. {
  6072. var cell = row.GetCell(i);
  6073. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6074. if (cell == null)
  6075. {
  6076. cell = row.CreateCell(i);
  6077. }
  6078. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6079. fontRed.CloneStyleFrom(cell.CellStyle);
  6080. IFont Font = workbook.CreateFont(); // 创建字体
  6081. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6082. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6083. fontRed.SetFont(Font);
  6084. byte[] rgb = new byte[3] { 255, 242, 204 };
  6085. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6086. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6087. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6088. if (workbook is XSSFWorkbook)
  6089. {
  6090. BackgroundColor255_242_204.FillForegroundColor = 0;
  6091. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6092. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6093. }
  6094. else
  6095. {
  6096. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6097. }
  6098. if (i == 1 || i > 6)
  6099. {
  6100. if (i > 6)
  6101. {
  6102. fontRed.FillForegroundColor = 0;
  6103. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6104. fontRed.FillPattern = FillPattern.SolidForeground;
  6105. }
  6106. cell.CellStyle = fontRed;
  6107. }
  6108. if (i > 2 && i < 7)
  6109. {
  6110. cell.CellStyle = BackgroundColor255_242_204;
  6111. }
  6112. cell.SetCellValue(setCellValue); //写入单元格
  6113. }
  6114. if (overspendSoure.ContainsKey(thisSid))
  6115. {
  6116. var overspendId = overspendSoure[thisSid];
  6117. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6118. }
  6119. cloneRowFn();
  6120. existsId.Add(new CarCompare
  6121. {
  6122. DataPrice = item.DatePrice.ObjToDate(),
  6123. Sid = item.SId
  6124. });
  6125. }
  6126. if (item.Equals(lastElem))
  6127. {
  6128. //合并小计行
  6129. //创建合并区域的实例
  6130. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6131. rowStartIndex, // 起始行索引(0-based)
  6132. rowStartIndex, // 结束行索引(0-based)
  6133. 0, // 起始列索引(0-based)
  6134. 3 // 结束列索引(0-based)
  6135. );
  6136. sheet.AddMergedRegion(cellRangeAddress);
  6137. var CellStyle = workbook.CreateCellStyle();
  6138. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6139. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6140. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6141. for (int i = 0; i <= clounmCount; i++)
  6142. {
  6143. if (i > 6)
  6144. {
  6145. var CellStyle1 = workbook.CreateCellStyle();
  6146. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6147. IFont Font = workbook.CreateFont(); // 创建字体
  6148. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6149. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6150. CellStyle1.SetFont(Font);
  6151. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6152. }
  6153. else
  6154. {
  6155. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6156. }
  6157. }
  6158. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6159. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6160. //超时合计
  6161. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6162. //超时数
  6163. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6164. //超时合计费用
  6165. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6166. cloneRowFn();
  6167. // 创建合并区域的实例
  6168. cellRangeAddress = new CellRangeAddress(
  6169. rowStartIndex, // 起始行索引(0-based)
  6170. rowStartIndex, // 结束行索引(0-based)
  6171. 0, // 起始列索引(0-based)
  6172. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6173. );
  6174. // 添加合并区域
  6175. sheet.AddMergedRegion(cellRangeAddress);
  6176. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6177. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6178. }
  6179. }
  6180. mergeRow();
  6181. // 保存修改后的Excel文件到新文件
  6182. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6183. // new FileStream(newFilePath, FileMode.CreateNew)
  6184. using (var stream = new MemoryStream())
  6185. {
  6186. workbook.Write(stream, true);
  6187. stream.Flush();
  6188. stream.Seek(0, SeekOrigin.Begin);
  6189. MemoryStream memoryStream = new MemoryStream();
  6190. stream.CopyTo(memoryStream);
  6191. memoryStream.Seek(0, SeekOrigin.Begin);
  6192. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6193. }
  6194. workbook.Close();
  6195. workbook.Dispose();
  6196. }
  6197. catch (Exception ex)
  6198. {
  6199. jw.Msg = "出现异常!" + ex.Message;
  6200. return Ok(jw);
  6201. }
  6202. }
  6203. if (Zips.Count > 0)
  6204. {
  6205. IOOperatorHelper io = new IOOperatorHelper();
  6206. var byts = io.ConvertZipStream(Zips);
  6207. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6208. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6209. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6210. }
  6211. else
  6212. {
  6213. jw.Msg = "暂无生成文件!";
  6214. }
  6215. return Ok(jw);
  6216. }
  6217. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6218. {
  6219. string outStr = string.Empty;
  6220. switch (i)
  6221. {
  6222. case 0:
  6223. outStr = arr[0].SidName;
  6224. break;
  6225. case 1:
  6226. outStr = arr[0].DataPriceStr;
  6227. break;
  6228. case 2:
  6229. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6230. break;
  6231. case 4:
  6232. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6233. break;
  6234. case 7:
  6235. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6236. {
  6237. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6238. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6239. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6240. }
  6241. break;
  6242. case 8:
  6243. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6244. {
  6245. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6246. }
  6247. break;
  6248. case 9:
  6249. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6250. {
  6251. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6252. }
  6253. break;
  6254. case 10:
  6255. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6256. {
  6257. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6258. }
  6259. break;
  6260. }
  6261. return outStr;
  6262. }
  6263. #region OP行程单
  6264. /// <summary>
  6265. /// OP行程单初始化
  6266. /// </summary>
  6267. /// <param name="dto"></param>
  6268. /// <returns></returns>
  6269. [HttpPost]
  6270. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6271. {
  6272. var jw = JsonView(false);
  6273. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6274. var group = groupList.First();
  6275. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6276. if (group == null)
  6277. {
  6278. jw.Msg = "暂无团组!";
  6279. return Ok(jw);
  6280. }
  6281. group = groupList.Find(x => x.Id == diid);
  6282. if (group == null)
  6283. {
  6284. jw.Msg = "请输入正确的团组ID!";
  6285. return Ok(jw);
  6286. }
  6287. string city = string.Empty;
  6288. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6289. if (blackCode.Count > 0)
  6290. {
  6291. var black = blackCode.First();
  6292. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6293. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6294. if (blackSp.Length > 0)
  6295. {
  6296. try
  6297. {
  6298. var cityArrCode = new List<string>(20);
  6299. foreach (var item in blackSp)
  6300. {
  6301. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6302. var IndexSelect = itemSp[2];
  6303. var cityArrCodeLength = cityArrCode.Count - 1;
  6304. var startCity = IndexSelect.Substring(0, 3);
  6305. if (cityArrCodeLength > 0)
  6306. {
  6307. var arrEndCity = cityArrCode[cityArrCodeLength];
  6308. if (arrEndCity != startCity)
  6309. {
  6310. cityArrCode.Add(startCity.ToUpper());
  6311. }
  6312. }
  6313. else
  6314. {
  6315. cityArrCode.Add(startCity.ToUpper());
  6316. }
  6317. var endCity = IndexSelect.Substring(3, 3);
  6318. cityArrCode.Add(endCity.ToUpper());
  6319. }
  6320. var cityThree = string.Empty;
  6321. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6322. cityThree = cityThree.TrimEnd(',');
  6323. if (string.IsNullOrWhiteSpace(cityThree))
  6324. {
  6325. throw new
  6326. Exception("error");
  6327. }
  6328. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6329. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6330. foreach (var item in cityArrCode)
  6331. {
  6332. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6333. if (find != null)
  6334. {
  6335. city += find.City + "/";
  6336. }
  6337. else
  6338. {
  6339. city += item + "三字码未收入/";
  6340. }
  6341. }
  6342. city = city.TrimEnd('/');
  6343. }
  6344. catch (Exception e)
  6345. {
  6346. city = "黑屏代码格式不正确!";
  6347. }
  6348. }
  6349. }
  6350. else
  6351. {
  6352. city = "未录入黑屏代码";
  6353. }
  6354. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6355. {
  6356. Date = x.Date,
  6357. Days = x.Days,
  6358. Diffgroup = x.Diffgroup,
  6359. Diid = x.Diid,
  6360. Traffic_First = x.Traffic_First,
  6361. Traffic_Second = x.Traffic_Second,
  6362. Trip = x.Trip,
  6363. WeekDay = x.WeekDay,
  6364. Id = x.Id
  6365. }).ToList();
  6366. jw.Data = new
  6367. {
  6368. groupList = groupList.Select(x => new
  6369. {
  6370. x.Id,
  6371. x.TeamName,
  6372. x.TourCode
  6373. }).ToList(),
  6374. groupInfo = new
  6375. {
  6376. group.VisitDays,
  6377. group.TourCode,
  6378. group.VisitPNumber,
  6379. group.TeamName,
  6380. city
  6381. },
  6382. OpTravelList
  6383. };
  6384. jw.Code = 200;
  6385. jw.Msg = "操作成功!";
  6386. return Ok(jw);
  6387. }
  6388. /// <summary>
  6389. /// 删除团组行程单
  6390. /// </summary>
  6391. /// <returns></returns>
  6392. [HttpPost]
  6393. public IActionResult DelTravel(DelOpTravelDto dto)
  6394. {
  6395. var jw = JsonView(false);
  6396. if (dto.UserId <= 0 || dto.Diid <= 0)
  6397. {
  6398. jw.Msg = "请输入正确的参数!";
  6399. return Ok(jw);
  6400. }
  6401. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6402. .SetColumns(x => new Grp_TravelList
  6403. {
  6404. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6405. DeleteUserId = dto.UserId,
  6406. IsDel = 1,
  6407. }).ExecuteCommand();
  6408. jw = JsonView(true);
  6409. return Ok(jw);
  6410. }
  6411. /// <summary>
  6412. /// 行程单保存
  6413. /// </summary>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. public IActionResult TravelSave(TravelSaveDto dto)
  6417. {
  6418. var jw = JsonView(false);
  6419. if (dto.Arr.Count > 0)
  6420. {
  6421. try
  6422. {
  6423. _sqlSugar.BeginTran();
  6424. foreach (var item in dto.Arr)
  6425. {
  6426. if (item.Id == 0)
  6427. {
  6428. throw new Exception("请传入正确的Id");
  6429. }
  6430. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6431. .SetColumns(x => new Grp_TravelList
  6432. {
  6433. Trip = item.Trip
  6434. }).ExecuteCommand();
  6435. }
  6436. _sqlSugar.CommitTran();
  6437. jw = JsonView(true);
  6438. }
  6439. catch (Exception ex)
  6440. {
  6441. _sqlSugar.RollbackTran();
  6442. jw.Msg = "程序异常!" + ex.Message;
  6443. }
  6444. }
  6445. else
  6446. {
  6447. jw.Msg = "请传入正确的参数!";
  6448. }
  6449. return Ok(jw);
  6450. }
  6451. /// <summary>
  6452. /// 导出行程单
  6453. /// </summary>
  6454. /// <param name="dto"></param>
  6455. /// <returns></returns>
  6456. [HttpPost]
  6457. public IActionResult ExportTravel(ExportTravelDto dto)
  6458. {
  6459. var jw = JsonView(false);
  6460. jw.Data = "";
  6461. int diid = 0;
  6462. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6463. if (Find == null)
  6464. {
  6465. jw.Msg = "请选择正确的团组!";
  6466. return Ok(jw);
  6467. }
  6468. else
  6469. {
  6470. diid = Find.Id;
  6471. }
  6472. //数据源
  6473. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6474. DataTable dtBlack = null;
  6475. try
  6476. {
  6477. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6478. }
  6479. catch (Exception)
  6480. {
  6481. jw.Msg = "机票黑屏代码有误!";
  6482. return Ok(jw);
  6483. }
  6484. string CityStr = string.Empty;
  6485. if (dtBlack.Rows.Count == 0)
  6486. {
  6487. jw.Msg = "机票黑屏代码有误!";
  6488. return Ok(jw);
  6489. }
  6490. else
  6491. {
  6492. foreach (DataRow row in dtBlack.Rows)
  6493. {
  6494. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6495. {
  6496. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6497. return Ok(jw);
  6498. }
  6499. }
  6500. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6501. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6502. }
  6503. //创建数据源Table
  6504. DataTable dtSource = new DataTable();
  6505. dtSource.Columns.Add("Days", typeof(string));
  6506. dtSource.Columns.Add("Date", typeof(string));
  6507. dtSource.Columns.Add("Week", typeof(string));
  6508. dtSource.Columns.Add("Traffic", typeof(string));
  6509. dtSource.Columns.Add("Trip", typeof(string));
  6510. //获取数据,放到datatable
  6511. foreach (var item in _travelList)
  6512. {
  6513. DataRow dr = dtSource.NewRow();
  6514. dr["Days"] = item.Days;
  6515. dr["Date"] = item.Date;
  6516. dr["Week"] = item.WeekDay;
  6517. dr["Traffic"] = item.Traffic_First
  6518. + "\r\n"
  6519. + item.Traffic_Second;
  6520. dr["Trip"] = item.Trip;
  6521. dtSource.Rows.Add(dr);
  6522. }
  6523. Dictionary<string, string> dic = new Dictionary<string, string>();
  6524. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6525. dic.Add("City", CityStr);
  6526. dic.Add("Days", Find.VisitDays.ToString());
  6527. dic.Add("DeleCode", Find.TourCode);
  6528. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6529. //模板路径
  6530. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6531. //载入模板
  6532. Document doc = null;
  6533. DocumentBuilder builder = null;
  6534. try
  6535. {
  6536. //载入模板
  6537. doc = new Document(tempPath);
  6538. builder = new DocumentBuilder(doc);
  6539. }
  6540. catch (Exception)
  6541. {
  6542. jw.Msg = "模板位置不存在!";
  6543. return Ok(jw);
  6544. }
  6545. foreach (var key in dic.Keys)
  6546. {
  6547. Bookmark bookmark = doc.Range.Bookmarks[key];
  6548. if (bookmark != null)
  6549. {
  6550. builder.MoveToBookmark(key);
  6551. builder.Write(dic[key]);
  6552. }
  6553. }
  6554. //获取word里所有表格
  6555. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6556. //获取所填表格的序数
  6557. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6558. try
  6559. {
  6560. //循环赋值
  6561. for (int i = 0; i < dtSource.Rows.Count; i++)
  6562. {
  6563. builder.MoveToCell(0, i + 1, 0, 0);
  6564. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6565. builder.MoveToCell(0, i + 1, 1, 0);
  6566. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6567. builder.MoveToCell(0, i + 1, 2, 0);
  6568. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6569. var trip = dtSource.Rows[i]["Trip"].ToString();
  6570. builder.MoveToCell(0, i + 1, 3, 0);
  6571. builder.Write(trip);
  6572. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6573. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6574. // 获取特定索引的段落
  6575. Paragraph paragraph = (Paragraph)paragraphs[0];
  6576. Run run = paragraph.Runs[0];
  6577. Aspose.Words.Font font = run.Font;
  6578. font.Name = "黑体";
  6579. //设置双休红色
  6580. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6581. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6582. paragraph = (Paragraph)paragraphs[1];
  6583. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6584. {
  6585. run = paragraph.Runs[0];
  6586. font = run.Font;
  6587. font.Color = Color.Red;
  6588. }
  6589. }
  6590. }
  6591. catch (Exception ex)
  6592. {
  6593. }
  6594. //删除多余行
  6595. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6596. {
  6597. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6598. }
  6599. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6600. if (!Directory.Exists(savePath))
  6601. {
  6602. try
  6603. {
  6604. Directory.CreateDirectory(savePath);
  6605. }
  6606. catch
  6607. {
  6608. }
  6609. }
  6610. string path = savePath + Find.TeamName + "出访日程";
  6611. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6612. try
  6613. {
  6614. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6615. string postfix = ".docx";
  6616. if (dto.IsPDF == 1)
  6617. {
  6618. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6619. postfix = ".pdf";
  6620. }
  6621. doc.Save(path + postfix, saveFormat);
  6622. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6623. }
  6624. catch (Exception)
  6625. {
  6626. jw = JsonView(false);
  6627. }
  6628. return Ok(jw);
  6629. }
  6630. /// <summary>
  6631. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6632. /// </summary>
  6633. /// <param name="num"></param>
  6634. /// <returns></returns>
  6635. string GetNum(string num)
  6636. {
  6637. string str = "";
  6638. switch (num)
  6639. {
  6640. case "1":
  6641. str = "一";
  6642. break;
  6643. case "2":
  6644. str = "二";
  6645. break;
  6646. case "3":
  6647. str = "三";
  6648. break;
  6649. case "4":
  6650. str = "四";
  6651. break;
  6652. case "5":
  6653. str = "五";
  6654. break;
  6655. case "6":
  6656. str = "六";
  6657. break;
  6658. case "7":
  6659. str = "七";
  6660. break;
  6661. case "8":
  6662. str = "八";
  6663. break;
  6664. case "9":
  6665. str = "九";
  6666. break;
  6667. case "10":
  6668. str = "十";
  6669. break;
  6670. case "11":
  6671. str = "十一";
  6672. break;
  6673. case "12":
  6674. str = "十二";
  6675. break;
  6676. case "一":
  6677. str = "1";
  6678. break;
  6679. case "二":
  6680. str = "2";
  6681. break;
  6682. case "三":
  6683. str = "3";
  6684. break;
  6685. case "四":
  6686. str = "4";
  6687. break;
  6688. case "五":
  6689. str = "5";
  6690. break;
  6691. case "六":
  6692. str = "6";
  6693. break;
  6694. case "七":
  6695. str = "7";
  6696. break;
  6697. case "八":
  6698. str = "8";
  6699. break;
  6700. case "九":
  6701. str = "9";
  6702. break;
  6703. case "十":
  6704. str = "10";
  6705. break;
  6706. case "十一":
  6707. str = "11";
  6708. break;
  6709. case "十二":
  6710. str = "12";
  6711. break;
  6712. }
  6713. return str;
  6714. }
  6715. #endregion
  6716. #endregion
  6717. #region 团组成本
  6718. /// <summary>
  6719. /// 团组成本数据初始化
  6720. /// </summary>
  6721. /// <param name="dto"></param>
  6722. /// <returns></returns>
  6723. [HttpPost]
  6724. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6725. {
  6726. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6727. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6728. WHEN COUNT(*) >= 0 THEN 'True'
  6729. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6730. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6731. ").ToList(); //团组列表
  6732. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6733. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6734. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6735. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6736. if (groupinfoValue != null)
  6737. {
  6738. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6739. var spArr = new string[1] { countryArr };
  6740. if (countryArr.Contains("|"))
  6741. {
  6742. spArr = countryArr.Split("|");
  6743. }
  6744. else if (countryArr.Contains("、"))
  6745. {
  6746. spArr = countryArr.Split("、");
  6747. }
  6748. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6749. {
  6750. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6751. if (dbQueryCountry != null)
  6752. {
  6753. visaCountryInfoArr.Add(dbQueryCountry);
  6754. }
  6755. }
  6756. }
  6757. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6758. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6759. var create = _GroupCostRepository.
  6760. CreateGroupCostByBlackCode(dto.Diid);
  6761. if (groupCost.Count == 0 && create.Code == 0)
  6762. {
  6763. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6764. }
  6765. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6766. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6767. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6768. groupCostMap = groupCostMap.Select(x =>
  6769. {
  6770. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6771. {
  6772. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6773. }
  6774. return x;
  6775. }).ToList();
  6776. //GroupCostParameter.Add(new
  6777. // Grp_GroupCostParameter());
  6778. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6779. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6780. return Ok(JsonView(new
  6781. {
  6782. groupList,
  6783. groupInfo,
  6784. groupChecks,
  6785. groupCost = groupCostMap,
  6786. hotelNumber,
  6787. GroupCostParameter = GroupCostParameterMap,
  6788. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6789. {
  6790. x.VisaCountry,
  6791. x.VisaPrice,
  6792. x.Id,
  6793. }).ToList(),
  6794. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6795. blackCodeIsTrue = create.Code == 0 ? true : false,
  6796. hotelIsTrue = hotelIsTrue,
  6797. }));
  6798. }
  6799. /// <summary>
  6800. /// 团组成本信息保存
  6801. /// </summary>
  6802. /// <param name="dto"></param>
  6803. /// <returns></returns>
  6804. [HttpPost]
  6805. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6806. {
  6807. if (dto.Diid <= 0 || dto.Userid <= 0)
  6808. {
  6809. return Ok(JsonView(false));
  6810. }
  6811. JsonView jw = null;
  6812. bool isTrue = false;
  6813. #region 复制团组成本
  6814. //if (dto.Diid == 2581)
  6815. //{
  6816. // dto.Diid = 2599;
  6817. // dto.CheckBoxs.ForEach(x =>
  6818. // {
  6819. // x.Diid = 2599;
  6820. // });
  6821. // dto.GroupCosts.ForEach(x =>
  6822. // {
  6823. // x.Diid = 2599;
  6824. // });
  6825. // dto.CostTypeHotelNumbers.ForEach(x =>
  6826. // {
  6827. // x.Diid = 2599;
  6828. // });
  6829. // dto.GroupCostParameters.ForEach(x =>
  6830. // {
  6831. // x.DiId = 2599;
  6832. // });
  6833. //}
  6834. #endregion
  6835. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6836. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6837. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6838. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6839. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6840. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6841. try
  6842. {
  6843. _sqlSugar.BeginTran();
  6844. isTrue = await _GroupCostRepository.
  6845. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6846. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6847. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6848. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6849. _sqlSugar.CommitTran();
  6850. jw = JsonView(true, "保存成功!", isTrue);
  6851. }
  6852. catch (Exception)
  6853. {
  6854. _sqlSugar.RollbackTran();
  6855. jw = JsonView(false);
  6856. }
  6857. return Ok(jw);
  6858. }
  6859. /// <summary>
  6860. /// 司兼导数据
  6861. /// </summary>
  6862. /// <param name="dto"></param>
  6863. /// <returns></returns>
  6864. [HttpPost]
  6865. public IActionResult GetCarGuides(CarGuidesDto dto)
  6866. {
  6867. JsonView jw = null;
  6868. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6869. jw = JsonView(true, "获取成功!", Data);
  6870. return Ok(jw);
  6871. }
  6872. /// <summary>
  6873. /// 导游数据
  6874. /// </summary>
  6875. /// <param name="dto"></param>
  6876. /// <returns></returns>
  6877. [HttpPost]
  6878. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6879. {
  6880. JsonView jw = null;
  6881. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6882. // 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
  6883. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6884. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6885. jw = JsonView(true, "获取成功!", Data);
  6886. return Ok(jw);
  6887. }
  6888. /// <summary>
  6889. /// 成本车数据
  6890. /// </summary>
  6891. /// <param name="dto"></param>
  6892. /// <returns></returns>
  6893. [HttpPost]
  6894. public IActionResult GetCarInfo(CarGuidesDto dto)
  6895. {
  6896. JsonView jw = null;
  6897. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6898. jw = JsonView(true, "获取成功!", Data);
  6899. return Ok(jw);
  6900. }
  6901. /// <summary>
  6902. /// 景点数据
  6903. /// </summary>
  6904. /// <param name="dto"></param>
  6905. /// <returns></returns>
  6906. [HttpPost]
  6907. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6908. {
  6909. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6910. return Ok(JsonView(true, "获取成功!", Data));
  6911. }
  6912. /// <summary>
  6913. /// 成本通知
  6914. /// </summary>
  6915. /// <param name="dto"></param>
  6916. /// <returns></returns>
  6917. [HttpPost]
  6918. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6919. {
  6920. if (dto.Diid < 0)
  6921. {
  6922. return Ok(JsonView(false));
  6923. }
  6924. JsonView jw = null;
  6925. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6926. if (GroupCostParameter != null)
  6927. {
  6928. int IsShare = 0;
  6929. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6930. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6931. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6932. string msg = string.Empty;
  6933. if (isTrue)
  6934. {
  6935. if (IsShare == 0)
  6936. {
  6937. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6938. }
  6939. else
  6940. {
  6941. #region 企微通知对应岗位用户
  6942. try
  6943. {
  6944. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6945. }
  6946. catch (Exception ex)
  6947. {
  6948. }
  6949. #endregion
  6950. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6951. }
  6952. jw = JsonView(isTrue, msg, new { IsShare });
  6953. }
  6954. else
  6955. {
  6956. msg = "修改失败!";
  6957. jw = JsonView(isTrue, msg);
  6958. }
  6959. }
  6960. else
  6961. {
  6962. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6963. }
  6964. return Ok(jw);
  6965. }
  6966. /// <summary>
  6967. /// 导出报价单
  6968. /// </summary>
  6969. /// <param name="dto"></param>
  6970. /// <returns></returns>
  6971. [HttpPost]
  6972. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6973. {
  6974. if (dto.Diid == 0)
  6975. {
  6976. return Ok(JsonView(false, "请传递团组id"));
  6977. }
  6978. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6979. if (deleInfo.Code != 0)
  6980. {
  6981. return Ok(JsonView(false, "团组信息查询失败!"));
  6982. }
  6983. var di = deleInfo.Data as DelegationInfoWebView;
  6984. if (di != null)
  6985. {
  6986. di.TeamName = di.TeamName.Replace("|","、");
  6987. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  6988. //文件名
  6989. string strFileName = di.TeamName + "-收款账单.doc";
  6990. //获取模板
  6991. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6992. //载入模板
  6993. Document doc = new Document(tmppath);
  6994. decimal TotalPrice = 0.00M;
  6995. string itemStr = string.Empty;
  6996. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6997. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6998. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6999. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7000. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7001. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7002. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7003. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7004. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7005. foreach (var cost in groupCostType)
  7006. {
  7007. var List = cost.ToList();
  7008. if (cost.Key == "A")
  7009. {
  7010. foreach (var ListItem in List)
  7011. {
  7012. if (ListItem.number > 0)
  7013. {
  7014. if (ListItem.code.Contains("TBR"))
  7015. {
  7016. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7017. }
  7018. else
  7019. {
  7020. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7021. }
  7022. TotalPrice += (ListItem.number * ListItem.price);
  7023. }
  7024. }
  7025. }
  7026. else
  7027. {
  7028. itemStr = itemStr.Insert(0, "A段\r\n");
  7029. itemStr += "B段\r\n";
  7030. foreach (var ListItem in List)
  7031. {
  7032. if (ListItem.number > 0)
  7033. {
  7034. if (ListItem.code.Contains("TBR"))
  7035. {
  7036. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7037. }
  7038. else
  7039. {
  7040. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7041. }
  7042. TotalPrice += (ListItem.number * ListItem.price);
  7043. }
  7044. }
  7045. }
  7046. }
  7047. #region 替换Word模板书签内容
  7048. Dictionary<string, string> marks = new Dictionary<string, string>();
  7049. marks.Add("To", di.ClientUnit);//付款方
  7050. marks.Add("ToTel", di.TellPhone);//付款方电话
  7051. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7052. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7053. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7054. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7055. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7056. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7057. marks.Add("PayItemContent", itemStr);//详细信息
  7058. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7059. #endregion
  7060. ////注
  7061. //if (doc.Range.Bookmarks["Attention"] != null)
  7062. //{
  7063. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7064. // mark.Text = frList[0].Attention;
  7065. //}
  7066. foreach (var item in marks.Keys)
  7067. {
  7068. if (doc.Range.Bookmarks[item] != null)
  7069. {
  7070. Bookmark mark = doc.Range.Bookmarks[item];
  7071. mark.Text = marks[item];
  7072. }
  7073. }
  7074. byte[] bytes = null;
  7075. using (MemoryStream stream = new MemoryStream())
  7076. {
  7077. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7078. bytes = stream.ToArray();
  7079. }
  7080. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7081. return Ok(JsonView(true, "", new
  7082. {
  7083. Data = bytes,
  7084. strFileName,
  7085. }));
  7086. }
  7087. else
  7088. {
  7089. return Ok(JsonView(false, "团组信息不存在!"));
  7090. }
  7091. }
  7092. /// <summary>
  7093. /// 导出团组成本
  7094. /// </summary>
  7095. /// <param name="dto"></param>
  7096. /// <returns></returns>
  7097. [HttpPost]
  7098. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7099. {
  7100. var jw = JsonView(false);
  7101. if (dto.Diid == 0)
  7102. {
  7103. return Ok(JsonView(false, "请传递团组id"));
  7104. }
  7105. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7106. if (deleInfo.Code != 0)
  7107. {
  7108. return Ok(JsonView(false, "团组信息查询失败!"));
  7109. }
  7110. var di = deleInfo.Data as DelegationInfoWebView;
  7111. if (di == null)
  7112. {
  7113. return Ok(JsonView(false, "团组信息查询失败!"));
  7114. }
  7115. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7116. WorkbookDesigner designer = new WorkbookDesigner();
  7117. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7118. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7119. for (int i = 0; i < List_GC.Count; i++)
  7120. {
  7121. GroupCost_Excel gc = new GroupCost_Excel();
  7122. gc.Id = List_GC[i].Id;
  7123. gc.Diid = List_GC[i].Diid.ToString();
  7124. gc.DAY = List_GC[i].DAY;
  7125. string week = "";
  7126. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7127. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7128. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7129. gc.ITIN = List_GC[i].ITIN;
  7130. gc.CarType = List_GC[i].CarType;
  7131. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7132. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7133. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7134. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7135. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7136. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7137. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7138. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7139. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7140. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7141. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7142. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7143. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7144. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7145. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7146. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7147. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7148. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7149. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7150. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7151. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7152. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7153. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7154. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7155. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7156. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7157. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7158. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7159. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7160. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7161. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7162. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7163. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7164. List_GC1.Add(gc);
  7165. }
  7166. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7167. dt.TableName = "TB";
  7168. //报表标题等不用dt的值
  7169. designer.SetDataSource("TeamName", dto.title.TeamName);
  7170. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7171. designer.SetDataSource("Tax", dto.title.Tax);
  7172. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7173. designer.SetDataSource("Currency", dto.title.Currency);
  7174. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7175. designer.SetDataSource("Rate", dto.title.Rate);
  7176. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7177. var Aparams = hotels.Find(x => x.Type == "Default");
  7178. if (Aparams == null)
  7179. {
  7180. return Ok(jw);
  7181. }
  7182. //酒店数量
  7183. var txtSGRNumber = Aparams.SGR.ToString();
  7184. var txtTBRNumber = Aparams.TBR.ToString();
  7185. var txtJSESNumber = Aparams.JSES.ToString();
  7186. var txtSUITENumbe = Aparams.SUITE.ToString();
  7187. if (dto.costType == "B")
  7188. {
  7189. Aparams = hotels.Find(x => x.Type == "A");
  7190. var Bparams = hotels.Find(x => x.Type == "B");
  7191. if (Aparams == null || Bparams == null)
  7192. {
  7193. return Ok(jw);
  7194. }
  7195. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7196. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7197. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7198. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7199. }
  7200. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7201. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7202. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7203. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7204. var ws = designer.Workbook.Worksheets[0];
  7205. int Row = List_GC.Count;
  7206. int startIndex = 11;
  7207. int HideRows = 0;
  7208. List<int> hideRowsList = new List<int>();
  7209. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7210. #region A段left数据
  7211. var left = dto.leftInfo.Find(x => x.Type == "A");
  7212. if (left == null)
  7213. {
  7214. return Ok(jw);
  7215. }
  7216. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7217. if (leftBindData != null)
  7218. {
  7219. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7220. designer.SetDataSource("VisaRS", leftBindData.rs);
  7221. designer.SetDataSource("VisaXS", leftBindData.xs);
  7222. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7223. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7224. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7225. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7226. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7227. }
  7228. else
  7229. {
  7230. hideRowsList.Add(Row + startIndex + HideRows);
  7231. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7232. }
  7233. HideRows += 2;
  7234. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7235. if (leftBindData != null)
  7236. {
  7237. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7238. designer.SetDataSource("BXRS", leftBindData.rs);
  7239. designer.SetDataSource("BXXS", leftBindData.xs);
  7240. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7241. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7242. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7243. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7244. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7245. }
  7246. else
  7247. {
  7248. hideRowsList.Add(Row + startIndex + HideRows);
  7249. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7250. }
  7251. HideRows += 2;
  7252. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7253. if (leftBindData != null)
  7254. {
  7255. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7256. designer.SetDataSource("HSRS", leftBindData.rs);
  7257. designer.SetDataSource("HSXS", leftBindData.xs);
  7258. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7259. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7260. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7261. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7262. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7263. }
  7264. else
  7265. {
  7266. hideRowsList.Add(Row + startIndex + HideRows);
  7267. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7268. }
  7269. HideRows += 2;
  7270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7271. if (leftBindData != null)
  7272. {
  7273. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7274. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7275. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7276. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7277. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7278. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7279. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7280. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7281. }
  7282. else
  7283. {
  7284. hideRowsList.Add(Row + startIndex + HideRows);
  7285. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7286. }
  7287. HideRows += 2;
  7288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7289. if (leftBindData != null)
  7290. {
  7291. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7292. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7293. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7294. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7295. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7296. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7297. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7298. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7299. }
  7300. else
  7301. {
  7302. hideRowsList.Add(Row + startIndex + HideRows);
  7303. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7304. }
  7305. HideRows += 2;
  7306. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7307. if (leftBindData != null)
  7308. {
  7309. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7310. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7311. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7312. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7313. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7314. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7315. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7316. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7317. }
  7318. else
  7319. {
  7320. hideRowsList.Add(Row + startIndex + HideRows);
  7321. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7322. }
  7323. HideRows += 2;
  7324. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7325. if (leftBindData != null)
  7326. {
  7327. ////TBR
  7328. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7329. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7330. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7331. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7332. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7333. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7334. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7335. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7336. }
  7337. else
  7338. {
  7339. hideRowsList.Add(Row + startIndex + HideRows);
  7340. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7341. }
  7342. HideRows += 2;
  7343. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7344. if (leftBindData != null)
  7345. {
  7346. ////SGR
  7347. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7348. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7349. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7350. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7351. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7352. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7353. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7354. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7355. }
  7356. else
  7357. {
  7358. hideRowsList.Add(Row + startIndex + HideRows);
  7359. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7360. }
  7361. HideRows += 2;
  7362. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7363. if (leftBindData != null)
  7364. {
  7365. ////JS/ES
  7366. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7367. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7368. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7369. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7370. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7371. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7372. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7373. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7374. }
  7375. else
  7376. {
  7377. hideRowsList.Add(Row + startIndex + HideRows);
  7378. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7379. }
  7380. HideRows += 2;
  7381. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7382. if (leftBindData != null)
  7383. {
  7384. ////SUITE
  7385. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7386. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7387. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7388. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7389. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7390. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7391. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7392. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7393. }
  7394. else
  7395. {
  7396. hideRowsList.Add(Row + startIndex + HideRows);
  7397. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7398. }
  7399. HideRows += 2;
  7400. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7401. if (leftBindData != null)
  7402. {
  7403. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7404. designer.SetDataSource("DJRS", leftBindData.rs);
  7405. designer.SetDataSource("DJXS", leftBindData.xs);
  7406. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7407. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7408. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7409. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7410. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7411. }
  7412. else
  7413. {
  7414. hideRowsList.Add(Row + startIndex + HideRows);
  7415. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7416. }
  7417. HideRows += 2;
  7418. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7419. if (leftBindData != null)
  7420. {
  7421. designer.SetDataSource("HCPCB", leftBindData.cb);
  7422. designer.SetDataSource("HCPRS", leftBindData.rs);
  7423. designer.SetDataSource("HCPXS", leftBindData.xs);
  7424. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7425. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7426. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7427. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7428. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7429. }
  7430. else
  7431. {
  7432. hideRowsList.Add(Row + startIndex + HideRows);
  7433. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7434. }
  7435. HideRows += 2;
  7436. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7437. if (leftBindData != null)
  7438. {
  7439. designer.SetDataSource("CPCB", leftBindData.cb);
  7440. designer.SetDataSource("CPRS", leftBindData.rs);
  7441. designer.SetDataSource("CPXS", leftBindData.xs);
  7442. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7443. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7444. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7445. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7446. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7447. }
  7448. else
  7449. {
  7450. hideRowsList.Add(Row + startIndex + HideRows);
  7451. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7452. }
  7453. HideRows += 2;
  7454. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7455. if (leftBindData != null)
  7456. {
  7457. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7458. designer.SetDataSource("GWRS", leftBindData.rs);
  7459. designer.SetDataSource("GWXS", leftBindData.xs);
  7460. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7461. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7462. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7463. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7464. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7465. }
  7466. else
  7467. {
  7468. hideRowsList.Add(Row + startIndex + HideRows);
  7469. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7470. }
  7471. HideRows += 2;
  7472. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7473. if (leftBindData != null)
  7474. {
  7475. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7476. designer.SetDataSource("LYJRS", leftBindData.rs);
  7477. designer.SetDataSource("LYJXS", leftBindData.xs);
  7478. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7479. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7480. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7481. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7482. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7483. }
  7484. else
  7485. {
  7486. hideRowsList.Add(Row + startIndex + HideRows);
  7487. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7488. }
  7489. #endregion
  7490. #region A段Right信息
  7491. var right = dto.rightInfo.Find(x => x.Type == "A");
  7492. if (right == null)
  7493. {
  7494. return Ok(jw);
  7495. }
  7496. HideRows += 4;
  7497. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7498. if (rightBindData != null)
  7499. {
  7500. //经济舱 + 双人间 TBR
  7501. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7502. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7503. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7504. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7505. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7506. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7507. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7508. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7509. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7510. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7511. }
  7512. else
  7513. {
  7514. hideRowsList.Add(Row + startIndex + HideRows);
  7515. }
  7516. HideRows += 2;
  7517. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7518. if (rightBindData != null)
  7519. {
  7520. //经济舱 + 单人间 SGR
  7521. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7522. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7523. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7524. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7525. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7526. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7527. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7528. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7529. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7530. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7531. }
  7532. else
  7533. {
  7534. hideRowsList.Add(Row + startIndex + HideRows);
  7535. }
  7536. HideRows += 2;
  7537. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7538. if (rightBindData != null)
  7539. {
  7540. //公务舱 + 单人间 SGR
  7541. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7542. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7543. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7544. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7545. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7546. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7547. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7548. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7549. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7550. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7551. }
  7552. else
  7553. {
  7554. hideRowsList.Add(Row + startIndex + HideRows);
  7555. }
  7556. HideRows += 2;
  7557. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7558. if (rightBindData != null)
  7559. {
  7560. //公务舱 + 小套房 JSES
  7561. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7562. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7563. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7564. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7565. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7566. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7567. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7568. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7569. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7570. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7571. }
  7572. else
  7573. {
  7574. hideRowsList.Add(Row + startIndex + HideRows);
  7575. }
  7576. HideRows += 2;
  7577. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7578. if (rightBindData != null)
  7579. {
  7580. //公务舱 + 小套房 JSES
  7581. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7582. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7583. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7584. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7585. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7586. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7587. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7588. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7589. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7590. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7591. }
  7592. else
  7593. {
  7594. hideRowsList.Add(Row + startIndex + HideRows);
  7595. }
  7596. HideRows += 2;
  7597. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7598. if (rightBindData != null)
  7599. {
  7600. //经济舱 + 大套房
  7601. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7602. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7603. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7604. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7605. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7606. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7607. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7608. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7609. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7610. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7611. }
  7612. else
  7613. {
  7614. hideRowsList.Add(Row + startIndex + HideRows);
  7615. }
  7616. HideRows += 2;
  7617. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7618. if (rightBindData != null)
  7619. {
  7620. //头等舱 + 小套房 JSES
  7621. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7622. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7623. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7624. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7625. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7626. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7627. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7628. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7629. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7630. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7631. }
  7632. else
  7633. {
  7634. hideRowsList.Add(Row + startIndex + HideRows);
  7635. }
  7636. HideRows += 2;
  7637. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7638. if (rightBindData != null)
  7639. {
  7640. //头等舱 + 大套房
  7641. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7642. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7643. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7644. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7645. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7646. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7647. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7648. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7649. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7650. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7651. }
  7652. else
  7653. {
  7654. hideRowsList.Add(Row + startIndex + HideRows);
  7655. }
  7656. #endregion
  7657. #region B段标题清空
  7658. designer.SetDataSource("CostBDRCB", "");
  7659. designer.SetDataSource("CostBRS", "");
  7660. designer.SetDataSource("CostBXS", "");
  7661. designer.SetDataSource("CostBZCB", "");
  7662. designer.SetDataSource("CostBDRBJ", "");
  7663. designer.SetDataSource("CostBZBJ", "");
  7664. designer.SetDataSource("CostBDRLR", "");
  7665. designer.SetDataSource("CostBZLR", "");
  7666. designer.SetDataSource("CostBDRCBOM", "");
  7667. designer.SetDataSource("CostBRSOM", "");
  7668. designer.SetDataSource("CostBZCBOM", "");
  7669. designer.SetDataSource("CostBDRBJOM", "");
  7670. designer.SetDataSource("CostBZBJOM", "");
  7671. designer.SetDataSource("CostBDRLROM", "");
  7672. designer.SetDataSource("CostBZLROM", "");
  7673. #endregion
  7674. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7675. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7676. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7677. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7678. designer.SetDataSource("DJName", "地接(CNY)");
  7679. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7680. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7681. designer.SetDataSource("GWName", "公务(CNY)");
  7682. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7683. designer.SetDataSource("LYJName", "零用金(CNY)");
  7684. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7685. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7686. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7687. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7688. designer.SetDataSource("BXName", "保险(CNY)");
  7689. designer.SetDataSource("VisaName", "签证(CNY)");
  7690. #region B段基本数据
  7691. if (dto.costType == "B")
  7692. {
  7693. left = dto.leftInfo.Find(x => x.Type == "B");
  7694. if (left == null)
  7695. {
  7696. return Ok(jw);
  7697. }
  7698. #region B段left数据
  7699. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7700. if (leftBindData != null)
  7701. {
  7702. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7703. designer.SetDataSource("BHSRS", leftBindData.rs);
  7704. designer.SetDataSource("BHSXS", leftBindData.xs);
  7705. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7706. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7707. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7708. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7709. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7710. }
  7711. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7712. if (leftBindData != null)
  7713. {
  7714. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7715. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7716. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7717. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7718. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7719. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7720. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7721. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7722. }
  7723. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7724. if (leftBindData != null)
  7725. {
  7726. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7727. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7728. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7729. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7730. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7731. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7732. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7733. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7734. }
  7735. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7736. if (leftBindData != null)
  7737. {
  7738. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  7739. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  7740. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  7741. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7742. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7743. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7744. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7745. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7746. }
  7747. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7748. if (leftBindData != null)
  7749. {
  7750. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7751. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7752. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7753. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7754. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7755. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7756. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7757. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7758. }
  7759. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7760. if (leftBindData != null)
  7761. {
  7762. designer.SetDataSource("BCPCB", leftBindData.cb);
  7763. designer.SetDataSource("BCPRS", leftBindData.rs);
  7764. designer.SetDataSource("BCPXS", leftBindData.xs);
  7765. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7766. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7767. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7768. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7769. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7770. }
  7771. //TBR
  7772. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7773. if (leftBindData != null)
  7774. {
  7775. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7776. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7777. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7778. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7779. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7780. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7781. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7782. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7783. }
  7784. //SGR
  7785. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7786. if (leftBindData != null)
  7787. {
  7788. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7789. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7790. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7791. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7792. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7793. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7794. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7795. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7796. }
  7797. //JS/ES
  7798. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7799. if (leftBindData != null)
  7800. {
  7801. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7802. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7803. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7804. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7805. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7806. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7807. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7808. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7809. }
  7810. //SUITE
  7811. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7812. if (leftBindData != null)
  7813. {
  7814. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7815. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7816. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7817. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7818. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7819. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7820. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7821. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7822. }
  7823. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7824. if (leftBindData != null)
  7825. {
  7826. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7827. designer.SetDataSource("BDJRS", leftBindData.rs);
  7828. designer.SetDataSource("BDJXS", leftBindData.xs);
  7829. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7830. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7831. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7832. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7833. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7834. }
  7835. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7836. if (leftBindData != null)
  7837. {
  7838. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7839. designer.SetDataSource("BGWRS", leftBindData.rs);
  7840. designer.SetDataSource("BGWXS", leftBindData.xs);
  7841. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7842. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7843. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7844. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7845. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7846. }
  7847. #region 优化方案
  7848. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7849. //excelBind.Add("零用金", new {
  7850. //cb="",
  7851. //rs="",
  7852. //xs ="",
  7853. //zcb = "",
  7854. //});
  7855. #endregion
  7856. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7857. if (leftBindData != null)
  7858. {
  7859. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7860. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7861. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7862. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7863. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7864. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7865. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7866. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7867. }
  7868. #endregion
  7869. #region B段Right信息
  7870. right = dto.rightInfo.Find(x => x.Type == "B");
  7871. if (right == null)
  7872. {
  7873. return Ok(jw);
  7874. }
  7875. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7876. if (rightBindData != null)
  7877. {
  7878. //经济舱 + 双人间 TBR
  7879. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7880. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7881. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7882. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7883. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7884. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7885. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7886. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7887. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7888. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7889. }
  7890. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7891. if (rightBindData != null)
  7892. {
  7893. //经济舱 + 单人间 SGR
  7894. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7895. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7896. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7897. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7898. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7899. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7900. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7901. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7902. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7903. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7904. }
  7905. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7906. if (rightBindData != null)
  7907. {
  7908. //公务舱 + 单人间 SGR
  7909. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7910. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7911. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7912. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7913. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7914. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7915. designer.SetDataSource("BlblGWCSGRZLR", (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. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7921. if (rightBindData != null)
  7922. {
  7923. //公务舱 + 小套房 JSES
  7924. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7925. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7926. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7927. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7928. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7929. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7930. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7931. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7932. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7933. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7934. }
  7935. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7936. if (rightBindData != null)
  7937. {
  7938. //公务舱 + 小套房 JSES
  7939. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7940. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7941. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7942. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7943. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7944. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7945. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7946. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7947. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7948. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7949. }
  7950. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7951. if (rightBindData != null)
  7952. {
  7953. //经济舱 + 大套房
  7954. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7955. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7956. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7957. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7958. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7959. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7960. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7961. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7962. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7963. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7964. }
  7965. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7966. if (rightBindData != null)
  7967. {
  7968. //头等舱 + 小套房 JSES
  7969. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  7970. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  7971. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7972. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  7973. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7974. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7975. designer.SetDataSource("BlblTDCJSESZLR", (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. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7981. if (rightBindData != null)
  7982. {
  7983. //头等舱 + 大套房
  7984. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  7985. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  7986. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7987. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  7988. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7989. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7990. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7991. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7992. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7993. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7994. }
  7995. #endregion
  7996. #region 标题
  7997. designer.SetDataSource("CostBDRCB", "单人成本");
  7998. designer.SetDataSource("CostBRS", "人数");
  7999. designer.SetDataSource("CostBXS", "系数");
  8000. designer.SetDataSource("CostBZCB", "总成本");
  8001. designer.SetDataSource("CostBDRBJ", "单人报价");
  8002. designer.SetDataSource("CostBZBJ", "总报价");
  8003. designer.SetDataSource("CostBDRLR", "单人利润");
  8004. designer.SetDataSource("CostBZLR", "总利润");
  8005. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8006. designer.SetDataSource("CostBRSOM", "人数");
  8007. designer.SetDataSource("CostBZCBOM", "总成本");
  8008. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8009. designer.SetDataSource("CostBZBJOM", "总报价");
  8010. designer.SetDataSource("CostBDRLROM", "单人利润");
  8011. designer.SetDataSource("CostBZLROM", "总利润");
  8012. #endregion
  8013. }
  8014. #endregion
  8015. designer.SetDataSource("TzZCB2", TzZCB2);
  8016. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8017. designer.SetDataSource("TzZLR2", TzZLR2);
  8018. string[] dataSourceKeys = new string[]
  8019. {
  8020. "VF",
  8021. "TGS",
  8022. "TGOF",
  8023. "TGM",
  8024. "TGA",
  8025. "TGTF",
  8026. "TGEF",
  8027. "CFM",
  8028. "CFOF",
  8029. "B",
  8030. "L",
  8031. "D",
  8032. "TBR",
  8033. "SGR",
  8034. "JSES",
  8035. "Suite",
  8036. "TV",
  8037. "1L",
  8038. "IF",
  8039. "EF",
  8040. "BRF",
  8041. "TE",
  8042. "TGT",
  8043. "DRVT",
  8044. "PC",
  8045. "TLF",
  8046. "ECT"
  8047. };
  8048. foreach (var item in dataSourceKeys)
  8049. {
  8050. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8051. if (find != null)
  8052. {
  8053. designer.SetDataSource(item, find.text);
  8054. }
  8055. else
  8056. {
  8057. designer.SetDataSource(item, 0);
  8058. }
  8059. }
  8060. designer.SetDataSource(dt);
  8061. //根据数据源处理生成报表内容
  8062. designer.Process();
  8063. designer.Workbook.Worksheets[0].Name = "清单";
  8064. Worksheet sheet = designer.Workbook.Worksheets[0];
  8065. foreach (var Rowindex in hideRowsList)
  8066. {
  8067. ws.Cells.HideRows(Rowindex, 2);
  8068. }
  8069. byte[] bytes = null;
  8070. string strFileName = di.TeamName + "-团组-成本.xls";
  8071. using (MemoryStream stream = new MemoryStream())
  8072. {
  8073. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8074. bytes = stream.ToArray();
  8075. }
  8076. return Ok(JsonView(true, "", new
  8077. {
  8078. Data = bytes,
  8079. strFileName,
  8080. }));
  8081. }
  8082. /// <summary>
  8083. /// 导出客户报表
  8084. /// </summary>
  8085. /// <returns></returns>
  8086. [HttpPost]
  8087. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8088. {
  8089. var jw = JsonView(false);
  8090. if (dto.Diid == 0)
  8091. {
  8092. return Ok(JsonView(false, "请传递团组id"));
  8093. }
  8094. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8095. if (deleInfo.Code != 0)
  8096. {
  8097. return Ok(JsonView(false, "团组信息查询失败!"));
  8098. }
  8099. var di = deleInfo.Data as DelegationInfoWebView;
  8100. if (di == null)
  8101. {
  8102. return Ok(JsonView(false, "团组信息查询失败!"));
  8103. }
  8104. //文件名
  8105. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8106. //获取模板
  8107. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8108. //载入模板
  8109. Document doc = new Document(tmppath);
  8110. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8111. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8112. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8113. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8114. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8115. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8116. if (AParameter == null)
  8117. {
  8118. return Ok(JsonView(false, "系数不存在!"));
  8119. }
  8120. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8121. , TzAirDesc, TzZCost;
  8122. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8123. = TzAirDesc = TzZCost = string.Empty;
  8124. TzNumber = AParameter.CostTypenumber.ToString();
  8125. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8126. CarGuides1 = dto.CarGuides1;
  8127. Meal = dto.Meal;
  8128. SubsidizedMeals = dto.SubsidizedMeals;
  8129. NightRepair = dto.NightRepair;
  8130. AttractionsTickets = dto.AttractionsTickets;
  8131. MiscellaneousFees = dto.MiscellaneousFees;
  8132. ATip = dto.ATip;
  8133. TzHotelDesc = "";
  8134. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8135. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8136. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8137. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8138. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8139. TzAirDesc = "";
  8140. TzZCost = dto.TzZCost;
  8141. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8142. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8143. var index = 1;
  8144. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8145. foreach (var item in TzHotelDescArr)
  8146. {
  8147. if (AinfoArr != null)
  8148. {
  8149. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8150. if (Ainfo != null)
  8151. {
  8152. if (int.Parse(Ainfo.rs) <= 0)
  8153. {
  8154. continue;
  8155. }
  8156. var hotelText = string.Empty;
  8157. switch (item)
  8158. {
  8159. case "SGR":
  8160. hotelText = "单人间";
  8161. break;
  8162. case "JSES":
  8163. hotelText = "小套房";
  8164. break;
  8165. case "SUITE":
  8166. hotelText = "套房";
  8167. break;
  8168. case "TBR":
  8169. hotelText = "双人间";
  8170. break;
  8171. }
  8172. if (item != "TBR")
  8173. {
  8174. 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";
  8175. }
  8176. else
  8177. {
  8178. 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";
  8179. }
  8180. index++;
  8181. }
  8182. }
  8183. }
  8184. index = 1;
  8185. foreach (var item in TzAirDescArr)
  8186. {
  8187. if (AinfoArr != null)
  8188. {
  8189. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8190. if (Ainfo != null)
  8191. {
  8192. if (int.Parse(Ainfo.rs) <= 0)
  8193. {
  8194. continue;
  8195. }
  8196. 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";
  8197. index++;
  8198. }
  8199. }
  8200. }
  8201. if (dto.costType == "B")
  8202. {
  8203. if (BParameter == null)
  8204. {
  8205. return Ok(JsonView(false, "B段系数不存在!"));
  8206. }
  8207. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8208. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8209. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8210. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8211. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8212. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8213. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8214. foreach (var item in TzHotelDescArr)
  8215. {
  8216. if (AinfoArr != null)
  8217. {
  8218. TzHotelDesc += "B段信息 \r\n";
  8219. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8220. if (Ainfo != null)
  8221. {
  8222. if (int.Parse(Ainfo.rs) <= 0)
  8223. {
  8224. continue;
  8225. }
  8226. var hotelText = string.Empty;
  8227. switch (item)
  8228. {
  8229. case "SGR":
  8230. hotelText = "单人间";
  8231. break;
  8232. case "JSES":
  8233. hotelText = "小套房";
  8234. break;
  8235. case "SUITE":
  8236. hotelText = "套房";
  8237. break;
  8238. case "TBR":
  8239. hotelText = "双人间";
  8240. break;
  8241. }
  8242. if (item != "TBR")
  8243. {
  8244. 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";
  8245. }
  8246. else
  8247. {
  8248. 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";
  8249. }
  8250. index++;
  8251. }
  8252. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8253. }
  8254. }
  8255. index = 1;
  8256. foreach (var item in TzAirDescArr)
  8257. {
  8258. if (AinfoArr != null)
  8259. {
  8260. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8261. if (Ainfo != null)
  8262. {
  8263. if (int.Parse(Ainfo.rs) <= 0)
  8264. {
  8265. continue;
  8266. }
  8267. 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";
  8268. index++;
  8269. }
  8270. }
  8271. }
  8272. }
  8273. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8274. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8275. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8276. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8277. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8278. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8279. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8280. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8281. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8282. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8283. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8284. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8285. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8286. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8287. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8288. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8289. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8290. DickeyValue.Add("TzZCost", TzZCost);
  8291. foreach (var key in DickeyValue.Keys)
  8292. {
  8293. if (doc.Range.Bookmarks[key] != null)
  8294. {
  8295. Bookmark mark = doc.Range.Bookmarks[key];
  8296. mark.Text = DickeyValue[key];
  8297. }
  8298. }
  8299. byte[] bytes = null;
  8300. string strFileName = di.TeamName + "-客户报价.doc";
  8301. using (MemoryStream stream = new MemoryStream())
  8302. {
  8303. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8304. bytes = stream.ToArray();
  8305. }
  8306. return Ok(JsonView(true, "", new
  8307. {
  8308. Data = bytes,
  8309. strFileName,
  8310. }));
  8311. }
  8312. /// <summary>
  8313. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8314. /// </summary>
  8315. /// <param name="dto"></param>
  8316. /// <returns></returns>
  8317. [HttpPost]
  8318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8319. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8320. {
  8321. try
  8322. {
  8323. #region 参数验证
  8324. if (dto.DiId < 0)
  8325. {
  8326. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8327. }
  8328. List<int> cTableIds = new List<int>() {
  8329. 76 ,//酒店预订
  8330. 77 ,//行程
  8331. 79 ,//车/导游地接
  8332. 80 ,//签证
  8333. 81 ,//邀请/公务活
  8334. 82 ,//团组客户保险
  8335. 85 ,//机票预订
  8336. 98 ,//其他款项
  8337. 285 ,//收款退还
  8338. 751 ,//酒店早餐
  8339. 1015 // 超支费用
  8340. };
  8341. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8342. {
  8343. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8344. }
  8345. #endregion
  8346. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8347. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8348. if (_GroupCostParameters.Count <= 0)
  8349. {
  8350. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8351. }
  8352. if (_GroupCostParameters[0].IsShare == 0)
  8353. {
  8354. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8355. }
  8356. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8357. //处理date为空问题
  8358. if (_GroupCosts.Count > 0)
  8359. {
  8360. for (int i = 0; i < _GroupCosts.Count; i++)
  8361. {
  8362. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8363. {
  8364. if (i > 0)
  8365. {
  8366. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8367. }
  8368. }
  8369. }
  8370. }
  8371. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8372. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8373. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8374. string currCode = "";
  8375. #region currCode 验证
  8376. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8377. if (isInt)
  8378. {
  8379. var currData = currDatas.Find(it => it.Id == intCurrency);
  8380. if (currData != null)
  8381. {
  8382. currCode = currData.Name;
  8383. }
  8384. }
  8385. else
  8386. {
  8387. currCode = _GroupCostParameters[0].Currency.Trim();
  8388. }
  8389. #endregion
  8390. //op,酒店单段模式存储
  8391. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8392. {
  8393. CurrencyCode = currCode,
  8394. Rate = _GroupCostParameters[0].Rate,
  8395. CostType = _GroupCostParameters[0].CostType,
  8396. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8397. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8398. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8399. };
  8400. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8401. if (_GroupCostParameters.Count == 2)
  8402. {
  8403. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8404. }
  8405. foreach (var item in _GroupCostParameters)
  8406. {
  8407. decimal _rate = 1;
  8408. decimal _rate1 = item.Rate;
  8409. decimal _scale = 1;
  8410. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8411. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8412. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8413. //if (userInfo != null)
  8414. //{
  8415. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8416. // {
  8417. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8418. // {
  8419. // _scale = 1.00M;
  8420. // }
  8421. // }
  8422. //}
  8423. #endregion
  8424. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8425. {
  8426. CurrencyCode = currCode,
  8427. Rate = _rate1,
  8428. CostType = item.CostType,
  8429. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8430. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8431. CostTypeNumber = item.CostTypenumber
  8432. };
  8433. if (_GroupCostParameters.Count > 1)
  8434. {
  8435. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8436. }
  8437. else
  8438. {
  8439. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8440. }
  8441. if (dto.CTable == 79)//
  8442. {
  8443. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8444. modulePromptInfo.TotalCost = item.DJCB;
  8445. }
  8446. List<string> costTypes = new List<string>() { "A", "B" };
  8447. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8448. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8449. if (_GroupCostsDuplicates.Count() == 1)
  8450. {
  8451. _GroupCostsTypeData = _GroupCosts;
  8452. }
  8453. else
  8454. {
  8455. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8456. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8457. }
  8458. /*
  8459. * 76 酒店预订
  8460. * 77 行程
  8461. * 79 车/导游地接
  8462. * 80 签证
  8463. * 81 邀请/公务活动
  8464. * 82 团组客户保险
  8465. * 85 机票预订
  8466. * 98 其他款项
  8467. * 285 收款退还
  8468. * 751 酒店早餐
  8469. * 1015 超支费用
  8470. */
  8471. switch (dto.CTable)
  8472. {
  8473. case 76: // 酒店预订
  8474. _ModuleSubPromptInfo.AddRange(
  8475. _GroupCostsTypeData.Select(it => new
  8476. {
  8477. it.DAY,
  8478. it.Date,
  8479. it.ACCON,
  8480. it.ITIN,
  8481. it.SGR,
  8482. it.TBR,
  8483. it.JS_ES,
  8484. it.Suite
  8485. })
  8486. );
  8487. break;
  8488. case 79: // 车/导游地接
  8489. _ModuleSubPromptInfo.AddRange(
  8490. _GroupCostsTypeData.Select(it => new
  8491. {
  8492. Date = it.Date, //日期
  8493. CarFee = it.CarCost * _rate * _scale, //车费用
  8494. CarType = it.CarType, //车型
  8495. DriverFee = it.CFS * _rate * _scale, //司机工资
  8496. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8497. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8498. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8499. GuideFee = it.TGS * _rate * _scale, //导游费用
  8500. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8501. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8502. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8503. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8504. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8505. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8506. Breakfast = it.B * _rate * _scale, //早餐费
  8507. Lunch = it.L * _rate * _scale, //午餐费
  8508. Dinner = it.D * _rate * _scale, //晚餐费
  8509. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8510. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8511. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8512. TicketFee = it.EF * _rate * _scale, //门票费
  8513. TicketRemark = it.EFR, //门票费描述
  8514. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8515. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8516. SpentCash = it.PC * _rate * _scale, //零用金
  8517. LeadersFee = it.TLF * _rate * _scale, //领队费
  8518. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8519. })
  8520. );
  8521. break;
  8522. case 85: // 机票
  8523. List<dynamic> datas = new List<dynamic>();
  8524. datas.Add(
  8525. new
  8526. {
  8527. AirType = "经济舱",
  8528. AirNum = item.JJCRS,
  8529. AirDRCB = item.JJCCB,
  8530. AirZCB = (item.JJCRS * item.JJCCB)
  8531. }
  8532. );
  8533. datas.Add(
  8534. new
  8535. {
  8536. AirType = "公务舱",
  8537. AirNum = item.GWCRS,
  8538. AirDRCB = item.GWCCB,
  8539. AirZCB = (item.GWCRS * item.GWCCB)
  8540. }
  8541. );
  8542. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8543. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8544. modulePromptInfo.Data = new
  8545. {
  8546. airFeeData = datas,
  8547. airInitData = initDatas
  8548. };
  8549. _ModulePromptInfos.Add(modulePromptInfo);
  8550. break;
  8551. default:
  8552. break;
  8553. }
  8554. }
  8555. if (dto.CTable != 85)
  8556. {
  8557. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8558. _ModulePromptInfos.Add(_ModulePromptInfo);
  8559. }
  8560. _view.ModulePromptInfos = _ModulePromptInfos;
  8561. return Ok(JsonView(true, "操作成功!", _view));
  8562. }
  8563. catch (Exception ex)
  8564. {
  8565. return Ok(JsonView(false, ex.Message));
  8566. }
  8567. }
  8568. /// <summary>
  8569. /// 根据黑屏代码重新生成行程
  8570. /// </summary>
  8571. /// <param name="dto"></param>
  8572. /// <returns></returns>
  8573. [HttpPost]
  8574. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8575. {
  8576. var jw = JsonView(false);
  8577. var Create = _GroupCostRepository.
  8578. CreateGroupCostByBlackCode(dto.Diid);
  8579. jw.Msg = Create.Msg;
  8580. if (Create.Code == 0)
  8581. {
  8582. jw.Code = 200;
  8583. jw.Data = new
  8584. {
  8585. groupCost = Create.Data,
  8586. blackCodeIsTrue = true
  8587. };
  8588. }
  8589. else
  8590. {
  8591. jw.Code = 400;
  8592. jw.Data = new
  8593. {
  8594. groupCost = Create.Data,
  8595. blackCodeIsTrue = false,
  8596. };
  8597. }
  8598. return Ok(jw);
  8599. }
  8600. /// <summary>
  8601. /// 成本获取OP历史车费用
  8602. /// </summary>
  8603. /// <param name="dto"></param>
  8604. /// <returns></returns>
  8605. [HttpPost]
  8606. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8607. {
  8608. var jw = JsonView(false);
  8609. try
  8610. {
  8611. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8612. //获取现有所有车的数据
  8613. if (!dto.Param.IsNullOrWhiteSpace())
  8614. {
  8615. string sql = $@"
  8616. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8617. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8618. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8619. 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
  8620. AND gctggr.ServiceEndTime is not NULL
  8621. ORDER by gctggrc.id DESC
  8622. ";
  8623. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8624. var numeberResult = await Task.Run(() =>
  8625. {
  8626. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8627. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8628. return numberArr;
  8629. });
  8630. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8631. foreach (var item in numeberResult)
  8632. {
  8633. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8634. {
  8635. Country = "数据异常!",
  8636. City = string.Empty,
  8637. };
  8638. item.Area = find.Country + " " + find.City;
  8639. }
  8640. dbResult.AddRange(numeberResult);
  8641. if (dto.Param.Contains("、"))
  8642. {
  8643. var sp = dto.Param.Split("、");
  8644. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8645. .Where(x =>
  8646. {
  8647. return System.Array.Exists(sp, e =>
  8648. {
  8649. bool where = false;
  8650. if (x.Area != null)
  8651. {
  8652. where = x.Area.Contains(e);
  8653. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8654. {
  8655. return false;
  8656. }
  8657. }
  8658. if (x.PriceName != null && !where)
  8659. {
  8660. where = x.PriceName.Contains(e);
  8661. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8662. {
  8663. return false;
  8664. }
  8665. }
  8666. return where;
  8667. });
  8668. }).ToList();
  8669. }
  8670. else
  8671. {
  8672. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8673. .Where(x =>
  8674. {
  8675. bool where = false;
  8676. if (x.Area != null)
  8677. {
  8678. where = x.Area.Contains(dto.Param);
  8679. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8680. {
  8681. return false;
  8682. }
  8683. }
  8684. if (x.PriceName != null && !where)
  8685. {
  8686. where = x.PriceName.Contains(dto.Param);
  8687. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8688. {
  8689. return false;
  8690. }
  8691. }
  8692. return where;
  8693. }
  8694. )
  8695. .ToList();
  8696. }
  8697. }
  8698. var view = dbResult.Select(x =>
  8699. {
  8700. decimal dp = 0.00M;
  8701. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8702. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8703. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8704. {
  8705. if (startB && endB)
  8706. {
  8707. var timesp = endD.Subtract(startD);
  8708. if ((timesp.Days + 1) != 0)
  8709. {
  8710. dp = x.Price / (timesp.Days + 1);
  8711. }
  8712. }
  8713. }
  8714. else
  8715. {
  8716. dp = x.Price;
  8717. }
  8718. return new
  8719. {
  8720. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8721. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8722. x.Area,
  8723. x.id,
  8724. price = x.Price.ToString("F2"),
  8725. x.PriceName,
  8726. x.PriceContent,
  8727. x.TeamName,
  8728. x.DatePrice,
  8729. dayPrice = dp.ToString("F2"),
  8730. };
  8731. }).OrderByDescending(x => x.id).ToList();
  8732. jw = JsonView(true, "获取成功!", view);
  8733. }
  8734. catch (Exception e)
  8735. {
  8736. jw = JsonView(false, e.Message);
  8737. }
  8738. return Ok(jw);
  8739. }
  8740. #endregion
  8741. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8742. /// <summary>
  8743. /// 酒店预订
  8744. /// 酒店费用列表 根据团组Id查询
  8745. /// </summary>
  8746. /// <param name="_dto"></param>
  8747. /// <returns></returns>
  8748. [HttpPost]
  8749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8750. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8751. {
  8752. #region 参数验证
  8753. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8754. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8755. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8756. #region 团组操作权限验证 76 酒店预定模块
  8757. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8758. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8759. #endregion
  8760. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8761. #region 页面操作权限验证
  8762. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8763. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8764. #endregion
  8765. #endregion
  8766. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8767. }
  8768. /// <summary>
  8769. /// 酒店预订
  8770. /// 基础数据
  8771. /// </summary>
  8772. /// <param name="_dto"></param>
  8773. /// <returns></returns>
  8774. [HttpPost]
  8775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8776. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8777. {
  8778. #region 参数验证
  8779. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8780. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8781. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8782. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8783. #region 页面操作权限验证
  8784. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8785. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8786. #endregion
  8787. #region 团组操作权限验证 76 酒店预定模块
  8788. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8789. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8790. #endregion
  8791. #endregion
  8792. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8793. }
  8794. /// <summary>
  8795. /// 酒店预订
  8796. /// 创建 入住卷号码
  8797. /// </summary>
  8798. /// <param name="_dto"></param>
  8799. /// <returns></returns>
  8800. [HttpPost]
  8801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8802. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8803. {
  8804. try
  8805. {
  8806. #region 参数验证
  8807. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8808. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8809. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8811. #region 页面操作权限验证
  8812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8813. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8814. #endregion
  8815. #region 团组操作权限验证 76 酒店预定模块
  8816. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8817. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8818. #endregion
  8819. #endregion
  8820. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8821. if (data.Code != 0)
  8822. {
  8823. return Ok(JsonView(false, data.Msg));
  8824. }
  8825. return Ok(JsonView(true, data.Msg, data.Data));
  8826. }
  8827. catch (Exception ex)
  8828. {
  8829. return Ok(JsonView(false, ex.Message));
  8830. }
  8831. }
  8832. /// <summary>
  8833. /// 酒店预订
  8834. /// 详情
  8835. /// </summary>
  8836. /// <param name="_dto"></param>
  8837. /// <returns></returns>
  8838. [HttpPost]
  8839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8840. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8841. {
  8842. #region 参数验证
  8843. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8844. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8845. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8846. #region 团组操作权限验证 76 酒店预定模块
  8847. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8848. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8849. #endregion
  8850. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8851. #region 页面操作权限验证
  8852. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8853. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8854. #endregion
  8855. #endregion
  8856. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8857. }
  8858. /// <summary>
  8859. /// 酒店预订
  8860. /// Add Or Edit
  8861. /// </summary>
  8862. /// <param name="_dto"></param>
  8863. /// <returns></returns>
  8864. [HttpPost]
  8865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8866. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8867. {
  8868. #region 参数验证
  8869. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8870. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8871. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8872. #region 团组操作权限验证 76 酒店预定模块
  8873. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8874. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8875. #endregion
  8876. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8877. #region 页面操作权限验证
  8878. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8879. if (_dto.Id == 0) // Add
  8880. {
  8881. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8882. }
  8883. else if (_dto.Id > 1) // Edit
  8884. {
  8885. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8886. }
  8887. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8888. #endregion
  8889. #endregion
  8890. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8891. if (_view.Code != 200)
  8892. {
  8893. return Ok(_view);
  8894. }
  8895. #region 应用推送
  8896. try
  8897. {
  8898. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8899. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8900. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8901. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8902. //自动审核
  8903. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8904. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  8905. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  8906. }
  8907. catch (Exception ex)
  8908. {
  8909. }
  8910. #endregion
  8911. return Ok(_view);
  8912. }
  8913. /// <summary>
  8914. /// 酒店自动审核测试
  8915. /// Add Or Edit
  8916. /// </summary>
  8917. /// <param name="_dto"></param>
  8918. /// <returns></returns>
  8919. [HttpPost]
  8920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8921. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  8922. {
  8923. #region 应用推送
  8924. try
  8925. {
  8926. //自动审核
  8927. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  8928. }
  8929. catch (Exception ex)
  8930. {
  8931. return Ok(JsonView(false, "操作失败"));
  8932. }
  8933. #endregion
  8934. return Ok(JsonView(false,"操作成功"));
  8935. }
  8936. /// <summary>
  8937. /// 酒店预订
  8938. /// Del
  8939. /// </summary>
  8940. /// <param name="_dto"></param>
  8941. /// <returns></returns>
  8942. [HttpPost]
  8943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8944. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8945. {
  8946. #region 参数验证
  8947. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8948. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8949. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8950. #region 团组操作权限验证 76 酒店预定模块
  8951. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8952. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8953. #endregion
  8954. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8955. #region 页面操作权限验证
  8956. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8957. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8958. #endregion
  8959. #endregion
  8960. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8961. }
  8962. /// <summary>
  8963. /// 酒店预订
  8964. /// 生成VOUCHER
  8965. /// 2024.05.06 之前版本
  8966. /// </summary>
  8967. /// <param name="_dto"></param>
  8968. /// <returns></returns>
  8969. [HttpPost]
  8970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8971. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  8972. {
  8973. try
  8974. {
  8975. #region 参数验证
  8976. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8977. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8978. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8979. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  8980. #region 团组操作权限验证 76 酒店预定模块
  8981. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8982. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8983. #endregion
  8984. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8985. #region 页面操作权限验证
  8986. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8987. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8988. #endregion
  8989. #endregion
  8990. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8991. //判断数据是否完整
  8992. if (hr != null)
  8993. {
  8994. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8995. {
  8996. string strFileName = "HotelStatement/";
  8997. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8998. if (dele != null)
  8999. strFileName += dele.TourCode;
  9000. //载入模板
  9001. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9002. Document doc = new Document(sss);
  9003. DocumentBuilder builder = new DocumentBuilder(doc);
  9004. #region 替换Word模板书签内容
  9005. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9006. //入住卷预定号码
  9007. if (doc.Range.Bookmarks["VNO"] != null)
  9008. {
  9009. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9010. mark.Text = hr.CheckNumber;
  9011. }
  9012. //酒店时间
  9013. if (doc.Range.Bookmarks["Date"] != null)
  9014. {
  9015. Bookmark mark = doc.Range.Bookmarks["Date"];
  9016. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9017. }
  9018. //团号
  9019. if (doc.Range.Bookmarks["TNo"] != null)
  9020. {
  9021. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9022. mark.Text = dele.TourCode;
  9023. }
  9024. //预定号码
  9025. if (doc.Range.Bookmarks["BookingId"] != null)
  9026. {
  9027. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9028. mark.Text = hr.ReservationsNo;
  9029. }
  9030. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9031. {
  9032. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9033. mark.Text = hr.DetermineNo;
  9034. }
  9035. //酒店城市
  9036. if (doc.Range.Bookmarks["City"] != null)
  9037. {
  9038. Bookmark mark = doc.Range.Bookmarks["City"];
  9039. mark.Text = hr.City;
  9040. }
  9041. //酒店名称
  9042. if (doc.Range.Bookmarks["HName"] != null)
  9043. {
  9044. Bookmark mark = doc.Range.Bookmarks["HName"];
  9045. mark.Text = hr.HotelName;
  9046. }
  9047. //酒店地址
  9048. if (doc.Range.Bookmarks["Address"] != null)
  9049. {
  9050. Bookmark mark = doc.Range.Bookmarks["Address"];
  9051. mark.Text = hr.HotelAddress;
  9052. }
  9053. //酒店电话
  9054. if (doc.Range.Bookmarks["Tel"] != null)
  9055. {
  9056. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9057. mark.Text = hr.HotelTel;
  9058. }
  9059. //酒店传真
  9060. if (doc.Range.Bookmarks["Fax"] != null)
  9061. {
  9062. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9063. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9064. {
  9065. mark.Text = hr.HotelFax;
  9066. }
  9067. }
  9068. //入住时间
  9069. if (doc.Range.Bookmarks["CIn"] != null)
  9070. {
  9071. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9072. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9073. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9074. }
  9075. //退房时间
  9076. if (doc.Range.Bookmarks["COut"] != null)
  9077. {
  9078. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9079. Bookmark mark = doc.Range.Bookmarks["COut"];
  9080. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9081. }
  9082. //客户名称
  9083. if (doc.Range.Bookmarks["GName"] != null)
  9084. {
  9085. string guestName = "";
  9086. string[] clients = new string[] { };
  9087. if (hr.GuestName.Contains(","))
  9088. {
  9089. clients = hr.GuestName.Split(",");
  9090. }
  9091. else
  9092. {
  9093. clients = new string[] { hr.GuestName };
  9094. }
  9095. List<int> clientIds_int = new List<int>();
  9096. if (clients.Length > 0)
  9097. {
  9098. foreach (var item in clients)
  9099. {
  9100. if (item.IsNumeric())
  9101. {
  9102. clientIds_int.Add(int.Parse(item));
  9103. }
  9104. }
  9105. }
  9106. if (clientIds_int.Count > 0)
  9107. {
  9108. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9109. foreach (var client in _clientDatas)
  9110. {
  9111. //男
  9112. if (client.Sex == 0) guestName += $"Mr.";
  9113. //女
  9114. else if (client.Sex == 1) guestName += $"Ms.";
  9115. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9116. {
  9117. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9118. }
  9119. //guestName += $"{client.Pinyin},";
  9120. }
  9121. if (guestName.Length > 0)
  9122. {
  9123. guestName = guestName.Substring(0, guestName.Length - 1);
  9124. }
  9125. }
  9126. else
  9127. {
  9128. guestName = hr.GuestName;
  9129. }
  9130. Bookmark mark = doc.Range.Bookmarks["GName"];
  9131. mark.Text = guestName;
  9132. }
  9133. //房间介绍
  9134. if (doc.Range.Bookmarks["ROOM"] != null)
  9135. {
  9136. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9137. mark.Text = hr.RoomExplanation;
  9138. }
  9139. //报价描述
  9140. if (doc.Range.Bookmarks["NOTE"] != null)
  9141. {
  9142. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9143. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9144. if (ss != null)
  9145. mark.Text = ss.Name;
  9146. }
  9147. //入住时间
  9148. if (doc.Range.Bookmarks["CheckIn"] != null)
  9149. {
  9150. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9151. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9152. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9153. }
  9154. //退房时间
  9155. if (doc.Range.Bookmarks["CheckOut"] != null)
  9156. {
  9157. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9158. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9159. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9160. }
  9161. //日期
  9162. if (doc.Range.Bookmarks["DT"] != null)
  9163. {
  9164. Bookmark mark = doc.Range.Bookmarks["DT"];
  9165. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9166. }
  9167. //名称
  9168. if (doc.Range.Bookmarks["VName"] != null)
  9169. {
  9170. Bookmark mark = doc.Range.Bookmarks["VName"];
  9171. mark.Text = hr.HotelName;
  9172. }
  9173. //号码
  9174. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9175. {
  9176. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9177. mark.Text = hr.CheckNumber;
  9178. }
  9179. #endregion
  9180. strFileName += "VOUCHER.doc";
  9181. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9182. doc.Save(fileDir);
  9183. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9184. return Ok(JsonView(true, "操作成功!", Url));
  9185. }
  9186. else
  9187. {
  9188. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9189. }
  9190. }
  9191. else
  9192. {
  9193. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9194. }
  9195. }
  9196. catch (Exception ex)
  9197. {
  9198. return Ok(JsonView(false, ex.Message));
  9199. }
  9200. }
  9201. /// <summary>
  9202. /// 酒店预订
  9203. /// 生成VOUCHER
  9204. /// 2024.05.06 之后版本
  9205. /// </summary>
  9206. /// <param name="_dto"></param>
  9207. /// <returns></returns>
  9208. [HttpPost]
  9209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9210. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9211. {
  9212. #region 参数验证
  9213. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9214. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9215. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9216. #region 团组操作权限验证 76 酒店预定模块
  9217. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9218. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9219. #endregion
  9220. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9221. #region 页面操作权限验证
  9222. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9223. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9224. #endregion
  9225. #endregion
  9226. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9227. //判断数据是否完整
  9228. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9229. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9230. string strFileName = "HotelStatement/";
  9231. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9232. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9233. #region 数据处理
  9234. List<int> guestIds = new List<int>();
  9235. int index = 0;
  9236. foreach (var item in hrDtas)
  9237. {
  9238. if (item.GuestName.Contains(","))
  9239. {
  9240. string[] guestIdArr = item.GuestName.Split(',');
  9241. foreach (var guestIdStr in guestIdArr)
  9242. {
  9243. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9244. if (guestBool)
  9245. {
  9246. guestIds.Add(guestId);
  9247. }
  9248. }
  9249. }
  9250. else guestNames += item.GuestName;
  9251. var voucherInfo = new HotelVoucherInfoView()
  9252. {
  9253. HotelName = item.HotelName,
  9254. CheckInDate = item.CheckInDate,
  9255. CheckOutDate = item.CheckOutDate,
  9256. ConfirmationNumber = item.DetermineNo.Trim(),
  9257. RoomType = item.RoomExplanation
  9258. };
  9259. vouchers.Add(voucherInfo);
  9260. }
  9261. if (guestIds.Count > 0)
  9262. {
  9263. guestIds = guestIds.Distinct().ToList();
  9264. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9265. if (guestDatas.Count > 0)
  9266. {
  9267. guestNames = "";
  9268. foreach (var guest in guestDatas)
  9269. {
  9270. string guestName = "";
  9271. if (guest.Sex == 0) guestName += @"MR.";
  9272. else if (guest.Sex == 1) guestName += @"MS.";
  9273. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9274. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9275. guestNames += @$"{guestName.Trim()}、";
  9276. }
  9277. if (guestNames.Length > 0)
  9278. {
  9279. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9280. }
  9281. }
  9282. }
  9283. #endregion
  9284. //载入模板
  9285. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9286. Document doc = new Document(sss);
  9287. DocumentBuilder builder = new DocumentBuilder(doc);
  9288. if (doc.Range.Bookmarks["GuestName"] != null)
  9289. {
  9290. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9291. mark.Text = guestNames;
  9292. }
  9293. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9294. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9295. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9296. for (int i = 1; i <= vouchers.Count; i++)
  9297. {
  9298. HotelVoucherInfoView hviv = vouchers[i - 1];
  9299. builder.MoveToCell(0, i, 0, 0);
  9300. builder.Write(hviv.HotelName);
  9301. builder.MoveToCell(0, i, 1, 0);
  9302. builder.Write(hviv.CheckInDate);
  9303. builder.MoveToCell(0, i, 2, 0);
  9304. builder.Write(hviv.CheckOutDate);
  9305. builder.MoveToCell(0, i, 3, 0);
  9306. builder.Write(hviv.RoomType);
  9307. builder.MoveToCell(0, i, 4, 0);
  9308. builder.Write(hviv.ConfirmationNumber);
  9309. }
  9310. //删除多余行
  9311. int currRowIndex = vouchers.Count + 1;
  9312. int delRows = 21 - currRowIndex;
  9313. if (delRows > 0)
  9314. {
  9315. for (int i = 0; i < delRows; i++)
  9316. {
  9317. table.Rows.RemoveAt(currRowIndex);
  9318. //cultivateRowIndex++;
  9319. }
  9320. }
  9321. strFileName += "VOUCHER.docx";
  9322. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9323. doc.Save(fileDir);
  9324. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9325. return Ok(JsonView(true, "操作成功!", Url));
  9326. }
  9327. /// <summary>
  9328. /// 酒店预订
  9329. /// 生成VOUCHER 批量生成
  9330. /// New
  9331. /// </summary>
  9332. /// <param name="_dto"></param>
  9333. /// <returns></returns>
  9334. [HttpPost]
  9335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9336. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9337. {
  9338. #region 参数验证
  9339. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9340. if (_dto.PageId < 1) _dto.PageId = 28;
  9341. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9342. #region 团组操作权限验证 76 酒店预定模块
  9343. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9344. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9345. #endregion
  9346. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9347. #region 页面操作权限验证
  9348. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9349. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9350. #endregion
  9351. #endregion
  9352. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9353. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9354. .OrderBy(x => x.CreateTime)
  9355. .ToListAsync();
  9356. //判断数据是否完整
  9357. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9358. string strFileName = "HotelStatement/";
  9359. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9360. if (dele != null)
  9361. strFileName += $"{dele.TourCode}_";
  9362. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9363. for (int i = 0; i < hrDtas.Count; i++)
  9364. {
  9365. string guestNames = string.Empty;
  9366. List<int> guestIds = new List<int>();
  9367. var item = hrDtas[i];
  9368. //处理客户姓名
  9369. if (item.GuestName.Contains(","))
  9370. {
  9371. string[] guestIdArr = item.GuestName.Split(',');
  9372. foreach (var guestIdStr in guestIdArr)
  9373. if (int.TryParse(guestIdStr, out int guestId))
  9374. guestIds.Add(guestId);
  9375. }
  9376. else guestNames += item.GuestName;
  9377. if (guestIds.Count > 0)
  9378. {
  9379. guestIds = guestIds.Distinct().ToList();
  9380. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9381. if (guestDatas1.Count > 0)
  9382. {
  9383. guestNames = "";
  9384. foreach (var guest in guestDatas1)
  9385. {
  9386. string guestName = "";
  9387. if (guest.Sex == 0) guestName += @"MR.";
  9388. else if (guest.Sex == 1) guestName += @"MS.";
  9389. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9390. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9391. guestNames += @$"{guestName.Trim()}、";
  9392. }
  9393. if (guestNames.Length > 0)
  9394. {
  9395. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9396. }
  9397. }
  9398. }
  9399. if (!string.IsNullOrEmpty(guestNames))
  9400. {
  9401. hrDtas[i].GuestName = guestNames;
  9402. }
  9403. }
  9404. strFileName += $"{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}_VOUCHER.docx";
  9405. Document doc = new Document();
  9406. DocumentBuilder builder = new DocumentBuilder(doc);
  9407. try
  9408. {
  9409. #region 设置页眉
  9410. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  9411. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  9412. //靠右
  9413. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  9414. // 设置页脚上下边距
  9415. builder.PageSetup.HeaderDistance = 42;
  9416. // 添加页眉线
  9417. Aspose.Words.Border borderHeader = null;
  9418. try
  9419. {
  9420. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  9421. }
  9422. catch (Exception e)
  9423. {
  9424. // TODO Auto-generated catch block
  9425. //e.printStackTrace();
  9426. }
  9427. borderHeader.Shadow = true;
  9428. borderHeader.DistanceFromText = 2;
  9429. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  9430. if (System.IO.File.Exists(voucherHeaderPath))
  9431. {
  9432. //页眉加载图片
  9433. var image = Image.FromFile(voucherHeaderPath);
  9434. builder.InsertImage(image, RelativeHorizontalPosition.Default, 1, RelativeVerticalPosition.Margin, 1, 1.20, 2.70, WrapType.Inline);
  9435. }
  9436. #endregion
  9437. builder.MoveToDocumentStart();
  9438. foreach (var item in hrDtas)
  9439. {
  9440. //标题
  9441. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9442. builder.ParagraphFormat.LineSpacing = 1;
  9443. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9444. //builder.ParagraphFormat.Style.Font.Size = 12;
  9445. //builder.ParagraphFormat.Style.Font.Bold = true;
  9446. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9447. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9448. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9449. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9450. builder.ParagraphFormat.LineSpacing = 1;
  9451. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9452. //builder.ParagraphFormat.Style.Font.Size = 12;
  9453. //builder.ParagraphFormat.Style.Font.Bold = true;
  9454. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9455. //获取Font对象
  9456. Aspose.Words.Font font = builder.Font;
  9457. //字体大小
  9458. font.Size = 8;
  9459. //是否粗体
  9460. font.Bold = false;
  9461. //下划线样式,None为无下划线
  9462. font.Underline = Underline.None;
  9463. builder.StartTable();
  9464. //RowFormat rowf = builder.RowFormat;
  9465. //rowf.Height = 20;
  9466. // 设置边框颜色
  9467. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9468. //设置边框样式
  9469. //builder.CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.Double;
  9470. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.None;
  9471. //表格
  9472. #region 第一行
  9473. builder.InsertCell();
  9474. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9475. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9476. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9477. builder.ParagraphFormat.Style.Font.Size = 8;
  9478. builder.ParagraphFormat.Style.Font.Bold = false;
  9479. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9480. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9481. builder.Write("TOUR NO:");
  9482. builder.InsertCell();
  9483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9484. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9485. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9486. builder.ParagraphFormat.Style.Font.Size = 8;
  9487. builder.ParagraphFormat.Style.Font.Bold = false;
  9488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9490. builder.Write($"{dele?.TourCode ?? "-"}");
  9491. builder.InsertCell();
  9492. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9493. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9494. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9495. builder.ParagraphFormat.Style.Font.Size = 8;
  9496. builder.ParagraphFormat.Style.Font.Bold = false;
  9497. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9498. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9499. builder.Write($"CITY:");
  9500. builder.InsertCell();
  9501. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9502. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9503. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9504. builder.ParagraphFormat.Style.Font.Size = 8;
  9505. builder.ParagraphFormat.Style.Font.Bold = false;
  9506. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9508. builder.Write($"{item.City}");
  9509. builder.EndRow();
  9510. #endregion
  9511. #region 第二行
  9512. builder.InsertCell();
  9513. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9514. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9515. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9516. builder.ParagraphFormat.Style.Font.Size = 8;
  9517. builder.ParagraphFormat.Style.Font.Bold = false;
  9518. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9519. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9520. builder.Write("CONFIRMATION NO:");
  9521. builder.InsertCell();
  9522. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9523. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9524. builder.ParagraphFormat.Style.Font.Size = 8;
  9525. builder.ParagraphFormat.Style.Font.Bold = false;
  9526. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9527. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9528. builder.CellFormat.VerticalMerge = CellMerge.None;
  9529. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9530. builder.Write($"{item.DetermineNo}");
  9531. builder.InsertCell();
  9532. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9533. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9534. builder.InsertCell();
  9535. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9536. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9537. builder.EndRow();
  9538. #endregion
  9539. #region 第三行
  9540. builder.InsertCell();
  9541. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9542. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9543. builder.ParagraphFormat.Style.Font.Size = 8;
  9544. builder.ParagraphFormat.Style.Font.Bold = false;
  9545. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9546. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9547. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9548. builder.Write($"HOTEL NAME:");
  9549. builder.InsertCell();
  9550. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9551. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9552. builder.ParagraphFormat.Style.Font.Size = 8;
  9553. builder.ParagraphFormat.Style.Font.Bold = false;
  9554. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9555. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9557. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9558. builder.Write($"{item.HotelName}");
  9559. builder.InsertCell();
  9560. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9561. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9562. builder.InsertCell();
  9563. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9564. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9565. builder.EndRow();
  9566. #endregion
  9567. #region 第四行
  9568. builder.InsertCell();
  9569. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9570. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9571. builder.ParagraphFormat.Style.Font.Size = 8;
  9572. builder.ParagraphFormat.Style.Font.Bold = false;
  9573. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9574. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9575. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9576. builder.Write($"HOTEL ADDRESS:");
  9577. builder.InsertCell();
  9578. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9579. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9580. builder.ParagraphFormat.Style.Font.Size = 8;
  9581. builder.ParagraphFormat.Style.Font.Bold = false;
  9582. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9583. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9584. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9585. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9586. builder.Write($"{item.HotelAddress}");
  9587. builder.InsertCell();
  9588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9589. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9590. builder.InsertCell();
  9591. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9592. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9593. builder.EndRow();
  9594. #endregion
  9595. #region 第五行
  9596. builder.InsertCell();
  9597. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9598. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9599. builder.ParagraphFormat.Style.Font.Size = 8;
  9600. builder.ParagraphFormat.Style.Font.Bold = false;
  9601. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9602. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9603. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9604. builder.Write("TEL:");
  9605. builder.InsertCell();
  9606. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9607. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9608. builder.ParagraphFormat.Style.Font.Size = 8;
  9609. builder.ParagraphFormat.Style.Font.Bold = false;
  9610. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9611. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9612. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9613. builder.Write($"{item.HotelTel}");
  9614. builder.InsertCell();
  9615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9616. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9617. builder.ParagraphFormat.Style.Font.Size = 8;
  9618. builder.ParagraphFormat.Style.Font.Bold = false;
  9619. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9620. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9621. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9622. builder.Write($"FAX:");
  9623. builder.InsertCell();
  9624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9625. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9626. builder.ParagraphFormat.Style.Font.Size = 8;
  9627. builder.ParagraphFormat.Style.Font.Bold = false;
  9628. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9629. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9630. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9631. builder.Write($"{item.HotelFax}");
  9632. builder.EndRow();
  9633. #endregion
  9634. #region 第六行
  9635. builder.InsertCell();
  9636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9637. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9638. builder.ParagraphFormat.Style.Font.Size = 8;
  9639. builder.ParagraphFormat.Style.Font.Bold = false;
  9640. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9643. builder.Write("CHECK IN:");
  9644. builder.InsertCell();
  9645. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9646. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9647. builder.ParagraphFormat.Style.Font.Size = 8;
  9648. builder.ParagraphFormat.Style.Font.Bold = false;
  9649. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9650. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9651. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9652. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  9653. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9654. builder.Write($"{checkInStr}");
  9655. builder.InsertCell();
  9656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9657. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9658. builder.ParagraphFormat.Style.Font.Size = 8;
  9659. builder.ParagraphFormat.Style.Font.Bold = false;
  9660. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9661. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9662. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9663. builder.Write($"CHECK OUT:");
  9664. builder.InsertCell();
  9665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9666. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9667. builder.ParagraphFormat.Style.Font.Size = 8;
  9668. builder.ParagraphFormat.Style.Font.Bold = false;
  9669. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9670. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9671. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9672. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  9673. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  9674. builder.Write($"{checkOutStr}");
  9675. builder.EndRow();
  9676. #endregion
  9677. #region 第七行
  9678. builder.InsertCell();
  9679. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9680. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9681. builder.ParagraphFormat.Style.Font.Size = 8;
  9682. builder.ParagraphFormat.Style.Font.Bold = false;
  9683. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9684. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9685. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9686. builder.Write($"GUEST NAME:");
  9687. builder.InsertCell();
  9688. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9689. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9690. builder.ParagraphFormat.Style.Font.Size = 8;
  9691. builder.ParagraphFormat.Style.Font.Bold = false;
  9692. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9693. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9694. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9695. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9696. builder.Write($"{item.GuestName}");
  9697. builder.InsertCell();
  9698. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9699. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9700. builder.InsertCell();
  9701. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9702. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9703. builder.EndRow();
  9704. #endregion
  9705. #region 第八行
  9706. builder.InsertCell();
  9707. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9708. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9709. builder.ParagraphFormat.Style.Font.Size = 8;
  9710. builder.ParagraphFormat.Style.Font.Bold = false;
  9711. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9712. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9713. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9714. builder.Write($"ROOM TYPE:");
  9715. builder.InsertCell();
  9716. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9717. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9718. builder.ParagraphFormat.Style.Font.Size = 8;
  9719. builder.ParagraphFormat.Style.Font.Bold = false;
  9720. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9721. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9722. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9723. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9724. builder.Write($"{item.RoomExplanation}");
  9725. builder.InsertCell();
  9726. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9727. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9728. builder.InsertCell();
  9729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9730. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9731. builder.EndRow();
  9732. #endregion
  9733. #region 第九行
  9734. builder.InsertCell();
  9735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9736. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9737. builder.ParagraphFormat.Style.Font.Size = 8;
  9738. builder.ParagraphFormat.Style.Font.Bold = false;
  9739. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9742. builder.Write($"NOTE:");
  9743. builder.InsertCell();
  9744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9745. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9746. builder.ParagraphFormat.Style.Font.Size = 8;
  9747. builder.ParagraphFormat.Style.Font.Bold = false;
  9748. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9749. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9750. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9751. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9752. builder.Write($"ROOM AND TAX ONLY\r\nTHIS SERVICE IS PAYABLE BY BEDSONLINE. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST");
  9753. builder.InsertCell();
  9754. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9755. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9756. builder.InsertCell();
  9757. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9758. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9759. builder.EndRow();
  9760. #endregion
  9761. builder.EndTable();
  9762. builder.Writeln("");
  9763. builder.Writeln("");
  9764. }
  9765. //// 遍历文档中的所有段落
  9766. //foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
  9767. //{
  9768. // // 设置段落的字体样式
  9769. // // 这里我们设置字体为Times New Roman,大小为12,加粗
  9770. // para.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9771. // para.ParagraphFormat.Style.Font.Size = 12;
  9772. // para.ParagraphFormat.Style.Font.Bold = true;
  9773. //}
  9774. }
  9775. catch (Exception ex)
  9776. {
  9777. }
  9778. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9779. doc.Save(fileDir);
  9780. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9781. return Ok(JsonView(true, "操作成功!", Url));
  9782. }
  9783. /// <summary>
  9784. /// 酒店预订
  9785. /// 生成 预定成本 Excel
  9786. /// </summary>
  9787. /// <param name="_dto"></param>
  9788. /// <returns></returns>
  9789. [HttpPost]
  9790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9791. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9792. {
  9793. #region 参数验证
  9794. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9795. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9796. if (!vadalitorRes.IsValid)
  9797. {
  9798. var errors = new StringBuilder();
  9799. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9800. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9801. }
  9802. #region 团组操作权限验证 76 酒店预定模块
  9803. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9804. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9805. #endregion
  9806. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9807. #region 页面操作权限验证
  9808. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9809. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9810. #endregion
  9811. #endregion
  9812. decimal _rate = 1.00M;
  9813. string _currency = "";
  9814. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9815. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9816. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9817. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9818. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9819. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9820. {
  9821. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9822. }
  9823. _currency = _GroupCostParameter.Currency;
  9824. bool isIntType = int.TryParse(_currency, out int currId);
  9825. if (isIntType)
  9826. {
  9827. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9828. }
  9829. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9830. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9831. if (currInfo == null)
  9832. {
  9833. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9834. }
  9835. if (!_currency.ToUpper().Equals("CNY"))
  9836. {
  9837. _rate = _GroupCostParameter.Rate;
  9838. }
  9839. _rate = currInfo.Rate;
  9840. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9841. string strFileName = "HotelStatement/";
  9842. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9843. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9844. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9845. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9846. #region 数据处理
  9847. foreach (var item in hrDtas)
  9848. {
  9849. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9850. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9851. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9852. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9853. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9854. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  9855. string singleRoomFeeStr = string.Empty,
  9856. doubleRoomFeeStr = string.Empty,
  9857. suiteRoomFeeStr = string.Empty,
  9858. otherRoomFeeStr = string.Empty,
  9859. payMoneyStr = string.Empty,
  9860. cardPriceStr = string.Empty;
  9861. if (roomCurr.Equals(_currency))
  9862. {
  9863. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9864. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9865. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9866. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9867. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9868. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9869. }
  9870. else
  9871. {
  9872. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9873. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9874. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9875. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9876. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9877. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9878. }
  9879. string breakfastPriceStr = string.Empty,
  9880. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9881. governmentRentStr = string.Empty,
  9882. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9883. cityTaxStrStr = string.Empty,
  9884. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9885. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9886. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9887. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9888. int payDId = roomInfo?.PayDId ?? 0;
  9889. pcfds.Add(new HotelReservations_PCFD_View()
  9890. {
  9891. City = item.City,
  9892. HotelName = item.HotelName,
  9893. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9894. // SingleRoomCount = item.SingleRoomCount,
  9895. SingleRoomPrice = singleRoomFeeStr,
  9896. // DoubleRoomCount = item.DoubleRoomCount,
  9897. DoubleRoomPrice = doubleRoomFeeStr,
  9898. //SuiteRoomCount = item.SuiteRoomCount,
  9899. SuiteRoomPrice = suiteRoomFeeStr,
  9900. OtherRoomPrice = otherRoomFeeStr,
  9901. //OtherRoomCount = item.OtherRoomCount,
  9902. BreakfastPrice = breakfastPriceStr,
  9903. GovernmentRent = governmentRentStr,
  9904. CityTax = cityTaxStrStr,
  9905. RoomExplanation = item.RoomExplanation,
  9906. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  9907. PayTime = roomInfo?.ConsumptionDate,
  9908. BankNo = roomInfo?.BankNo,
  9909. PayMoney = payMoneyStr,
  9910. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9911. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  9912. CardPrice = cardPriceStr,
  9913. Remark = ccpInfo.Remark
  9914. });
  9915. }
  9916. #endregion
  9917. //载入模板
  9918. WorkbookDesigner designer = new WorkbookDesigner();
  9919. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9920. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9921. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9922. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9923. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9924. designer.SetDataSource("Opertor", userInfo.CnName);
  9925. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9926. dt.TableName = "ViewMyHotelReservations";
  9927. designer.SetDataSource(dt);
  9928. designer.Process();
  9929. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9930. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9931. designer.Workbook.Save(serverPath);
  9932. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9933. #region 删除指定行
  9934. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9935. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9936. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9937. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9938. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9939. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9940. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9941. cssIndex = dt.Columns["CityTax"].Ordinal,
  9942. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9943. remarkIndex = dt.Columns["Remark"].Ordinal;
  9944. //删除指定列
  9945. foreach (DataRow item in dt.Rows)
  9946. {
  9947. string singleStr = item["SingleRoomPrice"].ToString();
  9948. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9949. if (containsDigitButNotZero1) singleDel = false;
  9950. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9951. string doubleStr = item["DoubleRoomPrice"].ToString();
  9952. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9953. if (containsDigitButNotZero2) doubleDel = false;
  9954. string suiteStr = item["SuiteRoomPrice"].ToString();
  9955. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9956. if (containsDigitButNotZero3) suiteDel = false;
  9957. string otherStr = item["OtherRoomPrice"].ToString();
  9958. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9959. if (containsDigitButNotZero4) otherDel = false;
  9960. string zcStr = item["BreakfastPrice"].ToString();
  9961. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9962. if (containsDigitButNotZero5) zcDel = false;
  9963. string dsStr = item["GovernmentRent"].ToString();
  9964. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9965. if (containsDigitButNotZero6) dsDel = false;
  9966. string cssStr = item["CityTax"].ToString();
  9967. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9968. if (containsDigitButNotZero7) cssDel = false;
  9969. string cpStr = item["ConsumptionPatterns"].ToString();
  9970. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9971. string remarkStr = item["Remark"].ToString();
  9972. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9973. }
  9974. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9975. DeleteColumn(serverPath, cpIndex, cpDel);
  9976. DeleteColumn(serverPath, dsIndex, dsDel);
  9977. DeleteColumn(serverPath, cssIndex, cssDel);
  9978. DeleteColumn(serverPath, zcIndex, zcDel);
  9979. DeleteColumn(serverPath, otherIndex, otherDel);
  9980. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9981. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9982. DeleteColumn(serverPath, singleIndex, singleDel);
  9983. #endregion
  9984. //只保留第一个表格
  9985. DeleteSheet(serverPath);
  9986. return Ok(JsonView(true, "操作成功", url = rst));
  9987. }
  9988. /// <summary>
  9989. /// 删除指定列
  9990. /// </summary>
  9991. /// <param name="file"></param>
  9992. /// <param name="columnIndex"></param>
  9993. /// <param name="isDel"></param>
  9994. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9995. {
  9996. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9997. //wb.Save(file);
  9998. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9999. if (sheet1 != null)
  10000. {
  10001. if (isDel)
  10002. {
  10003. Cells cells = sheet1.Cells;
  10004. cells.DeleteColumn(columnIndex);
  10005. }
  10006. }
  10007. wb.Save(file);
  10008. }
  10009. /// <summary>
  10010. /// 删除sheet
  10011. /// </summary>
  10012. /// <param name="file"></param>
  10013. /// <param name="sheetName"></param>
  10014. private void DeleteSheet(string file, string sheetName = "")
  10015. {
  10016. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10017. //wb.Save(file);
  10018. List<string> sheets = new List<string>();
  10019. foreach (var item in wb.Worksheets)
  10020. {
  10021. sheets.Add(item.Name);
  10022. }
  10023. if (sheets.Count > 0)
  10024. {
  10025. sheets.RemoveAt(0);//不删除第一个sheet
  10026. foreach (var item in sheets)
  10027. {
  10028. wb.Worksheets.RemoveAt(item);
  10029. }
  10030. }
  10031. wb.Save(file);
  10032. }
  10033. /// <summary>
  10034. /// 酒店预订
  10035. /// 确认单
  10036. /// </summary>
  10037. /// <param name="_dto"></param>
  10038. /// <returns></returns>
  10039. [HttpPost]
  10040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10041. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10042. {
  10043. try
  10044. {
  10045. #region 参数验证
  10046. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10047. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10048. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10049. #region 团组操作权限验证 76 酒店预定模块
  10050. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10051. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10052. #endregion
  10053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10054. #region 页面操作权限验证
  10055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10056. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10057. #endregion
  10058. #endregion
  10059. //团组信息
  10060. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10061. //酒店数据
  10062. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10063. if (listhoteldata.Count < 0)
  10064. {
  10065. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10066. }
  10067. //利datatable存储
  10068. DataTable dt = new DataTable();
  10069. dt.Columns.Add("CheckInDate", typeof(string));
  10070. dt.Columns.Add("City", typeof(string));
  10071. dt.Columns.Add("Hotel", typeof(string));
  10072. dt.Columns.Add("Room", typeof(string));
  10073. for (int i = 0; i < listhoteldata.Count; i++)
  10074. {
  10075. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10076. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10077. while (dayStart < dayEnd)
  10078. {
  10079. string temp = "";
  10080. DataRow row = dt.NewRow();
  10081. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10082. row["City"] = listhoteldata[i].City;
  10083. row["Hotel"] = listhoteldata[i].HotelName;
  10084. if (listhoteldata[i].SingleRoomCount > 0)
  10085. {
  10086. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10087. }
  10088. if (listhoteldata[i].DoubleRoomCount > 0)
  10089. {
  10090. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10091. }
  10092. if (listhoteldata[i].SuiteRoomCount > 0)
  10093. {
  10094. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10095. }
  10096. if (listhoteldata[i].OtherRoomCount > 0)
  10097. {
  10098. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10099. }
  10100. row["Room"] = temp;
  10101. dt.Rows.Add(row);
  10102. dayStart = dayStart.AddDays(1);
  10103. }
  10104. }
  10105. Dictionary<string, string> dic = new Dictionary<string, string>();
  10106. dic.Add("Dele", di.TeamName);
  10107. dic.Add("City", di.VisitCountry);
  10108. //模板路径
  10109. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10110. //载入模板
  10111. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10112. DocumentBuilder builder = new DocumentBuilder(doc);
  10113. foreach (var key in dic.Keys)
  10114. {
  10115. builder.MoveToBookmark(key);
  10116. builder.Write(dic[key]);
  10117. }
  10118. //获取word里所有表格
  10119. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10120. //获取所填表格的序数
  10121. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10122. var rowStart = tableOne.Rows[0]; //获取第1行
  10123. //循环赋值
  10124. for (int i = 0; i < dt.Rows.Count; i++)
  10125. {
  10126. builder.MoveToCell(0, i + 1, 0, 0);
  10127. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10128. builder.MoveToCell(0, i + 1, 1, 0);
  10129. builder.Write(dt.Rows[i]["City"].ToString());
  10130. builder.MoveToCell(0, i + 1, 2, 0);
  10131. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10132. builder.MoveToCell(0, i + 1, 3, 0);
  10133. builder.Write(dt.Rows[i]["Room"].ToString());
  10134. }
  10135. //删除多余行
  10136. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10137. {
  10138. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10139. }
  10140. string strFileName = di.TeamName + "酒店确认单.doc";
  10141. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10142. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10143. return Ok(JsonView(true, "成功", url));
  10144. }
  10145. catch (Exception ex)
  10146. {
  10147. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10148. }
  10149. }
  10150. #endregion
  10151. #region 团组状态
  10152. /// <summary>
  10153. /// 团组状态列表 Page
  10154. /// </summary>
  10155. /// <param name="dto">团组列表请求dto</param>
  10156. /// <returns></returns>
  10157. [HttpPost]
  10158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10159. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10160. {
  10161. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10162. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10163. {
  10164. string sqlWhere = string.Empty;
  10165. if (dto.IsSure == 0) //未完成
  10166. {
  10167. sqlWhere += string.Format(@" And IsSure = 0");
  10168. }
  10169. else if (dto.IsSure == 1) //已完成
  10170. {
  10171. sqlWhere += string.Format(@" And IsSure = 1");
  10172. }
  10173. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10174. {
  10175. string tj = dto.SearchCriteria;
  10176. 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}%')",
  10177. tj, tj, tj, tj, tj);
  10178. }
  10179. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10180. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10181. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10182. From (
  10183. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10184. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10185. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10186. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10187. From Grp_DelegationInfo gdi
  10188. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10189. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10190. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10191. Where gdi.IsDel = 0 {0}
  10192. ) temp ", sqlWhere);
  10193. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10194. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10195. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10196. }
  10197. else
  10198. {
  10199. return Ok(JsonView(false, "查询失败"));
  10200. }
  10201. }
  10202. /// <summary>
  10203. /// 团组状态
  10204. /// 设置操作完成
  10205. /// </summary>
  10206. /// <param name="dto">团组列表请求dto</param>
  10207. /// <returns></returns>
  10208. [HttpPost]
  10209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10210. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10211. {
  10212. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10213. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10214. {
  10215. Id = dto.Id,
  10216. IsSure = 1
  10217. };
  10218. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10219. .UpdateColumns(it => new { it.IsSure })
  10220. .WhereColumns(it => new { it.Id })
  10221. .ExecuteCommandAsync();
  10222. if (result > 0)
  10223. {
  10224. return Ok(JsonView(true, "操作完成!"));
  10225. }
  10226. return Ok(JsonView(false, "操作失败!"));
  10227. }
  10228. #endregion
  10229. #region 保险费用录入
  10230. /// <summary>
  10231. /// 根据团组Id查询保险费用列表
  10232. /// </summary>
  10233. /// <param name="dto"></param>
  10234. /// <returns></returns>
  10235. [HttpPost]
  10236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10237. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10238. {
  10239. try
  10240. {
  10241. Result groupData = await _customersRep.CustomersByDiId(dto);
  10242. if (groupData.Code != 0)
  10243. {
  10244. return Ok(JsonView(false, groupData.Msg));
  10245. }
  10246. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10247. }
  10248. catch (Exception ex)
  10249. {
  10250. return Ok(JsonView(false, ex.Message));
  10251. }
  10252. }
  10253. /// <summary>
  10254. /// 根据保险费用Id查询保险费用详细
  10255. /// </summary>
  10256. /// <param name="dto"></param>
  10257. /// <returns></returns>
  10258. [HttpPost]
  10259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10260. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10261. {
  10262. try
  10263. {
  10264. Result groupData = await _customersRep.CustomersById(dto);
  10265. if (groupData.Code != 0)
  10266. {
  10267. return Ok(JsonView(false, groupData.Msg));
  10268. }
  10269. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10270. }
  10271. catch (Exception ex)
  10272. {
  10273. return Ok(JsonView(false, ex.Message));
  10274. }
  10275. }
  10276. /// <summary>
  10277. /// 保险费用录入页面初始化绑定
  10278. /// </summary>
  10279. /// <param name="dto"></param>
  10280. /// <returns></returns>
  10281. [HttpPost]
  10282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10283. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10284. {
  10285. try
  10286. {
  10287. Result groupData = await _customersRep.CustomersInitialize(dto);
  10288. if (groupData.Code != 0)
  10289. {
  10290. return Ok(JsonView(false, groupData.Msg));
  10291. }
  10292. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10293. }
  10294. catch (Exception ex)
  10295. {
  10296. return Ok(JsonView(false, ex.Message));
  10297. }
  10298. }
  10299. /// <summary>
  10300. /// 保险费用操作(Status:1.新增,2.修改)
  10301. /// </summary>
  10302. /// <param name="dto"></param>
  10303. /// <returns></returns>
  10304. [HttpPost]
  10305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10306. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10307. {
  10308. try
  10309. {
  10310. Result groupData = await _customersRep.OpCustomers(dto);
  10311. if (groupData.Code != 0)
  10312. {
  10313. return Ok(JsonView(false, groupData.Msg));
  10314. }
  10315. #region 应用推送
  10316. try
  10317. {
  10318. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10319. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10320. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10321. }
  10322. catch (Exception ex)
  10323. {
  10324. }
  10325. #endregion
  10326. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10327. }
  10328. catch (Exception ex)
  10329. {
  10330. return Ok(JsonView(false, ex.Message));
  10331. }
  10332. }
  10333. /// <summary>
  10334. /// 保险文件上传
  10335. /// </summary>
  10336. /// <param name="file"></param>
  10337. /// <returns></returns>
  10338. [HttpPost]
  10339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10340. public async Task<IActionResult> UploadCus(IFormFile file)
  10341. {
  10342. try
  10343. {
  10344. if (file != null)
  10345. {
  10346. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10347. //文件名称
  10348. string projectFileName = file.FileName;
  10349. //上传的文件的路径
  10350. string filePath = "";
  10351. if (!Directory.Exists(fileDir))
  10352. {
  10353. Directory.CreateDirectory(fileDir);
  10354. }
  10355. //上传的文件的路径
  10356. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10357. using (FileStream fs = System.IO.File.Create(filePath))
  10358. {
  10359. file.CopyTo(fs);
  10360. fs.Flush();
  10361. }
  10362. return Ok(JsonView(true, "上传成功!", projectFileName));
  10363. }
  10364. else
  10365. {
  10366. return Ok(JsonView(false, "上传失败!"));
  10367. }
  10368. }
  10369. catch (Exception ex)
  10370. {
  10371. return Ok(JsonView(false, "程序错误!"));
  10372. throw;
  10373. }
  10374. }
  10375. /// <summary>
  10376. /// 保险删除指定文件
  10377. /// </summary>
  10378. /// <param name="dto"></param>
  10379. /// <returns></returns>
  10380. [HttpPost]
  10381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10382. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10383. {
  10384. try
  10385. {
  10386. string filePath = "";
  10387. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10388. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10389. //int id = 0;
  10390. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10391. // 删除该文件
  10392. try
  10393. {
  10394. System.IO.File.Delete(filePath);
  10395. 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()
  10396. {
  10397. Attachment = "",
  10398. }).ExecuteCommandAsync();
  10399. if (result != 0)
  10400. {
  10401. return Ok(JsonView(true, "成功!"));
  10402. }
  10403. else
  10404. {
  10405. return Ok(JsonView(false, "失败!"));
  10406. }
  10407. }
  10408. catch (Exception)
  10409. {
  10410. 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()
  10411. {
  10412. Attachment = "",
  10413. }).ExecuteCommandAsync();
  10414. if (result != 0)
  10415. {
  10416. return Ok(JsonView(true, "成功!"));
  10417. }
  10418. else
  10419. {
  10420. return Ok(JsonView(false, "失败!"));
  10421. }
  10422. }
  10423. }
  10424. catch (Exception ex)
  10425. {
  10426. return Ok(JsonView(false, "程序错误!"));
  10427. throw;
  10428. }
  10429. }
  10430. /// <summary>
  10431. /// 保险费用操作(删除)
  10432. /// </summary>
  10433. /// <param name="dto"></param>
  10434. /// <returns></returns>
  10435. [HttpPost]
  10436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10437. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10438. {
  10439. try
  10440. {
  10441. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10442. if (!res)
  10443. {
  10444. return Ok(JsonView(false, "删除失败"));
  10445. }
  10446. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10447. {
  10448. IsDel = 1,
  10449. DeleteUserId = dto.DeleteUserId,
  10450. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10451. }).ExecuteCommandAsync();
  10452. return Ok(JsonView(true, "删除成功!"));
  10453. }
  10454. catch (Exception ex)
  10455. {
  10456. return Ok(JsonView(false, "程序错误!"));
  10457. throw;
  10458. }
  10459. }
  10460. #endregion
  10461. #region 接团客户名单 PageId 104
  10462. /// <summary>
  10463. /// 接团客户名单
  10464. /// 迁移数据(慎用!)
  10465. /// </summary>
  10466. /// <param name="dto"></param>
  10467. /// <returns></returns>
  10468. [HttpPost]
  10469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10470. public async Task<IActionResult> PostTourClientListChange()
  10471. {
  10472. try
  10473. {
  10474. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10475. //var groupClinetData1
  10476. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10477. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10478. int updateCount = 0;
  10479. if (oldOAClientList.Count > 0)
  10480. {
  10481. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10482. _sqlSugar.BeginTran();
  10483. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10484. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10485. foreach (var item in oldOAClientList)
  10486. {
  10487. int comId = 0;
  10488. string format = "yyyy-MM-dd HH:mm:ss";
  10489. string data11 = "1990-01-01 00:00";
  10490. var data1 = IsValidDate(item.OPdate, format);
  10491. if (data1) data11 = item.OPdate;
  10492. //客户公司验证
  10493. if (!string.IsNullOrEmpty(item.Company))
  10494. {
  10495. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10496. if (clientComInfo == null) // add
  10497. {
  10498. var addInfo = new Crm_CustomerCompany()
  10499. {
  10500. CompanyAbbreviation = "",
  10501. CompanyFullName = item.Company,
  10502. Address = "",
  10503. PostCodes = "",
  10504. LastedOpUserId = item.OPer,
  10505. LastedOpDt = Convert.ToDateTime(data11),
  10506. CreateUserId = item.OPer,
  10507. CreateTime = Convert.ToDateTime(data11),
  10508. IsDel = 0
  10509. };
  10510. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10511. if (comId1 > 0) comId = comId1;
  10512. }
  10513. else comId = clientComInfo.Id;
  10514. }
  10515. //客户人员验证
  10516. int clientId = 0;
  10517. string name = item.LastName + item.Name;
  10518. if (!string.IsNullOrEmpty(name))
  10519. {
  10520. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10521. if (clientInfo == null)
  10522. {
  10523. DateTime? dateTime = null;
  10524. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10525. if (isDt) dateTime = birthDayDt;
  10526. var addInfo1 = new Crm_DeleClient()
  10527. {
  10528. CrmCompanyId = comId,
  10529. DiId = -1,
  10530. LastName = item.LastName,
  10531. FirstName = item.Name,
  10532. OldName = "",
  10533. Pinyin = item.Pinyin,
  10534. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10535. Marriage = 0,
  10536. Phone = item.Phone,
  10537. Job = item.Job,
  10538. BirthDay = dateTime
  10539. };
  10540. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10541. if (clientId1 > 0) clientId = clientId1;
  10542. }
  10543. else clientId = clientInfo.Id;
  10544. }
  10545. if (clientId < 1)
  10546. {
  10547. continue;
  10548. }
  10549. int airType = 0;
  10550. if (item.AirType == "超经舱") airType = 459;
  10551. else if (item.AirType == "公务舱") airType = 458;
  10552. else if (item.AirType == "经济舱") airType = 460;
  10553. else if (item.AirType == "其他") airType = 565;
  10554. else if (item.AirType == "头等舱") airType = 457;
  10555. var _TourClientListEntity = new Grp_TourClientList()
  10556. {
  10557. DiId = item.Diid,
  10558. ClientId = clientId,
  10559. CreateUserId = item.OPer,
  10560. CreateTime = Convert.ToDateTime(data11),
  10561. Remark = item.Remark,
  10562. IsDel = item.Isdel,
  10563. ShippingSpaceTypeId = airType,
  10564. ShippingSpaceSpecialNeeds = item.AirRemark,
  10565. HotelSpecialNeeds = item.RoomType
  10566. };
  10567. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10568. if (_TourClientList > 0)
  10569. {
  10570. updateCount++;
  10571. }
  10572. }
  10573. _sqlSugar.CommitTran();
  10574. }
  10575. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10576. }
  10577. catch (Exception ex)
  10578. {
  10579. _sqlSugar.RollbackTran();
  10580. return Ok(JsonView(false, ex.Message));
  10581. }
  10582. return Ok(JsonView(true));
  10583. }
  10584. private bool IsValidDate(string dateString, string format)
  10585. {
  10586. DateTime dateValue;
  10587. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10588. return valid;
  10589. }
  10590. /// <summary>
  10591. /// 接团客户名单
  10592. /// 根据团组Id查询List
  10593. /// </summary>
  10594. /// <param name="dto"></param>
  10595. /// <returns></returns>
  10596. [HttpPost]
  10597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10598. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10599. {
  10600. #region 参数验证
  10601. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10602. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10603. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10604. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10605. #region 页面操作权限验证
  10606. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10607. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10608. #endregion
  10609. #endregion
  10610. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10611. if (viewData.Code != 0)
  10612. {
  10613. return Ok(JsonView(false, viewData.Msg));
  10614. }
  10615. return Ok(JsonView(viewData.Data));
  10616. }
  10617. /// <summary>
  10618. /// 接团客户名单
  10619. /// 基础数据 Init
  10620. /// </summary>
  10621. /// <param name="_dto"></param>
  10622. /// <returns></returns>
  10623. [HttpPost]
  10624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10625. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10626. {
  10627. #region 参数验证
  10628. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10629. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10630. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10631. #region 页面操作权限验证
  10632. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10633. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10634. #endregion
  10635. #endregion
  10636. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10637. if (viewData.Code != 0)
  10638. {
  10639. return Ok(JsonView(false, viewData.Msg));
  10640. }
  10641. return Ok(JsonView(viewData.Data));
  10642. }
  10643. /// <summary>
  10644. /// 接团客户名单
  10645. /// 根据 Id查询 Details
  10646. /// </summary>
  10647. /// <param name="_dto"></param>
  10648. /// <returns></returns>
  10649. [HttpPost]
  10650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10651. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10652. {
  10653. #region 参数验证
  10654. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10655. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10656. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10657. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10658. #region 页面操作权限验证
  10659. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10660. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10661. #endregion
  10662. #endregion
  10663. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10664. if (viewData.Code != 0)
  10665. {
  10666. return Ok(JsonView(false, viewData.Msg));
  10667. }
  10668. return Ok(JsonView(viewData.Data));
  10669. }
  10670. /// <summary>
  10671. /// 接团客户名单
  10672. /// Add Or Edit
  10673. /// </summary>
  10674. /// <param name="_dto"></param>
  10675. /// <returns></returns>
  10676. [HttpPost]
  10677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10678. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10679. {
  10680. #region 参数验证
  10681. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10682. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10683. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10684. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10685. #region 页面操作权限验证
  10686. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10687. if (_dto.Id == 0) //添加
  10688. {
  10689. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10690. }
  10691. else if (_dto.Id >= 0) //修改
  10692. {
  10693. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10694. }
  10695. #endregion
  10696. #endregion
  10697. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10698. if (viewData.Code != 0)
  10699. {
  10700. return Ok(JsonView(false, viewData.Msg));
  10701. }
  10702. return Ok(JsonView(true));
  10703. }
  10704. /// <summary>
  10705. /// 接团客户名单
  10706. /// AddMultiple(添加多个)
  10707. /// </summary>
  10708. /// <param name="_dto"></param>
  10709. /// <returns></returns>
  10710. [HttpPost]
  10711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10712. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10713. {
  10714. #region 参数验证
  10715. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10716. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10717. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10718. #region 页面操作权限验证
  10719. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10720. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10721. #endregion
  10722. #endregion
  10723. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10724. if (viewData.Code != 0)
  10725. {
  10726. return Ok(JsonView(false, viewData.Msg));
  10727. }
  10728. return Ok(JsonView(true));
  10729. }
  10730. /// <summary>
  10731. /// 接团客户名单
  10732. /// Del
  10733. /// </summary>
  10734. /// <param name="_dto"></param>
  10735. /// <returns></returns>
  10736. [HttpPost]
  10737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10738. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10739. {
  10740. #region 参数验证
  10741. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10742. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10743. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10744. #region 页面操作权限验证
  10745. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10746. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10747. #endregion
  10748. #endregion
  10749. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10750. if (viewData.Code != 0)
  10751. {
  10752. return Ok(JsonView(false, viewData.Msg));
  10753. }
  10754. return Ok(JsonView(true));
  10755. }
  10756. /// <summary>
  10757. /// 接团客户名单
  10758. /// 文件下载 客户名单
  10759. /// </summary>
  10760. /// <param name="_dto"></param>
  10761. /// <returns></returns>
  10762. [HttpPost]
  10763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10764. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10765. {
  10766. #region 参数验证
  10767. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10768. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10769. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10770. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10771. #region 页面操作权限验证
  10772. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10773. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10774. #endregion
  10775. #endregion
  10776. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10777. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10778. From Grp_TourClientList tcl
  10779. Left Join
  10780. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10781. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10782. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10783. From Crm_DeleClient dc
  10784. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10785. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10786. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10787. Where dc.IsDel = 0) temp
  10788. On temp.DcId =tcl.ClientId
  10789. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10790. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10791. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10792. //载入模板
  10793. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10794. if (_dto.Language == 1)
  10795. {
  10796. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10797. }
  10798. //载入模板
  10799. var doc = new Document(tempPath);
  10800. DocumentBuilder builder = new DocumentBuilder(doc);
  10801. //获取word里所有表格
  10802. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10803. //获取所填表格的序数
  10804. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10805. var rowStart = tableOne.Rows[0]; //获取第1行
  10806. if (_dto.Language == 0)
  10807. {
  10808. //循环赋值
  10809. for (int i = 0; i < DcList.Count; i++)
  10810. {
  10811. builder.MoveToCell(0, i + 1, 0, 0);
  10812. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10813. builder.MoveToCell(0, i + 1, 1, 0);
  10814. int sex = DcList[i].Sex;
  10815. string sexStr = string.Empty;
  10816. if (sex == 0) sexStr = "男";
  10817. else if (sex == 1) sexStr = "女";
  10818. else sexStr = "未设置";
  10819. builder.Write(sexStr);
  10820. builder.MoveToCell(0, i + 1, 2, 0);
  10821. string birthDay = DcList[i].BirthDay;
  10822. string birthDayStr = string.Empty;
  10823. if (!string.IsNullOrEmpty(birthDay))
  10824. {
  10825. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10826. }
  10827. builder.Write(birthDayStr);
  10828. builder.MoveToCell(0, i + 1, 3, 0);
  10829. string company = "";
  10830. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10831. {
  10832. company = DcList[i].CompanyFullName.ToString();
  10833. }
  10834. builder.Write(company);
  10835. builder.MoveToCell(0, i + 1, 4, 0);
  10836. builder.Write(DcList[i].Job);
  10837. }
  10838. }
  10839. else if (_dto.Language == 1)
  10840. {
  10841. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10842. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10843. List<string> transArrayStr = new List<string>();
  10844. string transStrRes1 = "";
  10845. for (int i = 0; i < DcList.Count; i++)
  10846. {
  10847. var dc = DcList[i];
  10848. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  10849. if (dc.Job.Equals("暂无")) dc.Job = "-";
  10850. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  10851. if (DcList.Count - 1 == i) transStrRes1 += str1;
  10852. else transStrRes1 += $"{str1}|";
  10853. }
  10854. //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";
  10855. string transStrRes = "";
  10856. if (transStrRes1.Length > 0 )
  10857. {
  10858. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  10859. }
  10860. //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
  10861. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  10862. //List<string> transArray = new List<string> { };
  10863. List<TranslateInfo> transArray = new List<TranslateInfo>();
  10864. if (transStrRes.Contains("|"))
  10865. {
  10866. string[] transArray1 = transStrRes.Split('|');
  10867. if (transArray1.Length > 0)
  10868. {
  10869. foreach (var item in transArray1)
  10870. {
  10871. if (item.Contains("&"))
  10872. {
  10873. string[] transArray2 = item.Split('&');
  10874. int index = 0;
  10875. string companyName = "", job = "";
  10876. if (transArray2.Length > 0)
  10877. {
  10878. bool success = int.TryParse(transArray2[0].Trim(), out index);
  10879. if (1 < transArray2.Length) companyName = transArray2[1];
  10880. if (2 < transArray2.Length) job = transArray2[2];
  10881. }
  10882. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  10883. }
  10884. }
  10885. }
  10886. }
  10887. //循环赋值
  10888. for (int i = 0; i < DcList.Count; i++)
  10889. {
  10890. string PYName = "";
  10891. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10892. {
  10893. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10894. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10895. PYName = PY_First + " " + PY_Last;
  10896. }
  10897. else
  10898. {
  10899. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10900. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10901. PYName = PY_First + " " + PY_Last;
  10902. }
  10903. builder.MoveToCell(0, i + 1, 0, 0);
  10904. builder.Write(PYName);
  10905. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10906. builder.MoveToCell(0, i + 1, 1, 0);
  10907. builder.Write(sex);
  10908. DateTime birthDt;
  10909. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10910. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  10911. builder.MoveToCell(0, i + 1, 2, 0);
  10912. builder.Write(birthday);
  10913. string company = string.Empty,job = string.Empty;
  10914. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  10915. if (dcTransInfo != null)
  10916. {
  10917. company = dcTransInfo.CompanyName;
  10918. job = dcTransInfo.Job;
  10919. }
  10920. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10921. {
  10922. //查询对照表
  10923. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10924. if (tempCec != null)
  10925. {
  10926. company = tempCec.enName;
  10927. }
  10928. //翻译
  10929. else
  10930. {
  10931. }
  10932. }
  10933. builder.MoveToCell(0, i + 1, 3, 0);
  10934. builder.Write(company);
  10935. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10936. {
  10937. //查询对照表
  10938. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10939. if (tempPec != null)
  10940. {
  10941. job = tempPec.enName;
  10942. }
  10943. //翻译
  10944. else
  10945. {
  10946. }
  10947. }
  10948. builder.MoveToCell(0, i + 1, 4, 0);
  10949. builder.Write(job);
  10950. }
  10951. }
  10952. //删除多余行
  10953. while (tableOne.Rows.Count > DcList.Count + 1)
  10954. {
  10955. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10956. }
  10957. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10958. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10959. doc.Save(fileDir);
  10960. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10961. return Ok(JsonView(true, "操作成功!", Url));
  10962. }
  10963. private class TranslateInfo
  10964. {
  10965. public int Index { get; set; }
  10966. public string CompanyName { get; set; }
  10967. public string Job { get; set; }
  10968. }
  10969. #endregion
  10970. #region 团组倒推表
  10971. /// <summary>
  10972. /// 倒推表基础数据
  10973. /// Init
  10974. /// </summary>
  10975. /// <param name="dto"></param>
  10976. /// <returns></returns>
  10977. [HttpPost]
  10978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10979. public async Task<IActionResult> PostInvertedListInit()
  10980. {
  10981. var viewData = await _invertedListRep._Init();
  10982. if (viewData.Code != 0)
  10983. {
  10984. return Ok(JsonView(false, viewData.Msg));
  10985. }
  10986. return Ok(JsonView(viewData.Data));
  10987. }
  10988. /// <summary>
  10989. /// 倒推表
  10990. /// Info
  10991. /// </summary>
  10992. /// <param name="dto"></param>
  10993. /// <returns></returns>
  10994. [HttpPost]
  10995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10996. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10997. {
  10998. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10999. if (viewData.Code != 0)
  11000. {
  11001. return Ok(JsonView(false, viewData.Msg));
  11002. }
  11003. return Ok(JsonView(viewData.Data));
  11004. }
  11005. /// <summary>
  11006. /// 倒推表
  11007. /// Create
  11008. /// </summary>
  11009. /// <param name="dto"></param>
  11010. /// <returns></returns>
  11011. [HttpPost]
  11012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11013. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11014. {
  11015. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11016. if (viewData.Code != 0)
  11017. {
  11018. return Ok(JsonView(false, viewData.Msg));
  11019. }
  11020. return Ok(JsonView(viewData.Data));
  11021. }
  11022. /// <summary>
  11023. /// 倒推表
  11024. /// Update
  11025. /// </summary>
  11026. /// <param name="dto"></param>
  11027. /// <returns></returns>
  11028. [HttpPost]
  11029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11030. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11031. {
  11032. var viewData = await _invertedListRep._Update(dto);
  11033. if (viewData.Code != 0)
  11034. {
  11035. return Ok(JsonView(false, viewData.Msg));
  11036. }
  11037. return Ok(JsonView(viewData.Data));
  11038. }
  11039. /// <summary>
  11040. /// 倒推表
  11041. /// File Download
  11042. /// </summary>
  11043. /// <param name="dto"></param>
  11044. /// <returns></returns>
  11045. [HttpPost]
  11046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11047. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11048. {
  11049. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11050. if (info2.Code != 0)
  11051. {
  11052. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11053. }
  11054. var info1 = info2.Data as InvertedListInfoView;
  11055. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11056. string teamName = "";
  11057. if (info != null) teamName = info.TeamName;
  11058. //载入模板
  11059. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11060. DocumentBuilder builder = new DocumentBuilder(doc);
  11061. //利用键值对存放数据
  11062. Dictionary<string, string> dic = new Dictionary<string, string>();
  11063. dic.Add("TeamName", teamName);
  11064. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11065. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11066. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11067. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11068. dic.Add("SQRemark", info1.ApprovalRemark);
  11069. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11070. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11071. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11072. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11073. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11074. dic.Add("QZRemark", info1.VisaInformationRemark);
  11075. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11076. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11077. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11078. dic.Add("CQRemark", info1.IssueVisaRemark);
  11079. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11080. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11081. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11082. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11083. #region 填充word模板书签内容
  11084. foreach (var key in dic.Keys)
  11085. {
  11086. builder.MoveToBookmark(key);
  11087. builder.Write(dic[key]);
  11088. }
  11089. #endregion
  11090. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11091. string fileName = $"{teamName}团出行准备流程表.doc";
  11092. string filePath = fileDir + $@"InvertedList/{fileName}";
  11093. doc.Save(filePath);
  11094. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11095. return Ok(JsonView(true, "操作成功!", Url));
  11096. }
  11097. #endregion
  11098. #region 三公签证费用(签证费、代办费)
  11099. /// <summary>
  11100. /// 三公签证费用(签证费、代办费)
  11101. /// List
  11102. /// </summary>
  11103. /// <returns></returns>
  11104. [HttpPost]
  11105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11106. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11107. {
  11108. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11109. if (_view.Code != 0)
  11110. {
  11111. return Ok(JsonView(false, _view.Msg));
  11112. }
  11113. return Ok(JsonView(true, "操作成功!", _view.Data));
  11114. }
  11115. /// <summary>
  11116. /// 三公签证费用(签证费、代办费)
  11117. /// Add Or Update
  11118. /// </summary>
  11119. /// <returns></returns>
  11120. [HttpPost]
  11121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11122. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11123. {
  11124. var _view = await _visaFeeInfoRep._Update(_dto);
  11125. if (_view.Code != 0)
  11126. {
  11127. return Ok(JsonView(false, _view.Msg));
  11128. }
  11129. return Ok(JsonView(true, _view.Msg));
  11130. }
  11131. #endregion
  11132. #region 酒店询价
  11133. /// <summary>
  11134. /// 酒店询价
  11135. /// Init
  11136. /// </summary>
  11137. /// <param name="dto"></param>
  11138. /// <returns></returns>
  11139. [HttpPost]
  11140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11141. public async Task<IActionResult> PostHotelInquiryInit()
  11142. {
  11143. var res = await _hotelInquiryRep._Init();
  11144. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11145. return Ok(JsonView(true, res.Msg, res.Data));
  11146. }
  11147. /// <summary>
  11148. /// 酒店询价
  11149. /// page Item
  11150. /// </summary>
  11151. /// <param name="_dto"></param>
  11152. /// <returns></returns>
  11153. [HttpPost]
  11154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11155. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11156. {
  11157. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11158. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11159. var view = res.Data as PageDataViewBase;
  11160. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11161. }
  11162. /// <summary>
  11163. /// 酒店询价
  11164. /// info
  11165. /// </summary>
  11166. /// <param name="_dto"></param>
  11167. /// <returns></returns>
  11168. [HttpPost]
  11169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11170. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11171. {
  11172. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11173. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11174. return Ok(JsonView(true, res.Msg, res.Data));
  11175. }
  11176. /// <summary>
  11177. /// 酒店询价
  11178. /// Add Or Edit
  11179. /// </summary>
  11180. /// <param name="_dto"></param>
  11181. /// <returns></returns>
  11182. [HttpPost]
  11183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11184. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11185. {
  11186. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11187. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11188. return Ok(JsonView(true, res.Msg, res.Data));
  11189. }
  11190. /// <summary>
  11191. /// 酒店询价
  11192. /// Del
  11193. /// </summary>
  11194. /// <param name="_dto"></param>
  11195. /// <returns></returns>
  11196. [HttpPost]
  11197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11198. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11199. {
  11200. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11201. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11202. return Ok(JsonView(true, res.Msg, res.Data));
  11203. }
  11204. #endregion
  11205. #region 下载匹配op行程单
  11206. /// <summary>
  11207. /// 匹配op行程单
  11208. /// Init
  11209. /// </summary>
  11210. /// <param name="dto">团组列表请求dto</param>
  11211. /// <returns></returns>
  11212. [HttpPost]
  11213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11214. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11215. {
  11216. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11217. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11218. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11219. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11220. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11221. .Where(it => it.IsDel == 0)
  11222. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11223. .OrderByDescending(it => it.CreateUserId)
  11224. .ToList();
  11225. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11226. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11227. var diids = groupInfos.Select(it => it.Id).ToList();
  11228. List<string> countrys = new List<string>();
  11229. foreach (var item in country)
  11230. {
  11231. var data = _groupRepository.FormartTeamName(item);
  11232. var dataArray = _groupRepository.GroupSplitCountry(data);
  11233. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11234. }
  11235. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11236. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11237. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11238. foreach (var item in areaItem)
  11239. {
  11240. string areaStr = item.Value;
  11241. if (!string.IsNullOrEmpty(areaStr))
  11242. {
  11243. string[] str1 = areaStr.Split("-");
  11244. if (str1.Length > 0)
  11245. {
  11246. areaArray.AddRange(str1);
  11247. }
  11248. }
  11249. }
  11250. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11251. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11252. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11253. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11254. .ToList();
  11255. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11256. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11257. .Where(it => countriesIds.Contains(it.Id))
  11258. .Select(it => new { it.Id, Name = it.Name_CN })
  11259. .ToList();
  11260. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11261. .Select(it => it.TeamName).ToList();
  11262. stopwatch.Stop();
  11263. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11264. }
  11265. ///// <summary>
  11266. ///// 匹配op行程单
  11267. ///// Init 查询区域数据
  11268. ///// </summary>
  11269. ///// <param name="dto">团组列表请求dto</param>
  11270. ///// <returns></returns>
  11271. //[HttpPost]
  11272. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11273. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11274. //{
  11275. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11276. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11277. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11278. // if (string.IsNullOrEmpty(countriesDataStr))
  11279. // {
  11280. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11281. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11282. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11283. // }
  11284. // else
  11285. // {
  11286. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11287. // }
  11288. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11289. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11290. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11291. // List<dynamic> childList = new List<dynamic>();
  11292. // int parentId = dto.CountriesId;
  11293. // if (provinceData.Count > 1)
  11294. // {
  11295. // foreach (var item1 in provinceData)
  11296. // {
  11297. // List<dynamic> childList1 = new List<dynamic>();
  11298. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11299. // foreach (var item2 in citiesData1)
  11300. // {
  11301. // List<dynamic> childList2 = new List<dynamic>();
  11302. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11303. // foreach (var item3 in countiesData1)
  11304. // {
  11305. // childList2.Add(new
  11306. // {
  11307. // id = item3.Id,
  11308. // parentId = item2.Id,
  11309. // level = "district",
  11310. // name = item3.Name_CN,
  11311. // });
  11312. // }
  11313. // childList1.Add(new
  11314. // {
  11315. // id = item2.Id,
  11316. // parentId = item1.Id,
  11317. // level = "city",
  11318. // name = item2.Name_CN,
  11319. // childList = childList2
  11320. // });
  11321. // }
  11322. // childList.Add(new
  11323. // {
  11324. // id = item1.Id,
  11325. // parentId = parentId,
  11326. // level = "province",
  11327. // name = item1.Name_CN,
  11328. // childList = childList1
  11329. // });
  11330. // }
  11331. // //城市
  11332. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11333. // foreach (var item2 in citiesData2)
  11334. // {
  11335. // List<dynamic> childList22 = new List<dynamic>();
  11336. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11337. // foreach (var item3 in countiesData1)
  11338. // {
  11339. // childList22.Add(new
  11340. // {
  11341. // id = item3.Id,
  11342. // parentId = item2.Id,
  11343. // level = "district",
  11344. // name = item3.Name_CN,
  11345. // });
  11346. // }
  11347. // childList.Add(new
  11348. // {
  11349. // id = item2.Id,
  11350. // parentId = parentId,
  11351. // level = "city",
  11352. // name = item2.Name_CN,
  11353. // childList = childList22
  11354. // });
  11355. // }
  11356. // }
  11357. // else
  11358. // {
  11359. // foreach (var item2 in citiesData)
  11360. // {
  11361. // string cname = item2.Name_CN;
  11362. // List<dynamic> childList1 = new List<dynamic>();
  11363. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11364. // foreach (var item3 in countiesData1)
  11365. // {
  11366. // childList1.Add(new
  11367. // {
  11368. // Id = item3.Id,
  11369. // parentId = item2.Id,
  11370. // level = "district",
  11371. // name = item3.Name_CN
  11372. // });
  11373. // }
  11374. // childList.Add(new
  11375. // {
  11376. // id = item2.Id,
  11377. // parentId = parentId,
  11378. // level = "city",
  11379. // name = item2.Name_CN,
  11380. // childList = childList1
  11381. // });
  11382. // }
  11383. // }
  11384. // stopwatch.Stop();
  11385. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11386. //}
  11387. /// <summary>
  11388. /// 匹配op行程单
  11389. /// 接团信息列表 Page
  11390. /// </summary>
  11391. /// <param name="dto">团组列表请求dto</param>
  11392. /// <returns></returns>
  11393. [HttpPost]
  11394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11395. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11396. {
  11397. var swatch = new Stopwatch();
  11398. swatch.Start();
  11399. #region 参数验证
  11400. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11401. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11402. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11403. #region 页面操作权限验证
  11404. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11405. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11406. #endregion
  11407. #endregion
  11408. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11409. {
  11410. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11411. string sqlWhere = "";
  11412. if (!string.IsNullOrEmpty(dto.Country))
  11413. {
  11414. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11415. }
  11416. if (!string.IsNullOrEmpty(dto.Area))
  11417. {
  11418. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11419. }
  11420. if (!string.IsNullOrEmpty(dto.TeamName))
  11421. {
  11422. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11423. }
  11424. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11425. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11426. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11427. swatch.Stop();
  11428. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11429. }
  11430. else
  11431. {
  11432. return Ok(JsonView(false, "查询失败"));
  11433. }
  11434. }
  11435. /// <summary>
  11436. /// 匹配op行程单
  11437. /// 行程单下载
  11438. /// </summary>
  11439. /// <param name="dto">团组列表请求dto</param>
  11440. /// <returns></returns>
  11441. [HttpPost]
  11442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11443. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11444. {
  11445. #region 参数验证
  11446. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11447. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11448. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11449. #region 页面操作权限验证
  11450. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11451. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11452. #endregion
  11453. #endregion
  11454. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11455. {
  11456. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11457. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11458. }
  11459. else
  11460. {
  11461. return Ok(JsonView(false, "下载失败!"));
  11462. }
  11463. }
  11464. #endregion
  11465. #region 国家信息 数据 注释
  11466. //[HttpPost]
  11467. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11468. //{
  11469. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11470. // foreach (var item in dto)
  11471. // {
  11472. // infos.Add(new Grp_GroupsTaskAssignment()
  11473. // {
  11474. // DIId = item,
  11475. // CTId = 82,
  11476. // UId = 248,
  11477. // IsEnable = 1,
  11478. // CreateUserId = 233,
  11479. // CreateTime = DateTime.Now,
  11480. // IsDel = 0
  11481. // });
  11482. // infos.Add(new Grp_GroupsTaskAssignment()
  11483. // {
  11484. // DIId = item,
  11485. // CTId = 82,
  11486. // UId = 286,
  11487. // IsEnable = 1,
  11488. // CreateUserId = 233,
  11489. // CreateTime = DateTime.Now,
  11490. // IsDel = 0
  11491. // });
  11492. // }
  11493. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11494. // return Ok("操作成功");
  11495. //}
  11496. //public class paramJsonDto
  11497. //{
  11498. // public List<CountriesInfo> str { get; set; }
  11499. //}
  11500. //[HttpPost]
  11501. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11502. //{
  11503. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11504. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11505. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11506. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11507. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11508. // _sqlSugar.BeginTran();
  11509. // int countitiesIndex = 0;
  11510. // foreach (var item in dto.str)
  11511. // {
  11512. // dynamic data = item.c;
  11513. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11514. // if (data != null)
  11515. // {
  11516. // countitiesIndex++;
  11517. // foreach (var item1 in data)
  11518. // {
  11519. // string cnname = item1.cn;
  11520. // string enname = item1.en;
  11521. // Sys_Cities provinceInfo = new Sys_Cities()
  11522. // {
  11523. // CountriesId = countriesId,
  11524. // Name_CN = cnname,
  11525. // Name_EN = enname,
  11526. // ParentId = 0,
  11527. // IsCapital = 1,
  11528. // CreateUserId = 208,
  11529. // CreateTime = DateTime.Now,
  11530. // IsDel = 0
  11531. // };
  11532. // if (item1.lv == "province") //省份
  11533. // {
  11534. // provinceInfo.Level = 1;
  11535. // int provinceId = 0;
  11536. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11537. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11538. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11539. // var data1 = item1.c;
  11540. // foreach (var item2 in data1)
  11541. // {
  11542. // if (item2.lv == "city")
  11543. // {
  11544. // string citycnname = item2.cn;
  11545. // string cityenname = item2.en;
  11546. // Sys_Cities cityInfo = new Sys_Cities()
  11547. // {
  11548. // CountriesId = countriesId,
  11549. // ParentId = provinceId,
  11550. // Level = 2,
  11551. // Name_CN = citycnname,
  11552. // Name_EN = cityenname,
  11553. // IsCapital = 1,
  11554. // CreateUserId = 208,
  11555. // CreateTime = DateTime.Now,
  11556. // IsDel = 0
  11557. // };
  11558. // if (item2.c != null)
  11559. // {
  11560. // int cityId = 0;
  11561. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11562. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11563. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11564. // foreach (var item3 in item2.c)
  11565. // {
  11566. // if (item3.lv == "district")
  11567. // {
  11568. // var districtInfo = new Sys_Cities()
  11569. // {
  11570. // CountriesId = countriesId,
  11571. // Name_CN = item3.cn,
  11572. // Name_EN = item3.en,
  11573. // Level = 3,
  11574. // ParentId = cityId,
  11575. // IsCapital = 1,
  11576. // CreateUserId = 208,
  11577. // CreateTime = DateTime.Now,
  11578. // IsDel = 0
  11579. // };
  11580. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11581. // //{
  11582. // districts.Add(districtInfo);
  11583. // //}
  11584. // }
  11585. // }
  11586. // }
  11587. // else
  11588. // {
  11589. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11590. // //{
  11591. // cities.Add(cityInfo);
  11592. // //}
  11593. // }
  11594. // }
  11595. // }
  11596. // }
  11597. // else if (item1.lv == "city")//城市
  11598. // {
  11599. // provinceInfo.Level = 2;
  11600. // if (item1.c != null)
  11601. // {
  11602. // int cityId = 0;
  11603. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11604. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11605. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11606. // foreach (var item3 in item1.c)
  11607. // {
  11608. // if (item3.lv == "district")
  11609. // {
  11610. // var districtInfo = new Sys_Cities()
  11611. // {
  11612. // CountriesId = countriesId,
  11613. // Name_CN = item3.cn,
  11614. // Name_EN = item3.en,
  11615. // Level = 3,
  11616. // ParentId = cityId,
  11617. // IsCapital = 1,
  11618. // CreateUserId = 208,
  11619. // CreateTime = DateTime.Now,
  11620. // IsDel = 0
  11621. // };
  11622. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11623. // //{
  11624. // districts.Add(districtInfo);
  11625. // //}
  11626. // }
  11627. // }
  11628. // }
  11629. // else
  11630. // {
  11631. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11632. // //{
  11633. // cities.Add(provinceInfo);
  11634. // //}
  11635. // }
  11636. // }
  11637. // }
  11638. // }
  11639. // }
  11640. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11641. // cities = cities.Distinct().ToList();
  11642. // districts = districts.Distinct().ToList();
  11643. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11644. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11645. // cities.AddRange(districts);
  11646. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11647. // //_sqlSugar.RollbackTran();
  11648. // _sqlSugar.CommitTran();
  11649. // return Ok(JsonView(false, "操作成功!"));
  11650. //}
  11651. //[HttpPost]
  11652. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11653. //{
  11654. // List<CountitiesInfo> infos = dto.MyProperty;
  11655. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11656. // _sqlSugar.BeginTran();
  11657. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11658. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11659. // foreach (var item in infos)
  11660. // {
  11661. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11662. // if (countryInfo != null)
  11663. // {
  11664. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11665. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11666. // if (cityInfo1 != null)
  11667. // {
  11668. // cityInfo1.IsCapital = 0;
  11669. // cityInfos.Add(cityInfo1);
  11670. // }
  11671. // }
  11672. // }
  11673. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11674. // .UpdateColumns(it => it.IsCapital)
  11675. // .WhereColumns(it => it.Id)
  11676. // .ExecuteCommand();
  11677. // //_sqlSugar.RollbackTran();
  11678. // _sqlSugar.CommitTran();
  11679. // return Ok(JsonView(false, "操作成功!"));
  11680. //}
  11681. //public class CounrtiesDto
  11682. //{
  11683. // public List<CountitiesInfo> MyProperty { get; set; }
  11684. //}
  11685. //public class CountitiesInfo
  11686. //{
  11687. // /// <summary>
  11688. // /// 圣约翰
  11689. // /// </summary>
  11690. // public string capital_name_chinese { get; set; }
  11691. // /// <summary>
  11692. // ///
  11693. // /// </summary>
  11694. // public string capital_name { get; set; }
  11695. // /// <summary>
  11696. // ///
  11697. // /// </summary>
  11698. // public string country_type { get; set; }
  11699. // /// <summary>
  11700. // /// 安提瓜和巴布达
  11701. // /// </summary>
  11702. // public string country_name_chinese { get; set; }
  11703. // /// <summary>
  11704. // /// 安提瓜和巴布达
  11705. // /// </summary>
  11706. // public string country_name_chinese_short { get; set; }
  11707. // /// <summary>
  11708. // /// 安提瓜和巴布达
  11709. // /// </summary>
  11710. // public string country_name_chinese_UN { get; set; }
  11711. // /// <summary>
  11712. // ///
  11713. // /// </summary>
  11714. // public string country_name_english_abbreviation { get; set; }
  11715. // /// <summary>
  11716. // ///
  11717. // /// </summary>
  11718. // public string country_name_english_formal { get; set; }
  11719. // /// <summary>
  11720. // ///
  11721. // /// </summary>
  11722. // public string country_name_english_UN { get; set; }
  11723. // /// <summary>
  11724. // ///
  11725. // /// </summary>
  11726. // public string continent_name { get; set; }
  11727. // /// <summary>
  11728. // ///
  11729. // /// </summary>
  11730. // public string subregion_name { get; set; }
  11731. // /// <summary>
  11732. // ///
  11733. // /// </summary>
  11734. // public string country_code2 { get; set; }
  11735. // /// <summary>
  11736. // ///
  11737. // /// </summary>
  11738. // public string country_code3 { get; set; }
  11739. // /// <summary>
  11740. // ///
  11741. // /// </summary>
  11742. // public string phone_code { get; set; }
  11743. //}
  11744. //public class CountriesInfo : BasicInfo
  11745. //{
  11746. // public List<CitiesInfo> c { get; set; }
  11747. //}
  11748. //public class CitiesInfo : BasicInfo
  11749. //{
  11750. // public List<AreaInfo> c { get; set; }
  11751. //}
  11752. //public class AreaInfo : BasicInfo
  11753. //{
  11754. // public List<AreaInfo> c { get; set; }
  11755. //}
  11756. //public class BasicInfo
  11757. //{
  11758. // public string code { get; set; }
  11759. // public string cn { get; set; }
  11760. // public string lv { get; set; }
  11761. // public string en { get; set; }
  11762. //}
  11763. #endregion
  11764. #region 查看邀请方
  11765. /// <summary>
  11766. /// 查看邀请方
  11767. /// 邀请方信息 Init
  11768. /// </summary>
  11769. /// <param name="dto"></param>
  11770. /// <returns></returns>
  11771. [HttpPost]
  11772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11773. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11774. {
  11775. string sqlWhere = string.Empty;
  11776. if (!string.IsNullOrEmpty(dto.Search))
  11777. {
  11778. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11779. }
  11780. string sql = string.Format($@"Select
  11781. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11782. Id,
  11783. UnitName
  11784. From Res_InvitationOfficialActivityData
  11785. Where IsDel = 0
  11786. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11787. RefAsync<int> total = 0;
  11788. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11789. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11790. }
  11791. /// <summary>
  11792. /// 查看邀请方
  11793. /// 国家信息 Init
  11794. /// </summary>
  11795. /// <param name="dto"></param>
  11796. /// <returns></returns>
  11797. [HttpPost]
  11798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11799. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11800. {
  11801. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11802. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11803. var diids = groupInfos.Select(it => it.Id).ToList();
  11804. List<string> countrys = new List<string>();
  11805. foreach (var item in country)
  11806. {
  11807. var data = _groupRepository.FormartTeamName(item);
  11808. var dataArray = _groupRepository.GroupSplitCountry(data);
  11809. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11810. }
  11811. countrys = countrys.Distinct().ToList();
  11812. for (int i = 0; i < countrys.Count; i++)
  11813. {
  11814. string item = countrys[i];
  11815. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11816. {
  11817. countrys.Remove(item);
  11818. i--;
  11819. }
  11820. }
  11821. RefAsync<int> total = 0;
  11822. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11823. .Where(it => countrys.Contains(it.Name_CN))
  11824. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11825. .Select(it => new { id = it.Id, name = it.Name_CN })
  11826. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11827. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11828. }
  11829. /// <summary>
  11830. /// 查看邀请方
  11831. /// 城市信息 Init
  11832. /// </summary>
  11833. /// <param name="dto"></param>
  11834. /// <returns></returns>
  11835. [HttpPost]
  11836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11837. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11838. {
  11839. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11840. RefAsync<int> total = 0;
  11841. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11842. .Where(it => it.CountriesId == dto.CountiesId)
  11843. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11844. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  11845. .Select(it => new { id = it.Id, name = it.Name_CN })
  11846. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11847. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11848. }
  11849. /// <summary>
  11850. /// 查看邀请方
  11851. /// 团组名称 Init
  11852. /// </summary>
  11853. /// <param name="dto"></param>
  11854. /// <returns></returns>
  11855. [HttpPost]
  11856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11857. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  11858. {
  11859. var watch = new Stopwatch();
  11860. watch.Start();
  11861. RefAsync<int> total = 0;
  11862. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  11863. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  11864. .Where((oa, di) => oa.IsDel == 0)
  11865. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  11866. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  11867. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  11868. .Distinct()
  11869. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11870. watch.Stop();
  11871. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  11872. }
  11873. /// <summary>
  11874. /// 查看邀请方
  11875. /// 团组 & 邀请方信息
  11876. /// </summary>
  11877. /// <param name="dto"></param>
  11878. /// <returns></returns>
  11879. [HttpPost]
  11880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11881. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  11882. {
  11883. var watch = new Stopwatch();
  11884. watch.Start();
  11885. RefAsync<int> total = 0;
  11886. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  11887. .AS("Grp_DelegationInfo")
  11888. .Includes(x => x.InvitingInfos)
  11889. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  11890. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  11891. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  11892. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  11893. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  11894. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  11895. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11896. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  11897. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  11898. infos.ForEach(x =>
  11899. {
  11900. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  11901. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  11902. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  11903. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  11904. });
  11905. watch.Stop();
  11906. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  11907. }
  11908. #endregion
  11909. #region 报批行程
  11910. /// <summary>
  11911. /// 报批行程初始化
  11912. /// </summary>
  11913. /// <param name="dto"></param>
  11914. /// <returns></returns>
  11915. [HttpPost]
  11916. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11917. {
  11918. const int chiNumber = 5;
  11919. var jw = JsonView(false);
  11920. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11921. var group = groupList.First();
  11922. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11923. group = groupList.First(x => x.Id == diid);
  11924. if (group == null)
  11925. {
  11926. jw.Msg = "暂无团组!";
  11927. return Ok(jw);
  11928. }
  11929. var data = new
  11930. {
  11931. groupList = groupList.Select(x => new
  11932. {
  11933. x.TeamName,
  11934. x.Id
  11935. }),
  11936. content = new ArrayList(),
  11937. groupInfo = new
  11938. {
  11939. group.VisitDays,
  11940. group.TourCode,
  11941. group.VisitPNumber,
  11942. group.TeamName,
  11943. group.Id,
  11944. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  11945. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  11946. },
  11947. };
  11948. var resultArr = new ArrayList();
  11949. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11950. if (content.Count == 0)
  11951. {
  11952. var stay = "-";
  11953. var cityPath = "-";
  11954. //添加城市路径以及住宿地
  11955. //黑屏代码数据
  11956. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11957. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11958. {
  11959. jw = JsonView(true, "黑屏代码有误!", data);
  11960. return Ok(jw);
  11961. }
  11962. foreach (DataRow row in dtBlack.Rows)
  11963. {
  11964. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11965. {
  11966. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  11967. return Ok(jw);
  11968. }
  11969. }
  11970. //黑屏代码获取时间区间
  11971. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11972. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11973. _sqlSugar.BeginTran();
  11974. for (int i = 0; i < timeArr.Count; i++)
  11975. {
  11976. stay = "-";
  11977. cityPath = "-";
  11978. DateTime NewData = DateTime.Parse(timeArr[i]);
  11979. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11980. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11981. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11982. if (tbSelect.Length > 0)
  11983. {
  11984. List<string> threeCodeStr = new List<string>();
  11985. foreach (var item in tbSelect)
  11986. {
  11987. var threeCode = item["Three"].ToString() ?? "";
  11988. if (threeCode.Length == 6)
  11989. {
  11990. var start = threeCode.Substring(0, 3);
  11991. var end = threeCode.Substring(3, 3);
  11992. if (threeCodeStr.Count == 0)
  11993. {
  11994. threeCodeStr.Add(start);
  11995. threeCodeStr.Add(end);
  11996. }
  11997. else
  11998. {
  11999. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12000. {
  12001. threeCodeStr.Add(end);
  12002. }
  12003. else
  12004. {
  12005. threeCodeStr.Add(start);
  12006. threeCodeStr.Add(end);
  12007. }
  12008. }
  12009. }
  12010. }
  12011. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12012. var last = threeCodeStr.Last();
  12013. foreach (var item in threeCodeStr)
  12014. {
  12015. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12016. if (item.Equals(last))
  12017. {
  12018. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12019. }
  12020. }
  12021. cityPath = cityPath.Trim('-');
  12022. }
  12023. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12024. appro.Diid = diid ?? -1;
  12025. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12026. appro.Id = thisId;
  12027. appro.CreateUserId = dto.UserId;
  12028. appro.CreateTime = DateTime.Now;
  12029. content.Add(appro);
  12030. }
  12031. _sqlSugar.CommitTran();
  12032. }
  12033. foreach (var x in content)
  12034. {
  12035. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12036. if (chiList.Count < chiNumber)
  12037. {
  12038. for (int i = chiList.Count; i < chiNumber; i++)
  12039. {
  12040. chiList.Add(new Grp_ApprovalTravelDetails());
  12041. }
  12042. }
  12043. resultArr.Add(new
  12044. {
  12045. x.Id,
  12046. x.Date,
  12047. x.Diid,
  12048. chiList = chiList.Select(x1 => new
  12049. {
  12050. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12051. x1.Details,
  12052. x1.ParentId,
  12053. x1.Id
  12054. })
  12055. });
  12056. }
  12057. data = data with
  12058. {
  12059. content = resultArr,
  12060. };
  12061. jw = JsonView(true, "获取成功!", data);
  12062. return Ok(jw);
  12063. }
  12064. /// <summary>
  12065. /// 报批行程删除
  12066. /// </summary>
  12067. /// <param name="dto"></param>
  12068. /// <returns></returns>
  12069. [HttpPost]
  12070. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12071. {
  12072. var jw = JsonView(false);
  12073. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12074. if (group == null)
  12075. {
  12076. jw.Msg = "团组参数有误!";
  12077. return Ok(jw);
  12078. }
  12079. try
  12080. {
  12081. _sqlSugar.BeginTran();
  12082. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12083. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12084. {
  12085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12086. DeleteUserId = dto.uesrId,
  12087. IsDel = 1
  12088. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12089. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12090. {
  12091. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12092. DeleteUserId = dto.uesrId,
  12093. IsDel = 1
  12094. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12095. _sqlSugar.CommitTran();
  12096. jw = JsonView(true, "删除成功");
  12097. }
  12098. catch (Exception ex)
  12099. {
  12100. jw = JsonView(false, ex.Message);
  12101. }
  12102. return Ok(jw);
  12103. }
  12104. /// <summary>
  12105. /// 报批行程保存
  12106. /// </summary>
  12107. /// <param name="dto"></param>
  12108. /// <returns></returns>
  12109. [HttpPost]
  12110. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12111. {
  12112. var jw = JsonView(false);
  12113. var Find = dto.Arr.Find(x => x.id == 0);
  12114. if (Find != null)
  12115. {
  12116. jw.Msg = "生成的ID为0!";
  12117. return Ok(jw);
  12118. }
  12119. foreach (var item in dto.Arr)
  12120. {
  12121. foreach (var chi in item.chiList)
  12122. {
  12123. if (chi.parentId == 0)
  12124. {
  12125. chi.parentId = item.id;
  12126. }
  12127. }
  12128. }
  12129. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12130. _sqlSugar.BeginTran();
  12131. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12132. {
  12133. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12134. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12135. {
  12136. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12137. DeleteUserId = dto.UserId,
  12138. IsDel = 1
  12139. }).ExecuteCommand();
  12140. }
  12141. try
  12142. {
  12143. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12144. {
  12145. CreateTime = DateTime.Now,
  12146. CreateUserId = dto.UserId,
  12147. Details = x.details,
  12148. ParentId = x.parentId,
  12149. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12150. Remark = "",
  12151. IsDel = 0
  12152. }).ToList()).ExecuteCommand();
  12153. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12154. {
  12155. Id = x.id,
  12156. Details = x.details,
  12157. ParentId = x.parentId,
  12158. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12159. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12160. {
  12161. Details = x.Details,
  12162. ParentId = x.ParentId,
  12163. Time = x.Time
  12164. }).ExecuteCommand();
  12165. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12166. {
  12167. Id = x.id,
  12168. Date = x.date,
  12169. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12170. {
  12171. Date = x.Date
  12172. }).ExecuteCommand();
  12173. _sqlSugar.CommitTran();
  12174. jw = JsonView(true, "保存成功!");
  12175. }
  12176. catch (Exception ex)
  12177. {
  12178. _sqlSugar.RollbackTran();
  12179. jw = JsonView(false, "保存失败!" + ex.Message);
  12180. }
  12181. return Ok(jw);
  12182. }
  12183. /// <summary>
  12184. /// 报批行程生成
  12185. /// </summary>
  12186. /// <param name="dto"></param>
  12187. /// <returns></returns>
  12188. [HttpPost]
  12189. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12190. {
  12191. var jw = JsonView(false);
  12192. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12193. if (group == null)
  12194. {
  12195. jw.Msg = "暂无该团组!";
  12196. return Ok(jw);
  12197. }
  12198. //黑屏代码数据
  12199. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12200. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12201. {
  12202. jw.Msg = "黑屏代码有误!";
  12203. return Ok(jw);
  12204. }
  12205. foreach (DataRow row in dtBlack.Rows)
  12206. {
  12207. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12208. {
  12209. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12210. return Ok(jw);
  12211. }
  12212. }
  12213. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12214. var resultArr = new ArrayList();
  12215. if (officialActivitiesArr.Count == 0)
  12216. {
  12217. jw.Msg = "暂无公务出访信息!";
  12218. return Ok(jw);
  12219. }
  12220. try
  12221. {
  12222. _sqlSugar.BeginTran();
  12223. DeleteApprovalJourney(new
  12224. Domain.Dtos.Groups.DeleteApprovalJourney
  12225. {
  12226. Diid = dto.Diid,
  12227. uesrId = dto.Userid
  12228. });
  12229. var stay = "-";
  12230. var cityPath = "-";
  12231. //添加城市路径以及住宿地
  12232. //黑屏代码获取时间区间
  12233. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12234. var empty = "【未收入该三字码!请机票同事录入】";
  12235. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12236. for (int i = 0; i < timeArr.Count; i++)
  12237. {
  12238. stay = "-";
  12239. cityPath = "-";
  12240. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12241. DateTime NewData = DateTime.Parse(timeArr[i]);
  12242. 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();
  12243. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12244. if (tbSelect.Length > 0)
  12245. {
  12246. List<string> threeCodeStr = new List<string>();
  12247. bool isTrade = false;
  12248. string trip = string.Empty;
  12249. var rowLast = tbSelect.Last();
  12250. var rowFirst = tbSelect.First();
  12251. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12252. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12253. var takeOffTime = DateTime.Parse(timeArr[i]);
  12254. var fallToTime = DateTime.Parse(timeArr[i]);
  12255. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12256. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12257. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12258. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12259. foreach (var item in tbSelect)
  12260. {
  12261. var start = string.Empty;
  12262. var end = string.Empty;
  12263. var threeCode = item["Three"].ToString() ?? "";
  12264. if (threeCode.Length == 6)
  12265. {
  12266. start = threeCode.Substring(0, 3);
  12267. end = threeCode.Substring(3, 3);
  12268. if (threeCodeStr.Count == 0)
  12269. {
  12270. threeCodeStr.Add(start);
  12271. threeCodeStr.Add(end);
  12272. }
  12273. else
  12274. {
  12275. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12276. {
  12277. threeCodeStr.Add(end);
  12278. }
  12279. else
  12280. {
  12281. threeCodeStr.Add(start);
  12282. threeCodeStr.Add(end);
  12283. }
  12284. }
  12285. }
  12286. //处理机票信息
  12287. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12288. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12289. if (start_Object == null)
  12290. {
  12291. start_Object = new Res_ThreeCode()
  12292. {
  12293. AirPort = empty,
  12294. AirPort_En = empty,
  12295. City = empty,
  12296. Country = empty,
  12297. Four = empty,
  12298. Three = empty,
  12299. };
  12300. }
  12301. if (end_Object == null)
  12302. {
  12303. end_Object = new Res_ThreeCode()
  12304. {
  12305. AirPort = empty,
  12306. AirPort_En = empty,
  12307. City = empty,
  12308. Country = empty,
  12309. Four = empty,
  12310. Three = empty,
  12311. };
  12312. }
  12313. //机型判断
  12314. string airModel = item["AirModel"].ToString();
  12315. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12316. string flightTime = item["FlightTime"].ToString();
  12317. if (flightTime!.Contains(":"))
  12318. {
  12319. flightTime = flightTime.Replace(":", "小时");
  12320. flightTime += "分钟";
  12321. }
  12322. if (flightTime.Contains("H"))
  12323. {
  12324. flightTime = flightTime.Replace("H", "小时");
  12325. }
  12326. if (flightTime.Contains("M"))
  12327. {
  12328. flightTime = flightTime.Replace("M", "分钟");
  12329. }
  12330. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12331. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12332. {
  12333. flightTime = flightDataTime.Hour > 0
  12334. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12335. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12336. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12337. }
  12338. //航班号
  12339. string flightcode = item["Fliagtcode"].ToString();
  12340. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12341. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12342. if (aircompany == null)
  12343. {
  12344. aircompany = new Res_AirCompany
  12345. {
  12346. CnName = hsEmpty,
  12347. EnName = hsEmpty,
  12348. ShortCode = hsEmpty,
  12349. };
  12350. }
  12351. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12352. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12353. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12354. if (isTrade)
  12355. {
  12356. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12357. }
  12358. else
  12359. {
  12360. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12361. }
  12362. }
  12363. chiarr.Add(new Grp_ApprovalTravelDetails
  12364. {
  12365. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12366. CreateTime = DateTime.Now,
  12367. CreateUserId = dto.Userid,
  12368. ParentId = 0,
  12369. Details = trip
  12370. });
  12371. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12372. var last = threeCodeStr.Last();
  12373. foreach (var item in threeCodeStr)
  12374. {
  12375. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12376. if (item.Equals(last))
  12377. {
  12378. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12379. }
  12380. }
  12381. cityPath = cityPath.Trim('-');
  12382. }
  12383. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12384. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12385. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12386. appro.Diid = dto.Diid;
  12387. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12388. appro.Id = thisId;
  12389. appro.CreateUserId = dto.Userid;
  12390. appro.CreateTime = DateTime.Now;
  12391. foreach (var item in gwinfo)
  12392. {
  12393. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12394. chi.Details = "拜访" + item.Client;
  12395. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12396. {
  12397. chi.Details += "," + item.ReqSample;
  12398. }
  12399. chi.ParentId = thisId;
  12400. chi.Time = item.Time;
  12401. chiarr.Add(chi);
  12402. }
  12403. if (chiarr.Count < 5)
  12404. {
  12405. for (int j = chiarr.Count; j < 5; j++)
  12406. {
  12407. chiarr.Add(new
  12408. Grp_ApprovalTravelDetails());
  12409. }
  12410. }
  12411. resultArr.Add(new
  12412. {
  12413. appro.Id,
  12414. appro.Date,
  12415. appro.Diid,
  12416. chiList = chiarr.Select(x1 => new
  12417. {
  12418. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12419. x1.Details,
  12420. x1.ParentId,
  12421. x1.Id
  12422. })
  12423. });
  12424. }
  12425. _sqlSugar.CommitTran();
  12426. jw = JsonView(true, "生成成功!", resultArr);
  12427. }
  12428. catch (Exception ex)
  12429. {
  12430. jw.Code = 400;
  12431. jw.Msg = "生成失败!" + ex.Message;
  12432. }
  12433. return Ok(jw);
  12434. }
  12435. /// <summary>
  12436. /// 报批行程word导出
  12437. /// </summary>
  12438. /// <param name="dto"></param>
  12439. /// <returns></returns>
  12440. [HttpPost]
  12441. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12442. {
  12443. var jw = JsonView(false);
  12444. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12445. if (group == null)
  12446. {
  12447. jw.Msg = "暂无该团组!";
  12448. return Ok(jw);
  12449. }
  12450. //模板路径
  12451. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12452. //载入模板
  12453. Document doc = new Document(tempPath);
  12454. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12455. //获取所填表格的序数
  12456. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12457. Aspose.Words.Tables.Row titleRowClone = null;
  12458. Aspose.Words.Tables.Row CenterRowClone = null;
  12459. int index = 0;
  12460. int indexChi = 0;
  12461. int SetIndex = 0;
  12462. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12463. //获取数据,放到datatable
  12464. foreach (var item in ApprovalTravelArr)
  12465. {
  12466. if (index > 0)
  12467. {
  12468. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12469. tableOne.AppendChild(titleRowClone);
  12470. }
  12471. var textTime = item.Date;
  12472. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12473. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12474. SetIndex++;
  12475. if (ChiRep.Count > 0)
  12476. {
  12477. foreach (var itemChi in ChiRep)
  12478. {
  12479. var txtTime = itemChi.Time;
  12480. var txtDetail = itemChi.Details;
  12481. if (indexChi > 0)
  12482. {
  12483. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12484. tableOne.AppendChild(CenterRowClone);
  12485. }
  12486. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12487. {
  12488. SetCells(tableOne, doc, SetIndex, 0, "");
  12489. SetCells(tableOne, doc, SetIndex, 1, "");
  12490. indexChi++;
  12491. SetIndex++;
  12492. break;
  12493. }
  12494. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12495. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12496. indexChi++;
  12497. SetIndex++;
  12498. }
  12499. }
  12500. else
  12501. {
  12502. if (indexChi > 0)
  12503. {
  12504. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12505. tableOne.AppendChild(CenterRowClone);
  12506. }
  12507. SetCells(tableOne, doc, SetIndex, 0, "");
  12508. SetCells(tableOne, doc, SetIndex, 1, "");
  12509. indexChi++;
  12510. SetIndex++;
  12511. }
  12512. index++;
  12513. }
  12514. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12515. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12516. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12517. jw.Code = 200;
  12518. jw.Msg = "";
  12519. return Ok(jw);
  12520. }
  12521. private string intToString(int numberVal)
  12522. {
  12523. string numberval = numberVal.ToString();
  12524. Dictionary<char, string> Number = new Dictionary<char, string>();
  12525. Number.Add('1', "一");
  12526. Number.Add('2', "二");
  12527. Number.Add('3', "三");
  12528. Number.Add('4', "四");
  12529. Number.Add('5', "五");
  12530. Number.Add('6', "六");
  12531. Number.Add('7', "七");
  12532. Number.Add('8', "八");
  12533. Number.Add('9', "九");
  12534. string stringNumberVal = string.Empty;
  12535. for (int i = 0; i < numberval.Length; i++)
  12536. {
  12537. if (i == 0)
  12538. {
  12539. stringNumberVal += Number[numberval[i]];
  12540. }
  12541. else if (i >= 1)
  12542. {
  12543. if (numberval[i] == '0')
  12544. {
  12545. stringNumberVal = "十";
  12546. }
  12547. else
  12548. {
  12549. stringNumberVal += "十" + Number[numberval[i]];
  12550. }
  12551. }
  12552. }
  12553. return stringNumberVal;
  12554. }
  12555. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12556. {
  12557. //获取table中的某个单元格,从0开始
  12558. Cell lshCell = table.Rows[rows].Cells[cells];
  12559. //将单元格中段落移除
  12560. foreach (Node item in lshCell.Paragraphs)
  12561. {
  12562. lshCell.Paragraphs.Remove(item);
  12563. }
  12564. if (val.Contains("\r\n"))
  12565. {
  12566. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12567. foreach (var item in spArr)
  12568. {
  12569. //新建一个段落
  12570. Paragraph p = new Paragraph(doc);
  12571. var r = new Run(doc, item);
  12572. //把设置的值赋给之前新建的段落
  12573. p.AppendChild(r);
  12574. //将此段落加到单元格内
  12575. lshCell.AppendChild(p);
  12576. }
  12577. }
  12578. else
  12579. {
  12580. //新建一个段落
  12581. Paragraph p = new Paragraph(doc);
  12582. var r = new Run(doc, val);
  12583. //把设置的值赋给之前新建的段落
  12584. p.AppendChild(r);
  12585. //将此段落加到单元格内
  12586. lshCell.AppendChild(p);
  12587. }
  12588. }
  12589. [HttpPost]
  12590. public async Task<IActionResult> ServerHttp(string paramStr)
  12591. {
  12592. paramStr = paramStr.TrimEnd('\'');
  12593. paramStr = paramStr.TrimStart('\'');
  12594. JsonView jw = JsonView(false);
  12595. JObject param = JObject.Parse(paramStr);
  12596. if (!param.ContainsKey("url"))
  12597. {
  12598. jw.Msg = "url null";
  12599. return Ok(jw);
  12600. }
  12601. string url = param["url"]!.ToString();
  12602. var methon = "get";
  12603. Dictionary<string, string> bodyValues = null;
  12604. Dictionary<string, string> headValues = null;
  12605. if (param.ContainsKey("methon"))
  12606. {
  12607. methon = param["methon"]!.ToString();
  12608. }
  12609. if (param.ContainsKey("header"))
  12610. {
  12611. var header = param["header"]!.ToString();
  12612. JObject headerJobject = JObject.Parse(header);
  12613. headValues = new Dictionary<string, string>();
  12614. foreach (JProperty item in headerJobject.Properties())
  12615. {
  12616. var value = item.Value.ToString();
  12617. var head = item.Path;
  12618. headValues.Add(head, value);
  12619. }
  12620. }
  12621. if (param.ContainsKey("body"))
  12622. {
  12623. var body = param["body"]!.ToString();
  12624. bodyValues = new Dictionary<string, string>();
  12625. JObject bodyJobject = JObject.Parse(body);
  12626. foreach (JProperty item in bodyJobject.Properties())
  12627. {
  12628. var value = item.Value.ToString();
  12629. var head = item.Path;
  12630. bodyValues.Add(head, value);
  12631. }
  12632. }
  12633. HttpClient client = new HttpClient();
  12634. string responseString = string.Empty;
  12635. if (param.ContainsKey("isJson"))
  12636. {
  12637. }
  12638. if (headValues != null)
  12639. {
  12640. foreach (var item in headValues.Keys)
  12641. {
  12642. client.DefaultRequestHeaders.Add(item, headValues[item]);
  12643. }
  12644. }
  12645. try
  12646. {
  12647. if (methon == "get")
  12648. {
  12649. responseString = await client.GetStringAsync(url);
  12650. }
  12651. else if (methon == "post")
  12652. {
  12653. if (bodyValues == null)
  12654. {
  12655. jw.Msg = "methon post body null";
  12656. return Ok(jw);
  12657. }
  12658. // 数据转化为 key=val 格式
  12659. var content = new FormUrlEncodedContent(bodyValues);
  12660. var response = await client.PostAsync(url, content);
  12661. // 获取数据
  12662. responseString = await response.Content.ReadAsStringAsync();
  12663. }
  12664. else
  12665. {
  12666. jw.Msg = "methon error";
  12667. }
  12668. jw = JsonView(true, "success", responseString);
  12669. }
  12670. catch (Exception ex)
  12671. {
  12672. jw.Msg = "error " + ex.Message;
  12673. jw.Data = ex.StackTrace;
  12674. }
  12675. finally
  12676. {
  12677. client.Dispose();
  12678. }
  12679. return Ok(jw);
  12680. }
  12681. #endregion
  12682. // /// <summary>
  12683. // ///
  12684. // /// </summary>
  12685. // /// <param name="_dto"></param>
  12686. // /// <returns></returns>
  12687. // [HttpPost]
  12688. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12689. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12690. // {
  12691. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12692. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  12693. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  12694. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12695. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  12696. // dic_psg.Add("客人", 974);
  12697. // dic_psg.Add("司机", 975);
  12698. // dic_psg.Add("导游", 976);
  12699. // dic_psg.Add("公司内部人员", 977);
  12700. // dic_psg.Add("司机/导游/公司内部人员", 978);
  12701. // foreach (var item in list_visa)
  12702. // {
  12703. // Grp_VisaInfo temp = new Grp_VisaInfo();
  12704. // temp.Id = item.Id;
  12705. // temp.DIId = item.DIId;
  12706. // temp.VisaClient = item.VisaClient;
  12707. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  12708. // temp.VisaCurrency = item.VisaCurrency;
  12709. // temp.IsThird = item.IsThird;
  12710. // if (dic_psg.ContainsKey(item.PassengerType))
  12711. // {
  12712. // temp.PassengerType = dic_psg[item.PassengerType];
  12713. // }
  12714. // else {
  12715. // temp.PassengerType = -1;
  12716. // }
  12717. // temp.VisaNumber = item.VisaNumber;
  12718. // temp.VisaFreeNumber = item.VisaFreeNumber;
  12719. // temp.CreateUserId = item.Operators;
  12720. // DateTime dt_ct;
  12721. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  12722. // if (b_ct)
  12723. // {
  12724. // temp.CreateTime = dt_ct;
  12725. // }
  12726. // else
  12727. // {
  12728. // temp.CreateTime = DateTime.Now;
  12729. // }
  12730. // temp.DeleteTime = "";
  12731. // temp.DeleteUserId = 0;
  12732. // temp.Remark = item.Remark;
  12733. // if (string.IsNullOrEmpty(temp.Remark)) {
  12734. // temp.Remark = "";
  12735. // }
  12736. // temp.IsDel = item.IsDel;
  12737. // temp.VisaDescription = item.VisaAttachment;
  12738. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  12739. //([Id]
  12740. // ,[DIId]
  12741. // ,[VisaClient]
  12742. // ,[VisaPrice]
  12743. // ,[VisaCurrency]
  12744. // ,[IsThird]
  12745. // ,[PassengerType]
  12746. // ,[VisaNumber]
  12747. // ,[VisaFreeNumber]
  12748. // ,[CreateUserId]
  12749. // ,[CreateTime]
  12750. // ,[DeleteTime]
  12751. // ,[DeleteUserId]
  12752. // ,[Remark]
  12753. // ,[IsDel]
  12754. // ,[visaDescription])
  12755. // VALUES
  12756. // ({0},{1},'{2}',{3},{4}
  12757. //,{5},{6},{7},{8},{9}
  12758. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  12759. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  12760. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  12761. //);
  12762. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  12763. // }
  12764. // return Ok(JsonView(true, "操作成功!"));
  12765. // }
  12766. /// <summary>
  12767. /// 123132123
  12768. /// </summary>
  12769. /// <param name="_dto"></param>
  12770. /// <returns></returns>
  12771. [HttpPost]
  12772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12773. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12774. {
  12775. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12776. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  12777. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  12778. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12779. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  12780. dicDetail.Add(789, 1034);
  12781. dicDetail.Add(790, 1035);
  12782. dicDetail.Add(791, 1036);
  12783. dicDetail.Add(792, 1037);
  12784. dicDetail.Add(793, 1038);
  12785. dicDetail.Add(794, 1039);
  12786. dicDetail.Add(795, 1040);
  12787. dicDetail.Add(796, 1041);
  12788. dicDetail.Add(797, 1042);
  12789. dicDetail.Add(798, 1043);
  12790. dicDetail.Add(801, 1044);
  12791. dicDetail.Add(802, 1045);
  12792. dicDetail.Add(803, 1046);
  12793. Dictionary<int, int> dic = new Dictionary<int, int>();
  12794. dic.Add(806, 1027);
  12795. dic.Add(807, 1028);
  12796. dic.Add(808, 1029);
  12797. dic.Add(809, 1030);
  12798. dic.Add(810, 1031);
  12799. dic.Add(811, 1032);
  12800. dic.Add(812, 1033);
  12801. foreach (var item in list_visa)
  12802. {
  12803. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  12804. temp.Coefficient = item.coefficient;
  12805. DateTime dtCrt;
  12806. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  12807. if (b1)
  12808. {
  12809. temp.CreateTime = dtCrt;
  12810. }
  12811. else
  12812. {
  12813. temp.CreateTime = DateTime.Now;
  12814. }
  12815. temp.CreateUserId = item.Operators;
  12816. temp.DeleteTime = "";
  12817. temp.DeleteUserId = 0;
  12818. temp.DiId = int.Parse(item.DIID);
  12819. temp.FilePath = item.FilePath;
  12820. temp.IsDel = item.IsDel;
  12821. temp.Price = item.Price;
  12822. temp.PriceCount = 1;
  12823. temp.PriceCurrency = item.Currency;
  12824. int detailId = 0;
  12825. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  12826. {
  12827. detailId = dicDetail[item.PriceTypeDetail];
  12828. }
  12829. temp.PriceDetailType = detailId;
  12830. temp.PriceDt = DateTime.Now;
  12831. temp.PriceName = item.PriceName;
  12832. temp.PriceSum = item.Price;
  12833. int tid = 0;
  12834. if (dic.ContainsKey(item.PriceType))
  12835. {
  12836. tid = dic[item.PriceType];
  12837. }
  12838. temp.PriceType = tid;
  12839. temp.Remark = item.Remark;
  12840. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  12841. }
  12842. return Ok(JsonView(true, "操作成功!"));
  12843. }
  12844. }
  12845. }