GroupsController.cs 590 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. using static Pipelines.Sockets.Unofficial.SocketConnection;
  90. using System.Diagnostics.PerformanceData;
  91. using System.Drawing.Printing;
  92. namespace OASystem.API.Controllers
  93. {
  94. /// <summary>
  95. /// 团组相关
  96. /// </summary>
  97. //[Authorize]
  98. [Route("api/[controller]/[action]")]
  99. public class GroupsController : ControllerBase
  100. {
  101. private readonly GrpScheduleRepository _grpScheduleRep;
  102. private readonly IMapper _mapper;
  103. private readonly DelegationInfoRepository _groupRepository;
  104. private readonly TaskAssignmentRepository _taskAssignmentRep;
  105. private readonly AirTicketResRepository _airTicketResRep;
  106. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  107. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  108. private readonly DelegationEnDataRepository _delegationEnDataRep;
  109. private readonly DelegationVisaRepository _delegationVisaRep;
  110. private readonly VisaPriceRepository _visaPriceRep;
  111. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  112. private readonly HotelPriceRepository _hotelPriceRep;
  113. private readonly CustomersRepository _customersRep;
  114. private readonly MessageRepository _message;
  115. private readonly SqlSugarClient _sqlSugar;
  116. private readonly TourClientListRepository _tourClientListRep;
  117. private readonly TeamRateRepository _teamRateRep;
  118. #region 成本相关
  119. private readonly CheckBoxsRepository _checkBoxs;
  120. private readonly GroupCostRepository _GroupCostRepository;
  121. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  122. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  123. #endregion
  124. private readonly SetDataRepository _setDataRep;
  125. private string url;
  126. private string path;
  127. private readonly EnterExitCostRepository _enterExitCostRep;
  128. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  129. private readonly UsersRepository _usersRep;
  130. private readonly IJuHeApiService _juHeApi;
  131. private readonly InvertedListRepository _invertedListRep;
  132. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  133. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  134. private readonly ThreeCodeRepository _threeCodeRepository;
  135. private readonly HotelInquiryRepository _hotelInquiryRep;
  136. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  137. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  138. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  139. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  140. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  141. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  142. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  143. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep, ThreeCodeRepository threeCodeRepository)
  144. {
  145. _mapper = mapper;
  146. _grpScheduleRep = grpScheduleRep;
  147. _groupRepository = groupRepository;
  148. _taskAssignmentRep = taskAssignmentRep;
  149. _airTicketResRep = airTicketResRep;
  150. _sqlSugar = sqlSugar;
  151. url = AppSettingsHelper.Get("ExcelBaseUrl");
  152. path = AppSettingsHelper.Get("ExcelBasePath");
  153. if (!System.IO.Directory.Exists(path))
  154. {
  155. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  156. }
  157. _decreasePaymentsRep = decreasePaymentsRep;
  158. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  159. _delegationEnDataRep = delegationEnDataRep;
  160. _enterExitCostRep = enterExitCostRep;
  161. _delegationVisaRep = delegationVisaRep;
  162. _message = message;
  163. _visaPriceRep = visaPriceRep;
  164. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  165. _checkBoxs = checkBoxs;
  166. _GroupCostRepository = GroupCostRepository;
  167. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  168. _GroupCostParameterRepository = GroupCostParameterRepository;
  169. _hotelPriceRep = hotelPriceRep;
  170. _customersRep = customersRep;
  171. _setDataRep = setDataRep;
  172. _tourClientListRep = tourClientListRep;
  173. _teamRateRep = teamRateRep;
  174. _hubContext = hubContext;
  175. _usersRep = usersRep;
  176. _juHeApi = juHeApi;
  177. _invertedListRep = invertedListRep;
  178. _visaFeeInfoRep = visaFeeInfoRep;
  179. _ticketBlackCodeRep = ticketBlackCodeRep;
  180. _hotelInquiryRep = hotelInquiryRep;
  181. _threeCodeRepository = threeCodeRepository;
  182. }
  183. #region 流程管控
  184. /// <summary>
  185. /// 获取团组流程管控信息
  186. /// </summary>
  187. /// <param name="paras">参数Json字符串</param>
  188. /// <returns></returns>
  189. [HttpPost]
  190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  191. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  192. {
  193. if (string.IsNullOrEmpty(_jsonDto.Paras))
  194. {
  195. return Ok(JsonView(false, "参数为空"));
  196. }
  197. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  198. if (_ScheduleDto != null)
  199. {
  200. if (_ScheduleDto.SearchType == 2)//获取列表
  201. {
  202. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  203. return Ok(JsonView(_grpScheduleViewList));
  204. }
  205. else//获取对象
  206. {
  207. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  208. if (_grpScheduleView != null)
  209. {
  210. return Ok(JsonView(_grpScheduleView));
  211. }
  212. }
  213. }
  214. else
  215. {
  216. return Ok(JsonView(false, "参数反序列化失败"));
  217. }
  218. return Ok(JsonView(false, "暂无数据!"));
  219. }
  220. /// <summary>
  221. /// 修改团组流程管控详细表数据
  222. /// </summary>
  223. /// <param name="paras"></param>
  224. /// <returns></returns>
  225. [HttpPost]
  226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  227. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  228. {
  229. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  230. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  231. .SetColumns(it => it.Duty == _detail.Duty)
  232. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  233. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  234. .SetColumns(it => it.JobContent == _detail.JobContent)
  235. .SetColumns(it => it.Remark == _detail.Remark)
  236. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  237. .Where(s => s.Id == dto.Id)
  238. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  239. .ExecuteCommandAsync();
  240. if (result > 0)
  241. {
  242. return Ok(JsonView(true, "保存成功!"));
  243. }
  244. return Ok(JsonView(false, "保存失败!"));
  245. }
  246. /// <summary>
  247. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  248. /// </summary>
  249. /// <param name="dto"></param>
  250. /// <returns></returns>
  251. [HttpPost]
  252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  253. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  254. {
  255. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  256. _detail.IsDel = 1;
  257. _detail.DeleteUserId = dto.Duty;
  258. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  259. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  260. .SetColumns(it => it.IsDel == _detail.IsDel)
  261. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  262. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  263. .Where(it => it.Id == dto.Id)
  264. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  265. //.WhereColumns(s => s.Id == dto.Id)
  266. .ExecuteCommandAsync();
  267. if (result > 0)
  268. {
  269. return Ok(JsonView(true, "删除成功!"));
  270. }
  271. return Ok(JsonView(false, "删除失败!"));
  272. }
  273. /// <summary>
  274. /// 增加团组流程管控详细表数据
  275. /// </summary>
  276. /// <param name="dto"></param>
  277. /// <returns></returns>
  278. [HttpPost]
  279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  280. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  281. {
  282. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  283. if (DateTime.Now < _detail.ExpectBeginDt)
  284. {
  285. _detail.StepStatus = 0;
  286. }
  287. else
  288. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  289. _detail.StepStatus = 1;
  290. }
  291. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  292. if (result > 0)
  293. {
  294. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  295. return Ok(JsonView(true, "添加成功!", _result));
  296. }
  297. return Ok(JsonView(false, "添加失败!"));
  298. }
  299. #endregion
  300. #region 团组基本信息
  301. /// <summary>
  302. /// 接团信息列表
  303. /// </summary>
  304. /// <param name="dto">团组列表请求dto</param>
  305. /// <returns></returns>
  306. [HttpPost]
  307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  308. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  309. {
  310. var groupData = await _groupRepository.GetGroupList(dto);
  311. if (groupData.Code != 0)
  312. {
  313. return Ok(JsonView(false, groupData.Msg));
  314. }
  315. return Ok(JsonView(groupData.Data));
  316. }
  317. /// <summary>
  318. /// 接团信息列表 Page
  319. /// </summary>
  320. /// <param name="dto">团组列表请求dto</param>
  321. /// <returns></returns>
  322. [HttpPost]
  323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  324. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  325. {
  326. #region 参数验证
  327. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  328. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  329. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  330. #region 页面操作权限验证
  331. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  332. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  333. #endregion
  334. #endregion
  335. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  336. {
  337. string sqlWhere = string.Empty;
  338. if (dto.IsSure == 0) //未完成
  339. {
  340. sqlWhere += string.Format(@" And IsSure = 0");
  341. }
  342. else if (dto.IsSure == 1) //已完成
  343. {
  344. sqlWhere += string.Format(@" And IsSure = 1");
  345. }
  346. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  347. {
  348. string tj = dto.SearchCriteria;
  349. 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}%')",
  350. tj, tj, tj, tj, tj);
  351. }
  352. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  353. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  354. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  355. JietuanOperator,IsSure,CreateTime
  356. From (
  357. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  358. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  359. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  360. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  361. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  362. From Grp_DelegationInfo gdi
  363. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  364. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  365. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  366. Where gdi.IsDel = 0 {0}
  367. ) temp", sqlWhere);
  368. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  369. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  370. #region 处理所属部门
  371. /*
  372. * 1.sq 和 gyy 等显示 市场部
  373. * 2.王鸽和主管及张总还有管理员号统一国交部
  374. * 2-1. 4 管理员 ,21 张海麟
  375. */
  376. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  377. List<int> userIds1 = new List<int>() { 4, 21 };
  378. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  379. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  380. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  381. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  382. .ToList();
  383. foreach (var item in _DelegationList)
  384. {
  385. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  386. }
  387. #endregion
  388. var _view = new
  389. {
  390. PageFuncAuth = pageFunAuthView,
  391. Data = _DelegationList
  392. };
  393. return Ok(JsonView(true, "查询成功!", _view, total));
  394. }
  395. else
  396. {
  397. return Ok(JsonView(false, "查询失败"));
  398. }
  399. }
  400. /// <summary>
  401. /// 团组列表
  402. /// </summary>
  403. /// <returns></returns>
  404. [HttpPost]
  405. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  406. {
  407. #region 参数验证
  408. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  409. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  410. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  411. #region 页面操作权限验证
  412. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  413. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  414. #endregion
  415. #endregion
  416. if (dto.PortType != 1 && dto.PortType != 2)
  417. {
  418. return Ok(JsonView(false, "查询失败!"));
  419. }
  420. string orderbyStr = "order by gdi.CreateTime Desc";
  421. string sqlWhere = string.Empty;
  422. if (dto.IsSure == 0) //未完成
  423. {
  424. sqlWhere += string.Format(@" And IsSure = 0");
  425. }
  426. else if (dto.IsSure == 1) //已完成
  427. {
  428. sqlWhere += string.Format(@" And IsSure = 1");
  429. }
  430. //团组类型
  431. if (dto.TeamDid > 0)
  432. {
  433. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  434. }
  435. //团组名称
  436. if (!string.IsNullOrEmpty(dto.TeamName))
  437. {
  438. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  439. }
  440. //客户名称
  441. if (!string.IsNullOrEmpty(dto.ClientName))
  442. {
  443. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  444. }
  445. //客户单位
  446. if (!string.IsNullOrEmpty(dto.ClientUnit))
  447. {
  448. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  449. }
  450. //出访时间
  451. if (!string.IsNullOrEmpty(dto.visitDataTime))
  452. {
  453. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  454. orderbyStr = "order by gdi.VisitDate";
  455. }
  456. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  457. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  458. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  459. JietuanOperator,IsSure,CreateTime
  460. From (
  461. Select row_number() over({0}) as Row_Number,
  462. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  463. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  464. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  465. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  466. From Grp_DelegationInfo gdi
  467. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  468. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  469. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  470. Where gdi.IsDel = 0 {1}
  471. ) temp ", orderbyStr, sqlWhere);
  472. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  473. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  474. #region 处理所属部门
  475. /*
  476. * 1.sq 和 gyy 等显示 市场部
  477. * 2.王鸽和主管及张总还有管理员号统一国交部
  478. * 2-1. 4 管理员 ,21 张海麟
  479. */
  480. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  481. List<int> userIds1 = new List<int>() { 4, 21 };
  482. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  483. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  484. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  485. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  486. .ToList();
  487. foreach (var item in _DelegationList)
  488. {
  489. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  490. }
  491. #endregion
  492. var _view = new
  493. {
  494. PageFuncAuth = pageFunAuthView,
  495. Data = _DelegationList
  496. };
  497. return Ok(JsonView(true, "查询成功!", _view, total));
  498. }
  499. /// <summary>
  500. /// 接团信息详情
  501. /// </summary>
  502. /// <param name="dto">团组info请求dto</param>
  503. /// <returns></returns>
  504. [HttpPost]
  505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  506. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  507. {
  508. var groupData = await _groupRepository.GetGroupInfo(dto);
  509. if (groupData.Code != 0)
  510. {
  511. return Ok(JsonView(false, groupData.Msg));
  512. }
  513. return Ok(JsonView(groupData.Data));
  514. }
  515. /// <summary>
  516. /// 接团信息 编辑添加
  517. /// 基础信息数据源
  518. /// </summary>
  519. /// <param name="dto"></param>
  520. /// <returns></returns>
  521. [HttpPost]
  522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  523. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  524. {
  525. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  526. if (groupData.Code != 0)
  527. {
  528. return Ok(JsonView(false, groupData.Msg));
  529. }
  530. return Ok(JsonView(groupData.Data));
  531. }
  532. /// <summary>
  533. /// 接团信息 操作(增改)
  534. /// </summary>
  535. /// <param name="dto"></param>
  536. /// <returns></returns>
  537. [HttpPost]
  538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  539. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  540. {
  541. try
  542. {
  543. var groupData = await _groupRepository.GroupOperation(dto);
  544. if (groupData.Code != 0)
  545. {
  546. return Ok(JsonView(false, groupData.Msg));
  547. }
  548. int diId = 0;
  549. //添加时 默认加入团组汇率
  550. if (dto.Status == 1) //添加
  551. {
  552. diId = groupData.Data;
  553. //添加默认币种
  554. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  555. //默认分配权限
  556. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  557. //消息提示 王鸽 主管号
  558. List<int> _managerIds = new List<int>() { 22, 32 };
  559. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  560. if (userIds.Count > 0)
  561. {
  562. userIds.Add(208);
  563. //创建团组管控
  564. GroupStepForDelegation.CreateWorkStep(diId);
  565. //发送消息
  566. string groupName = dto.TeamName;
  567. string createGroupUser = string.Empty;
  568. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  569. if (userInfo != null) createGroupUser = userInfo.CnName;
  570. string title = $"系统通知";
  571. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  572. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  573. }
  574. //默认创建倒推表
  575. await _invertedListRep._Create(dto.UserId, diId);
  576. }
  577. else if (dto.Status == 2)
  578. {
  579. diId = dto.Id;
  580. }
  581. return Ok(JsonView(true, "操作成功!", diId));
  582. }
  583. catch (Exception ex)
  584. {
  585. Logs("[response]" + JsonConvert.SerializeObject(dto));
  586. Logs(ex.Message);
  587. return Ok(JsonView(false, ex.Message));
  588. }
  589. }
  590. /// <summary>
  591. /// 接团流程操作(增改)
  592. /// 安卓端使用 建团时添加客户名单
  593. /// </summary>
  594. /// <param name="dto"></param>
  595. /// <returns></returns>
  596. [HttpPost]
  597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  598. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  599. {
  600. try
  601. {
  602. #region 参数验证
  603. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  604. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  605. #region 页面操作权限验证
  606. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  607. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  608. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  609. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  610. #endregion
  611. #endregion
  612. _sqlSugar.BeginTran();
  613. var _dto = new GroupOperationDto();
  614. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  615. var groupData = await _groupRepository.GroupOperation(_dto);
  616. if (groupData.Code != 0)
  617. {
  618. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  619. }
  620. int diId = 0;
  621. //添加时 默认加入团组汇率
  622. if (dto.Status == 1) //添加
  623. {
  624. diId = groupData.Data;
  625. //添加默认币种
  626. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  627. //默认分配权限
  628. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  629. //消息提示 王鸽 主管号
  630. List<int> _managerIds = new List<int>() { 22, 32 };
  631. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  632. if (userIds.Count > 0)
  633. {
  634. userIds.Add(208);
  635. //创建团组管控
  636. GroupStepForDelegation.CreateWorkStep(diId);
  637. //发送消息
  638. string groupName = dto.TeamName;
  639. string createGroupUser = string.Empty;
  640. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  641. if (userInfo != null) createGroupUser = userInfo.CnName;
  642. string title = $"系统通知";
  643. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  644. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  645. }
  646. }
  647. if (dto.Status == 2)
  648. {
  649. diId = dto.Id;
  650. if (diId == 0)
  651. {
  652. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  653. }
  654. }
  655. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  656. if (viewData.Code != 0)
  657. {
  658. _sqlSugar.RollbackTran();
  659. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  660. }
  661. _sqlSugar.CommitTran();
  662. return Ok(JsonView(true, "添加成功"));
  663. }
  664. catch (Exception ex)
  665. {
  666. _sqlSugar.RollbackTran();
  667. return Ok(JsonView(false, ex.Message));
  668. }
  669. }
  670. /// <summary>
  671. /// 接团信息 操作(删除)
  672. /// </summary>
  673. /// <param name="dto"></param>
  674. /// <returns></returns>
  675. [HttpPost]
  676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  677. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  678. {
  679. try
  680. {
  681. var groupData = await _groupRepository.GroupDel(dto);
  682. if (groupData.Code != 0)
  683. {
  684. return Ok(JsonView(false, groupData.Msg));
  685. }
  686. return Ok(JsonView(true));
  687. }
  688. catch (Exception ex)
  689. {
  690. Logs("[response]" + JsonConvert.SerializeObject(dto));
  691. Logs(ex.Message);
  692. return Ok(JsonView(false, ex.Message));
  693. }
  694. }
  695. /// <summary>
  696. /// 获取团组销售报价号
  697. /// 团组添加时 使用
  698. /// </summary>
  699. /// <returns></returns>
  700. [HttpPost]
  701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  702. public async Task<IActionResult> GetGroupSalesQuoteNo()
  703. {
  704. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  705. if (groupData.Code != 0)
  706. {
  707. return Ok(JsonView(false, groupData.Msg));
  708. }
  709. object salesQuoteNo = new
  710. {
  711. SalesQuoteNo = groupData.Data
  712. };
  713. return Ok(JsonView(salesQuoteNo));
  714. }
  715. /// <summary>
  716. /// 设置确认出团
  717. /// </summary>
  718. /// <param name="dto"></param>
  719. /// <returns></returns>
  720. [HttpPost]
  721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  722. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  723. {
  724. var groupData = await _groupRepository.ConfirmationGroup(dto);
  725. if (groupData.Code != 0)
  726. {
  727. return Ok(JsonView(false, groupData.Msg));
  728. }
  729. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  730. #region OA消息推送
  731. try
  732. {
  733. string groupName = groupInfo.TeamName;
  734. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  735. List<int> userIds = new List<int>();
  736. listUser.ForEach(s => userIds.Add(s.Id));
  737. string title = $"系统通知";
  738. string content = $"团组[{groupName}]已确认出团!";
  739. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  740. }
  741. catch (Exception ex)
  742. {
  743. }
  744. #endregion
  745. #region 应用推送
  746. try
  747. {
  748. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  749. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  750. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  751. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  752. {
  753. List<string> userList = new List<string>() { users.QiyeChatUserId };
  754. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  755. }
  756. }
  757. catch (Exception ex)
  758. {
  759. }
  760. #endregion
  761. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  762. return Ok(JsonView(true, "操作成功!", groupData.Data));
  763. }
  764. /// <summary>
  765. /// 获取团组名称data And 签证国别Data
  766. /// </summary>
  767. /// <param name="dto"></param>
  768. /// <returns></returns>
  769. [HttpPost]
  770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  771. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  772. {
  773. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  774. if (groupData.Code != 0)
  775. {
  776. return Ok(JsonView(false, groupData.Msg));
  777. }
  778. return Ok(JsonView(groupData.Data));
  779. }
  780. /// <summary>
  781. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  782. /// </summary>
  783. /// <returns></returns>
  784. [HttpPost]
  785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  786. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  787. {
  788. try
  789. {
  790. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  791. if (groupData.Code != 0)
  792. {
  793. return Ok(JsonView(false, groupData.Msg));
  794. }
  795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  796. }
  797. catch (Exception ex)
  798. {
  799. return Ok(JsonView(false, "程序错误!"));
  800. throw;
  801. }
  802. }
  803. #endregion
  804. #region 团组&签证
  805. /// <summary>
  806. /// 根据团组Id获取签证客户信息List
  807. /// </summary>
  808. /// <param name="dto">请求dto</param>
  809. /// <returns></returns>
  810. [HttpPost]
  811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  812. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  813. {
  814. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  815. if (groupData.Code != 0)
  816. {
  817. return Ok(JsonView(false, groupData.Msg));
  818. }
  819. return Ok(JsonView(groupData.Data));
  820. }
  821. /// <summary>
  822. /// IOS获取团组签证拍照上传进度01(团组列表)
  823. /// </summary>
  824. /// <param name="dto">请求dto</param>
  825. /// <returns></returns>
  826. [HttpPost]
  827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  828. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  829. {
  830. if (dto == null)
  831. {
  832. return Ok(JsonView(false, "参数为空"));
  833. }
  834. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  835. return Ok(JsonView(visaList));
  836. }
  837. /// <summary>
  838. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  839. /// </summary>
  840. /// <returns></returns>
  841. [HttpPost]
  842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  843. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  844. {
  845. if (dto == null)
  846. {
  847. return Ok(JsonView(false, "请求错误:"));
  848. }
  849. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  850. return Ok(JsonView(list));
  851. }
  852. /// <summary>
  853. /// IOS获取团组签证拍照上传进度03(相册)
  854. /// </summary>
  855. /// <returns></returns>
  856. [HttpPost]
  857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  858. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  859. {
  860. if (dto == null)
  861. {
  862. return Ok(JsonView(false, "请求错误:"));
  863. }
  864. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  865. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  866. list.ForEach(s => s.url = url);
  867. return Ok(JsonView(list));
  868. }
  869. /// <summary>
  870. /// IOS获取团组签证拍照上传进度04(图片上传)
  871. /// </summary>
  872. /// <param name="dto"></param>
  873. /// <returns></returns>
  874. [HttpPost]
  875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  876. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  877. {
  878. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  879. //if (!string.IsNullOrEmpty(result))
  880. //{
  881. //}
  882. //else {
  883. // return Ok(JsonView(false, "上传失败"));
  884. //}
  885. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  886. int sucNum = 0;
  887. try
  888. {
  889. foreach (var item in dto.base64DataList)
  890. {
  891. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  892. string result = decodeBase64ToImage(item, imageName);
  893. if (!string.IsNullOrEmpty(result))
  894. {
  895. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  896. pic.CreateUserId = dto.CreateUserId;
  897. pic.PicName = imageName;
  898. pic.PicPath = result;
  899. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  900. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  901. if (insertResult > 0)
  902. {
  903. sucNum++;
  904. }
  905. }
  906. }
  907. }
  908. catch (Exception ex)
  909. {
  910. return Ok(JsonView(false, ex.Message));
  911. }
  912. string msg = string.Format(@"成功上传{0}张", sucNum);
  913. return Ok(JsonView(true, msg));
  914. }
  915. private string decodeBase64ToImage(string base64DataURL, string imgName)
  916. {
  917. string filename = "";//声明一个string类型的相对路径
  918. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  919. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  920. try//会有异常抛出,try,catch一下
  921. {
  922. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  923. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  924. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  925. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  926. //文件名称
  927. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  928. //上传的文件的路径
  929. string filePath = "";
  930. if (!Directory.Exists(fileDir))
  931. {
  932. Directory.CreateDirectory(fileDir);
  933. }
  934. //上传的文件的路径
  935. filePath = fileDir + filename;
  936. //string url = HttpRuntime.AppDomainAppPath.ToString();
  937. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  938. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  939. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  940. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  941. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  942. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  943. ms.Close();//关闭当前流,并释放所有与之关联的资源
  944. bitmap.Dispose();
  945. }
  946. catch (Exception e)
  947. {
  948. string massage = e.Message;
  949. Logs("IOS图片上传Error:" + massage);
  950. //filename = e.Message;
  951. }
  952. return filename;//返回相对路径
  953. }
  954. /// <summary>
  955. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  956. /// </summary>
  957. /// <param name="dto"></param>
  958. /// <returns></returns>
  959. [HttpPost]
  960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  961. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  962. {
  963. if (dto == null)
  964. {
  965. return Ok(JsonView(false, "请求错误:"));
  966. }
  967. string msg = "参数错误";
  968. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  969. {
  970. try
  971. {
  972. //_delegationVisaRep.BeginTran();
  973. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  974. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  975. .Where(s => s.Id == dto.visaProgressCustomerId)
  976. .ExecuteCommandAsync();
  977. if (updCount > 0 && dto.publishCode == 1)
  978. {
  979. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  980. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  981. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  982. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  983. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  984. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  985. if (groupData == null)
  986. {
  987. _delegationVisaRep.RollbackTran();
  988. }
  989. string title = string.Format(@"[签证进度更新]");
  990. string content = string.Format(@"测试文本");
  991. bool rst = await _message.AddMsg(new MessageDto()
  992. {
  993. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  994. IssuerId = dto.publisher,
  995. Title = title,
  996. Content = content,
  997. ReleaseTime = DateTime.Now,
  998. UIdList = new List<int> {
  999. 234
  1000. }
  1001. });
  1002. if (rst)
  1003. {
  1004. return Ok(JsonView(true, "发送通知成功"));
  1005. }
  1006. }
  1007. //_delegationVisaRep.CommitTran();
  1008. }
  1009. catch (Exception)
  1010. {
  1011. //_delegationVisaRep.RollbackTran();
  1012. }
  1013. }
  1014. return Ok(JsonView(true, msg));
  1015. }
  1016. #endregion
  1017. #region 团组任务分配
  1018. /// <summary>
  1019. /// 团组任务分配初始化
  1020. /// </summary>
  1021. /// <param name="dto"></param>
  1022. /// <returns></returns>
  1023. [HttpPost]
  1024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1025. public async Task<IActionResult> GetTaskAssignmen()
  1026. {
  1027. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1028. if (groupData.Code != 0)
  1029. {
  1030. return Ok(JsonView(false, groupData.Msg));
  1031. }
  1032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1033. }
  1034. /// <summary>
  1035. /// 团组任务分配查询
  1036. /// </summary>
  1037. /// <param name="dto"></param>
  1038. /// <returns></returns>
  1039. [HttpPost]
  1040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1041. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1042. {
  1043. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1044. if (groupData.Code != 0)
  1045. {
  1046. return Ok(JsonView(false, groupData.Msg));
  1047. }
  1048. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1049. }
  1050. /// <summary>
  1051. /// 团组任务分配操作
  1052. /// </summary>
  1053. /// <param name="dto"></param>
  1054. /// <returns></returns>
  1055. [HttpPost]
  1056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1057. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1058. {
  1059. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1060. if (groupData.Code != 0)
  1061. {
  1062. return Ok(JsonView(false, groupData.Msg));
  1063. }
  1064. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1065. }
  1066. #endregion
  1067. #region 团组费用审核
  1068. /// <summary>
  1069. /// 费用审核
  1070. /// 团组列表 Page
  1071. /// </summary>
  1072. /// <param name="_dto">团组列表请求dto</param>
  1073. /// <returns></returns>
  1074. [HttpPost]
  1075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1076. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1077. {
  1078. #region 参数验证
  1079. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1080. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1082. #region 页面操作权限验证
  1083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1084. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1085. #endregion
  1086. #endregion
  1087. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1088. {
  1089. string sqlWhere = string.Empty;
  1090. if (_dto.IsSure == 0) //未完成
  1091. {
  1092. sqlWhere += string.Format(@" And IsSure = 0");
  1093. }
  1094. else if (_dto.IsSure == 1) //已完成
  1095. {
  1096. sqlWhere += string.Format(@" And IsSure = 1");
  1097. }
  1098. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1099. {
  1100. string tj = _dto.SearchCriteria;
  1101. 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}%')",
  1102. tj, tj, tj, tj, tj);
  1103. }
  1104. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1105. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1106. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1107. From (
  1108. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1109. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1110. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1111. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1112. From Grp_DelegationInfo gdi
  1113. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1114. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1115. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1116. Where gdi.IsDel = 0 {0}
  1117. ) temp ", sqlWhere);
  1118. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1119. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1120. var _view = new
  1121. {
  1122. PageFuncAuth = pageFunAuthView,
  1123. Data = _DelegationList
  1124. };
  1125. return Ok(JsonView(true, "查询成功!", _view, total));
  1126. }
  1127. else
  1128. {
  1129. return Ok(JsonView(false, "查询失败"));
  1130. }
  1131. }
  1132. /// <summary>
  1133. /// 获取团组费用审核
  1134. /// </summary>
  1135. /// <param name="paras">参数Json字符串</param>
  1136. /// <returns></returns>
  1137. [HttpPost]
  1138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1139. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1140. {
  1141. try
  1142. {
  1143. #region 参数验证
  1144. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1145. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1146. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1147. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1148. #region 页面操作权限验证
  1149. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1150. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1151. #endregion
  1152. #endregion
  1153. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1154. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1155. #region 费用清单
  1156. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1157. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1158. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1159. List<Grp_CreditCardPayment> entityList = _groupRepository
  1160. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1161. .Where(exp.ToExpression())
  1162. .ToList();
  1163. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1164. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1165. /*
  1166. * 76://酒店预订
  1167. */
  1168. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1169. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1170. .ToListAsync();
  1171. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1172. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1173. .ToListAsync();
  1174. /*
  1175. * 79://车/导游地接
  1176. */
  1177. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1178. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1179. .ToListAsync();
  1180. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1181. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1182. .ToListAsync();
  1183. /*
  1184. * 80: //签证
  1185. */
  1186. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1187. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1188. .ToListAsync();
  1189. /*
  1190. *81: //邀请/公务活动
  1191. */
  1192. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1193. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1194. .ToListAsync();
  1195. /*
  1196. * 82: //团组客户保险
  1197. */
  1198. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1199. /*
  1200. * Lable = 85 机票预订
  1201. */
  1202. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1203. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1204. .ToListAsync();
  1205. /*
  1206. * 85 机票预定
  1207. */
  1208. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1209. /*
  1210. * 98 其他款项
  1211. */
  1212. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1213. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1214. .ToListAsync();
  1215. /*
  1216. * 285:收款退还
  1217. */
  1218. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1219. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1220. .ToListAsync();
  1221. /*
  1222. * 1015: //超支费用
  1223. */
  1224. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1225. /*
  1226. * 币种信息
  1227. */
  1228. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1229. /*
  1230. * 车/导游地接 费用类型
  1231. */
  1232. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1233. /*
  1234. * 车/导游地接 费用类型
  1235. */
  1236. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1237. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1238. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1239. /*
  1240. * 用户信息
  1241. */
  1242. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1243. /*
  1244. * 费用模块
  1245. */
  1246. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1247. string priceModule = string.Empty;
  1248. if (sdPriceName != null)
  1249. {
  1250. priceModule = sdPriceName.Name;
  1251. }
  1252. /*
  1253. * 处理详情数据
  1254. */
  1255. foreach (var entity in entityList)
  1256. {
  1257. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1258. _detail.Id = entity.Id;
  1259. _detail.PriceName = priceModule;
  1260. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1261. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1262. /*
  1263. * 应付款金额
  1264. */
  1265. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1266. string PaymentCurrency_WaitPay = "Unknown";
  1267. string hotelCurrncyCode = "Unknown";
  1268. string hotelCurrncyName = "Unknown";
  1269. if (sdPaymentCurrency_WaitPay != null)
  1270. {
  1271. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1272. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1273. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1274. if (hotelCurrncyCode.Equals("CNY"))
  1275. {
  1276. entity.DayRate = 1.0000M;
  1277. }
  1278. }
  1279. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1280. /*
  1281. * 此次付款金额
  1282. */
  1283. decimal CurrPayStr = 0;
  1284. if (entity.PayPercentage == 0)
  1285. {
  1286. if (entity.PayThenMoney != 0)
  1287. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1288. }
  1289. else
  1290. {
  1291. if (entity.PayMoney != 0)
  1292. {
  1293. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1294. }
  1295. }
  1296. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1297. /*
  1298. * 剩余尾款
  1299. */
  1300. decimal BalanceStr = 0;
  1301. if (CurrPayStr != 0)
  1302. {
  1303. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1304. BalanceStr = 0;
  1305. else
  1306. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1307. }
  1308. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1309. /*
  1310. * Bus名称
  1311. */
  1312. _detail.BusName = "待增加";
  1313. /*
  1314. *费用所属
  1315. */
  1316. switch (entity.CTable)
  1317. {
  1318. case 76://酒店预订
  1319. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1320. if (hotelReservations != null)
  1321. {
  1322. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1323. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1324. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1325. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1326. /*
  1327. * 费用类型
  1328. * 1:房费
  1329. * 2:早餐
  1330. * 3:地税
  1331. * 4:城市税
  1332. * </summary>
  1333. */
  1334. //地税
  1335. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1336. if (governmentRentData != null)
  1337. {
  1338. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1339. governmentRentFee = governmentRentData.Price;
  1340. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1341. if (governmentRentCurrData != null)
  1342. {
  1343. governmentRentCode = governmentRentCurrData.Name;
  1344. governmentRentName = $"({governmentRentCurrData.Remark})";
  1345. }
  1346. }
  1347. //城市税
  1348. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1349. if (cityTaxData != null)
  1350. {
  1351. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1352. cityTaxFee = cityTaxData.Price;
  1353. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1354. if (cityTaxCurrData != null)
  1355. {
  1356. cityTaxCode = cityTaxCurrData.Name;
  1357. cityTaxName = $"({cityTaxCurrData.Remark})";
  1358. }
  1359. }
  1360. //酒店早餐
  1361. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1362. if (breakfastData != null)
  1363. {
  1364. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1365. breakfastFee = breakfastData.Price;
  1366. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1367. if (breakfastCurrData != null)
  1368. {
  1369. breakfastCode = breakfastCurrData.Name;
  1370. breakfastName = $"({breakfastCurrData.Remark})";
  1371. }
  1372. }
  1373. //房间费用
  1374. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1375. if (roomData != null)
  1376. {
  1377. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1378. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1379. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1380. roomFee = roomData.Price;
  1381. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1382. if (roomCurrData != null)
  1383. {
  1384. roomCode = roomCurrData.Name;
  1385. roomName = $"({roomCurrData.Remark})";
  1386. }
  1387. }
  1388. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1389. $"房间说明: {hotelReservations.Remark} <br/>" +
  1390. $"房间费用: {roomFee.ToString("#0.00")} {roomCode} {roomName} 当时汇率{roomData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{roomBool}<br/>" +
  1391. $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率{breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/>" +
  1392. $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率{governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/>" +
  1393. $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率{cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1394. _detail.PriceNameContent = hotelReservations.HotelName;
  1395. }
  1396. break;
  1397. case 79://车/导游地接
  1398. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1399. if (touristGuideGroundReservations != null)
  1400. {
  1401. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1402. {
  1403. _detail.BusName = touristGuideGroundReservations.BusName;
  1404. }
  1405. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1406. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1407. //if (isInt)
  1408. //{
  1409. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1410. // if (cityInfo != null)
  1411. // {
  1412. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1413. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1414. // if (carFeeItem != null)
  1415. // {
  1416. // nameContent += $@"({carFeeItem.Name})";
  1417. // }
  1418. // _detail.PriceNameContent = nameContent;
  1419. // }
  1420. //}
  1421. //else
  1422. //{
  1423. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1424. //}
  1425. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1426. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1427. string priceMsg = string.Empty;
  1428. foreach (var item in touristGuideGroundReservationsContents)
  1429. {
  1430. string typeName = "Unknown";
  1431. string carCurrencyCode = "Unknown";
  1432. string carCurrencyName = "Unknown";
  1433. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1434. if (carTypeData != null) typeName = carTypeData.Name;
  1435. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1436. if (currencyData != null)
  1437. {
  1438. carCurrencyCode = currencyData.Name;
  1439. carCurrencyName = currencyData.Remark;
  1440. }
  1441. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1442. "明细:" + item.PriceContent + "<br/>" +
  1443. "备注:" + item.Remark + "<br/><br/>";
  1444. }
  1445. _detail.PriceMsgContent = priceMsg;
  1446. }
  1447. break;
  1448. case 80: //签证
  1449. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1450. if (visaInfo != null)
  1451. {
  1452. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1453. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1454. }
  1455. break;
  1456. case 81: //邀请/公务活动
  1457. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1458. if (_ioa != null)
  1459. {
  1460. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1461. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1462. sendCurrName = "Unknown", //快递费用币种 Name
  1463. sendCurrCode = "Unknown", //快递费用币种 Code
  1464. eventsCurrName = "Unknown", //公务活动费币种 Name
  1465. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1466. translateCurrName = "Unknown", //公务翻译费 Name
  1467. translateCurrCode = "Unknown"; //公务翻译费 Code
  1468. #region 处理费用币种
  1469. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1470. if (inviteCurrData != null)
  1471. {
  1472. inviteCurrName = inviteCurrData.Remark;
  1473. inviteCurrCode = inviteCurrData.Name;
  1474. }
  1475. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1476. if (sendCurrData != null)
  1477. {
  1478. sendCurrName = sendCurrData.Remark;
  1479. sendCurrCode = sendCurrData.Name;
  1480. }
  1481. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1482. if (eventsCurrData != null)
  1483. {
  1484. eventsCurrName = eventsCurrData.Remark;
  1485. eventsCurrCode = eventsCurrData.Name;
  1486. }
  1487. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1488. if (translateCurrData != null)
  1489. {
  1490. translateCurrName = translateCurrData.Remark;
  1491. translateCurrCode = translateCurrData.Name;
  1492. }
  1493. #endregion
  1494. _detail.PriceNameContent = _ioa.InviterArea;
  1495. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1496. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1497. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1498. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1499. $@"备注:" + _ioa.Remark + "<br/>";
  1500. }
  1501. break;
  1502. case 82: //团组客户保险
  1503. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1504. if (customers != null)
  1505. {
  1506. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1507. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1508. }
  1509. break;
  1510. case 85: //机票预订
  1511. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1512. if (jpRes != null)
  1513. {
  1514. string FlightsDescription = jpRes.FlightsDescription;
  1515. string PriceDescription = jpRes.PriceDescription;
  1516. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1517. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1518. }
  1519. break;
  1520. case 98://其他款项
  1521. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1522. if (gdpRes != null)
  1523. {
  1524. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1525. _detail.PriceNameContent = gdpRes.PriceName;
  1526. }
  1527. break;
  1528. case 285://收款退还
  1529. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1530. if (refundAndOtherMoney != null)
  1531. {
  1532. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1533. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1534. }
  1535. break;
  1536. case 751://酒店早餐
  1537. break;
  1538. case 1015://超支费用
  1539. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1540. if (groupExtraCost != null)
  1541. {
  1542. _detail.PriceNameContent = groupExtraCost.PriceName;
  1543. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1544. }
  1545. break;
  1546. default:
  1547. break;
  1548. }
  1549. /*
  1550. * 申请人
  1551. */
  1552. string operatorName = " - ";
  1553. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1554. if (_opUser != null)
  1555. {
  1556. operatorName = _opUser.CnName;
  1557. }
  1558. _detail.OperatorName = operatorName;
  1559. /*
  1560. * 审核人
  1561. */
  1562. string auditOperatorName = "Unknown";
  1563. if (entity.AuditGMOperate == 0)
  1564. auditOperatorName = " - ";
  1565. else if (entity.AuditGMOperate == 4)
  1566. auditOperatorName = "自动审核";
  1567. else
  1568. {
  1569. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1570. if (_adUser != null)
  1571. {
  1572. auditOperatorName = _adUser.CnName;
  1573. }
  1574. }
  1575. _detail.AuditOperatorName = auditOperatorName;
  1576. /*
  1577. * 超预算比例
  1578. */
  1579. string overBudgetStr = "";
  1580. if (entity.ExceedBudget == -1)
  1581. overBudgetStr = sdPriceName.Name + "尚无预算";
  1582. else if (entity.ExceedBudget == 0)
  1583. overBudgetStr = "未超预算";
  1584. else
  1585. overBudgetStr = entity.ExceedBudget.ToString("P");
  1586. _detail.OverBudget = overBudgetStr;
  1587. /*
  1588. * 费用总计
  1589. */
  1590. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1591. {
  1592. CurrencyId = entity.PaymentCurrency,
  1593. CurrencyName = PaymentCurrency_WaitPay,
  1594. AmountPayable = entity.PayMoney,
  1595. ThisPayment = CurrPayStr,
  1596. BalancePayment = BalanceStr,
  1597. AuditedFunds = CurrPayStr
  1598. });
  1599. _detail.IsAuditGM = entity.IsAuditGM;
  1600. detailList.Add(_detail);
  1601. }
  1602. #endregion
  1603. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1604. /*
  1605. * 下方描述处理
  1606. */
  1607. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1608. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1609. if (ccpCurrencyPrice != null)
  1610. {
  1611. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1612. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1613. }
  1614. else
  1615. {
  1616. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1617. }
  1618. string amountPayableStr = string.Format(@"应付款总金额: ");
  1619. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1620. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1621. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1622. foreach (var item in nonDuplicat)
  1623. {
  1624. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1625. if (strs.Count > 0)
  1626. {
  1627. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1628. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1629. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1630. //单独处理此次付款金额
  1631. if (item.CurrencyId == 836) //人民币
  1632. {
  1633. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1634. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1635. }
  1636. else
  1637. {
  1638. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1639. }
  1640. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1641. //单独处理已审核费用
  1642. if (item.CurrencyId == 836) //人民币
  1643. {
  1644. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1645. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1646. }
  1647. else
  1648. {
  1649. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1650. }
  1651. }
  1652. }
  1653. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1654. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1655. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1656. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1657. var _view1 = new
  1658. {
  1659. PageFuncAuth = pageFunAuthView,
  1660. Data = _view
  1661. };
  1662. return Ok(JsonView(_view1));
  1663. }
  1664. catch (Exception ex)
  1665. {
  1666. return Ok(JsonView(false, ex.Message));
  1667. }
  1668. }
  1669. /// <summary>
  1670. /// 费用审核
  1671. /// 修改团组费用审核状态
  1672. /// </summary>
  1673. /// <param name="_dto">参数Json字符串</param>
  1674. /// <returns></returns>
  1675. [HttpPost]
  1676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1677. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1678. {
  1679. #region 参数验证
  1680. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1681. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1682. #endregion
  1683. #region 页面操作权限验证
  1684. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1685. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1686. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1687. #endregion
  1688. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1689. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1690. DateTime dtNow = DateTime.Now;
  1691. _groupRepository.BeginTran();
  1692. int rst = 0;
  1693. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1694. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1695. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1696. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1697. List<dynamic> msgDatas = new List<dynamic>();
  1698. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1699. foreach (var item in idList)
  1700. {
  1701. int CreditId = int.Parse(item);
  1702. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1703. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1704. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1705. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1706. .Where(s => s.Id == CreditId)
  1707. .ExecuteCommandAsync();
  1708. if (result < 1)
  1709. {
  1710. rst = -1;
  1711. _groupRepository.RollbackTran();
  1712. return Ok(JsonView(false, "操作失败并回滚!"));
  1713. }
  1714. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1715. if (creditData != null)
  1716. {
  1717. #region 应用通知配置
  1718. try
  1719. {
  1720. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1721. }
  1722. catch (Exception ex)
  1723. {
  1724. }
  1725. #endregion
  1726. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1727. string groupNameStr = string.Empty;
  1728. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1729. if (groupData != null) groupNameStr = groupData.TeamName;
  1730. string creditTypeStr = string.Empty;
  1731. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1732. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1733. string creditCurrency = string.Empty;
  1734. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1735. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1736. if (creditCurrency.Equals("CNY"))
  1737. {
  1738. creditData.DayRate = 1.0000M;
  1739. }
  1740. if (creditData.PayPercentage == 0.00M)
  1741. {
  1742. creditData.PayPercentage = 100M;
  1743. }
  1744. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1745. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1746. string msgContent = "";
  1747. if (creditCurrency.Equals("CNY"))
  1748. {
  1749. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1750. }
  1751. else
  1752. {
  1753. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1754. }
  1755. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1756. }
  1757. }
  1758. if (rst == 0)
  1759. {
  1760. _groupRepository.CommitTran();
  1761. foreach (var item in msgDatas)
  1762. {
  1763. //发送消息
  1764. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1765. }
  1766. #region 应用推送
  1767. try
  1768. {
  1769. foreach (var ccpId in dic_ccp_user.Keys)
  1770. {
  1771. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1772. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1773. }
  1774. }
  1775. catch (Exception)
  1776. {
  1777. }
  1778. #endregion
  1779. return Ok(JsonView(true, "操作成功!"));
  1780. }
  1781. return Ok(JsonView(false, "操作失败!"));
  1782. }
  1783. #endregion
  1784. #region 机票费用录入
  1785. /// <summary>
  1786. /// 机票录入当前登录人可操作团组
  1787. /// </summary>
  1788. /// <param name="dto"></param>
  1789. /// <returns></returns>
  1790. [HttpPost]
  1791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1792. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1793. {
  1794. try
  1795. {
  1796. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1797. if (groupData.Code != 0)
  1798. {
  1799. return Ok(JsonView(false, groupData.Msg));
  1800. }
  1801. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1802. }
  1803. catch (Exception ex)
  1804. {
  1805. return Ok(JsonView(false, "程序错误!"));
  1806. throw;
  1807. }
  1808. }
  1809. /// <summary>
  1810. /// 机票费用录入列表
  1811. /// </summary>
  1812. /// <param name="dto"></param>
  1813. /// <returns></returns>
  1814. [HttpPost]
  1815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1816. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1817. {
  1818. try
  1819. {
  1820. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1821. if (groupData.Code != 0)
  1822. {
  1823. return Ok(JsonView(false, groupData.Msg));
  1824. }
  1825. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1826. }
  1827. catch (Exception ex)
  1828. {
  1829. return Ok(JsonView(false, ex.Message));
  1830. throw;
  1831. }
  1832. }
  1833. /// <summary>
  1834. /// 根据id查询费用录入信息
  1835. /// </summary>
  1836. /// <param name="dto"></param>
  1837. /// <returns></returns>
  1838. [HttpPost]
  1839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1840. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1841. {
  1842. try
  1843. {
  1844. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1845. if (groupData.Code != 0)
  1846. {
  1847. return Ok(JsonView(false, groupData.Msg));
  1848. }
  1849. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1850. }
  1851. catch (Exception ex)
  1852. {
  1853. return Ok(JsonView(false, "程序错误!"));
  1854. throw;
  1855. }
  1856. }
  1857. /// <summary>
  1858. /// 机票费用录入操作(Status:1.新增,2.修改)
  1859. /// </summary>
  1860. /// <param name="dto"></param>
  1861. /// <returns></returns>
  1862. [HttpPost]
  1863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1864. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1865. {
  1866. try
  1867. {
  1868. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1869. if (groupData.Code != 0)
  1870. {
  1871. return Ok(JsonView(false, groupData.Msg));
  1872. }
  1873. #region 应用推送
  1874. try
  1875. {
  1876. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1877. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1878. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1879. }
  1880. catch (Exception ex)
  1881. {
  1882. }
  1883. #endregion
  1884. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1885. }
  1886. catch (Exception ex)
  1887. {
  1888. return Ok(JsonView(false, "程序错误!"));
  1889. throw;
  1890. }
  1891. }
  1892. /// <summary>
  1893. /// 根据舱位类型查询接团客户名单信息
  1894. /// </summary>
  1895. /// <param name="dto"></param>
  1896. /// <returns></returns>
  1897. [HttpPost]
  1898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1899. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1900. {
  1901. try
  1902. {
  1903. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1904. if (crm_Groups.Count != 0)
  1905. {
  1906. List<dynamic> Customer = new List<dynamic>();
  1907. foreach (var item in crm_Groups)
  1908. {
  1909. var data = new
  1910. {
  1911. Id = item.Id,
  1912. Pinyin = item.Pinyin,
  1913. Name = item.LastName + item.FirstName
  1914. };
  1915. Customer.Add(data);
  1916. }
  1917. return Ok(JsonView(true, "查询成功!", Customer));
  1918. }
  1919. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1920. }
  1921. catch (Exception ex)
  1922. {
  1923. return Ok(JsonView(false, "程序错误!"));
  1924. throw;
  1925. }
  1926. }
  1927. /// <summary>
  1928. /// 根据团号获取客户信息
  1929. /// </summary>
  1930. /// <param name="dto"></param>
  1931. /// <returns></returns>
  1932. [HttpPost]
  1933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1934. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1935. {
  1936. var jw = JsonView(false);
  1937. if (dto.DIID < 1)
  1938. {
  1939. jw.Msg += "请输入正确的diid";
  1940. return Ok(jw);
  1941. }
  1942. var arr = getSimplClientList(dto.DIID);
  1943. jw = JsonView(true, "获取成功!", arr);
  1944. return Ok(jw);
  1945. }
  1946. private List<SimplClientInfo> getSimplClientList(int diId)
  1947. {
  1948. 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);
  1949. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1950. return arr;
  1951. }
  1952. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  1953. {
  1954. string result = origin;
  1955. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  1956. {
  1957. string[] temparr = origin.Split(',');
  1958. string fistrStr = temparr[0];
  1959. int count = temparr.Count();
  1960. int tempId;
  1961. bool success = int.TryParse(fistrStr, out tempId);
  1962. if (success)
  1963. {
  1964. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1965. if (tempInfo != null)
  1966. {
  1967. if (count > 1)
  1968. {
  1969. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1970. }
  1971. else
  1972. {
  1973. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1974. }
  1975. }
  1976. }
  1977. }
  1978. return result;
  1979. }
  1980. /// <summary>
  1981. /// 机票费用录入,删除
  1982. /// </summary>
  1983. /// <param name="dto"></param>
  1984. /// <returns></returns>
  1985. [HttpPost]
  1986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1987. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1988. {
  1989. try
  1990. {
  1991. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1992. if (res)
  1993. {
  1994. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1995. {
  1996. IsDel = 1,
  1997. DeleteUserId = dto.DeleteUserId,
  1998. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1999. }).ExecuteCommandAsync();
  2000. return Ok(JsonView(true, "删除成功!"));
  2001. }
  2002. return Ok(JsonView(false, "删除失败!"));
  2003. }
  2004. catch (Exception ex)
  2005. {
  2006. return Ok(JsonView(false, "程序错误!"));
  2007. throw;
  2008. }
  2009. }
  2010. /// <summary>
  2011. /// 导出机票录入报表
  2012. /// </summary>
  2013. /// <param name="dto"></param>
  2014. /// <returns></returns>
  2015. [HttpPost]
  2016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2017. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2018. {
  2019. try
  2020. {
  2021. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2022. if (groupData.Code != 0)
  2023. {
  2024. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2025. }
  2026. else
  2027. {
  2028. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2029. if (AirTicketReservations.Count != 0)
  2030. {
  2031. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2032. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2033. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2034. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2035. WorkbookDesigner designer = new WorkbookDesigner();
  2036. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2037. decimal countCost = 0;
  2038. foreach (var item in AirTicketReservations)
  2039. {
  2040. #region 处理客人姓名
  2041. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2042. item.ClientName = clientNames;
  2043. #endregion
  2044. if (item.BankType == "其他")
  2045. {
  2046. item.BankNo = "--";
  2047. }
  2048. else
  2049. {
  2050. if (!string.IsNullOrEmpty(item.BankType))
  2051. {
  2052. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2053. }
  2054. }
  2055. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2056. item.Price = System.Decimal.Round(item.Price, 2);
  2057. countCost += Convert.ToDecimal(item.Price);
  2058. }
  2059. designer.SetDataSource("Export", AirTicketReservations);
  2060. designer.SetDataSource("ExportDiCode", diCode);
  2061. designer.SetDataSource("ExportDiName", diName);
  2062. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2063. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2064. designer.Process();
  2065. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2066. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2067. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2068. return Ok(JsonView(true, "成功", url = rst));
  2069. }
  2070. else
  2071. {
  2072. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2073. }
  2074. }
  2075. }
  2076. catch (Exception ex)
  2077. {
  2078. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2079. throw;
  2080. }
  2081. }
  2082. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2083. /// <summary>
  2084. /// 行程单导出
  2085. /// </summary>
  2086. /// <param name="dto"></param>
  2087. /// <returns></returns>
  2088. [HttpPost]
  2089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2090. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2091. {
  2092. try
  2093. {
  2094. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2095. if (groupData.Code != 0)
  2096. {
  2097. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2098. }
  2099. else
  2100. {
  2101. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2102. if (dto.Language == "CN")
  2103. {
  2104. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2105. DocumentBuilder builder = new DocumentBuilder(doc);
  2106. int tableIndex = 0;//表格索引
  2107. //得到文档中的第一个表格
  2108. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2109. foreach (var item in _AirTicketReservations)
  2110. {
  2111. #region 处理固定数据
  2112. string[] FlightsCode = item.FlightsCode.Split('/');
  2113. if (FlightsCode.Length != 0)
  2114. {
  2115. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2116. if (_AirCompany != null)
  2117. {
  2118. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2119. }
  2120. else
  2121. {
  2122. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2123. }
  2124. }
  2125. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2126. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2127. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2128. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2129. string name = "";
  2130. foreach (string clientName in nameArray)
  2131. {
  2132. if (!name.Contains(clientName))
  2133. {
  2134. name += clientName + ",";
  2135. }
  2136. }
  2137. if (!string.IsNullOrWhiteSpace(name))
  2138. {
  2139. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2140. }
  2141. else
  2142. {
  2143. table.Range.Bookmarks["ClientName"].Text = "--";
  2144. }
  2145. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2146. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2147. table.Range.Bookmarks["JointTicket"].Text = "--";
  2148. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2149. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2150. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2151. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2152. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2153. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2154. #endregion
  2155. #region 循环数据处理
  2156. List<AirInfo> airs = new List<AirInfo>();
  2157. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2158. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2159. for (int i = 0; i < FlightsCode.Length; i++)
  2160. {
  2161. AirInfo air = new AirInfo();
  2162. string[] tempstr = DayArray[i]
  2163. .Replace("\r\n", string.Empty)
  2164. .Replace("\\r\\n", string.Empty)
  2165. .TrimStart().TrimEnd()
  2166. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2167. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2168. string starCity = "";
  2169. if (star_Three != null)
  2170. {
  2171. starCity = star_Three.AirPort;
  2172. }
  2173. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2174. string EndCity = "";
  2175. if (End_Three != null)
  2176. {
  2177. EndCity = End_Three.AirPort;
  2178. }
  2179. air.Destination = starCity + "/" + EndCity;
  2180. air.Flight = FlightsCode[i];
  2181. air.SeatingClass = item.CTypeName;
  2182. string dateTime = tempstr[2];
  2183. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2184. air.FlightDate = DateTemp;
  2185. air.DepartureTime = tempstr[5];
  2186. air.LandingTime = tempstr[6];
  2187. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2188. air.TicketStatus = "--";
  2189. air.Luggage = "--";
  2190. air.DepartureTerminal = "--";
  2191. air.LandingTerminal = "--";
  2192. airs.Add(air);
  2193. }
  2194. int row = 13;
  2195. for (int i = 0; i < airs.Count; i++)
  2196. {
  2197. if (airs.Count > 2)
  2198. {
  2199. for (int j = 0; j < airs.Count - 2; j++)
  2200. {
  2201. var CopyRow = table.Rows[12].Clone(true);
  2202. table.Rows.Add(CopyRow);
  2203. }
  2204. }
  2205. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2206. int index = 0;
  2207. foreach (PropertyInfo property in properties)
  2208. {
  2209. string value = property.GetValue(airs[i]).ToString();
  2210. Cell ishcel0 = table.Rows[row].Cells[index];
  2211. Paragraph p = new Paragraph(doc);
  2212. string s = value;
  2213. p.AppendChild(new Run(doc, s));
  2214. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2215. ishcel0.AppendChild(p);
  2216. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2217. index++;
  2218. }
  2219. row++;
  2220. }
  2221. #endregion
  2222. Paragraph lastParagraph = new Paragraph(doc);
  2223. //第一个表格末尾加段落
  2224. table.ParentNode.InsertAfter(lastParagraph, table);
  2225. //复制第一个表格
  2226. Table cloneTable = (Table)table.Clone(true);
  2227. //在文档末尾段落后面加入复制的表格
  2228. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2229. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2230. {
  2231. int rownewsIndex = 13;
  2232. for (int i = 0; i < 2; i++)
  2233. {
  2234. var CopyRow = table.Rows[12].Clone(true);
  2235. table.Rows.RemoveAt(13);
  2236. table.Rows.Add(CopyRow);
  2237. rownewsIndex++;
  2238. }
  2239. }
  2240. else
  2241. {
  2242. table.Rows.RemoveAt(12);
  2243. }
  2244. cloneTable.Rows.RemoveAt(12);
  2245. }
  2246. if (_AirTicketReservations.Count != 0)
  2247. {
  2248. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2249. if (FlightsCode.Length != 0)
  2250. {
  2251. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2252. if (_AirCompany != null)
  2253. {
  2254. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2255. }
  2256. else
  2257. {
  2258. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2259. }
  2260. }
  2261. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2262. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2263. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2264. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2265. string name = "";
  2266. foreach (string clientName in nameArray)
  2267. {
  2268. if (!name.Contains(clientName))
  2269. {
  2270. name += clientName + ",";
  2271. }
  2272. }
  2273. if (!string.IsNullOrWhiteSpace(name))
  2274. {
  2275. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2276. }
  2277. else
  2278. {
  2279. table.Range.Bookmarks["ClientName"].Text = "--";
  2280. }
  2281. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2282. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2283. table.Range.Bookmarks["JointTicket"].Text = "--";
  2284. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2285. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2286. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2287. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2288. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2289. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2290. }
  2291. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2292. //保存合并后的文档
  2293. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2294. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2295. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2296. return Ok(JsonView(true, "成功!", rst));
  2297. }
  2298. else
  2299. {
  2300. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2301. DocumentBuilder builder = new DocumentBuilder(doc);
  2302. int tableIndex = 0;//表格索引
  2303. //得到文档中的第一个表格
  2304. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2305. List<string> texts = new List<string>();
  2306. foreach (var item in _AirTicketReservations)
  2307. {
  2308. string[] FlightsCode = item.FlightsCode.Split('/');
  2309. if (FlightsCode.Length != 0)
  2310. {
  2311. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2312. if (_AirCompany != null)
  2313. {
  2314. if (!transDic.ContainsKey(_AirCompany.CnName))
  2315. {
  2316. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2317. }
  2318. }
  2319. else
  2320. {
  2321. if (!transDic.ContainsKey("--"))
  2322. {
  2323. transDic.Add("--", "--");
  2324. }
  2325. }
  2326. }
  2327. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2328. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2329. string name = "";
  2330. foreach (string clientName in nameArray)
  2331. {
  2332. name += clientName + ",";
  2333. }
  2334. if (!texts.Contains(name))
  2335. {
  2336. texts.Add(name);
  2337. }
  2338. List<AirInfo> airs = new List<AirInfo>();
  2339. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2340. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2341. for (int i = 0; i < FlightsCode.Length; i++)
  2342. {
  2343. AirInfo air = new AirInfo();
  2344. string[] tempstr = DayArray[i]
  2345. .Replace("\r\n", string.Empty)
  2346. .Replace("\\r\\n", string.Empty)
  2347. .TrimStart().TrimEnd()
  2348. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2349. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2350. if (star_Three != null)
  2351. {
  2352. if (!transDic.ContainsKey(star_Three.AirPort))
  2353. {
  2354. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2355. }
  2356. }
  2357. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2358. if (End_Three != null)
  2359. {
  2360. if (!transDic.ContainsKey(End_Three.AirPort))
  2361. {
  2362. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2363. }
  2364. }
  2365. if (!texts.Contains(item.CTypeName))
  2366. {
  2367. texts.Add(item.CTypeName);
  2368. }
  2369. }
  2370. }
  2371. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2372. if (transData.Count > 0)
  2373. {
  2374. foreach (TranslateResult item in transData)
  2375. {
  2376. if (!transDic.ContainsKey(item.Query))
  2377. {
  2378. transDic.Add(item.Query, item.Translation);
  2379. }
  2380. }
  2381. }
  2382. foreach (var item in _AirTicketReservations)
  2383. {
  2384. #region 处理固定数据
  2385. string[] FlightsCode = item.FlightsCode.Split('/');
  2386. if (FlightsCode.Length != 0)
  2387. {
  2388. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2389. if (_AirCompany != null)
  2390. {
  2391. string str = "--";
  2392. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2393. if (!string.IsNullOrEmpty(translateResult))
  2394. {
  2395. str = translateResult;
  2396. str = _airTicketResRep.Processing(str);
  2397. }
  2398. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2399. }
  2400. else
  2401. {
  2402. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2403. }
  2404. }
  2405. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2406. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2407. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2408. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2409. string names = "";
  2410. foreach (string clientName in nameArray)
  2411. {
  2412. names += clientName + ",";
  2413. }
  2414. if (!string.IsNullOrWhiteSpace(names))
  2415. {
  2416. string str = "--";
  2417. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2418. if (!string.IsNullOrEmpty(translateResult))
  2419. {
  2420. str = translateResult;
  2421. str = _airTicketResRep.Processing(str);
  2422. }
  2423. table.Range.Bookmarks["ClientName"].Text = str;
  2424. }
  2425. else
  2426. {
  2427. table.Range.Bookmarks["ClientName"].Text = "--";
  2428. }
  2429. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2430. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2431. table.Range.Bookmarks["JointTicket"].Text = "--";
  2432. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2433. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2434. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2435. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2436. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2437. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2438. #endregion
  2439. #region 循环数据处理
  2440. List<AirInfo> airs = new List<AirInfo>();
  2441. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2442. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2443. for (int i = 0; i < FlightsCode.Length; i++)
  2444. {
  2445. AirInfo air = new AirInfo();
  2446. string[] tempstr = DayArray[i]
  2447. .Replace("\r\n", string.Empty)
  2448. .Replace("\\r\\n", string.Empty)
  2449. .TrimStart().TrimEnd()
  2450. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2451. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2452. string starCity = "";
  2453. if (star_Three != null)
  2454. {
  2455. string str2 = "--";
  2456. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2457. if (!string.IsNullOrEmpty(translateResult2))
  2458. {
  2459. str2 = translateResult2;
  2460. str2 = _airTicketResRep.Processing(str2);
  2461. }
  2462. starCity = str2;
  2463. }
  2464. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2465. string EndCity = "";
  2466. if (End_Three != null)
  2467. {
  2468. string str1 = "--";
  2469. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2470. if (!string.IsNullOrEmpty(translateResult1))
  2471. {
  2472. str1 = translateResult1;
  2473. str1 = _airTicketResRep.Processing(str1);
  2474. }
  2475. EndCity = str1;
  2476. }
  2477. air.Destination = starCity + "/" + EndCity;
  2478. air.Flight = FlightsCode[i];
  2479. string str = "--";
  2480. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2481. if (!string.IsNullOrEmpty(translateResult))
  2482. {
  2483. str = translateResult;
  2484. str = _airTicketResRep.Processing(str);
  2485. }
  2486. air.SeatingClass = str;
  2487. string dateTime = tempstr[2];
  2488. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2489. air.FlightDate = DateTemp;
  2490. air.DepartureTime = tempstr[5];
  2491. air.LandingTime = tempstr[6];
  2492. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2493. air.TicketStatus = "--";
  2494. air.Luggage = "--";
  2495. air.DepartureTerminal = "--";
  2496. air.LandingTerminal = "--";
  2497. airs.Add(air);
  2498. }
  2499. int row = 13;
  2500. for (int i = 0; i < airs.Count; i++)
  2501. {
  2502. if (airs.Count > 2)
  2503. {
  2504. for (int j = 0; j < airs.Count - 2; j++)
  2505. {
  2506. var CopyRow = table.Rows[12].Clone(true);
  2507. table.Rows.Add(CopyRow);
  2508. }
  2509. }
  2510. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2511. int index = 0;
  2512. foreach (PropertyInfo property in properties)
  2513. {
  2514. string value = property.GetValue(airs[i]).ToString();
  2515. Cell ishcel0 = table.Rows[row].Cells[index];
  2516. Paragraph p = new Paragraph(doc);
  2517. string s = value;
  2518. p.AppendChild(new Run(doc, s));
  2519. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2520. ishcel0.AppendChild(p);
  2521. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2522. //ishcel0.CellFormat.VerticalAlignment=
  2523. index++;
  2524. }
  2525. row++;
  2526. }
  2527. #endregion
  2528. Paragraph lastParagraph = new Paragraph(doc);
  2529. //第一个表格末尾加段落
  2530. table.ParentNode.InsertAfter(lastParagraph, table);
  2531. //复制第一个表格
  2532. Table cloneTable = (Table)table.Clone(true);
  2533. //在文档末尾段落后面加入复制的表格
  2534. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2535. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2536. {
  2537. int rownewsIndex = 13;
  2538. for (int i = 0; i < 2; i++)
  2539. {
  2540. var CopyRow = table.Rows[12].Clone(true);
  2541. table.Rows.RemoveAt(13);
  2542. table.Rows.Add(CopyRow);
  2543. rownewsIndex++;
  2544. }
  2545. }
  2546. else
  2547. {
  2548. table.Rows.RemoveAt(12);
  2549. }
  2550. cloneTable.Rows.RemoveAt(12);
  2551. }
  2552. if (_AirTicketReservations.Count != 0)
  2553. {
  2554. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2555. if (FlightsCode.Length != 0)
  2556. {
  2557. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2558. if (_AirCompany != null)
  2559. {
  2560. string str = "--";
  2561. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2562. if (!string.IsNullOrEmpty(translateResult))
  2563. {
  2564. str = translateResult;
  2565. str = _airTicketResRep.Processing(str);
  2566. }
  2567. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2568. }
  2569. else
  2570. {
  2571. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2572. }
  2573. }
  2574. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2575. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2576. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2577. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2578. string names = "";
  2579. foreach (string clientName in nameArray)
  2580. {
  2581. names += clientName + ",";
  2582. }
  2583. if (!string.IsNullOrWhiteSpace(names))
  2584. {
  2585. string str = "--";
  2586. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2587. if (!string.IsNullOrEmpty(translateResult))
  2588. {
  2589. str = translateResult;
  2590. str = _airTicketResRep.Processing(str);
  2591. }
  2592. table.Range.Bookmarks["ClientName"].Text = str;
  2593. }
  2594. else
  2595. {
  2596. table.Range.Bookmarks["ClientName"].Text = "--";
  2597. }
  2598. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2599. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2600. table.Range.Bookmarks["JointTicket"].Text = "--";
  2601. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2602. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2603. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2604. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2605. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2606. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2607. }
  2608. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2609. //保存合并后的文档
  2610. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2611. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2612. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2613. return Ok(JsonView(true, "成功!", rst));
  2614. }
  2615. }
  2616. }
  2617. catch (Exception ex)
  2618. {
  2619. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2620. throw;
  2621. }
  2622. }
  2623. #endregion
  2624. #region 团组增减款项 --> 其他款项
  2625. /// <summary>
  2626. /// 团组增减款项下拉框绑定
  2627. /// </summary>
  2628. /// <param name="dto"></param>
  2629. /// <returns></returns>
  2630. [HttpPost]
  2631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2632. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2633. {
  2634. #region 参数验证
  2635. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2636. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2637. #endregion
  2638. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2639. }
  2640. /// <summary>
  2641. /// 根据团组Id查询团组增减款项
  2642. /// </summary>
  2643. /// <param name="dto"></param>
  2644. /// <returns></returns>
  2645. [HttpPost]
  2646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2647. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2648. {
  2649. #region 参数验证
  2650. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2651. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2652. #endregion
  2653. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2654. }
  2655. /// <summary>
  2656. /// 团组增减款项操作(Status:1.新增,2.修改)
  2657. /// </summary>
  2658. /// <param name="dto"></param>
  2659. /// <returns></returns>
  2660. [HttpPost]
  2661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2662. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2663. {
  2664. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2665. if (groupData.Code != 200)
  2666. {
  2667. return Ok(JsonView(false, groupData.Msg));
  2668. }
  2669. #region 应用推送
  2670. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2671. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2672. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2673. #endregion
  2674. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2675. }
  2676. /// <summary>
  2677. /// 团组增减款项操作 删除
  2678. /// </summary>
  2679. /// <param name="dto"></param>
  2680. /// <returns></returns>
  2681. [HttpPost]
  2682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2683. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2684. {
  2685. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2686. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2687. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2688. if (res.Code == 0)
  2689. {
  2690. return Ok(JsonView(true, "删除成功!"));
  2691. }
  2692. return Ok(JsonView(false, "删除失败!"));
  2693. }
  2694. /// <summary>
  2695. /// 根据团组增减款项Id查询
  2696. /// </summary>
  2697. /// <param name="dto"></param>
  2698. /// <returns></returns>
  2699. [HttpPost]
  2700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2701. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2702. {
  2703. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2704. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2705. }
  2706. /// <summary>
  2707. /// 查询供应商名称
  2708. /// </summary>
  2709. /// <param name="dto"></param>
  2710. /// <returns></returns>
  2711. [HttpPost]
  2712. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2713. {
  2714. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2715. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2716. ?? new List<Grp_DecreasePayments>();
  2717. dbResult = dbResult.Distinct(new
  2718. ProductComparer()).ToList();
  2719. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2720. {
  2721. x.Id,
  2722. x.SupplierAddress,
  2723. x.SupplierArea,
  2724. x.SupplierContact,
  2725. x.SupplierContactNumber,
  2726. x.SupplierEmail,
  2727. x.SupplierName,
  2728. x.SupplierSocialAccount,
  2729. x.SupplierTypeId,
  2730. }).ToList());
  2731. return Ok(jw);
  2732. }
  2733. #endregion
  2734. #region 文件上传、删除
  2735. /// <summary>
  2736. /// region 文件上传 可以带参数
  2737. /// </summary>
  2738. /// <param name="file"></param>
  2739. /// <returns></returns>
  2740. [HttpPost]
  2741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2742. public async Task<IActionResult> UploadProject(IFormFile file)
  2743. {
  2744. try
  2745. {
  2746. var TypeName = Request.Headers["TypeName"].ToString();
  2747. if (file != null)
  2748. {
  2749. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2750. //文件名称
  2751. string projectFileName = file.FileName;
  2752. //上传的文件的路径
  2753. string filePath = "";
  2754. if (TypeName == "A")//A代表团组增减款项
  2755. {
  2756. if (!Directory.Exists(fileDir))
  2757. {
  2758. Directory.CreateDirectory(fileDir);
  2759. }
  2760. //上传的文件的路径
  2761. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2762. }
  2763. else if (TypeName == "B")//B代表商邀相关文件
  2764. {
  2765. if (!Directory.Exists(fileDir))
  2766. {
  2767. Directory.CreateDirectory(fileDir);
  2768. }
  2769. //上传的文件的路径
  2770. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2771. }
  2772. using (FileStream fs = System.IO.File.Create(filePath))
  2773. {
  2774. file.CopyTo(fs);
  2775. fs.Flush();
  2776. }
  2777. return Ok(JsonView(true, "上传成功!", projectFileName));
  2778. }
  2779. else
  2780. {
  2781. return Ok(JsonView(false, "上传失败!"));
  2782. }
  2783. }
  2784. catch (Exception ex)
  2785. {
  2786. return Ok(JsonView(false, "程序错误!"));
  2787. throw;
  2788. }
  2789. }
  2790. /// <summary>
  2791. /// 删除指定文件
  2792. /// </summary>
  2793. /// <param name="dto"></param>
  2794. /// <returns></returns>
  2795. [HttpPost]
  2796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2797. public async Task<IActionResult> DelFile(DelFileDto dto)
  2798. {
  2799. try
  2800. {
  2801. var TypeName = Request.Headers["TypeName"].ToString();
  2802. string filePath = "";
  2803. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2804. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2805. int id = 0;
  2806. if (TypeName == "A")
  2807. {
  2808. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2809. // 删除该文件
  2810. System.IO.File.Delete(filePath);
  2811. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2812. }
  2813. else if (TypeName == "B")
  2814. {
  2815. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2816. // 删除该文件
  2817. System.IO.File.Delete(filePath);
  2818. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2819. }
  2820. if (id != 0)
  2821. {
  2822. return Ok(JsonView(true, "成功!"));
  2823. }
  2824. else
  2825. {
  2826. return Ok(JsonView(false, "失败!"));
  2827. }
  2828. }
  2829. catch (Exception ex)
  2830. {
  2831. return Ok(JsonView(false, "程序错误!"));
  2832. throw;
  2833. }
  2834. }
  2835. #endregion
  2836. #region 商邀费用录入
  2837. /// <summary>
  2838. /// 根据团组Id查询商邀费用列表
  2839. /// </summary>
  2840. /// <param name="dto"></param>
  2841. /// <returns></returns>
  2842. [HttpPost]
  2843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2844. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2845. {
  2846. try
  2847. {
  2848. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2849. if (groupData.Code != 0)
  2850. {
  2851. return Ok(JsonView(false, groupData.Msg));
  2852. }
  2853. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2854. }
  2855. catch (Exception ex)
  2856. {
  2857. return Ok(JsonView(false, "程序错误!"));
  2858. throw;
  2859. }
  2860. }
  2861. //
  2862. /// <summary>
  2863. /// 商邀费用 Info Page 基础数据源
  2864. /// </summary>
  2865. /// <param name="dto"></param>
  2866. /// <returns></returns>
  2867. [HttpPost]
  2868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2869. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2870. {
  2871. try
  2872. {
  2873. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2874. if (groupData.Code != 0)
  2875. {
  2876. return Ok(JsonView(false, groupData.Msg));
  2877. }
  2878. return Ok(JsonView(true, "操作成功", groupData.Data));
  2879. }
  2880. catch (Exception ex)
  2881. {
  2882. return Ok(JsonView(false, ex.Message));
  2883. throw;
  2884. }
  2885. }
  2886. /// <summary>
  2887. /// 根据商邀费用ID查询C表和商邀费用数据
  2888. /// </summary>
  2889. /// <param name="dto"></param>
  2890. /// <returns></returns>
  2891. [HttpPost]
  2892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2893. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2894. {
  2895. try
  2896. {
  2897. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2898. if (groupData.Code != 0)
  2899. {
  2900. return Ok(JsonView(false, groupData.Msg));
  2901. }
  2902. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2903. }
  2904. catch (Exception ex)
  2905. {
  2906. return Ok(JsonView(false, ex.Message));
  2907. throw;
  2908. }
  2909. }
  2910. /// <summary>
  2911. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2912. /// </summary>
  2913. /// <param name="dto"></param>
  2914. /// <returns></returns>
  2915. [HttpPost]
  2916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2917. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2918. {
  2919. try
  2920. {
  2921. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  2922. if (groupData.Code != 0)
  2923. {
  2924. return Ok(JsonView(false, groupData.Msg));
  2925. }
  2926. #region 应用推送
  2927. try
  2928. {
  2929. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2930. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2931. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2932. }
  2933. catch (Exception ex)
  2934. {
  2935. }
  2936. #endregion
  2937. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2938. }
  2939. catch (Exception ex)
  2940. {
  2941. return Ok(JsonView(false, "程序错误!"));
  2942. throw;
  2943. }
  2944. }
  2945. /// <summary>
  2946. /// 商邀删除
  2947. /// </summary>
  2948. /// <param name="dto"></param>
  2949. /// <returns></returns>
  2950. [HttpPost]
  2951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2952. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2953. {
  2954. try
  2955. {
  2956. _sqlSugar.BeginTran();
  2957. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2958. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2959. {
  2960. IsDel = 1,
  2961. DeleteUserId = dto.DeleteUserId,
  2962. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2963. })
  2964. .Where(it => it.Id == dto.Id)
  2965. .ExecuteCommand();
  2966. if (res1 > 0)
  2967. {
  2968. int _diId = 0;
  2969. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2970. if (_ioaInfo != null)
  2971. {
  2972. _diId = _ioaInfo.DiId;
  2973. }
  2974. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2975. .SetColumns(a => new Grp_CreditCardPayment()
  2976. {
  2977. IsDel = 1,
  2978. DeleteUserId = dto.DeleteUserId,
  2979. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2980. })
  2981. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  2982. .ExecuteCommand();
  2983. if (res2 > 0)
  2984. {
  2985. _sqlSugar.CommitTran();
  2986. return Ok(JsonView(true, "删除成功!"));
  2987. }
  2988. }
  2989. _sqlSugar.RollbackTran();
  2990. return Ok(JsonView(false, "删除失败"));
  2991. }
  2992. catch (Exception ex)
  2993. {
  2994. _sqlSugar.RollbackTran();
  2995. return Ok(JsonView(false, ex.Message));
  2996. }
  2997. }
  2998. #endregion
  2999. #region 团组英文资料
  3000. /// <summary>
  3001. /// 查询团组英文所有资料
  3002. /// </summary>
  3003. /// <param name="dto"></param>
  3004. /// <returns></returns>
  3005. [HttpPost]
  3006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3007. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3008. {
  3009. try
  3010. {
  3011. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3012. if (groupData.Code != 0)
  3013. {
  3014. return Ok(JsonView(false, groupData.Msg));
  3015. }
  3016. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3017. }
  3018. catch (Exception ex)
  3019. {
  3020. return Ok(JsonView(false, "程序错误!"));
  3021. throw;
  3022. }
  3023. }
  3024. /// <summary>
  3025. /// 团组英文资料操作(Status:1.新增,2.修改)
  3026. /// </summary>
  3027. /// <param name="dto"></param>
  3028. /// <returns></returns>
  3029. [HttpPost]
  3030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3031. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3032. {
  3033. try
  3034. {
  3035. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3036. if (groupData.Code != 0)
  3037. {
  3038. return Ok(JsonView(false, groupData.Msg));
  3039. }
  3040. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3041. }
  3042. catch (Exception ex)
  3043. {
  3044. return Ok(JsonView(false, "程序错误!"));
  3045. throw;
  3046. }
  3047. }
  3048. /// <summary>
  3049. /// 团组英文资料Id查询数据
  3050. /// </summary>
  3051. /// <param name="dto"></param>
  3052. /// <returns></returns>
  3053. [HttpPost]
  3054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3055. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3056. {
  3057. try
  3058. {
  3059. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3060. if (_DelegationEnData != null)
  3061. {
  3062. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3063. }
  3064. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3065. }
  3066. catch (Exception ex)
  3067. {
  3068. return Ok(JsonView(false, "程序错误!"));
  3069. throw;
  3070. }
  3071. }
  3072. /// <summary>
  3073. /// 团组英文资料删除
  3074. /// </summary>
  3075. /// <param name="dto"></param>
  3076. /// <returns></returns>
  3077. [HttpPost]
  3078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3079. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3080. {
  3081. try
  3082. {
  3083. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3084. if (!res)
  3085. {
  3086. return Ok(JsonView(false, "删除失败"));
  3087. }
  3088. return Ok(JsonView(true, "删除成功!"));
  3089. }
  3090. catch (Exception ex)
  3091. {
  3092. return Ok(JsonView(false, "程序错误!"));
  3093. throw;
  3094. }
  3095. }
  3096. #endregion
  3097. #region 导出邀请函
  3098. /// <summary>
  3099. /// 导出邀请函页面初始化
  3100. /// </summary>
  3101. /// <param name="dto"></param>
  3102. /// <returns></returns>
  3103. [HttpPost]
  3104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3105. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3106. {
  3107. try
  3108. {
  3109. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3110. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3111. if (dto.DiId == 0)
  3112. {
  3113. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3114. }
  3115. else
  3116. {
  3117. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3118. }
  3119. return Ok(JsonView(true, "查询成功!", new
  3120. {
  3121. deleClient = crm_Deles,
  3122. delegations = grp_Delegations
  3123. }));
  3124. }
  3125. catch (Exception ex)
  3126. {
  3127. return Ok(JsonView(false, "程序错误!"));
  3128. throw;
  3129. }
  3130. }
  3131. /// <summary>
  3132. /// 导出邀请函
  3133. /// </summary>
  3134. /// <param name="dto"></param>
  3135. /// <returns></returns>
  3136. [HttpPost]
  3137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3138. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3139. {
  3140. #region 参数验证
  3141. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3142. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3143. #endregion
  3144. try
  3145. {
  3146. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3147. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3148. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3149. From Grp_TourClientList tcl
  3150. Left Join
  3151. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3152. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3153. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3154. From Crm_DeleClient dc
  3155. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3156. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3157. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3158. Where dc.IsDel = 0) temp
  3159. On temp.DcId =tcl.ClientId
  3160. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3161. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3162. List<string> texts = new List<string>();
  3163. if (datas.Count != 0)
  3164. {
  3165. foreach (TourClientListDetailsView item in datas)
  3166. {
  3167. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3168. {
  3169. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3170. }
  3171. else
  3172. {
  3173. string name = item.LastName + item.FirstName;
  3174. texts.Add(name);
  3175. }
  3176. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3177. {
  3178. if (!transDic.ContainsKey(item.Job))
  3179. {
  3180. texts.Add(item.Job);
  3181. }
  3182. }
  3183. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3184. {
  3185. texts.Add(item.CompanyFullName);
  3186. }
  3187. }
  3188. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3189. if (transData.Count > 0)
  3190. {
  3191. foreach (TranslateResult item in transData)
  3192. {
  3193. if (!transDic.ContainsKey(item.Query))
  3194. {
  3195. transDic.Add(item.Query, item.Translation);
  3196. }
  3197. }
  3198. }
  3199. List<GuestList> list = new List<GuestList>();
  3200. foreach (TourClientListDetailsView dele in datas)
  3201. {
  3202. GuestList guestList = new GuestList();
  3203. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3204. {
  3205. guestList.Name = dele.Pinyin;
  3206. }
  3207. else
  3208. {
  3209. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3210. guestList.Name = Name;
  3211. }
  3212. if (dele.Sex == 0)
  3213. {
  3214. guestList.Sex = "Male";
  3215. }
  3216. else if (dele.Sex == 1)
  3217. {
  3218. guestList.Sex = "Female";
  3219. }
  3220. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3221. if (!string.IsNullOrEmpty(dele.Job))
  3222. {
  3223. guestList.Job = dele.Job;
  3224. }
  3225. list.Add(guestList);
  3226. }
  3227. //载入模板
  3228. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3229. DocumentBuilder builder = new DocumentBuilder(doc);
  3230. //获取word里所有表格
  3231. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3232. //获取所填表格的序数
  3233. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3234. var rowStart = tableOne.Rows[0]; //获取第1行
  3235. //循环赋值
  3236. for (int i = 0; i < list.Count; i++)
  3237. {
  3238. builder.MoveToCell(0, i + 1, 0, 0);
  3239. builder.Write(list[i].Name.ToString());
  3240. builder.MoveToCell(0, i + 1, 1, 0);
  3241. builder.Write(list[i].Sex.ToString());
  3242. builder.MoveToCell(0, i + 1, 2, 0);
  3243. builder.Write(list[i].DOB.ToString());
  3244. builder.MoveToCell(0, i + 1, 3, 0);
  3245. builder.Write(list[i].Job.ToString());
  3246. }
  3247. //删除多余行
  3248. while (tableOne.Rows.Count > list.Count + 1)
  3249. {
  3250. tableOne.Rows.RemoveAt(list.Count + 1);
  3251. }
  3252. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3253. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3254. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3255. doc.Save(filePath);
  3256. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3257. return Ok(JsonView(true, "操作成功!", Url));
  3258. }
  3259. else
  3260. {
  3261. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3262. }
  3263. }
  3264. catch (Exception ex)
  3265. {
  3266. return Ok(JsonView(false, ex.Message));
  3267. throw;
  3268. }
  3269. }
  3270. #endregion
  3271. #region 团组经理模块 出入境费用
  3272. ///// <summary>
  3273. ///// 团组模块 - 出入境费用
  3274. ///// </summary>
  3275. ///// <returns></returns>
  3276. //[HttpPost]
  3277. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3278. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3279. //{
  3280. // try
  3281. // {
  3282. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3283. // if (data.Code != 0)
  3284. // {
  3285. // return Ok(JsonView(false, data.Msg));
  3286. // }
  3287. // return Ok(JsonView(true, "查询成功!"));
  3288. // }
  3289. // catch (Exception ex)
  3290. // {
  3291. // return Ok(JsonView(false, ex.Message));
  3292. // throw;
  3293. // }
  3294. //}
  3295. /// <summary>
  3296. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3297. /// </summary>
  3298. /// <returns></returns>
  3299. [HttpPost]
  3300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3301. public async Task<IActionResult> SetDayAndCostAreaChange()
  3302. {
  3303. try
  3304. {
  3305. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3306. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3307. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3308. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3309. foreach (var item in unite) //处理交集数据
  3310. {
  3311. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3312. }
  3313. foreach (var item in merge) //处理差集数据
  3314. {
  3315. int nationalTravelFeeId = 0;
  3316. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3317. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3318. else
  3319. {
  3320. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3321. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3322. }
  3323. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3324. }
  3325. //只更新dayAndCost 的 nationalTravelFeeId;
  3326. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3327. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3328. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3329. }
  3330. catch (Exception ex)
  3331. {
  3332. return Ok(JsonView(false, ex.Message));
  3333. throw;
  3334. }
  3335. }
  3336. /// <summary>
  3337. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3338. /// </summary>
  3339. /// <returns></returns>
  3340. [HttpPost]
  3341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3342. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3343. {
  3344. try
  3345. {
  3346. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3347. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3348. //SetDataInfoView
  3349. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3350. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3351. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3352. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3353. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3354. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3355. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3356. //默认币种显示
  3357. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3358. {
  3359. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3360. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3361. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3362. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3363. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3364. };
  3365. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3366. if (_currencyRate.Count > 0)
  3367. {
  3368. foreach (var item in _currencyInfos)
  3369. {
  3370. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3371. if (rateInfo != null)
  3372. {
  3373. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3374. rate1 *= 1.03M;
  3375. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3376. }
  3377. }
  3378. }
  3379. return Ok(JsonView(true, "查询成功!", new
  3380. {
  3381. GroupNameData = groupNameData.Data,
  3382. CurrencyData = _CurrencyData,
  3383. WordTypeData = _WordTypeData,
  3384. ExcelTypeData = _ExcelTypeData,
  3385. CurrencyInit = _currencyInfos
  3386. }));
  3387. }
  3388. catch (Exception ex)
  3389. {
  3390. return Ok(JsonView(false, ex.Message));
  3391. throw;
  3392. }
  3393. }
  3394. /// <summary>
  3395. /// 团组模块 - 出入境费用
  3396. /// 实时汇率 tips
  3397. /// 签证费用 tips
  3398. /// </summary>
  3399. /// <returns></returns>
  3400. [HttpPost]
  3401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3402. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3403. {
  3404. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3405. //默认币种显示
  3406. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3407. {
  3408. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3409. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3410. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3411. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3412. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3413. };
  3414. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3415. List<dynamic> reteInfos = new List<dynamic>();
  3416. if (_currencyRate.Count > 0)
  3417. {
  3418. foreach (var item in _currencyInfos)
  3419. {
  3420. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3421. if (rateInfo != null)
  3422. {
  3423. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3424. decimal rate1 = item.Rate;
  3425. rate1 *= 1.03M;
  3426. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3427. reteInfos.Add(new
  3428. {
  3429. currCode = item.CurrencyCode,
  3430. currName = item.CurrencyName,
  3431. rate = rate2,
  3432. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3433. });
  3434. }
  3435. }
  3436. }
  3437. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3438. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3439. return Ok(JsonView(true, "查询成功!", new
  3440. {
  3441. //GroupNameData = groupNameData.Data,
  3442. visaData = visaData.Data,
  3443. airData = airData.Data,
  3444. reteInfos = reteInfos
  3445. }));
  3446. }
  3447. /// <summary>
  3448. /// 团组模块 - 出入境费用 - Info
  3449. /// </summary>
  3450. /// <returns></returns>
  3451. [HttpPost]
  3452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3453. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3454. {
  3455. try
  3456. {
  3457. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3458. if (data.Code != 0)
  3459. {
  3460. return Ok(JsonView(false, data.Msg));
  3461. }
  3462. return Ok(JsonView(true, "查询成功!", data.Data));
  3463. }
  3464. catch (Exception ex)
  3465. {
  3466. return Ok(JsonView(false, ex.Message));
  3467. }
  3468. }
  3469. /// <summary>
  3470. /// 团组模块 - 出入境费用 - Add And Update
  3471. /// </summary>
  3472. /// <returns></returns>
  3473. [HttpPost]
  3474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3475. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3476. {
  3477. try
  3478. {
  3479. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3480. if (data.Code != 0)
  3481. {
  3482. return Ok(JsonView(false, data.Msg));
  3483. }
  3484. return Ok(JsonView(true, data.Msg, data.Data));
  3485. }
  3486. catch (Exception ex)
  3487. {
  3488. return Ok(JsonView(false, ex.Message));
  3489. }
  3490. }
  3491. /// <summary>
  3492. /// 团组模块 - 出入境费用 - File downlaod
  3493. /// </summary>
  3494. /// <param name="dto"></param>
  3495. /// <returns></returns>
  3496. [HttpPost]
  3497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3498. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3499. {
  3500. try
  3501. {
  3502. if (dto.DiId < 1)
  3503. {
  3504. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3505. }
  3506. if (dto.ExportType < 1)
  3507. {
  3508. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3509. }
  3510. if (dto.SubTypeId < 1)
  3511. {
  3512. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3513. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3514. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3515. 3 团组成员名单 1 团组成员名单"));
  3516. }
  3517. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3518. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3519. if (_EnterExitCosts == null)
  3520. {
  3521. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3522. }
  3523. //数据源
  3524. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3525. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3526. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3527. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3528. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3529. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3530. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3531. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3532. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3533. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3534. .Select((tcl, dc, cc) => new
  3535. {
  3536. Name = dc.LastName + dc.FirstName,
  3537. Sex = dc.Sex,
  3538. Birthday = dc.BirthDay,
  3539. Company = cc.CompanyFullName,
  3540. Job = dc.Job
  3541. })
  3542. .ToList();
  3543. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3544. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3545. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3546. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3547. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3548. if (dto.ExportType == 1) //明细表
  3549. {
  3550. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3551. {
  3552. //获取模板
  3553. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3554. //载入模板
  3555. Document doc = new Document(tempPath);
  3556. DocumentBuilder builder = new DocumentBuilder(doc);
  3557. //利用键值对存放数据
  3558. Dictionary<string, string> dic = new Dictionary<string, string>();
  3559. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3560. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3561. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3562. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3563. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3564. string row1_1 = "";
  3565. if (_EnterExitCosts.Visa > 0)
  3566. {
  3567. //insidePayTotal += _EnterExitCosts.Visa;
  3568. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3569. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3570. {
  3571. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3572. }
  3573. }
  3574. string row1_2 = "";
  3575. if (_EnterExitCosts.YiMiao > 0)
  3576. {
  3577. //insidePayTotal += _EnterExitCosts.YiMiao;
  3578. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3579. }
  3580. if (_EnterExitCosts.HeSuan > 0)
  3581. {
  3582. //insidePayTotal += _EnterExitCosts.HeSuan;
  3583. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3584. }
  3585. if (_EnterExitCosts.Service > 0)
  3586. {
  3587. //insidePayTotal += _EnterExitCosts.Service;
  3588. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3589. }
  3590. string row1_3 = "";
  3591. if (_EnterExitCosts.Safe > 0)
  3592. {
  3593. //insidePayTotal += _EnterExitCosts.Safe;
  3594. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3595. }
  3596. if (_EnterExitCosts.Ticket > 0)
  3597. {
  3598. //insidePayTotal += _EnterExitCosts.Ticket;
  3599. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3600. }
  3601. string row1 = "";
  3602. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3603. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3604. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3605. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3606. dic.Add("Row1Str", row1);
  3607. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3608. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3609. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3610. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3611. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3612. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3613. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3614. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3615. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3616. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3617. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3618. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3619. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3620. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3621. #region 填充word模板书签内容
  3622. foreach (var key in dic.Keys)
  3623. {
  3624. builder.MoveToBookmark(key);
  3625. builder.Write(dic[key]);
  3626. }
  3627. #endregion
  3628. #region 填充word表格内容
  3629. ////获读取指定表格方法二
  3630. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3631. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3632. for (int i = 0; i < dac1.Count; i++)
  3633. {
  3634. Grp_DayAndCost dac = dac1[i];
  3635. if (dac == null) continue;
  3636. builder.MoveToCell(0, i, 0, 0);
  3637. builder.Write("第" + dac.Days.ToString() + "晚:");
  3638. builder.MoveToCell(0, i, 1, 0);
  3639. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3640. //builder.Write(dac.Place == null ? "" : dac.Place);
  3641. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3642. builder.MoveToCell(0, i, 2, 0);
  3643. builder.Write("费用标准:");
  3644. string curr = "";
  3645. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3646. if (currData != null)
  3647. {
  3648. curr = currData.Name;
  3649. }
  3650. builder.MoveToCell(0, i, 3, 0);
  3651. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3652. builder.MoveToCell(0, i, 4, 0);
  3653. builder.Write("费用小计:");
  3654. builder.MoveToCell(0, i, 5, 0);
  3655. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3656. }
  3657. //删除多余行
  3658. while (table1.Rows.Count > dac1.Count)
  3659. {
  3660. table1.Rows.RemoveAt(dac1.Count);
  3661. }
  3662. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3663. for (int i = 0; i < dac2.Count; i++)
  3664. {
  3665. Grp_DayAndCost dac = dac2[i];
  3666. if (dac == null) continue;
  3667. builder.MoveToCell(1, i, 0, 0);
  3668. builder.Write("第" + dac.Days.ToString() + "天:");
  3669. builder.MoveToCell(1, i, 1, 0);
  3670. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3671. builder.MoveToCell(1, i, 2, 0);
  3672. builder.Write("费用标准:");
  3673. string curr = "";
  3674. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3675. if (currData != null)
  3676. {
  3677. curr = currData.Name;
  3678. }
  3679. builder.MoveToCell(1, i, 3, 0);
  3680. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3681. builder.MoveToCell(1, i, 4, 0);
  3682. builder.Write("费用小计:");
  3683. builder.MoveToCell(1, i, 5, 0);
  3684. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3685. }
  3686. //删除多余行
  3687. while (table2.Rows.Count > dac2.Count)
  3688. {
  3689. table2.Rows.RemoveAt(dac2.Count);
  3690. }
  3691. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3692. for (int i = 0; i < dac3.Count; i++)
  3693. {
  3694. Grp_DayAndCost dac = dac3[i];
  3695. if (dac == null) continue;
  3696. builder.MoveToCell(2, i, 0, 0);
  3697. builder.Write("第" + dac.Days.ToString() + "天:");
  3698. builder.MoveToCell(2, i, 1, 0);
  3699. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3700. builder.MoveToCell(2, i, 2, 0);
  3701. builder.Write("费用标准:");
  3702. string curr = "";
  3703. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3704. if (currData != null)
  3705. {
  3706. curr = currData.Name;
  3707. }
  3708. builder.MoveToCell(2, i, 3, 0);
  3709. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3710. builder.MoveToCell(2, i, 4, 0);
  3711. builder.Write("费用小计:");
  3712. builder.MoveToCell(2, i, 5, 0);
  3713. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3714. }
  3715. //删除多余行
  3716. while (table3.Rows.Count > dac3.Count)
  3717. {
  3718. table3.Rows.RemoveAt(dac3.Count);
  3719. }
  3720. #endregion
  3721. //文件名
  3722. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3723. AsposeHelper.removewatermark_v2180();
  3724. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3725. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3726. return Ok(JsonView(true, "成功", new { Url = url }));
  3727. }
  3728. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3729. {
  3730. //获取模板
  3731. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3732. //载入模板
  3733. Document doc = new Document(tempPath);
  3734. DocumentBuilder builder = new DocumentBuilder(doc);
  3735. Dictionary<string, string> dic = new Dictionary<string, string>();
  3736. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3737. {
  3738. List<string> list = new List<string>();
  3739. try
  3740. {
  3741. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3742. foreach (var item in spilitArr)
  3743. {
  3744. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3745. var depCode = spDotandEmpty[2].Substring(0, 3);
  3746. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3747. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3748. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3749. list.Add(depName);
  3750. list.Add(arrName);
  3751. }
  3752. list = list.Distinct().ToList();
  3753. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3754. }
  3755. catch (Exception)
  3756. {
  3757. dic.Add("ReturnCode", "行程录入不正确!");
  3758. }
  3759. }
  3760. else
  3761. {
  3762. dic.Add("ReturnCode", "未录入行程!");
  3763. }
  3764. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3765. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3766. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3767. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3768. {
  3769. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3770. dic.Add("Day", sp.Days.ToString());
  3771. }
  3772. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3773. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3774. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3775. //dic.Add("Names", Names);
  3776. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3777. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3778. decimal dac1totalPrice = 0.00M;
  3779. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3780. foreach (var dac in dac1)
  3781. {
  3782. if (dac.SubTotal == 0.00M)
  3783. {
  3784. continue;
  3785. }
  3786. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3787. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3788. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3789. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3790. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3791. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3792. builder.Write(currency);//币种
  3793. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3794. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3795. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3796. builder.Write("");//人数
  3797. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3798. builder.Write("");//天数
  3799. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3800. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3801. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3802. decimal rate = 0.00M;
  3803. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3804. builder.Write(rate.ToString("#0.0000"));//汇率
  3805. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3806. decimal rbmPrice = dac.SubTotal;
  3807. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3808. accommodationStartIndex++;
  3809. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3810. }
  3811. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3812. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3813. {
  3814. table1.Rows.RemoveAt(i - 1);
  3815. foodandotherStartIndex--;
  3816. }
  3817. if (dac2.Count == dac3.Count)//国家 币种 金额
  3818. {
  3819. for (int i = 0; i < dac2.Count; i++)
  3820. {
  3821. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3822. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3823. }
  3824. }
  3825. decimal dac2totalPrice = 0.00M;
  3826. foreach (var dac in dac2)
  3827. {
  3828. if (dac.SubTotal == 0)
  3829. {
  3830. continue;
  3831. }
  3832. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3833. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3834. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3835. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3836. builder.Write(currency);//币种
  3837. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3838. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3839. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3840. builder.Write("");//人数
  3841. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3842. builder.Write("");//天数
  3843. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3844. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3845. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3846. decimal rate = 0.00M;
  3847. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3848. builder.Write(rate.ToString("#0.0000"));//汇率
  3849. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3850. decimal rbmPrice = dac.SubTotal;
  3851. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3852. foodandotherStartIndex++;
  3853. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3854. }
  3855. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3856. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3857. {
  3858. table1.Rows.RemoveAt(i - 1);
  3859. }
  3860. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3861. string otherFeeStr = "";
  3862. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3863. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3864. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3865. if (otherFeeStr.Length > 0)
  3866. {
  3867. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3868. otherFeeStr = $"({otherFeeStr})";
  3869. dic.Add("OtherFeeStr", otherFeeStr);
  3870. }
  3871. //总计
  3872. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3873. //国际旅费
  3874. string outsideJJ = "";
  3875. string allPriceJJ = "";
  3876. if (_EnterExitCosts.SumJJC == 1)
  3877. {
  3878. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3879. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3880. }
  3881. string outsideGW = "";
  3882. string allPriceGW = "";
  3883. if (_EnterExitCosts.SumGWC == 1)
  3884. {
  3885. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3886. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3887. }
  3888. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3889. {
  3890. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3891. dic.Add("InTravelPrice", InTravelPriceStr);
  3892. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3893. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3894. }
  3895. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3896. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3897. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3898. foreach (var key in dic.Keys)
  3899. {
  3900. builder.MoveToBookmark(key);
  3901. builder.Write(dic[key]);
  3902. }
  3903. //模板文件名
  3904. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3905. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3906. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3907. return Ok(JsonView(true, "成功", new { Url = url }));
  3908. }
  3909. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3910. {
  3911. //获取模板
  3912. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3913. //载入模板
  3914. WorkbookDesigner designer = new WorkbookDesigner();
  3915. designer.Workbook = new Workbook(tempPath);
  3916. Dictionary<string, string> dic = new Dictionary<string, string>();
  3917. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3918. {
  3919. List<string> list = new List<string>();
  3920. try
  3921. {
  3922. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3923. foreach (var item in spilitArr)
  3924. {
  3925. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3926. var depCode = spDotandEmpty[2].Substring(0, 3);
  3927. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3928. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3929. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3930. list.Add(depName);
  3931. list.Add(arrName);
  3932. }
  3933. list = list.Distinct().ToList();
  3934. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3935. }
  3936. catch (Exception)
  3937. {
  3938. dic.Add("ReturnCode", "行程录入不正确!");
  3939. }
  3940. }
  3941. else
  3942. {
  3943. dic.Add("ReturnCode", "未录入行程!");
  3944. }
  3945. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3946. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3947. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3948. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3949. {
  3950. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3951. dic.Add("Day", sp.Days.ToString());
  3952. }
  3953. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3954. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3955. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3956. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3957. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3958. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3959. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3960. designer.SetDataSource("Name", Names);
  3961. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3962. designer.SetDataSource("Day", dic["Day"] + "天");
  3963. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3964. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3965. int startIndex = 10;
  3966. const int startIndexcopy = 10;
  3967. if (dac2.Count == dac3.Count)//国家 币种 金额
  3968. {
  3969. for (int i = 0; i < dac2.Count; i++)
  3970. {
  3971. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3972. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3973. }
  3974. }
  3975. DataTable dtdac1 = new DataTable();
  3976. List<string> place = new List<string>();
  3977. dtdac1.Columns.AddRange(new DataColumn[] {
  3978. new DataColumn(){ ColumnName = "city"},
  3979. new DataColumn(){ ColumnName = "curr"},
  3980. new DataColumn(){ ColumnName = "criterion"},
  3981. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3982. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3983. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3984. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3985. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3986. });
  3987. DataTable dtdac2 = new DataTable();
  3988. dtdac2.Columns.AddRange(new DataColumn[] {
  3989. new DataColumn(){ ColumnName = "city"},
  3990. new DataColumn(){ ColumnName = "curr"},
  3991. new DataColumn(){ ColumnName = "criterion"},
  3992. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3993. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3994. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3995. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3996. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3997. });
  3998. dtdac1.TableName = "tb1";
  3999. dtdac2.TableName = "tb2";
  4000. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4001. foreach (var item in dac1)
  4002. {
  4003. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4004. if (place.Contains(item.Place))
  4005. {
  4006. continue;
  4007. }
  4008. DataRow row = dtdac1.NewRow();
  4009. row["city"] = item.Place;
  4010. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4011. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4012. row["curr"] = currency;
  4013. row["rate"] = rate.ToString("#0.0000");
  4014. row["criterion"] = item.Cost.ToString("#0.00");
  4015. row["number"] = 1;
  4016. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4017. //row["costRMB"] = rbmPrice;
  4018. dtdac1.Rows.Add(row);
  4019. place.Add(item.Place);
  4020. }
  4021. place = new List<string>();
  4022. foreach (var item in dac2)
  4023. {
  4024. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4025. if (place.Contains(item.Place))
  4026. {
  4027. continue;
  4028. }
  4029. DataRow row = dtdac2.NewRow();
  4030. row["city"] = item.Place;
  4031. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4032. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4033. row["curr"] = currency;
  4034. row["rate"] = rate.ToString("#0.0000");
  4035. row["criterion"] = item.Cost.ToString("#0.00");
  4036. row["number"] = 1;
  4037. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4038. //row["cost"] = item.SubTotal;
  4039. //row["costRMB"] = rbmPrice;
  4040. dtdac2.Rows.Add(row);
  4041. place.Add(item.Place);
  4042. //dac2totalPrice += rbmPrice;
  4043. }
  4044. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4045. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4046. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4047. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4048. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4049. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4050. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4051. string cellStr = $" 5.其他费用(";
  4052. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4053. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4054. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4055. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4056. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4057. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4058. if (cellStr.Length > 8)
  4059. {
  4060. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4061. }
  4062. cellStr += ")";
  4063. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4064. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4065. decimal pxFee = dac4.Sum(it => it.Cost);
  4066. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4067. string celllastStr1 = "";
  4068. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4069. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4070. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4071. celllastStr1 += $",国际旅费 元";
  4072. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4073. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4074. designer.SetDataSource("cell4Str", cell4Str);
  4075. designer.SetDataSource("cellStr", cellStr);
  4076. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4077. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4078. designer.SetDataSource("celllastStr", celllastStr);
  4079. Workbook wb = designer.Workbook;
  4080. var sheet = wb.Worksheets[0];
  4081. //绑定datatable数据集
  4082. designer.SetDataSource(dtdac1);
  4083. designer.SetDataSource(dtdac2);
  4084. designer.Process();
  4085. var rowStart = dtdac1.Rows.Count;
  4086. while (rowStart > 0)
  4087. {
  4088. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4089. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4090. startIndex++;
  4091. rowStart--;
  4092. }
  4093. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4094. startIndex += 1; //总计行
  4095. rowStart = dtdac2.Rows.Count;
  4096. while (rowStart > 0)
  4097. {
  4098. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4099. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4100. startIndex++;
  4101. rowStart--;
  4102. }
  4103. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4104. wb.CalculateFormula(true);
  4105. //模板文件名
  4106. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4107. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4108. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4109. return Ok(JsonView(true, "成功", new { Url = url }));
  4110. }
  4111. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4112. {
  4113. //获取模板
  4114. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4115. //载入模板
  4116. Document doc = new Document(tempPath);
  4117. DocumentBuilder builder = new DocumentBuilder(doc);
  4118. Dictionary<string, string> dic = new Dictionary<string, string>();
  4119. dic.Add("GroupName", _DelegationInfo.TeamName);
  4120. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4121. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4122. string missionLeaderJob = "";//负责人job
  4123. int groupNumber = 0; //团人数
  4124. if (DeleClientList.Count > 0)
  4125. {
  4126. missionLeader = DeleClientList[0]?.Name ?? "";
  4127. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4128. }
  4129. dic.Add("MissionLeader", missionLeader); //团负责人
  4130. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4131. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4132. #region MyRegion
  4133. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4134. //{
  4135. // List<string> list = new List<string>();
  4136. // try
  4137. // {
  4138. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4139. // foreach (var item in spilitArr)
  4140. // {
  4141. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4142. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4143. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4144. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4145. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4146. // list.Add(depName);
  4147. // list.Add(arrName);
  4148. // }
  4149. // list = list.Distinct().ToList();
  4150. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4151. // }
  4152. // catch (Exception)
  4153. // {
  4154. // dic.Add("ReturnCode", "行程录入不正确!");
  4155. // }
  4156. //}
  4157. //else
  4158. //{
  4159. // dic.Add("ReturnCode", "未录入行程!");
  4160. //}
  4161. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4162. dic.Add("ReturnCode", string.Join("、", countrys));
  4163. #endregion
  4164. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4165. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4166. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4167. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4168. //{
  4169. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4170. // dic.Add("Day", sp.Days.ToString());
  4171. //}
  4172. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4173. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4174. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4175. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4176. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4177. //培训人员名单
  4178. int cultivateRowIndex = 7;
  4179. foreach (var item in DeleClientList)
  4180. {
  4181. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4182. builder.Write(item.Name);
  4183. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4184. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4185. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4186. string birthDay = "";
  4187. if (item.Birthday != null)
  4188. {
  4189. DateTime dt = Convert.ToDateTime(item.Birthday);
  4190. birthDay = $"{dt.Year}.{dt.Month}";
  4191. }
  4192. builder.Write(birthDay);
  4193. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4194. builder.Write(item.Company);
  4195. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4196. builder.Write(item.Job);
  4197. cultivateRowIndex++;
  4198. }
  4199. //删除多余行
  4200. //cultivateRowIndex -= 2;
  4201. int delRows = 10 + 7 - cultivateRowIndex;
  4202. if (delRows > 0)
  4203. {
  4204. for (int i = 0; i < delRows; i++)
  4205. {
  4206. table1.Rows.RemoveAt(cultivateRowIndex);
  4207. //cultivateRowIndex++;
  4208. }
  4209. }
  4210. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4211. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4212. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4213. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4214. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4215. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4216. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4217. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4218. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4219. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4220. //其他费用
  4221. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4222. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4223. //其他费用合计
  4224. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4225. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4226. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4227. //公务舱合计
  4228. //国际旅费
  4229. string outsideJJ = "";
  4230. string allPriceJJ = "";
  4231. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4232. {
  4233. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4234. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4235. }
  4236. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4237. {
  4238. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4239. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4240. }
  4241. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4242. {
  4243. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4244. dic.Add("AirFeeTotal", airFeeTotalStr);
  4245. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4246. dic.Add("FeeTotal", feeTotalStr);
  4247. }
  4248. foreach (var key in dic.Keys)
  4249. {
  4250. builder.MoveToBookmark(key);
  4251. builder.Write(dic[key]);
  4252. }
  4253. //模板文件名
  4254. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4255. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4256. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4257. return Ok(JsonView(true, "成功", new { Url = url }));
  4258. }
  4259. }
  4260. else if (dto.ExportType == 2) //表格
  4261. {
  4262. //利用键值对存放数据
  4263. Dictionary<string, string> dic = new Dictionary<string, string>();
  4264. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4265. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4266. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4267. dic.Add("Day", sp.Days.ToString());
  4268. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4269. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4270. {
  4271. //获取模板
  4272. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4273. //载入模板
  4274. Document doc = new Document(tempPath);
  4275. DocumentBuilder builder = new DocumentBuilder(doc);
  4276. dic.Add("TeamName", _DelegationInfo.TeamName);
  4277. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4278. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4279. string missionLeaderName = "",
  4280. missionLeaderJob = "";
  4281. if (DeleClientList.Count > 0)
  4282. {
  4283. missionLeaderName = DeleClientList[0].Name;
  4284. missionLeaderJob = DeleClientList[0].Job;
  4285. }
  4286. dic.Add("MissionLeaderName", missionLeaderName);
  4287. dic.Add("MissionLeaderJob", missionLeaderJob);
  4288. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4289. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4290. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4291. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4292. int rowCount = 10;//总人数行
  4293. int startRowIndex = 7; //起始行
  4294. for (int i = 0; i < DeleClientList.Count; i++)
  4295. {
  4296. builder.MoveToCell(0, startRowIndex, 0, 0);
  4297. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4298. builder.MoveToCell(0, startRowIndex, 1, 0);
  4299. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4300. builder.Write(sex);//性别
  4301. builder.MoveToCell(0, startRowIndex, 2, 0);
  4302. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4303. builder.MoveToCell(0, startRowIndex, 3, 0);
  4304. builder.Write(DeleClientList[i].Company);//工作单位
  4305. builder.MoveToCell(0, startRowIndex, 4, 0);
  4306. builder.Write(DeleClientList[i].Job);//职务及级别
  4307. builder.MoveToCell(0, startRowIndex, 5, 0);
  4308. builder.Write("");//人员属性
  4309. builder.MoveToCell(0, startRowIndex, 6, 0);
  4310. builder.Write("");//上次出国时间
  4311. startRowIndex++;
  4312. }
  4313. int nullRow = rowCount - DeleClientList.Count;//空行
  4314. for (int i = 0; i < nullRow; i++)
  4315. {
  4316. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4317. }
  4318. foreach (var key in dic.Keys)
  4319. {
  4320. builder.MoveToBookmark(key);
  4321. builder.Write(dic[key]);
  4322. }
  4323. //模板文件名
  4324. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4325. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4326. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4327. return Ok(JsonView(true, "成功", new { Url = url }));
  4328. }
  4329. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4330. {
  4331. //获取模板
  4332. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4333. //载入模板
  4334. Document doc = new Document(tempPath);
  4335. DocumentBuilder builder = new DocumentBuilder(doc);
  4336. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4337. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4338. dic.Add("Names", Names);
  4339. int accommodationRows = 12, foodandotherRows = 12;
  4340. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4341. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4342. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4343. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4344. int accommodationStartIndex = 6;
  4345. decimal dac1totalPrice = 0.00M;
  4346. foreach (var dac in dac1)
  4347. {
  4348. if (dac.SubTotal == 0)
  4349. {
  4350. continue;
  4351. }
  4352. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4353. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4354. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4355. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4356. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4357. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4358. builder.Write(currency);//币种
  4359. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4360. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4361. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4362. builder.Write("");//人数
  4363. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4364. builder.Write("");//天数
  4365. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4366. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4367. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4368. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4369. builder.Write(rate.ToString("#0.0000"));//汇率
  4370. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4371. decimal rbmPrice = rate * dac.SubTotal;
  4372. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4373. accommodationStartIndex++;
  4374. dac1totalPrice += rbmPrice;
  4375. }
  4376. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4377. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4378. builder.Write("小计");
  4379. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4380. builder.Write(dac1totalPrice.ToString("#0.00"));
  4381. accommodationStartIndex++;
  4382. int nullRow = accommodationRows - dac1.Count;
  4383. //删除空行
  4384. //if (nullRow > 0)
  4385. //{
  4386. // int rowIndex = accommodationStartIndex;
  4387. // for (int i = 0; i < nullRow; i++)
  4388. // {
  4389. // Row row = table1.Rows[rowIndex];
  4390. // row.Remove();
  4391. // rowIndex++;
  4392. // }
  4393. //}
  4394. if (dac2.Count == dac3.Count)//国家 币种 金额
  4395. {
  4396. for (int i = 0; i < dac2.Count; i++)
  4397. {
  4398. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4399. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4400. }
  4401. }
  4402. int foodandotherStartIndex = 19;//
  4403. decimal dac2totalPrice = 0.00M;
  4404. foreach (var dac in dac2)
  4405. {
  4406. if (dac.SubTotal == 0)
  4407. {
  4408. continue;
  4409. }
  4410. //foodandotherStartIndex = 12;
  4411. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4412. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4413. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4414. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4415. builder.Write(currency);//币种
  4416. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4417. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4418. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4419. builder.Write("");//人数
  4420. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4421. builder.Write("");//天数
  4422. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4423. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4424. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4425. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4426. builder.Write(rate.ToString("#0.0000"));//汇率
  4427. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4428. decimal rbmPrice = rate * dac.SubTotal;
  4429. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4430. foodandotherStartIndex++;
  4431. dac2totalPrice += rbmPrice;
  4432. }
  4433. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4434. //删除空行
  4435. if (dac2.Count < foodandotherRows)
  4436. {
  4437. //int nullRow = accommodationRows - dac2.Count;
  4438. //while (table2.Rows.Count > dac2.Count)
  4439. //{
  4440. // table2.Rows.RemoveAt(dac2.Count);
  4441. //}
  4442. }
  4443. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4444. string otherFeeStr = "";
  4445. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4446. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4447. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4448. if (otherFeeStr.Length > 0)
  4449. {
  4450. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4451. otherFeeStr = $"({otherFeeStr})";
  4452. dic.Add("OtherFeeStr", otherFeeStr);
  4453. }
  4454. foreach (var key in dic.Keys)
  4455. {
  4456. builder.MoveToBookmark(key);
  4457. builder.Write(dic[key]);
  4458. }
  4459. //模板文件名
  4460. string strFileName = $"省级单位出(境)经费报销单.docx";
  4461. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4462. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4463. return Ok(JsonView(true, "成功", new { Url = url }));
  4464. }
  4465. }
  4466. else if (dto.ExportType == 3)
  4467. {
  4468. if (dto.SubTypeId == 1) //团组成员名单
  4469. {
  4470. if (DeleClientList.Count < 1)
  4471. {
  4472. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4473. }
  4474. //获取模板
  4475. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4476. //载入模板
  4477. Document doc = new Document(tempPath);
  4478. DocumentBuilder builder = new DocumentBuilder(doc);
  4479. //获取word里所有表格
  4480. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4481. //获取所填表格的序数
  4482. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4483. var rowStart = tableOne.Rows[0]; //获取第1行
  4484. //循环赋值
  4485. for (int i = 0; i < DeleClientList.Count; i++)
  4486. {
  4487. builder.MoveToCell(0, i + 1, 0, 0);
  4488. builder.Write(DeleClientList[i].Name);
  4489. builder.MoveToCell(0, i + 1, 1, 0);
  4490. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4491. builder.Write(sex);
  4492. builder.MoveToCell(0, i + 1, 2, 0);
  4493. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4494. builder.MoveToCell(0, i + 1, 3, 0);
  4495. builder.Write(DeleClientList[i].Company);
  4496. builder.MoveToCell(0, i + 1, 4, 0);
  4497. builder.Write(DeleClientList[i].Job);
  4498. }
  4499. //删除多余行
  4500. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4501. {
  4502. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4503. }
  4504. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4505. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4506. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4507. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4508. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4509. return Ok(JsonView(true, "成功", new { Url = url }));
  4510. }
  4511. }
  4512. return Ok(JsonView(false, "操作失败!"));
  4513. }
  4514. catch (Exception ex)
  4515. {
  4516. return Ok(JsonView(false, ex.Message));
  4517. }
  4518. }
  4519. /// <summary>
  4520. /// 获取三公费用标准city
  4521. /// </summary>
  4522. /// <param name="placeData"></param>
  4523. /// <param name="nationalTravelFeeId"></param>
  4524. /// <returns></returns>
  4525. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4526. {
  4527. string _city = string.Empty;
  4528. if (placeData.Count < 1) return _city;
  4529. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4530. if (data == null) return _city;
  4531. string country = data.Country;
  4532. string city = data.City;
  4533. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4534. else _city = city;
  4535. return _city;
  4536. }
  4537. /// <summary>
  4538. /// 团组模块 - 出入境费用 - 明细表导出
  4539. /// </summary>
  4540. /// <returns></returns>
  4541. [HttpPost]
  4542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4543. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4544. {
  4545. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4546. if (data.Code != 0)
  4547. {
  4548. return Ok(JsonView(false, data.Msg));
  4549. }
  4550. return Ok(JsonView(true, data.Msg, data.Data));
  4551. }
  4552. /// <summary>
  4553. /// 团组模块 - 出入境费用 - 一键清空
  4554. /// </summary>
  4555. /// <returns></returns>
  4556. [HttpPost]
  4557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4558. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4559. {
  4560. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4561. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4562. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4563. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4564. if (_view.Code == 0)
  4565. {
  4566. return Ok(JsonView(true, "操作成功"));
  4567. }
  4568. return Ok(JsonView(false, "操作失败"));
  4569. }
  4570. /// <summary>
  4571. /// 团组模块 - 出入境费用 - 子项删除
  4572. /// </summary>
  4573. /// <returns></returns>
  4574. [HttpPost]
  4575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4576. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4577. {
  4578. try
  4579. {
  4580. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4581. if (data.Code != 0)
  4582. {
  4583. return Ok(JsonView(false, data.Msg));
  4584. }
  4585. return Ok(JsonView(true, "操作成功!", data.Data));
  4586. }
  4587. catch (Exception ex)
  4588. {
  4589. return Ok(JsonView(false, ex.Message));
  4590. }
  4591. }
  4592. /// <summary>
  4593. /// 团组模块 - 出入境国家费用标准 List
  4594. /// </summary>
  4595. /// <returns></returns>
  4596. [HttpPost]
  4597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4598. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4599. {
  4600. try
  4601. {
  4602. Stopwatch sw = new Stopwatch();
  4603. sw.Start();
  4604. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4605. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4606. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4607. Where gntf.Isdel = 0");
  4608. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4609. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4610. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4611. //foreach (var item in nationalTravel)
  4612. //{
  4613. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4614. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4615. // if (otherData != null)
  4616. // {
  4617. // cityData.Remove(otherData);
  4618. // cityData.Add(otherData);
  4619. // }
  4620. // nationalTravelFeeData1.Add(new
  4621. // {
  4622. // Country = item.Country,
  4623. // CityData = cityData
  4624. // });
  4625. //}
  4626. sw.Stop();
  4627. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4628. }
  4629. catch (Exception ex)
  4630. {
  4631. return Ok(JsonView(false, ex.Message));
  4632. throw;
  4633. }
  4634. }
  4635. /// <summary>
  4636. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4637. /// </summary>
  4638. /// <returns></returns>
  4639. [HttpPost]
  4640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4641. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4642. {
  4643. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4644. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4645. List<string> countryData = new List<string>();
  4646. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4647. countryData = countryData.Distinct().ToList();
  4648. List<dynamic> dataSource = new List<dynamic>();
  4649. foreach (var item in countryData)
  4650. {
  4651. List<string> cityData1 = new List<string>();
  4652. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4653. var countryData2 = new
  4654. {
  4655. CountryName = item,
  4656. CityData = cityData1
  4657. };
  4658. dataSource.Add(countryData2);
  4659. }
  4660. return Ok(JsonView(true, "查询成功!", dataSource));
  4661. }
  4662. /// <summary>
  4663. /// 团组模块 - 出入境国家费用标准 Page List
  4664. /// </summary>
  4665. /// <returns></returns>
  4666. [HttpPost]
  4667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4668. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4669. {
  4670. int portId = dto.PortType;
  4671. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4672. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4673. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4674. string whereSql = string.Empty;
  4675. if (!string.IsNullOrEmpty(dto.Country))
  4676. {
  4677. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4678. }
  4679. if (!string.IsNullOrEmpty(dto.City))
  4680. {
  4681. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4682. }
  4683. string pageSql = string.Format(@"Select * From (
  4684. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4685. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4686. From Grp_NationalTravelFee gntf
  4687. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4688. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4689. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4690. RefAsync<int> total = 0;
  4691. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4692. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4693. }
  4694. /// <summary>
  4695. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4696. /// </summary>
  4697. /// <returns></returns>
  4698. [HttpPost]
  4699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4700. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4701. {
  4702. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4703. int portId = dto.PortType;
  4704. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4705. string whereSql = string.Empty;
  4706. if (!string.IsNullOrEmpty(dto.Country))
  4707. {
  4708. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4709. }
  4710. if (!string.IsNullOrEmpty(dto.City))
  4711. {
  4712. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4713. }
  4714. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4715. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4716. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4717. From Grp_NationalTravelFee gntf
  4718. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4719. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4720. Where gntf.Isdel = 0 {0} ", whereSql);
  4721. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4722. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4723. }
  4724. /// <summary>
  4725. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4726. /// </summary>
  4727. /// <returns></returns>
  4728. [HttpPost]
  4729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4730. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4731. {
  4732. try
  4733. {
  4734. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4735. if (data.Code != 0)
  4736. {
  4737. return Ok(JsonView(false, data.Msg));
  4738. }
  4739. return Ok(JsonView(true, "操作成功!", data.Data));
  4740. }
  4741. catch (Exception ex)
  4742. {
  4743. return Ok(JsonView(false, ex.Message));
  4744. }
  4745. }
  4746. /// <summary>
  4747. /// 团组模块 - 出入境国家费用标准 - Del
  4748. /// </summary>
  4749. /// <returns></returns>
  4750. [HttpPost]
  4751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4752. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4753. {
  4754. try
  4755. {
  4756. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4757. {
  4758. Id = dto.Id,
  4759. DeleteUserId = dto.DeleteUserId,
  4760. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4761. IsDel = 1
  4762. };
  4763. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4764. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4765. .WhereColumns(it => new { it.Id })
  4766. .ExecuteCommandAsync();
  4767. if (delStatus <= 0)
  4768. {
  4769. return Ok(JsonView(false, "删除失败!"));
  4770. }
  4771. return Ok(JsonView(true, "操作成功!"));
  4772. }
  4773. catch (Exception ex)
  4774. {
  4775. return Ok(JsonView(false, ex.Message));
  4776. }
  4777. }
  4778. #endregion
  4779. #region 签证费用录入
  4780. /// <summary>
  4781. /// 根据diid查询签证费用列表
  4782. /// </summary>
  4783. /// <param name="dto"></param>
  4784. /// <returns></returns>
  4785. [HttpPost]
  4786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4787. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4788. {
  4789. try
  4790. {
  4791. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4792. if (groupData.Code != 0)
  4793. {
  4794. return Ok(JsonView(false, groupData.Msg));
  4795. }
  4796. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4797. }
  4798. catch (Exception ex)
  4799. {
  4800. return Ok(JsonView(false, ex.Message));
  4801. }
  4802. }
  4803. /// <summary>
  4804. /// 根据签证费用Id查询单条数据及c表数据
  4805. /// </summary>
  4806. /// <param name="dto"></param>
  4807. /// <returns></returns>
  4808. [HttpPost]
  4809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4810. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4811. {
  4812. try
  4813. {
  4814. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4815. if (groupData.Code != 0)
  4816. {
  4817. return Ok(JsonView(false, groupData.Msg));
  4818. }
  4819. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4820. }
  4821. catch (Exception ex)
  4822. {
  4823. return Ok(JsonView(false, ex.Message));
  4824. }
  4825. }
  4826. /// <summary>
  4827. /// 签证费用删除
  4828. /// </summary>
  4829. /// <param name="dto"></param>
  4830. /// <returns></returns>
  4831. [HttpPost]
  4832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4833. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4834. {
  4835. _sqlSugar.BeginTran();
  4836. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4837. if (!res)
  4838. {
  4839. _sqlSugar.RollbackTran();
  4840. return Ok(JsonView(false, "删除失败"));
  4841. }
  4842. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4843. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4844. .SetColumns(a => new Grp_CreditCardPayment()
  4845. {
  4846. IsDel = 1,
  4847. DeleteUserId = dto.DeleteUserId,
  4848. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4849. }).ExecuteCommand();
  4850. if (resSub < 1)
  4851. {
  4852. _sqlSugar.RollbackTran();
  4853. return Ok(JsonView(false, "删除失败"));
  4854. }
  4855. _sqlSugar.CommitTran();
  4856. return Ok(JsonView(true, "删除成功!"));
  4857. }
  4858. /// <summary>
  4859. /// 签证费用录入下拉框初始化
  4860. /// </summary>
  4861. /// <returns></returns>
  4862. [HttpPost]
  4863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4864. public async Task<IActionResult> VisaPriceAddSelect()
  4865. {
  4866. try
  4867. {
  4868. //支付方式
  4869. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4870. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4871. //币种
  4872. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4873. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4874. //乘客类型
  4875. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4876. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4877. //卡类型
  4878. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4879. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4880. var data = new
  4881. {
  4882. Payment = _Payment,
  4883. CurrencyList = _CurrencyList,
  4884. PassengerType = _PassengerType,
  4885. BankCard = _BankCard
  4886. };
  4887. return Ok(JsonView(true, "查询成功!", data));
  4888. }
  4889. catch (Exception ex)
  4890. {
  4891. return Ok(JsonView(false, "程序错误!"));
  4892. throw;
  4893. }
  4894. }
  4895. /// <summary>
  4896. /// 签证费用录入操作(Status:1.新增,2.修改)
  4897. /// </summary>
  4898. /// <param name="dto"></param>
  4899. /// <returns></returns>
  4900. [HttpPost]
  4901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4902. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4903. {
  4904. try
  4905. {
  4906. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4907. if (groupData.Code != 0)
  4908. {
  4909. return Ok(JsonView(false, groupData.Msg));
  4910. }
  4911. #region 应用推送
  4912. try
  4913. {
  4914. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4915. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4916. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4917. }
  4918. catch (Exception ex)
  4919. {
  4920. }
  4921. #endregion
  4922. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4923. }
  4924. catch (Exception ex)
  4925. {
  4926. return Ok(JsonView(false, ex.Message));
  4927. }
  4928. }
  4929. #endregion
  4930. #region op费用录入
  4931. /// <summary>
  4932. /// 根据diid查询op费用列表
  4933. /// </summary>
  4934. /// <param name="dto"></param>
  4935. /// <returns></returns>
  4936. [HttpPost]
  4937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4938. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4939. {
  4940. try
  4941. {
  4942. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4943. if (groupData.Code != 0)
  4944. {
  4945. return Ok(JsonView(false, groupData.Msg));
  4946. }
  4947. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4948. }
  4949. catch (Exception ex)
  4950. {
  4951. return Ok(JsonView(false, ex.Message));
  4952. }
  4953. }
  4954. /// <summary>
  4955. /// 根据op费用Id查询单条数据及c表数据
  4956. /// </summary>
  4957. /// <param name="dto"></param>
  4958. /// <returns></returns>
  4959. [HttpPost]
  4960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4961. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4962. {
  4963. try
  4964. {
  4965. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4966. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4967. var data = new
  4968. {
  4969. CarTouristGuideGround = _groupData,
  4970. CreditCardPayment = _creditCardPayment
  4971. };
  4972. return Ok(JsonView(true, "查询成功!", data));
  4973. }
  4974. catch (Exception ex)
  4975. {
  4976. return Ok(JsonView(false, "程序错误!"));
  4977. }
  4978. }
  4979. /// <summary>
  4980. /// op费用删除
  4981. /// </summary>
  4982. /// <param name="dto"></param>
  4983. /// <returns></returns>
  4984. [HttpPost]
  4985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4986. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4987. {
  4988. try
  4989. {
  4990. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4991. if (!res)
  4992. {
  4993. return Ok(JsonView(false, "删除失败"));
  4994. }
  4995. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4996. {
  4997. IsDel = 1,
  4998. DeleteUserId = dto.DeleteUserId,
  4999. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5000. }).ExecuteCommandAsync();
  5001. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5002. {
  5003. IsDel = 1,
  5004. DeleteUserId = dto.DeleteUserId,
  5005. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5006. }).ExecuteCommandAsync();
  5007. return Ok(JsonView(true, "删除成功!"));
  5008. }
  5009. catch (Exception ex)
  5010. {
  5011. return Ok(JsonView(false, "程序错误!"));
  5012. throw;
  5013. }
  5014. }
  5015. /// <summary>
  5016. /// op费用录入操作(Status:1.新增,2.修改)
  5017. /// </summary>
  5018. /// <param name="dto"></param>
  5019. /// <returns></returns>
  5020. [HttpPost]
  5021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5022. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5023. {
  5024. try
  5025. {
  5026. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5027. if (groupData.Code != 0)
  5028. {
  5029. return Ok(JsonView(false, groupData.Msg));
  5030. }
  5031. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5032. }
  5033. catch (Exception ex)
  5034. {
  5035. return Ok(JsonView(false, ex.Message));
  5036. }
  5037. }
  5038. /// <summary>
  5039. /// 填写费用详细页面初始化绑定
  5040. /// </summary>
  5041. /// <param name="dto"></param>
  5042. /// <returns></returns>
  5043. [HttpPost]
  5044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5045. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5046. {
  5047. try
  5048. {
  5049. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5050. if (groupData.Code != 0)
  5051. {
  5052. return Ok(JsonView(false, groupData.Msg));
  5053. }
  5054. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5055. }
  5056. catch (Exception ex)
  5057. {
  5058. return Ok(JsonView(false, ex.Message));
  5059. }
  5060. }
  5061. /// <summary>
  5062. /// 根据op费用Id查询详细数据
  5063. /// </summary>
  5064. /// <param name="dto"></param>
  5065. /// <returns></returns>
  5066. [HttpPost]
  5067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5068. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5069. {
  5070. try
  5071. {
  5072. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5073. if (groupData.Code != 0)
  5074. {
  5075. return Ok(JsonView(false, groupData.Msg));
  5076. }
  5077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5078. }
  5079. catch (Exception ex)
  5080. {
  5081. return Ok(JsonView(false, ex.Message));
  5082. }
  5083. }
  5084. /// <summary>
  5085. /// OP费用录入填写详情
  5086. /// </summary>
  5087. /// <param name="dto"></param>
  5088. /// <returns></returns>
  5089. [HttpPost]
  5090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5091. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5092. {
  5093. try
  5094. {
  5095. #region 参数校验
  5096. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5097. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5098. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5099. #endregion
  5100. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5101. if (groupData.Code != 0)
  5102. {
  5103. return Ok(JsonView(false, groupData.Msg));
  5104. }
  5105. #region 应用推送
  5106. try
  5107. {
  5108. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5109. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5110. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5111. }
  5112. catch (Exception ex)
  5113. {
  5114. }
  5115. #endregion
  5116. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5117. }
  5118. catch (Exception ex)
  5119. {
  5120. return Ok(JsonView(false, ex.Message));
  5121. }
  5122. }
  5123. /// <summary>
  5124. /// 获取三公详细所有城市
  5125. /// </summary>
  5126. /// <returns></returns>
  5127. [HttpGet]
  5128. public IActionResult OpCarCityResult()
  5129. {
  5130. var jw = JsonView(false);
  5131. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5132. {
  5133. x.Id,
  5134. x.Country,
  5135. x.City,
  5136. }).ToList();
  5137. if (data.Count > 0)
  5138. {
  5139. jw = JsonView(true, "获取成功!", data);
  5140. }
  5141. else
  5142. {
  5143. jw.Msg = "城市数据为空!";
  5144. jw.Data = new string[0];
  5145. }
  5146. return Ok(jw);
  5147. }
  5148. /// <summary>
  5149. /// 导出地接费用明细
  5150. /// </summary>
  5151. /// <param name="dto"></param>
  5152. /// <returns></returns>
  5153. [HttpPost]
  5154. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5155. {
  5156. var jw = JsonView(false);
  5157. if (dto.Diid < 1)
  5158. {
  5159. jw.Msg = "请输入正确的diid!";
  5160. return Ok(jw);
  5161. }
  5162. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5163. if (group == null)
  5164. {
  5165. jw.Msg = "未找到团组信息!";
  5166. return Ok(jw);
  5167. }
  5168. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5169. if (localGuideArr.Count == 0)
  5170. {
  5171. jw.Msg = "该团组暂无地接信息!";
  5172. return Ok(jw);
  5173. }
  5174. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5175. var overspendSoure = new Dictionary<int, int>
  5176. {
  5177. { 91, 982 }, //车
  5178. { 92 , 1059} ,//导游
  5179. { 994 , 1073}, //翻译
  5180. { 988 , 1074 }, //早餐
  5181. { 93 , 1075 }, //午餐
  5182. { 989 , 1076 }, //晚餐
  5183. };
  5184. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5185. foreach (var groupArr in localGroup)
  5186. {
  5187. var keyValue = groupArr.Key;
  5188. if (int.TryParse(keyValue, out int cityid))
  5189. {
  5190. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5191. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5192. }
  5193. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5194. foreach (var item in groupArr)
  5195. {
  5196. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5197. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5198. new Grp_CarTouristGuideGroundReservationsContentExtend
  5199. {
  5200. Count = a.Count,
  5201. CreateTime = a.CreateTime,
  5202. CreateUserId = a.CreateUserId,
  5203. CTGGRId = a.CTGGRId,
  5204. Currency = a.Currency,
  5205. DatePrice = a.DatePrice,
  5206. DeleteTime = a.DeleteTime,
  5207. DeleteUserId = a.DeleteUserId,
  5208. DiId = a.DiId,
  5209. Id = a.Id,
  5210. IsDel = a.IsDel,
  5211. Price = a.Price,
  5212. PriceContent = a.PriceContent,
  5213. Remark = a.Remark,
  5214. SId = a.SId,
  5215. SidName = b.Name,
  5216. Units = a.Units,
  5217. }
  5218. ).ToList();
  5219. if (content.Count > 0)
  5220. {
  5221. contentArr.Add(content);
  5222. }
  5223. }
  5224. //open excel
  5225. //set excel
  5226. //save excel
  5227. try
  5228. {
  5229. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5230. IWorkbook workbook;
  5231. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5232. {
  5233. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5234. }
  5235. else
  5236. {
  5237. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5238. }
  5239. ISheet sheet = workbook.GetSheetAt(0);
  5240. var rowStartIndex = 2;
  5241. var clounmCount = 10;
  5242. var initStyleRow = sheet.GetRow(2);
  5243. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5244. //var overspendArrDetail =
  5245. var existsId = new List<CarCompare>();
  5246. var lastElem = arr.Last();
  5247. var thisSid = -1;
  5248. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5249. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5250. {
  5251. Name = "未知币种!",
  5252. Remark = "未知币种!",
  5253. };
  5254. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5255. Action cloneRowFn = () =>
  5256. {
  5257. rowStartIndex++;
  5258. var cloneRow = sheet.CreateRow(rowStartIndex);
  5259. // 复制样式
  5260. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5261. {
  5262. ICell sourceCell = initStyleRow.GetCell(i);
  5263. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5264. // 确保单元格存在样式
  5265. if (sourceCell.CellStyle != null)
  5266. {
  5267. targetCell.CellStyle = sourceCell.CellStyle;
  5268. }
  5269. }
  5270. };
  5271. var mergeRow = () =>
  5272. {
  5273. for (int i = 2; i < sheet.LastRowNum; i++)
  5274. {
  5275. var row = sheet.GetRow(i);
  5276. var cellFirst = row.GetCell(0);
  5277. var thisIndex = i + 1;
  5278. while (thisIndex < sheet.LastRowNum)
  5279. {
  5280. var nextRow = sheet.GetRow(thisIndex);
  5281. var nextCellFirst = nextRow.GetCell(0);
  5282. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5283. {
  5284. thisIndex++;
  5285. }
  5286. else
  5287. {
  5288. break;
  5289. }
  5290. }
  5291. thisIndex--;
  5292. if (thisIndex != i)
  5293. {
  5294. //合并row
  5295. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5296. i, // 起始行索引(0-based)
  5297. thisIndex, // 结束行索引(0-based)
  5298. 0, // 起始列索引(0-based)
  5299. 0 // 结束列索引(0-based)
  5300. );
  5301. sheet.AddMergedRegion(cellRangeAddress);
  5302. i = thisIndex;
  5303. }
  5304. }
  5305. };
  5306. var chaoshiNumber = 0;
  5307. var totalNumber = 0.00M;
  5308. string lastStr = "";
  5309. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5310. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5311. {
  5312. b.IsAuditGM,
  5313. x.Id,
  5314. x.Area,
  5315. b.PayPercentage,
  5316. b.PayMoney,
  5317. }).ToList();
  5318. string yesPayment = "", noPayment = "";
  5319. foreach (var item in queryCarArrByCityAndDiid)
  5320. {
  5321. if (item.IsAuditGM == 1)
  5322. {
  5323. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5324. }
  5325. else
  5326. {
  5327. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5328. }
  5329. }
  5330. lastStr = yesPayment + noPayment;
  5331. foreach (var item in arr)
  5332. {
  5333. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5334. {
  5335. if (thisSid != item.SId)
  5336. {
  5337. if (thisSid == -1)
  5338. {
  5339. thisSid = item.SId;
  5340. }
  5341. else
  5342. {
  5343. //合并小计行
  5344. //创建合并区域的实例
  5345. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5346. rowStartIndex, // 起始行索引(0-based)
  5347. rowStartIndex, // 结束行索引(0-based)
  5348. 0, // 起始列索引(0-based)
  5349. 3 // 结束列索引(0-based)
  5350. );
  5351. sheet.AddMergedRegion(cellRangeAddress);
  5352. var CellStyle = workbook.CreateCellStyle();
  5353. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5354. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5355. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5356. for (int i = 0; i <= clounmCount; i++)
  5357. {
  5358. if (i > 6)
  5359. {
  5360. var CellStyle1 = workbook.CreateCellStyle();
  5361. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5362. IFont Font = workbook.CreateFont(); // 创建字体
  5363. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5364. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5365. CellStyle1.SetFont(Font);
  5366. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5367. }
  5368. else
  5369. {
  5370. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5371. }
  5372. }
  5373. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5374. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5375. //超时合计
  5376. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5377. //超时数
  5378. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5379. //超时合计费用
  5380. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5381. thisSid = item.SId;
  5382. cloneRowFn();
  5383. chaoshiNumber = 0;
  5384. totalNumber = 0;
  5385. }
  5386. }
  5387. IRow row = sheet.GetRow(rowStartIndex);
  5388. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5389. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5390. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5391. if (isOpenOverspendSoure)
  5392. {
  5393. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5394. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5395. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5396. }
  5397. for (int i = 0; i <= clounmCount; i++)
  5398. {
  5399. var cell = row.GetCell(i);
  5400. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5401. if (cell == null)
  5402. {
  5403. cell = row.CreateCell(i);
  5404. }
  5405. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5406. fontRed.CloneStyleFrom(cell.CellStyle);
  5407. IFont Font = workbook.CreateFont(); // 创建字体
  5408. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5409. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5410. fontRed.SetFont(Font);
  5411. byte[] rgb = new byte[3] { 255, 242, 204 };
  5412. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5413. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5414. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5415. if (workbook is XSSFWorkbook)
  5416. {
  5417. BackgroundColor255_242_204.FillForegroundColor = 0;
  5418. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5419. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5420. }
  5421. else
  5422. {
  5423. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5424. }
  5425. if (i == 1 || i > 6)
  5426. {
  5427. if (i > 6)
  5428. {
  5429. fontRed.FillForegroundColor = 0;
  5430. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5431. fontRed.FillPattern = FillPattern.SolidForeground;
  5432. }
  5433. cell.CellStyle = fontRed;
  5434. }
  5435. if (i > 2 && i < 7)
  5436. {
  5437. cell.CellStyle = BackgroundColor255_242_204;
  5438. }
  5439. cell.SetCellValue(setCellValue); //写入单元格
  5440. }
  5441. if (overspendSoure.ContainsKey(thisSid)) {
  5442. var overspendId = overspendSoure[thisSid];
  5443. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5444. }
  5445. cloneRowFn();
  5446. existsId.Add(new CarCompare
  5447. {
  5448. DataPrice = item.DatePrice.ObjToDate(),
  5449. Sid = item.SId
  5450. });
  5451. }
  5452. if (item.Equals(lastElem))
  5453. {
  5454. //合并小计行
  5455. //创建合并区域的实例
  5456. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5457. rowStartIndex, // 起始行索引(0-based)
  5458. rowStartIndex, // 结束行索引(0-based)
  5459. 0, // 起始列索引(0-based)
  5460. 3 // 结束列索引(0-based)
  5461. );
  5462. sheet.AddMergedRegion(cellRangeAddress);
  5463. var CellStyle = workbook.CreateCellStyle();
  5464. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5465. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5466. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5467. for (int i = 0; i <= clounmCount; i++)
  5468. {
  5469. if (i > 6)
  5470. {
  5471. var CellStyle1 = workbook.CreateCellStyle();
  5472. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5473. IFont Font = workbook.CreateFont(); // 创建字体
  5474. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5475. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5476. CellStyle1.SetFont(Font);
  5477. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5478. }
  5479. else
  5480. {
  5481. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5482. }
  5483. }
  5484. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5485. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5486. //超时合计
  5487. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5488. //超时数
  5489. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5490. //超时合计费用
  5491. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5492. cloneRowFn();
  5493. // 创建合并区域的实例
  5494. cellRangeAddress = new CellRangeAddress(
  5495. rowStartIndex, // 起始行索引(0-based)
  5496. rowStartIndex, // 结束行索引(0-based)
  5497. 0, // 起始列索引(0-based)
  5498. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5499. );
  5500. // 添加合并区域
  5501. sheet.AddMergedRegion(cellRangeAddress);
  5502. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5503. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5504. }
  5505. }
  5506. mergeRow();
  5507. // 保存修改后的Excel文件到新文件
  5508. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5509. // new FileStream(newFilePath, FileMode.CreateNew)
  5510. using (var stream = new MemoryStream())
  5511. {
  5512. workbook.Write(stream, true);
  5513. stream.Flush();
  5514. stream.Seek(0, SeekOrigin.Begin);
  5515. MemoryStream memoryStream = new MemoryStream();
  5516. stream.CopyTo(memoryStream);
  5517. memoryStream.Seek(0, SeekOrigin.Begin);
  5518. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5519. }
  5520. workbook.Close();
  5521. workbook.Dispose();
  5522. }
  5523. catch (Exception ex)
  5524. {
  5525. jw.Msg = "出现异常!" + ex.Message;
  5526. return Ok(jw);
  5527. }
  5528. }
  5529. if (Zips.Count > 0)
  5530. {
  5531. IOOperatorHelper io = new IOOperatorHelper();
  5532. var byts = io.ConvertZipStream(Zips);
  5533. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5534. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5535. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5536. }
  5537. else
  5538. {
  5539. jw.Msg = "暂无生成文件!";
  5540. }
  5541. return Ok(jw);
  5542. }
  5543. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5544. {
  5545. string outStr = string.Empty;
  5546. switch (i)
  5547. {
  5548. case 0:
  5549. outStr = arr[0].SidName;
  5550. break;
  5551. case 1:
  5552. outStr = arr[0].DataPriceStr;
  5553. break;
  5554. case 2:
  5555. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5556. break;
  5557. case 4:
  5558. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5559. break;
  5560. case 7:
  5561. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5562. {
  5563. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5564. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5565. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5566. }
  5567. break;
  5568. case 8:
  5569. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5570. {
  5571. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5572. }
  5573. break;
  5574. case 9:
  5575. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5576. {
  5577. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5578. }
  5579. break;
  5580. case 10:
  5581. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5582. {
  5583. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5584. }
  5585. break;
  5586. }
  5587. return outStr;
  5588. }
  5589. #region OP行程单
  5590. /// <summary>
  5591. /// OP行程单初始化
  5592. /// </summary>
  5593. /// <param name="dto"></param>
  5594. /// <returns></returns>
  5595. [HttpPost]
  5596. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5597. {
  5598. var jw = JsonView(false);
  5599. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5600. var group = groupList.First();
  5601. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5602. if (group == null)
  5603. {
  5604. jw.Msg = "暂无团组!";
  5605. return Ok(jw);
  5606. }
  5607. group = groupList.Find(x => x.Id == diid);
  5608. if (group == null)
  5609. {
  5610. jw.Msg = "请输入正确的团组ID!";
  5611. return Ok(jw);
  5612. }
  5613. string city = string.Empty;
  5614. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5615. if (blackCode.Count > 0)
  5616. {
  5617. var black = blackCode.First();
  5618. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5619. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5620. if (blackSp.Length > 0)
  5621. {
  5622. try
  5623. {
  5624. var cityArrCode = new List<string>(20);
  5625. foreach (var item in blackSp)
  5626. {
  5627. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5628. var IndexSelect = itemSp[2];
  5629. var cityArrCodeLength = cityArrCode.Count - 1;
  5630. var startCity = IndexSelect.Substring(0, 3);
  5631. if (cityArrCodeLength > 0)
  5632. {
  5633. var arrEndCity = cityArrCode[cityArrCodeLength];
  5634. if (arrEndCity != startCity)
  5635. {
  5636. cityArrCode.Add(startCity.ToUpper());
  5637. }
  5638. }
  5639. else
  5640. {
  5641. cityArrCode.Add(startCity.ToUpper());
  5642. }
  5643. var endCity = IndexSelect.Substring(3, 3);
  5644. cityArrCode.Add(endCity.ToUpper());
  5645. }
  5646. var cityThree = string.Empty;
  5647. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5648. cityThree = cityThree.TrimEnd(',');
  5649. if (string.IsNullOrWhiteSpace(cityThree))
  5650. {
  5651. throw new
  5652. Exception("error");
  5653. }
  5654. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5655. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5656. foreach (var item in cityArrCode)
  5657. {
  5658. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5659. if (find != null)
  5660. {
  5661. city += find.City + "/";
  5662. }
  5663. else
  5664. {
  5665. city += item + "三字码未收入/";
  5666. }
  5667. }
  5668. city = city.TrimEnd('/');
  5669. }
  5670. catch (Exception e)
  5671. {
  5672. city = "黑屏代码格式不正确!";
  5673. }
  5674. }
  5675. }
  5676. else
  5677. {
  5678. city = "未录入黑屏代码";
  5679. }
  5680. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5681. {
  5682. Date = x.Date,
  5683. Days = x.Days,
  5684. Diffgroup = x.Diffgroup,
  5685. Diid = x.Diid,
  5686. Traffic_First = x.Traffic_First,
  5687. Traffic_Second = x.Traffic_Second,
  5688. Trip = x.Trip,
  5689. WeekDay = x.WeekDay,
  5690. Id = x.Id
  5691. }).ToList();
  5692. jw.Data = new
  5693. {
  5694. groupList = groupList.Select(x => new
  5695. {
  5696. x.Id,
  5697. x.TeamName,
  5698. x.TourCode
  5699. }).ToList(),
  5700. groupInfo = new
  5701. {
  5702. group.VisitDays,
  5703. group.TourCode,
  5704. group.VisitPNumber,
  5705. group.TeamName,
  5706. city
  5707. },
  5708. OpTravelList
  5709. };
  5710. jw.Code = 200;
  5711. jw.Msg = "操作成功!";
  5712. return Ok(jw);
  5713. }
  5714. /// <summary>
  5715. /// 删除团组行程单
  5716. /// </summary>
  5717. /// <returns></returns>
  5718. [HttpPost]
  5719. public IActionResult DelTravel(DelOpTravelDto dto)
  5720. {
  5721. var jw = JsonView(false);
  5722. if (dto.UserId <= 0 || dto.Diid <= 0)
  5723. {
  5724. jw.Msg = "请输入正确的参数!";
  5725. return Ok(jw);
  5726. }
  5727. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5728. .SetColumns(x => new Grp_TravelList
  5729. {
  5730. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5731. DeleteUserId = dto.UserId,
  5732. IsDel = 1,
  5733. }).ExecuteCommand();
  5734. jw = JsonView(true);
  5735. return Ok(jw);
  5736. }
  5737. /// <summary>
  5738. /// 行程单保存
  5739. /// </summary>
  5740. /// <returns></returns>
  5741. [HttpPost]
  5742. public IActionResult TravelSave(TravelSaveDto dto)
  5743. {
  5744. var jw = JsonView(false);
  5745. if (dto.Arr.Count > 0)
  5746. {
  5747. try
  5748. {
  5749. _sqlSugar.BeginTran();
  5750. foreach (var item in dto.Arr)
  5751. {
  5752. if (item.Id == 0)
  5753. {
  5754. throw new Exception("请传入正确的Id");
  5755. }
  5756. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5757. .SetColumns(x => new Grp_TravelList
  5758. {
  5759. Trip = item.Trip
  5760. }).ExecuteCommand();
  5761. }
  5762. _sqlSugar.CommitTran();
  5763. jw = JsonView(true);
  5764. }
  5765. catch (Exception ex)
  5766. {
  5767. _sqlSugar.RollbackTran();
  5768. jw.Msg = "程序异常!" + ex.Message;
  5769. }
  5770. }
  5771. else
  5772. {
  5773. jw.Msg = "请传入正确的参数!";
  5774. }
  5775. return Ok(jw);
  5776. }
  5777. /// <summary>
  5778. /// 导出行程单
  5779. /// </summary>
  5780. /// <param name="dto"></param>
  5781. /// <returns></returns>
  5782. [HttpPost]
  5783. public IActionResult ExportTravel(InitOpTravelDto dto)
  5784. {
  5785. var jw = JsonView(false);
  5786. int diid = 0;
  5787. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5788. if (Find == null)
  5789. {
  5790. jw.Msg = "请选择正确的团组!";
  5791. return Ok(jw);
  5792. }
  5793. else
  5794. {
  5795. diid = Find.Id;
  5796. }
  5797. //数据源
  5798. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5799. DataTable dtBlack = null;
  5800. try
  5801. {
  5802. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  5803. }
  5804. catch (Exception)
  5805. {
  5806. jw.Msg = "机票黑屏代码有误!";
  5807. return Ok(jw);
  5808. }
  5809. string CityStr = string.Empty;
  5810. if (dtBlack.Rows.Count == 0)
  5811. {
  5812. jw.Msg = "机票黑屏代码有误!";
  5813. return Ok(jw);
  5814. }
  5815. else
  5816. {
  5817. foreach (DataRow row in dtBlack.Rows)
  5818. {
  5819. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  5820. {
  5821. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  5822. return Ok(jw);
  5823. }
  5824. }
  5825. CityStr = GeneralMethod.GetGroupCityLine(diid,"/");
  5826. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  5827. }
  5828. //创建数据源Table
  5829. DataTable dtSource = new DataTable();
  5830. dtSource.Columns.Add("Days", typeof(string));
  5831. dtSource.Columns.Add("Date", typeof(string));
  5832. dtSource.Columns.Add("Week", typeof(string));
  5833. dtSource.Columns.Add("Traffic", typeof(string));
  5834. dtSource.Columns.Add("Trip", typeof(string));
  5835. //获取数据,放到datatable
  5836. foreach (var item in _travelList)
  5837. {
  5838. DataRow dr = dtSource.NewRow();
  5839. dr["Days"] = item.Days;
  5840. dr["Date"] = item.Date;
  5841. dr["Week"] = item.WeekDay;
  5842. dr["Traffic"] = item.Traffic_First
  5843. + "\r\n"
  5844. + item.Traffic_Second;
  5845. dr["Trip"] = item.Trip;
  5846. dtSource.Rows.Add(dr);
  5847. }
  5848. Dictionary<string, string> dic = new Dictionary<string, string>();
  5849. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5850. dic.Add("City", CityStr);
  5851. dic.Add("Days", Find.VisitDays.ToString());
  5852. dic.Add("DeleCode", Find.TourCode);
  5853. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5854. //模板路径
  5855. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5856. //载入模板
  5857. Document doc = null;
  5858. DocumentBuilder builder = null;
  5859. try
  5860. {
  5861. //载入模板
  5862. doc = new Document(tempPath);
  5863. builder = new DocumentBuilder(doc);
  5864. }
  5865. catch (Exception)
  5866. {
  5867. jw.Msg = "模板位置不存在!";
  5868. return Ok(jw);
  5869. }
  5870. foreach (var key in dic.Keys)
  5871. {
  5872. Bookmark bookmark = doc.Range.Bookmarks[key];
  5873. if (bookmark != null)
  5874. {
  5875. builder.MoveToBookmark(key);
  5876. builder.Write(dic[key]);
  5877. }
  5878. }
  5879. //获取word里所有表格
  5880. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5881. //获取所填表格的序数
  5882. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5883. try
  5884. {
  5885. //循环赋值
  5886. for (int i = 0; i < dtSource.Rows.Count; i++)
  5887. {
  5888. builder.MoveToCell(0, i + 1, 0, 0);
  5889. builder.Write(dtSource.Rows[i]["Days"].ToString());
  5890. builder.MoveToCell(0, i + 1, 1, 0);
  5891. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  5892. builder.MoveToCell(0, i + 1, 2, 0);
  5893. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  5894. var trip = dtSource.Rows[i]["Trip"].ToString();
  5895. builder.MoveToCell(0, i + 1, 3, 0);
  5896. builder.Write(trip);
  5897. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  5898. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  5899. // 获取特定索引的段落
  5900. Paragraph paragraph = (Paragraph)paragraphs[0];
  5901. Run run = paragraph.Runs[0];
  5902. Aspose.Words.Font font = run.Font;
  5903. font.Name = "黑体";
  5904. //设置双休红色
  5905. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  5906. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  5907. paragraph = (Paragraph)paragraphs[1];
  5908. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  5909. {
  5910. run = paragraph.Runs[0];
  5911. font = run.Font;
  5912. font.Color = Color.Red;
  5913. }
  5914. }
  5915. }
  5916. catch (Exception ex)
  5917. {
  5918. }
  5919. //删除多余行
  5920. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  5921. {
  5922. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  5923. }
  5924. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  5925. if (!Directory.Exists(savePath))
  5926. {
  5927. try
  5928. {
  5929. Directory.CreateDirectory(savePath);
  5930. }
  5931. catch
  5932. {
  5933. }
  5934. }
  5935. string path = savePath + Find.TeamName + "出访日程.docx";
  5936. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  5937. try
  5938. {
  5939. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  5940. jw = JsonView(true, "导出成功", ftpPath);
  5941. }
  5942. catch (Exception)
  5943. {
  5944. jw = JsonView(false);
  5945. }
  5946. return Ok(jw);
  5947. }
  5948. /// <summary>
  5949. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  5950. /// </summary>
  5951. /// <param name="num"></param>
  5952. /// <returns></returns>
  5953. string GetNum(string num)
  5954. {
  5955. string str = "";
  5956. switch (num)
  5957. {
  5958. case "1":
  5959. str = "一";
  5960. break;
  5961. case "2":
  5962. str = "二";
  5963. break;
  5964. case "3":
  5965. str = "三";
  5966. break;
  5967. case "4":
  5968. str = "四";
  5969. break;
  5970. case "5":
  5971. str = "五";
  5972. break;
  5973. case "6":
  5974. str = "六";
  5975. break;
  5976. case "7":
  5977. str = "七";
  5978. break;
  5979. case "8":
  5980. str = "八";
  5981. break;
  5982. case "9":
  5983. str = "九";
  5984. break;
  5985. case "10":
  5986. str = "十";
  5987. break;
  5988. case "11":
  5989. str = "十一";
  5990. break;
  5991. case "12":
  5992. str = "十二";
  5993. break;
  5994. case "一":
  5995. str = "1";
  5996. break;
  5997. case "二":
  5998. str = "2";
  5999. break;
  6000. case "三":
  6001. str = "3";
  6002. break;
  6003. case "四":
  6004. str = "4";
  6005. break;
  6006. case "五":
  6007. str = "5";
  6008. break;
  6009. case "六":
  6010. str = "6";
  6011. break;
  6012. case "七":
  6013. str = "7";
  6014. break;
  6015. case "八":
  6016. str = "8";
  6017. break;
  6018. case "九":
  6019. str = "9";
  6020. break;
  6021. case "十":
  6022. str = "10";
  6023. break;
  6024. case "十一":
  6025. str = "11";
  6026. break;
  6027. case "十二":
  6028. str = "12";
  6029. break;
  6030. }
  6031. return str;
  6032. }
  6033. #endregion
  6034. #endregion
  6035. #region 团组成本
  6036. /// <summary>
  6037. /// 团组成本数据初始化
  6038. /// </summary>
  6039. /// <param name="dto"></param>
  6040. /// <returns></returns>
  6041. [HttpPost]
  6042. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6043. {
  6044. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6045. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6046. WHEN COUNT(*) >= 0 THEN 'True'
  6047. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6048. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6049. ").ToList(); //团组列表
  6050. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6051. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6052. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6053. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6054. if (groupinfoValue != null)
  6055. {
  6056. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6057. var spArr = new string[1] { countryArr };
  6058. if (countryArr.Contains("|"))
  6059. {
  6060. spArr = countryArr.Split("|");
  6061. }
  6062. else if (countryArr.Contains("、"))
  6063. {
  6064. spArr = countryArr.Split("、");
  6065. }
  6066. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6067. {
  6068. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6069. if (dbQueryCountry != null)
  6070. {
  6071. visaCountryInfoArr.Add(dbQueryCountry);
  6072. }
  6073. }
  6074. }
  6075. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6076. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6077. var create = _GroupCostRepository.
  6078. CreateGroupCostByBlackCode(dto.Diid);
  6079. if (groupCost.Count == 0 && create.Code == 0)
  6080. {
  6081. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6082. }
  6083. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6084. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6085. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6086. groupCostMap = groupCostMap.Select(x =>
  6087. {
  6088. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6089. {
  6090. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6091. }
  6092. return x;
  6093. }).ToList();
  6094. //GroupCostParameter.Add(new
  6095. // Grp_GroupCostParameter());
  6096. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6097. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6098. return Ok(JsonView(new
  6099. {
  6100. groupList,
  6101. groupInfo,
  6102. groupChecks,
  6103. groupCost = groupCostMap,
  6104. hotelNumber,
  6105. GroupCostParameter = GroupCostParameterMap,
  6106. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6107. {
  6108. x.VisaCountry,
  6109. x.VisaPrice,
  6110. x.Id,
  6111. }).ToList(),
  6112. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6113. blackCodeIsTrue = create.Code == 0 ? true : false,
  6114. hotelIsTrue = hotelIsTrue,
  6115. }));
  6116. }
  6117. /// <summary>
  6118. /// 团组成本信息保存
  6119. /// </summary>
  6120. /// <param name="dto"></param>
  6121. /// <returns></returns>
  6122. [HttpPost]
  6123. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6124. {
  6125. if (dto.Diid <= 0 || dto.Userid <= 0)
  6126. {
  6127. return Ok(JsonView(false));
  6128. }
  6129. JsonView jw = null;
  6130. bool isTrue = false;
  6131. #region 复制团组成本
  6132. //if (dto.Diid == 2581)
  6133. //{
  6134. // dto.Diid = 2599;
  6135. // dto.CheckBoxs.ForEach(x =>
  6136. // {
  6137. // x.Diid = 2599;
  6138. // });
  6139. // dto.GroupCosts.ForEach(x =>
  6140. // {
  6141. // x.Diid = 2599;
  6142. // });
  6143. // dto.CostTypeHotelNumbers.ForEach(x =>
  6144. // {
  6145. // x.Diid = 2599;
  6146. // });
  6147. // dto.GroupCostParameters.ForEach(x =>
  6148. // {
  6149. // x.DiId = 2599;
  6150. // });
  6151. //}
  6152. #endregion
  6153. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6154. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6155. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6156. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6157. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6158. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6159. try
  6160. {
  6161. _sqlSugar.BeginTran();
  6162. isTrue = await _GroupCostRepository.
  6163. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6164. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6165. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6166. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6167. _sqlSugar.CommitTran();
  6168. jw = JsonView(true, "保存成功!", isTrue);
  6169. }
  6170. catch (Exception)
  6171. {
  6172. _sqlSugar.RollbackTran();
  6173. jw = JsonView(false);
  6174. }
  6175. return Ok(jw);
  6176. }
  6177. /// <summary>
  6178. /// 司兼导数据
  6179. /// </summary>
  6180. /// <param name="dto"></param>
  6181. /// <returns></returns>
  6182. [HttpPost]
  6183. public IActionResult GetCarGuides(CarGuidesDto dto)
  6184. {
  6185. JsonView jw = null;
  6186. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6187. jw = JsonView(true, "获取成功!", Data);
  6188. return Ok(jw);
  6189. }
  6190. /// <summary>
  6191. /// 导游数据
  6192. /// </summary>
  6193. /// <param name="dto"></param>
  6194. /// <returns></returns>
  6195. [HttpPost]
  6196. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6197. {
  6198. JsonView jw = null;
  6199. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6200. // 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
  6201. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6202. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6203. jw = JsonView(true, "获取成功!", Data);
  6204. return Ok(jw);
  6205. }
  6206. /// <summary>
  6207. /// 成本车数据
  6208. /// </summary>
  6209. /// <param name="dto"></param>
  6210. /// <returns></returns>
  6211. [HttpPost]
  6212. public IActionResult GetCarInfo(CarGuidesDto dto)
  6213. {
  6214. JsonView jw = null;
  6215. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6216. jw = JsonView(true, "获取成功!", Data);
  6217. return Ok(jw);
  6218. }
  6219. /// <summary>
  6220. /// 景点数据
  6221. /// </summary>
  6222. /// <param name="dto"></param>
  6223. /// <returns></returns>
  6224. [HttpPost]
  6225. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6226. {
  6227. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6228. return Ok(JsonView(true, "获取成功!", Data));
  6229. }
  6230. /// <summary>
  6231. /// 成本通知
  6232. /// </summary>
  6233. /// <param name="dto"></param>
  6234. /// <returns></returns>
  6235. [HttpPost]
  6236. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6237. {
  6238. if (dto.Diid < 0)
  6239. {
  6240. return Ok(JsonView(false));
  6241. }
  6242. JsonView jw = null;
  6243. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6244. if (GroupCostParameter != null)
  6245. {
  6246. int IsShare = 0;
  6247. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6248. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6249. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6250. string msg = string.Empty;
  6251. if (isTrue)
  6252. {
  6253. if (IsShare == 0)
  6254. {
  6255. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6256. }
  6257. else
  6258. {
  6259. #region 企微通知对应岗位用户
  6260. try
  6261. {
  6262. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6263. }
  6264. catch (Exception ex)
  6265. {
  6266. }
  6267. #endregion
  6268. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6269. }
  6270. jw = JsonView(isTrue, msg, new { IsShare });
  6271. }
  6272. else
  6273. {
  6274. msg = "修改失败!";
  6275. jw = JsonView(isTrue, msg);
  6276. }
  6277. }
  6278. else
  6279. {
  6280. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6281. }
  6282. return Ok(jw);
  6283. }
  6284. /// <summary>
  6285. /// 导出报价单
  6286. /// </summary>
  6287. /// <param name="dto"></param>
  6288. /// <returns></returns>
  6289. [HttpPost]
  6290. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6291. {
  6292. if (dto.Diid == 0)
  6293. {
  6294. return Ok(JsonView(false, "请传递团组id"));
  6295. }
  6296. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6297. if (deleInfo.Code != 0)
  6298. {
  6299. return Ok(JsonView(false, "团组信息查询失败!"));
  6300. }
  6301. var di = deleInfo.Data as DelegationInfoWebView;
  6302. if (di != null)
  6303. {
  6304. //文件名
  6305. string strFileName = di.TeamName + "-收款账单.doc";
  6306. //获取模板
  6307. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6308. //载入模板
  6309. Document doc = new Document(tmppath);
  6310. decimal TotalPrice = 0.00M;
  6311. string itemStr = string.Empty;
  6312. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6313. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6314. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6315. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6316. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6317. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6318. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6319. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6320. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6321. foreach (var cost in groupCostType)
  6322. {
  6323. var List = cost.ToList();
  6324. if (cost.Key == "A")
  6325. {
  6326. foreach (var ListItem in List)
  6327. {
  6328. if (ListItem.number > 0)
  6329. {
  6330. if (ListItem.code.Contains("TBR"))
  6331. {
  6332. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6333. }
  6334. else
  6335. {
  6336. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6337. }
  6338. TotalPrice += (ListItem.number * ListItem.price);
  6339. }
  6340. }
  6341. }
  6342. else
  6343. {
  6344. itemStr = itemStr.Insert(0, "A段\r\n");
  6345. itemStr += "B段\r\n";
  6346. foreach (var ListItem in List)
  6347. {
  6348. if (ListItem.number > 0)
  6349. {
  6350. if (ListItem.code.Contains("TBR"))
  6351. {
  6352. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6353. }
  6354. else
  6355. {
  6356. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6357. }
  6358. TotalPrice += (ListItem.number * ListItem.price);
  6359. }
  6360. }
  6361. }
  6362. }
  6363. #region 替换Word模板书签内容
  6364. Dictionary<string, string> marks = new Dictionary<string, string>();
  6365. marks.Add("To", di.ClientUnit);//付款方
  6366. marks.Add("ToTel", di.TellPhone);//付款方电话
  6367. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6368. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6369. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6370. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6371. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6372. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  6373. marks.Add("PayItemContent", itemStr);//详细信息
  6374. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6375. #endregion
  6376. ////注
  6377. //if (doc.Range.Bookmarks["Attention"] != null)
  6378. //{
  6379. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6380. // mark.Text = frList[0].Attention;
  6381. //}
  6382. foreach (var item in marks.Keys)
  6383. {
  6384. if (doc.Range.Bookmarks[item] != null)
  6385. {
  6386. Bookmark mark = doc.Range.Bookmarks[item];
  6387. mark.Text = marks[item];
  6388. }
  6389. }
  6390. byte[] bytes = null;
  6391. using (MemoryStream stream = new MemoryStream())
  6392. {
  6393. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6394. bytes = stream.ToArray();
  6395. }
  6396. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6397. return Ok(JsonView(true, "", new
  6398. {
  6399. Data = bytes,
  6400. strFileName,
  6401. }));
  6402. }
  6403. else
  6404. {
  6405. return Ok(JsonView(false, "团组信息不存在!"));
  6406. }
  6407. }
  6408. /// <summary>
  6409. /// 导出团组成本
  6410. /// </summary>
  6411. /// <param name="dto"></param>
  6412. /// <returns></returns>
  6413. [HttpPost]
  6414. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  6415. {
  6416. var jw = JsonView(false);
  6417. if (dto.Diid == 0)
  6418. {
  6419. return Ok(JsonView(false, "请传递团组id"));
  6420. }
  6421. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6422. if (deleInfo.Code != 0)
  6423. {
  6424. return Ok(JsonView(false, "团组信息查询失败!"));
  6425. }
  6426. var di = deleInfo.Data as DelegationInfoWebView;
  6427. if (di == null)
  6428. {
  6429. return Ok(JsonView(false, "团组信息查询失败!"));
  6430. }
  6431. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  6432. WorkbookDesigner designer = new WorkbookDesigner();
  6433. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  6434. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  6435. for (int i = 0; i < List_GC.Count; i++)
  6436. {
  6437. GroupCost_Excel gc = new GroupCost_Excel();
  6438. gc.Id = List_GC[i].Id;
  6439. gc.Diid = List_GC[i].Diid.ToString();
  6440. gc.DAY = List_GC[i].DAY;
  6441. string week = "";
  6442. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  6443. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  6444. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  6445. gc.ITIN = List_GC[i].ITIN;
  6446. gc.CarType = List_GC[i].CarType;
  6447. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  6448. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  6449. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  6450. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  6451. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  6452. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  6453. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  6454. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  6455. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  6456. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  6457. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  6458. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  6459. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6460. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6461. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  6462. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  6463. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  6464. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  6465. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  6466. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  6467. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  6468. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  6469. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  6470. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  6471. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  6472. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  6473. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  6474. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  6475. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  6476. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  6477. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  6478. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  6479. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  6480. List_GC1.Add(gc);
  6481. }
  6482. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  6483. dt.TableName = "TB";
  6484. //报表标题等不用dt的值
  6485. designer.SetDataSource("TeamName", dto.title.TeamName);
  6486. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  6487. designer.SetDataSource("Tax", dto.title.Tax);
  6488. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  6489. designer.SetDataSource("Currency", dto.title.Currency);
  6490. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  6491. designer.SetDataSource("Rate", dto.title.Rate);
  6492. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  6493. var Aparams = hotels.Find(x => x.Type == "Default");
  6494. if (Aparams == null)
  6495. {
  6496. return Ok(jw);
  6497. }
  6498. //酒店数量
  6499. var txtSGRNumber = Aparams.SGR.ToString();
  6500. var txtTBRNumber = Aparams.TBR.ToString();
  6501. var txtJSESNumber = Aparams.JSES.ToString();
  6502. var txtSUITENumbe = Aparams.SUITE.ToString();
  6503. if (dto.costType == "B")
  6504. {
  6505. Aparams = hotels.Find(x => x.Type == "A");
  6506. var Bparams = hotels.Find(x => x.Type == "B");
  6507. if (Aparams == null || Bparams == null)
  6508. {
  6509. return Ok(jw);
  6510. }
  6511. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  6512. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  6513. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  6514. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  6515. }
  6516. designer.SetDataSource("SGRNumber", txtSGRNumber);
  6517. designer.SetDataSource("TBRNumber", txtTBRNumber);
  6518. designer.SetDataSource("JSESNumber", txtJSESNumber);
  6519. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  6520. var ws = designer.Workbook.Worksheets[0];
  6521. int Row = List_GC.Count;
  6522. int startIndex = 11;
  6523. int HideRows = 0;
  6524. List<int> hideRowsList = new List<int>();
  6525. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  6526. #region A段left数据
  6527. var left = dto.leftInfo.Find(x => x.Type == "A");
  6528. if (left == null)
  6529. {
  6530. return Ok(jw);
  6531. }
  6532. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  6533. if (leftBindData != null)
  6534. {
  6535. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  6536. designer.SetDataSource("VisaRS", leftBindData.rs);
  6537. designer.SetDataSource("VisaXS", leftBindData.xs);
  6538. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6539. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6540. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6541. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6542. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6543. }
  6544. else
  6545. {
  6546. hideRowsList.Add(Row + startIndex + HideRows);
  6547. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6548. }
  6549. HideRows += 2;
  6550. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  6551. if (leftBindData != null)
  6552. {
  6553. designer.SetDataSource("BXDRCB", leftBindData.cb);
  6554. designer.SetDataSource("BXRS", leftBindData.rs);
  6555. designer.SetDataSource("BXXS", leftBindData.xs);
  6556. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6557. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6558. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6559. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6560. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6561. }
  6562. else
  6563. {
  6564. hideRowsList.Add(Row + startIndex + HideRows);
  6565. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6566. }
  6567. HideRows += 2;
  6568. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6569. if (leftBindData != null)
  6570. {
  6571. designer.SetDataSource("HSDRCB", leftBindData.cb);
  6572. designer.SetDataSource("HSRS", leftBindData.rs);
  6573. designer.SetDataSource("HSXS", leftBindData.xs);
  6574. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6575. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6576. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6577. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6578. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6579. }
  6580. else
  6581. {
  6582. hideRowsList.Add(Row + startIndex + HideRows);
  6583. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6584. }
  6585. HideRows += 2;
  6586. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6587. if (leftBindData != null)
  6588. {
  6589. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  6590. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  6591. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  6592. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6593. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6594. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6595. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6596. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6597. }
  6598. else
  6599. {
  6600. hideRowsList.Add(Row + startIndex + HideRows);
  6601. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6602. }
  6603. HideRows += 2;
  6604. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6605. if (leftBindData != null)
  6606. {
  6607. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  6608. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  6609. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  6610. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6611. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6612. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6613. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6614. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6615. }
  6616. else
  6617. {
  6618. hideRowsList.Add(Row + startIndex + HideRows);
  6619. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6620. }
  6621. HideRows += 2;
  6622. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  6623. if (leftBindData != null)
  6624. {
  6625. ////TBR
  6626. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  6627. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  6628. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  6629. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6630. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6631. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6632. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6633. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6634. }
  6635. else
  6636. {
  6637. hideRowsList.Add(Row + startIndex + HideRows);
  6638. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6639. }
  6640. HideRows += 2;
  6641. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  6642. if (leftBindData != null)
  6643. {
  6644. ////SGR
  6645. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  6646. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  6647. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  6648. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6649. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6650. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6651. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6652. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6653. }
  6654. else
  6655. {
  6656. hideRowsList.Add(Row + startIndex + HideRows);
  6657. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6658. }
  6659. HideRows += 2;
  6660. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  6661. if (leftBindData != null)
  6662. {
  6663. ////JS/ES
  6664. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  6665. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  6666. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  6667. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6668. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6669. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6670. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6671. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6672. }
  6673. else
  6674. {
  6675. hideRowsList.Add(Row + startIndex + HideRows);
  6676. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6677. }
  6678. HideRows += 2;
  6679. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  6680. if (leftBindData != null)
  6681. {
  6682. ////SUITE
  6683. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  6684. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  6685. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  6686. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6687. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6688. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6689. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6690. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6691. }
  6692. else
  6693. {
  6694. hideRowsList.Add(Row + startIndex + HideRows);
  6695. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6696. }
  6697. HideRows += 2;
  6698. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  6699. if (leftBindData != null)
  6700. {
  6701. designer.SetDataSource("DJDRCB", leftBindData.cb);
  6702. designer.SetDataSource("DJRS", leftBindData.rs);
  6703. designer.SetDataSource("DJXS", leftBindData.xs);
  6704. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6705. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6706. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6707. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6708. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6709. }
  6710. else
  6711. {
  6712. hideRowsList.Add(Row + startIndex + HideRows);
  6713. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6714. }
  6715. HideRows += 2;
  6716. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6717. if (leftBindData != null)
  6718. {
  6719. designer.SetDataSource("HCPCB", leftBindData.cb);
  6720. designer.SetDataSource("HCPRS", leftBindData.rs);
  6721. designer.SetDataSource("HCPXS", leftBindData.xs);
  6722. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6723. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6724. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6725. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6726. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6727. }
  6728. else
  6729. {
  6730. hideRowsList.Add(Row + startIndex + HideRows);
  6731. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6732. }
  6733. HideRows += 2;
  6734. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  6735. if (leftBindData != null)
  6736. {
  6737. designer.SetDataSource("CPCB", leftBindData.cb);
  6738. designer.SetDataSource("CPRS", leftBindData.rs);
  6739. designer.SetDataSource("CPXS", leftBindData.xs);
  6740. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6741. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6742. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6743. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6744. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6745. }
  6746. else
  6747. {
  6748. hideRowsList.Add(Row + startIndex + HideRows);
  6749. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6750. }
  6751. HideRows += 2;
  6752. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  6753. if (leftBindData != null)
  6754. {
  6755. designer.SetDataSource("GWDRCD", leftBindData.cb);
  6756. designer.SetDataSource("GWRS", leftBindData.rs);
  6757. designer.SetDataSource("GWXS", leftBindData.xs);
  6758. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6759. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6760. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6761. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6762. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6763. }
  6764. else
  6765. {
  6766. hideRowsList.Add(Row + startIndex + HideRows);
  6767. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6768. }
  6769. HideRows += 2;
  6770. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  6771. if (leftBindData != null)
  6772. {
  6773. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  6774. designer.SetDataSource("LYJRS", leftBindData.rs);
  6775. designer.SetDataSource("LYJXS", leftBindData.xs);
  6776. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6777. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6778. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6779. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6780. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6781. }
  6782. else
  6783. {
  6784. hideRowsList.Add(Row + startIndex + HideRows);
  6785. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6786. }
  6787. #endregion
  6788. #region A段Right信息
  6789. var right = dto.rightInfo.Find(x => x.Type == "A");
  6790. if (right == null)
  6791. {
  6792. return Ok(jw);
  6793. }
  6794. HideRows += 4;
  6795. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  6796. if (rightBindData != null)
  6797. {
  6798. //经济舱 + 双人间 TBR
  6799. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  6800. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  6801. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6802. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  6803. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6804. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6805. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6806. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6807. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6808. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6809. }
  6810. else
  6811. {
  6812. hideRowsList.Add(Row + startIndex + HideRows);
  6813. }
  6814. HideRows += 2;
  6815. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  6816. if (rightBindData != null)
  6817. {
  6818. //经济舱 + 单人间 SGR
  6819. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  6820. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  6821. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6822. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  6823. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6824. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6825. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6826. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6827. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6828. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6829. }
  6830. else
  6831. {
  6832. hideRowsList.Add(Row + startIndex + HideRows);
  6833. }
  6834. HideRows += 2;
  6835. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  6836. if (rightBindData != null)
  6837. {
  6838. //公务舱 + 单人间 SGR
  6839. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  6840. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  6841. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6842. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  6843. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6844. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6845. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6846. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6847. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6848. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6849. }
  6850. else
  6851. {
  6852. hideRowsList.Add(Row + startIndex + HideRows);
  6853. }
  6854. HideRows += 2;
  6855. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  6856. if (rightBindData != null)
  6857. {
  6858. //公务舱 + 小套房 JSES
  6859. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  6860. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  6861. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6862. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  6863. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6864. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6865. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6866. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6867. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6868. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6869. }
  6870. else
  6871. {
  6872. hideRowsList.Add(Row + startIndex + HideRows);
  6873. }
  6874. HideRows += 2;
  6875. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  6876. if (rightBindData != null)
  6877. {
  6878. //公务舱 + 小套房 JSES
  6879. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  6880. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  6881. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6882. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  6883. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6884. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6885. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6886. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6887. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6888. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6889. }
  6890. else
  6891. {
  6892. hideRowsList.Add(Row + startIndex + HideRows);
  6893. }
  6894. HideRows += 2;
  6895. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  6896. if (rightBindData != null)
  6897. {
  6898. //经济舱 + 大套房
  6899. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  6900. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  6901. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6902. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  6903. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6904. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6905. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6906. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6907. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6908. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6909. }
  6910. else
  6911. {
  6912. hideRowsList.Add(Row + startIndex + HideRows);
  6913. }
  6914. #endregion
  6915. #region B段标题清空
  6916. designer.SetDataSource("CostBDRCB", "");
  6917. designer.SetDataSource("CostBRS", "");
  6918. designer.SetDataSource("CostBXS", "");
  6919. designer.SetDataSource("CostBZCB", "");
  6920. designer.SetDataSource("CostBDRBJ", "");
  6921. designer.SetDataSource("CostBZBJ", "");
  6922. designer.SetDataSource("CostBDRLR", "");
  6923. designer.SetDataSource("CostBZLR", "");
  6924. designer.SetDataSource("CostBDRCBOM", "");
  6925. designer.SetDataSource("CostBRSOM", "");
  6926. designer.SetDataSource("CostBZCBOM", "");
  6927. designer.SetDataSource("CostBDRBJOM", "");
  6928. designer.SetDataSource("CostBZBJOM", "");
  6929. designer.SetDataSource("CostBDRLROM", "");
  6930. designer.SetDataSource("CostBZLROM", "");
  6931. #endregion
  6932. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  6933. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  6934. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  6935. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  6936. designer.SetDataSource("DJName", "地接(CNY)");
  6937. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  6938. designer.SetDataSource("CPName", "地接-船票(CNY)");
  6939. designer.SetDataSource("GWName", "公务(CNY)");
  6940. designer.SetDataSource("YQHName", "邀请函(CNY)");
  6941. designer.SetDataSource("LYJName", "零用金(CNY)");
  6942. designer.SetDataSource("HSName", "核酸检测(CNY)");
  6943. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  6944. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  6945. designer.SetDataSource("BXName", "保险(CNY)");
  6946. designer.SetDataSource("VisaName", "签证(CNY)");
  6947. #region B段基本数据
  6948. if (dto.costType == "B")
  6949. {
  6950. left = dto.leftInfo.Find(x => x.Type == "B");
  6951. if (left == null)
  6952. {
  6953. return Ok(jw);
  6954. }
  6955. #region B段left数据
  6956. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6957. if (leftBindData != null)
  6958. {
  6959. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  6960. designer.SetDataSource("BHSRS", leftBindData.rs);
  6961. designer.SetDataSource("BHSXS", leftBindData.xs);
  6962. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6963. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6964. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6965. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6966. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6967. }
  6968. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6969. if (leftBindData != null)
  6970. {
  6971. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  6972. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  6973. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  6974. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6975. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6976. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6977. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6978. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6979. }
  6980. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6981. if (leftBindData != null)
  6982. {
  6983. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  6984. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  6985. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  6986. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6987. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6988. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6989. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6990. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6991. }
  6992. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6993. if (leftBindData != null)
  6994. {
  6995. designer.SetDataSource("BHCPCB", leftBindData.cb);
  6996. designer.SetDataSource("BHCPRS", leftBindData.rs);
  6997. designer.SetDataSource("BHCPXS", leftBindData.xs);
  6998. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6999. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7000. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7001. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7002. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7003. }
  7004. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7005. if (leftBindData != null)
  7006. {
  7007. designer.SetDataSource("BCPCB", leftBindData.cb);
  7008. designer.SetDataSource("BCPRS", leftBindData.rs);
  7009. designer.SetDataSource("BCPXS", leftBindData.xs);
  7010. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7011. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7012. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7013. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7014. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7015. }
  7016. //TBR
  7017. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7018. if (leftBindData != null)
  7019. {
  7020. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7021. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7022. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7023. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7024. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7025. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7026. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7027. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7028. }
  7029. //SGR
  7030. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7031. if (leftBindData != null)
  7032. {
  7033. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7034. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7035. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7036. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7037. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7038. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7039. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7040. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7041. }
  7042. //JS/ES
  7043. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7044. if (leftBindData != null)
  7045. {
  7046. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7047. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7048. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7049. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7050. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7051. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7052. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7053. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7054. }
  7055. //SUITE
  7056. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7057. if (leftBindData != null)
  7058. {
  7059. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7060. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7061. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7062. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7063. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7064. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7065. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7066. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7067. }
  7068. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7069. if (leftBindData != null)
  7070. {
  7071. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7072. designer.SetDataSource("BDJRS", leftBindData.rs);
  7073. designer.SetDataSource("BDJXS", leftBindData.xs);
  7074. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7075. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7076. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7077. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7078. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7079. }
  7080. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7081. if (leftBindData != null)
  7082. {
  7083. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7084. designer.SetDataSource("BGWRS", leftBindData.rs);
  7085. designer.SetDataSource("BGWXS", leftBindData.xs);
  7086. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7087. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7088. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7089. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7090. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7091. }
  7092. #region 优化方案
  7093. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7094. //excelBind.Add("零用金", new {
  7095. //cb="",
  7096. //rs="",
  7097. //xs ="",
  7098. //zcb = "",
  7099. //});
  7100. #endregion
  7101. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7102. if (leftBindData != null)
  7103. {
  7104. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7105. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7106. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7107. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7108. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7109. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7110. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7111. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7112. }
  7113. #endregion
  7114. #region B段Right信息
  7115. right = dto.rightInfo.Find(x => x.Type == "B");
  7116. if (right == null)
  7117. {
  7118. return Ok(jw);
  7119. }
  7120. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7121. if (rightBindData != null)
  7122. {
  7123. //经济舱 + 双人间 TBR
  7124. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7125. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7126. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7127. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7128. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7129. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7130. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7131. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7132. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7133. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7134. }
  7135. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7136. if (rightBindData != null)
  7137. {
  7138. //经济舱 + 单人间 SGR
  7139. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7140. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7141. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7142. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7143. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7144. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7145. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7146. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7147. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7148. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7149. }
  7150. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7151. if (rightBindData != null)
  7152. {
  7153. //公务舱 + 单人间 SGR
  7154. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7155. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7156. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7157. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7158. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7159. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7160. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7161. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7162. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7163. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7164. }
  7165. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7166. if (rightBindData != null)
  7167. {
  7168. //公务舱 + 小套房 JSES
  7169. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7170. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7171. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7172. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7173. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7174. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7175. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7176. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7177. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7178. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7179. }
  7180. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7181. if (rightBindData != null)
  7182. {
  7183. //公务舱 + 小套房 JSES
  7184. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7185. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7186. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7187. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7188. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7189. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7190. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7191. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7192. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7193. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7194. }
  7195. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7196. if (rightBindData != null)
  7197. {
  7198. //经济舱 + 大套房
  7199. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7200. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7201. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7202. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7203. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7204. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7205. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7206. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7207. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7208. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7209. }
  7210. #endregion
  7211. #region 标题
  7212. designer.SetDataSource("CostBDRCB", "单人成本");
  7213. designer.SetDataSource("CostBRS", "人数");
  7214. designer.SetDataSource("CostBXS", "系数");
  7215. designer.SetDataSource("CostBZCB", "总成本");
  7216. designer.SetDataSource("CostBDRBJ", "单人报价");
  7217. designer.SetDataSource("CostBZBJ", "总报价");
  7218. designer.SetDataSource("CostBDRLR", "单人利润");
  7219. designer.SetDataSource("CostBZLR", "总利润");
  7220. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7221. designer.SetDataSource("CostBRSOM", "人数");
  7222. designer.SetDataSource("CostBZCBOM", "总成本");
  7223. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7224. designer.SetDataSource("CostBZBJOM", "总报价");
  7225. designer.SetDataSource("CostBDRLROM", "单人利润");
  7226. designer.SetDataSource("CostBZLROM", "总利润");
  7227. #endregion
  7228. }
  7229. #endregion
  7230. designer.SetDataSource("TzZCB2", TzZCB2);
  7231. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7232. designer.SetDataSource("TzZLR2", TzZLR2);
  7233. string[] dataSourceKeys = new string[]
  7234. {
  7235. "VF",
  7236. "TGS",
  7237. "TGOF",
  7238. "TGM",
  7239. "TGA",
  7240. "TGTF",
  7241. "TGEF",
  7242. "CFM",
  7243. "CFOF",
  7244. "B",
  7245. "L",
  7246. "D",
  7247. "TBR",
  7248. "SGR",
  7249. "JSES",
  7250. "Suite",
  7251. "TV",
  7252. "1L",
  7253. "IF",
  7254. "EF",
  7255. "BRF",
  7256. "TE",
  7257. "TGT",
  7258. "DRVT",
  7259. "PC",
  7260. "TLF",
  7261. "ECT"
  7262. };
  7263. foreach (var item in dataSourceKeys)
  7264. {
  7265. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7266. if (find != null)
  7267. {
  7268. designer.SetDataSource(item, find.text);
  7269. }
  7270. else
  7271. {
  7272. designer.SetDataSource(item, 0);
  7273. }
  7274. }
  7275. designer.SetDataSource(dt);
  7276. //根据数据源处理生成报表内容
  7277. designer.Process();
  7278. designer.Workbook.Worksheets[0].Name = "清单";
  7279. Worksheet sheet = designer.Workbook.Worksheets[0];
  7280. foreach (var Rowindex in hideRowsList)
  7281. {
  7282. ws.Cells.HideRows(Rowindex, 2);
  7283. }
  7284. byte[] bytes = null;
  7285. string strFileName = di.TeamName + "-团组-成本.xls";
  7286. using (MemoryStream stream = new MemoryStream())
  7287. {
  7288. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7289. bytes = stream.ToArray();
  7290. }
  7291. return Ok(JsonView(true, "", new
  7292. {
  7293. Data = bytes,
  7294. strFileName,
  7295. }));
  7296. }
  7297. /// <summary>
  7298. /// 导出客户报表
  7299. /// </summary>
  7300. /// <returns></returns>
  7301. [HttpPost]
  7302. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7303. {
  7304. var jw = JsonView(false);
  7305. if (dto.Diid == 0)
  7306. {
  7307. return Ok(JsonView(false, "请传递团组id"));
  7308. }
  7309. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7310. if (deleInfo.Code != 0)
  7311. {
  7312. return Ok(JsonView(false, "团组信息查询失败!"));
  7313. }
  7314. var di = deleInfo.Data as DelegationInfoWebView;
  7315. if (di == null)
  7316. {
  7317. return Ok(JsonView(false, "团组信息查询失败!"));
  7318. }
  7319. //文件名
  7320. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7321. //获取模板
  7322. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7323. //载入模板
  7324. Document doc = new Document(tmppath);
  7325. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7326. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7327. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7328. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7329. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7330. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7331. if (AParameter == null)
  7332. {
  7333. return Ok(JsonView(false, "系数不存在!"));
  7334. }
  7335. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7336. , TzAirDesc, TzZCost;
  7337. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7338. = TzAirDesc = TzZCost = string.Empty;
  7339. TzNumber = AParameter.CostTypenumber.ToString();
  7340. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7341. CarGuides1 = dto.CarGuides1;
  7342. Meal = dto.Meal;
  7343. SubsidizedMeals = dto.SubsidizedMeals;
  7344. NightRepair = dto.NightRepair;
  7345. AttractionsTickets = dto.AttractionsTickets;
  7346. MiscellaneousFees = dto.MiscellaneousFees;
  7347. ATip = dto.ATip;
  7348. TzHotelDesc = "";
  7349. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7350. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7351. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7352. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7353. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7354. TzAirDesc = "";
  7355. TzZCost = dto.TzZCost;
  7356. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7357. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7358. var index = 1;
  7359. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7360. foreach (var item in TzHotelDescArr)
  7361. {
  7362. if (AinfoArr != null)
  7363. {
  7364. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7365. if (Ainfo != null)
  7366. {
  7367. if (int.Parse(Ainfo.rs) <= 0)
  7368. {
  7369. continue;
  7370. }
  7371. var hotelText = string.Empty;
  7372. switch (item)
  7373. {
  7374. case "SGR":
  7375. hotelText = "单人间";
  7376. break;
  7377. case "JSES":
  7378. hotelText = "小套房";
  7379. break;
  7380. case "SUITE":
  7381. hotelText = "套房";
  7382. break;
  7383. case "TBR":
  7384. hotelText = "双人间";
  7385. break;
  7386. }
  7387. if (item != "TBR")
  7388. {
  7389. 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";
  7390. }
  7391. else
  7392. {
  7393. 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";
  7394. }
  7395. index++;
  7396. }
  7397. }
  7398. }
  7399. index = 1;
  7400. foreach (var item in TzAirDescArr)
  7401. {
  7402. if (AinfoArr != null)
  7403. {
  7404. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7405. if (Ainfo != null)
  7406. {
  7407. if (int.Parse(Ainfo.rs) <= 0)
  7408. {
  7409. continue;
  7410. }
  7411. 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";
  7412. index++;
  7413. }
  7414. }
  7415. }
  7416. if (dto.costType == "B")
  7417. {
  7418. if (BParameter == null)
  7419. {
  7420. return Ok(JsonView(false, "B段系数不存在!"));
  7421. }
  7422. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  7423. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  7424. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  7425. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  7426. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  7427. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  7428. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  7429. foreach (var item in TzHotelDescArr)
  7430. {
  7431. if (AinfoArr != null)
  7432. {
  7433. TzHotelDesc += "B段信息 \r\n";
  7434. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7435. if (Ainfo != null)
  7436. {
  7437. if (int.Parse(Ainfo.rs) <= 0)
  7438. {
  7439. continue;
  7440. }
  7441. var hotelText = string.Empty;
  7442. switch (item)
  7443. {
  7444. case "SGR":
  7445. hotelText = "单人间";
  7446. break;
  7447. case "JSES":
  7448. hotelText = "小套房";
  7449. break;
  7450. case "SUITE":
  7451. hotelText = "套房";
  7452. break;
  7453. case "TBR":
  7454. hotelText = "双人间";
  7455. break;
  7456. }
  7457. if (item != "TBR")
  7458. {
  7459. 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";
  7460. }
  7461. else
  7462. {
  7463. 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";
  7464. }
  7465. index++;
  7466. }
  7467. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  7468. }
  7469. }
  7470. index = 1;
  7471. foreach (var item in TzAirDescArr)
  7472. {
  7473. if (AinfoArr != null)
  7474. {
  7475. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7476. if (Ainfo != null)
  7477. {
  7478. if (int.Parse(Ainfo.rs) <= 0)
  7479. {
  7480. continue;
  7481. }
  7482. 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";
  7483. index++;
  7484. }
  7485. }
  7486. }
  7487. }
  7488. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  7489. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  7490. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  7491. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  7492. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  7493. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  7494. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  7495. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  7496. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  7497. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  7498. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  7499. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  7500. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  7501. DickeyValue.Add("Visa", Visa); // 签证单人报价
  7502. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  7503. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  7504. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  7505. DickeyValue.Add("TzZCost", TzZCost);
  7506. foreach (var key in DickeyValue.Keys)
  7507. {
  7508. if (doc.Range.Bookmarks[key] != null)
  7509. {
  7510. Bookmark mark = doc.Range.Bookmarks[key];
  7511. mark.Text = DickeyValue[key];
  7512. }
  7513. }
  7514. byte[] bytes = null;
  7515. string strFileName = di.TeamName + "-客户报价.doc";
  7516. using (MemoryStream stream = new MemoryStream())
  7517. {
  7518. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7519. bytes = stream.ToArray();
  7520. }
  7521. return Ok(JsonView(true, "", new
  7522. {
  7523. Data = bytes,
  7524. strFileName,
  7525. }));
  7526. }
  7527. /// <summary>
  7528. /// 团组成本 各模块(酒店,地接,机票)成本提示
  7529. /// </summary>
  7530. /// <param name="dto"></param>
  7531. /// <returns></returns>
  7532. [HttpPost]
  7533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7534. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  7535. {
  7536. try
  7537. {
  7538. #region 参数验证
  7539. if (dto.DiId < 0)
  7540. {
  7541. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7542. }
  7543. List<int> cTableIds = new List<int>() {
  7544. 76 ,//酒店预订
  7545. 77 ,//行程
  7546. 79 ,//车/导游地接
  7547. 80 ,//签证
  7548. 81 ,//邀请/公务活
  7549. 82 ,//团组客户保险
  7550. 85 ,//机票预订
  7551. 98 ,//其他款项
  7552. 285 ,//收款退还
  7553. 751 ,//酒店早餐
  7554. 1015 // 超支费用
  7555. };
  7556. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  7557. {
  7558. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  7559. }
  7560. #endregion
  7561. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  7562. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7563. if (_GroupCostParameters.Count <= 0)
  7564. {
  7565. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  7566. }
  7567. if (_GroupCostParameters[0].IsShare == 0)
  7568. {
  7569. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  7570. }
  7571. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7572. //处理date为空问题
  7573. if (_GroupCosts.Count > 0)
  7574. {
  7575. for (int i = 0; i < _GroupCosts.Count; i++)
  7576. {
  7577. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  7578. {
  7579. if (i > 0)
  7580. {
  7581. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  7582. }
  7583. }
  7584. }
  7585. }
  7586. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  7587. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  7588. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7589. string currCode = "";
  7590. #region currCode 验证
  7591. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  7592. if (isInt)
  7593. {
  7594. var currData = currDatas.Find(it => it.Id == intCurrency);
  7595. if (currData != null)
  7596. {
  7597. currCode = currData.Name;
  7598. }
  7599. }
  7600. else
  7601. {
  7602. currCode = _GroupCostParameters[0].Currency.Trim();
  7603. }
  7604. #endregion
  7605. //op,酒店单段模式存储
  7606. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  7607. {
  7608. CurrencyCode = currCode,
  7609. Rate = _GroupCostParameters[0].Rate,
  7610. CostType = _GroupCostParameters[0].CostType,
  7611. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  7612. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  7613. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  7614. };
  7615. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  7616. if (_GroupCostParameters.Count == 2)
  7617. {
  7618. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  7619. }
  7620. foreach (var item in _GroupCostParameters)
  7621. {
  7622. decimal _rate = 1;
  7623. decimal _rate1 = item.Rate;
  7624. decimal _scale = 1;
  7625. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  7626. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  7627. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  7628. //if (userInfo != null)
  7629. //{
  7630. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  7631. // {
  7632. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  7633. // {
  7634. // _scale = 1.00M;
  7635. // }
  7636. // }
  7637. //}
  7638. #endregion
  7639. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  7640. {
  7641. CurrencyCode = currCode,
  7642. Rate = _rate1,
  7643. CostType = item.CostType,
  7644. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  7645. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  7646. CostTypeNumber = item.CostTypenumber
  7647. };
  7648. if (_GroupCostParameters.Count > 1)
  7649. {
  7650. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  7651. }
  7652. else
  7653. {
  7654. modulePromptInfo.CostTypeNumber = item.LYJRS;
  7655. }
  7656. if (dto.CTable == 79)//
  7657. {
  7658. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  7659. modulePromptInfo.TotalCost = item.DJCB;
  7660. }
  7661. List<string> costTypes = new List<string>() { "A", "B" };
  7662. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  7663. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  7664. if (_GroupCostsDuplicates.Count() == 1)
  7665. {
  7666. _GroupCostsTypeData = _GroupCosts;
  7667. }
  7668. else
  7669. {
  7670. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  7671. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  7672. }
  7673. /*
  7674. * 76 酒店预订
  7675. * 77 行程
  7676. * 79 车/导游地接
  7677. * 80 签证
  7678. * 81 邀请/公务活动
  7679. * 82 团组客户保险
  7680. * 85 机票预订
  7681. * 98 其他款项
  7682. * 285 收款退还
  7683. * 751 酒店早餐
  7684. * 1015 超支费用
  7685. */
  7686. switch (dto.CTable)
  7687. {
  7688. case 76: // 酒店预订
  7689. _ModuleSubPromptInfo.AddRange(
  7690. _GroupCostsTypeData.Select(it => new
  7691. {
  7692. it.DAY,
  7693. it.Date,
  7694. it.ACCON,
  7695. it.ITIN,
  7696. it.SGR,
  7697. it.TBR,
  7698. it.JS_ES,
  7699. it.Suite
  7700. })
  7701. );
  7702. break;
  7703. case 79: // 车/导游地接
  7704. _ModuleSubPromptInfo.AddRange(
  7705. _GroupCostsTypeData.Select(it => new
  7706. {
  7707. Date = it.Date, //日期
  7708. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  7709. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  7710. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  7711. TicketFee = it.EF * _rate * _scale, //门票费
  7712. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  7713. AirportTransferFee = 0.00M,
  7714. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  7715. TravelSupplies = it.TE * _rate * _scale, //出行物资
  7716. LeadersFee = it.TLF * _rate * _scale, //领队费
  7717. CarFee1 = it.CarCost * _rate * _scale,
  7718. CarType = it.CarType, //车型
  7719. SpentCash = it.PC * _rate * _scale, //零用金
  7720. })
  7721. );
  7722. break;
  7723. case 85: // 机票
  7724. List<dynamic> datas = new List<dynamic>();
  7725. datas.Add(
  7726. new
  7727. {
  7728. AirType = "经济舱",
  7729. AirNum = item.JJCRS,
  7730. AirDRCB = item.JJCCB,
  7731. AirZCB = (item.JJCRS * item.JJCCB)
  7732. }
  7733. );
  7734. datas.Add(
  7735. new
  7736. {
  7737. AirType = "公务舱",
  7738. AirNum = item.GWCRS,
  7739. AirDRCB = item.GWCCB,
  7740. AirZCB = (item.GWCRS * item.GWCCB)
  7741. }
  7742. );
  7743. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7744. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  7745. modulePromptInfo.Data = new {
  7746. airFeeData = datas,
  7747. airInitData = initDatas
  7748. };
  7749. _ModulePromptInfos.Add(modulePromptInfo);
  7750. break;
  7751. default:
  7752. break;
  7753. }
  7754. }
  7755. if (dto.CTable != 85)
  7756. {
  7757. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  7758. _ModulePromptInfos.Add(_ModulePromptInfo);
  7759. }
  7760. _view.ModulePromptInfos = _ModulePromptInfos;
  7761. return Ok(JsonView(true, "操作成功!", _view));
  7762. }
  7763. catch (Exception ex)
  7764. {
  7765. return Ok(JsonView(false, ex.Message));
  7766. }
  7767. }
  7768. /// <summary>
  7769. /// 根据黑屏代码重新生成行程
  7770. /// </summary>
  7771. /// <param name="dto"></param>
  7772. /// <returns></returns>
  7773. [HttpPost]
  7774. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  7775. {
  7776. var jw = JsonView(false);
  7777. var Create = _GroupCostRepository.
  7778. CreateGroupCostByBlackCode(dto.Diid);
  7779. jw.Msg = Create.Msg;
  7780. if (Create.Code == 0)
  7781. {
  7782. jw.Code = 200;
  7783. jw.Data = new
  7784. {
  7785. groupCost = Create.Data,
  7786. blackCodeIsTrue = true
  7787. };
  7788. }
  7789. else
  7790. {
  7791. jw.Code = 400;
  7792. jw.Data = new
  7793. {
  7794. groupCost = Create.Data,
  7795. blackCodeIsTrue = false,
  7796. };
  7797. }
  7798. return Ok(jw);
  7799. }
  7800. /// <summary>
  7801. /// 成本获取OP历史车费用
  7802. /// </summary>
  7803. /// <param name="dto"></param>
  7804. /// <returns></returns>
  7805. [HttpPost]
  7806. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  7807. {
  7808. var jw = JsonView(false);
  7809. try
  7810. {
  7811. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  7812. //获取现有所有车的数据
  7813. if (!dto.Param.IsNullOrWhiteSpace())
  7814. {
  7815. string sql = $@"
  7816. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  7817. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  7818. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  7819. 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
  7820. AND gctggr.ServiceEndTime is not NULL
  7821. ORDER by gctggrc.id DESC
  7822. ";
  7823. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  7824. var numeberResult = await Task.Run(() =>
  7825. {
  7826. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  7827. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  7828. return numberArr;
  7829. });
  7830. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  7831. foreach (var item in numeberResult)
  7832. {
  7833. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  7834. {
  7835. Country = "数据异常!",
  7836. City = string.Empty,
  7837. };
  7838. item.Area = find.Country + " " + find.City;
  7839. }
  7840. dbResult.AddRange(numeberResult);
  7841. if (dto.Param.Contains("、"))
  7842. {
  7843. var sp = dto.Param.Split("、");
  7844. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  7845. .Where(x =>
  7846. {
  7847. return System.Array.Exists(sp, e =>
  7848. {
  7849. bool where = false;
  7850. if (x.Area != null)
  7851. {
  7852. where = x.Area.Contains(e);
  7853. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  7854. {
  7855. return false;
  7856. }
  7857. }
  7858. if (x.PriceName != null && !where)
  7859. {
  7860. where = x.PriceName.Contains(e);
  7861. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  7862. {
  7863. return false;
  7864. }
  7865. }
  7866. return where;
  7867. });
  7868. }).ToList();
  7869. }
  7870. else
  7871. {
  7872. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  7873. .Where(x =>
  7874. {
  7875. bool where = false;
  7876. if (x.Area != null)
  7877. {
  7878. where = x.Area.Contains(dto.Param);
  7879. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  7880. {
  7881. return false;
  7882. }
  7883. }
  7884. if (x.PriceName != null && !where)
  7885. {
  7886. where = x.PriceName.Contains(dto.Param);
  7887. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  7888. {
  7889. return false;
  7890. }
  7891. }
  7892. return where;
  7893. }
  7894. )
  7895. .ToList();
  7896. }
  7897. }
  7898. var view = dbResult.Select(x => {
  7899. decimal dp = 0.00M;
  7900. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  7901. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  7902. if (string.IsNullOrWhiteSpace(x.DatePrice))
  7903. {
  7904. if (startB && endB)
  7905. {
  7906. var timesp = endD.Subtract(startD);
  7907. if ((timesp.Days + 1) != 0)
  7908. {
  7909. dp = x.Price / (timesp.Days + 1);
  7910. }
  7911. }
  7912. }
  7913. else
  7914. {
  7915. dp = x.Price;
  7916. }
  7917. return new
  7918. {
  7919. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  7920. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  7921. x.Area,
  7922. x.id,
  7923. price = x.Price.ToString("F2"),
  7924. x.PriceName,
  7925. x.PriceContent,
  7926. x.TeamName,
  7927. x.DatePrice,
  7928. dayPrice = dp.ToString("F2"),
  7929. };
  7930. }).OrderByDescending(x => x.id).ToList();
  7931. jw = JsonView(true, "获取成功!", view);
  7932. }
  7933. catch (Exception e)
  7934. {
  7935. jw = JsonView(false, e.Message);
  7936. }
  7937. return Ok(jw);
  7938. }
  7939. #endregion
  7940. #region 酒店预订 新 雷怡 2023-12-28 17:45
  7941. /// <summary>
  7942. /// 酒店预订
  7943. /// 酒店费用列表 根据团组Id查询
  7944. /// </summary>
  7945. /// <param name="_dto"></param>
  7946. /// <returns></returns>
  7947. [HttpPost]
  7948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7949. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  7950. {
  7951. #region 参数验证
  7952. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7953. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7954. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7955. #region 团组操作权限验证 76 酒店预定模块
  7956. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7957. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7958. #endregion
  7959. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7960. #region 页面操作权限验证
  7961. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7962. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7963. #endregion
  7964. #endregion
  7965. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  7966. }
  7967. /// <summary>
  7968. /// 酒店预订
  7969. /// 基础数据
  7970. /// </summary>
  7971. /// <param name="_dto"></param>
  7972. /// <returns></returns>
  7973. [HttpPost]
  7974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7975. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  7976. {
  7977. #region 参数验证
  7978. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7979. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7980. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7981. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7982. #region 页面操作权限验证
  7983. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7984. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7985. #endregion
  7986. #region 团组操作权限验证 76 酒店预定模块
  7987. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7988. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7989. #endregion
  7990. #endregion
  7991. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  7992. }
  7993. /// <summary>
  7994. /// 酒店预订
  7995. /// 创建 入住卷号码
  7996. /// </summary>
  7997. /// <param name="_dto"></param>
  7998. /// <returns></returns>
  7999. [HttpPost]
  8000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8001. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8002. {
  8003. try
  8004. {
  8005. #region 参数验证
  8006. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8007. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8008. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8009. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8010. #region 页面操作权限验证
  8011. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8012. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8013. #endregion
  8014. #region 团组操作权限验证 76 酒店预定模块
  8015. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8016. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8017. #endregion
  8018. #endregion
  8019. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8020. if (data.Code != 0)
  8021. {
  8022. return Ok(JsonView(false, data.Msg));
  8023. }
  8024. return Ok(JsonView(true, data.Msg, data.Data));
  8025. }
  8026. catch (Exception ex)
  8027. {
  8028. return Ok(JsonView(false, ex.Message));
  8029. }
  8030. }
  8031. /// <summary>
  8032. /// 酒店预订
  8033. /// 详情
  8034. /// </summary>
  8035. /// <param name="_dto"></param>
  8036. /// <returns></returns>
  8037. [HttpPost]
  8038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8039. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8040. {
  8041. #region 参数验证
  8042. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8043. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8044. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8045. #region 团组操作权限验证 76 酒店预定模块
  8046. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8047. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8048. #endregion
  8049. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8050. #region 页面操作权限验证
  8051. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8052. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8053. #endregion
  8054. #endregion
  8055. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8056. }
  8057. /// <summary>
  8058. /// 酒店预订
  8059. /// Add Or Edit
  8060. /// </summary>
  8061. /// <param name="_dto"></param>
  8062. /// <returns></returns>
  8063. [HttpPost]
  8064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8065. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8066. {
  8067. #region 参数验证
  8068. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8069. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8070. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8071. #region 团组操作权限验证 76 酒店预定模块
  8072. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8073. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8074. #endregion
  8075. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8076. #region 页面操作权限验证
  8077. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8078. if (_dto.Id == 0) // Add
  8079. {
  8080. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8081. }
  8082. else if (_dto.Id > 1) // Edit
  8083. {
  8084. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8085. } else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8086. #endregion
  8087. #endregion
  8088. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8089. if (_view.Code != 200)
  8090. {
  8091. return Ok(_view);
  8092. }
  8093. #region 应用推送
  8094. //TODO:酒店预订费用消息推送 移动端完成后取消注释
  8095. //try
  8096. //{
  8097. // int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8098. // int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8099. // await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8100. //}
  8101. //catch (Exception ex)
  8102. //{
  8103. //}
  8104. #endregion
  8105. return Ok(_view);
  8106. }
  8107. /// <summary>
  8108. /// 酒店预订
  8109. /// Del
  8110. /// </summary>
  8111. /// <param name="_dto"></param>
  8112. /// <returns></returns>
  8113. [HttpPost]
  8114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8115. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8116. {
  8117. #region 参数验证
  8118. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8119. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8120. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8121. #region 团组操作权限验证 76 酒店预定模块
  8122. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8123. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8124. #endregion
  8125. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8126. #region 页面操作权限验证
  8127. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8128. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8129. #endregion
  8130. #endregion
  8131. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8132. }
  8133. /// <summary>
  8134. /// 酒店预订
  8135. /// 生成VOUCHER
  8136. /// 2024.05.06 之前版本
  8137. /// </summary>
  8138. /// <param name="_dto"></param>
  8139. /// <returns></returns>
  8140. [HttpPost]
  8141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8142. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8143. {
  8144. try
  8145. {
  8146. #region 参数验证
  8147. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8148. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8149. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8150. #region 团组操作权限验证 76 酒店预定模块
  8151. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8152. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8153. #endregion
  8154. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8155. #region 页面操作权限验证
  8156. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8157. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8158. #endregion
  8159. #endregion
  8160. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8161. //判断数据是否完整
  8162. if (hr != null)
  8163. {
  8164. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8165. {
  8166. string strFileName = "HotelStatement/";
  8167. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8168. if (dele != null)
  8169. strFileName += dele.TourCode;
  8170. //载入模板
  8171. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8172. Document doc = new Document(sss);
  8173. DocumentBuilder builder = new DocumentBuilder(doc);
  8174. #region 替换Word模板书签内容
  8175. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8176. //入住卷预定号码
  8177. if (doc.Range.Bookmarks["VNO"] != null)
  8178. {
  8179. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8180. mark.Text = hr.CheckNumber;
  8181. }
  8182. //酒店时间
  8183. if (doc.Range.Bookmarks["Date"] != null)
  8184. {
  8185. Bookmark mark = doc.Range.Bookmarks["Date"];
  8186. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8187. }
  8188. //团号
  8189. if (doc.Range.Bookmarks["TNo"] != null)
  8190. {
  8191. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8192. mark.Text = dele.TourCode;
  8193. }
  8194. //预定号码
  8195. if (doc.Range.Bookmarks["BookingId"] != null)
  8196. {
  8197. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8198. mark.Text = hr.ReservationsNo;
  8199. }
  8200. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8201. {
  8202. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8203. mark.Text = hr.DetermineNo;
  8204. }
  8205. //酒店城市
  8206. if (doc.Range.Bookmarks["City"] != null)
  8207. {
  8208. Bookmark mark = doc.Range.Bookmarks["City"];
  8209. mark.Text = hr.City;
  8210. }
  8211. //酒店名称
  8212. if (doc.Range.Bookmarks["HName"] != null)
  8213. {
  8214. Bookmark mark = doc.Range.Bookmarks["HName"];
  8215. mark.Text = hr.HotelName;
  8216. }
  8217. //酒店地址
  8218. if (doc.Range.Bookmarks["Address"] != null)
  8219. {
  8220. Bookmark mark = doc.Range.Bookmarks["Address"];
  8221. mark.Text = hr.HotelAddress;
  8222. }
  8223. //酒店电话
  8224. if (doc.Range.Bookmarks["Tel"] != null)
  8225. {
  8226. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8227. mark.Text = hr.HotelTel;
  8228. }
  8229. //酒店传真
  8230. if (doc.Range.Bookmarks["Fax"] != null)
  8231. {
  8232. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8233. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8234. {
  8235. mark.Text = hr.HotelFax;
  8236. }
  8237. }
  8238. //入住时间
  8239. if (doc.Range.Bookmarks["CIn"] != null)
  8240. {
  8241. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8242. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8243. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8244. }
  8245. //退房时间
  8246. if (doc.Range.Bookmarks["COut"] != null)
  8247. {
  8248. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8249. Bookmark mark = doc.Range.Bookmarks["COut"];
  8250. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8251. }
  8252. //客户名称
  8253. if (doc.Range.Bookmarks["GName"] != null)
  8254. {
  8255. string guestName = "";
  8256. string[] clients = new string[] { };
  8257. if (hr.GuestName.Contains(","))
  8258. {
  8259. clients = hr.GuestName.Split(",");
  8260. }
  8261. else
  8262. {
  8263. clients = new string[] { hr.GuestName };
  8264. }
  8265. List<int> clientIds_int = new List<int>();
  8266. if (clients.Length > 0)
  8267. {
  8268. foreach (var item in clients)
  8269. {
  8270. if (item.IsNumeric())
  8271. {
  8272. clientIds_int.Add(int.Parse(item));
  8273. }
  8274. }
  8275. }
  8276. if (clientIds_int.Count > 0)
  8277. {
  8278. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8279. foreach (var client in _clientDatas)
  8280. {
  8281. //男
  8282. if (client.Sex == 0) guestName += $"Mr.";
  8283. //女
  8284. else if (client.Sex == 1) guestName += $"Ms.";
  8285. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8286. {
  8287. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8288. }
  8289. //guestName += $"{client.Pinyin},";
  8290. }
  8291. if (guestName.Length > 0)
  8292. {
  8293. guestName = guestName.Substring(0, guestName.Length - 1);
  8294. }
  8295. }
  8296. else
  8297. {
  8298. guestName = hr.GuestName;
  8299. }
  8300. Bookmark mark = doc.Range.Bookmarks["GName"];
  8301. mark.Text = guestName;
  8302. }
  8303. //房间介绍
  8304. if (doc.Range.Bookmarks["ROOM"] != null)
  8305. {
  8306. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8307. mark.Text = hr.RoomExplanation;
  8308. }
  8309. //报价描述
  8310. if (doc.Range.Bookmarks["NOTE"] != null)
  8311. {
  8312. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8313. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8314. if (ss != null)
  8315. mark.Text = ss.Name;
  8316. }
  8317. //入住时间
  8318. if (doc.Range.Bookmarks["CheckIn"] != null)
  8319. {
  8320. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8321. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8322. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8323. }
  8324. //退房时间
  8325. if (doc.Range.Bookmarks["CheckOut"] != null)
  8326. {
  8327. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8328. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8329. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8330. }
  8331. //日期
  8332. if (doc.Range.Bookmarks["DT"] != null)
  8333. {
  8334. Bookmark mark = doc.Range.Bookmarks["DT"];
  8335. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8336. }
  8337. //名称
  8338. if (doc.Range.Bookmarks["VName"] != null)
  8339. {
  8340. Bookmark mark = doc.Range.Bookmarks["VName"];
  8341. mark.Text = hr.HotelName;
  8342. }
  8343. //号码
  8344. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8345. {
  8346. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8347. mark.Text = hr.CheckNumber;
  8348. }
  8349. #endregion
  8350. strFileName += "VOUCHER.doc";
  8351. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8352. doc.Save(fileDir);
  8353. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8354. return Ok(JsonView(true, "操作成功!", Url));
  8355. }
  8356. else
  8357. {
  8358. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8359. }
  8360. }
  8361. else
  8362. {
  8363. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  8364. }
  8365. }
  8366. catch (Exception ex)
  8367. {
  8368. return Ok(JsonView(false, ex.Message));
  8369. }
  8370. }
  8371. /// <summary>
  8372. /// 酒店预订
  8373. /// 生成VOUCHER
  8374. /// 2024.05.06 之后版本
  8375. /// </summary>
  8376. /// <param name="_dto"></param>
  8377. /// <returns></returns>
  8378. [HttpPost]
  8379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8380. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  8381. {
  8382. #region 参数验证
  8383. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8384. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8385. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8386. #region 团组操作权限验证 76 酒店预定模块
  8387. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8388. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8389. #endregion
  8390. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8391. #region 页面操作权限验证
  8392. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8393. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8394. #endregion
  8395. #endregion
  8396. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8397. //判断数据是否完整
  8398. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  8399. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8400. string strFileName = "HotelStatement/";
  8401. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8402. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  8403. #region 数据处理
  8404. List<int> guestIds = new List<int>();
  8405. int index = 0;
  8406. foreach (var item in hrDtas)
  8407. {
  8408. if (item.GuestName.Contains(","))
  8409. {
  8410. string[] guestIdArr = item.GuestName.Split(',');
  8411. foreach (var guestIdStr in guestIdArr)
  8412. {
  8413. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  8414. if (guestBool)
  8415. {
  8416. guestIds.Add(guestId);
  8417. }
  8418. }
  8419. }
  8420. else guestNames += item.GuestName;
  8421. var voucherInfo = new HotelVoucherInfoView()
  8422. {
  8423. HotelName = item.HotelName,
  8424. CheckInDate = item.CheckInDate,
  8425. CheckOutDate = item.CheckOutDate,
  8426. ConfirmationNumber = item.DetermineNo.Trim(),
  8427. RoomType = item.RoomExplanation
  8428. };
  8429. vouchers.Add(voucherInfo);
  8430. }
  8431. if (guestIds.Count > 0)
  8432. {
  8433. guestIds = guestIds.Distinct().ToList();
  8434. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  8435. if (guestDatas.Count > 0)
  8436. {
  8437. guestNames = "";
  8438. foreach (var guest in guestDatas)
  8439. {
  8440. string guestName = "";
  8441. if (guest.Sex == 0) guestName += @"MR.";
  8442. else if (guest.Sex == 1) guestName += @"MS.";
  8443. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  8444. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  8445. guestNames += @$"{guestName.Trim()}、";
  8446. }
  8447. if (guestNames.Length > 0)
  8448. {
  8449. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  8450. }
  8451. }
  8452. }
  8453. #endregion
  8454. //载入模板
  8455. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  8456. Document doc = new Document(sss);
  8457. DocumentBuilder builder = new DocumentBuilder(doc);
  8458. if (doc.Range.Bookmarks["GuestName"] != null)
  8459. {
  8460. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  8461. mark.Text = guestNames;
  8462. }
  8463. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8464. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  8465. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  8466. for (int i = 1; i <= vouchers.Count; i++)
  8467. {
  8468. HotelVoucherInfoView hviv = vouchers[i - 1];
  8469. builder.MoveToCell(0, i, 0, 0);
  8470. builder.Write(hviv.HotelName);
  8471. builder.MoveToCell(0, i, 1, 0);
  8472. builder.Write(hviv.CheckInDate);
  8473. builder.MoveToCell(0, i, 2, 0);
  8474. builder.Write(hviv.CheckOutDate);
  8475. builder.MoveToCell(0, i, 3, 0);
  8476. builder.Write(hviv.RoomType);
  8477. builder.MoveToCell(0, i, 4, 0);
  8478. builder.Write(hviv.ConfirmationNumber);
  8479. }
  8480. //删除多余行
  8481. int currRowIndex = vouchers.Count + 1;
  8482. int delRows = 21 - currRowIndex;
  8483. if (delRows > 0)
  8484. {
  8485. for (int i = 0; i < delRows; i++)
  8486. {
  8487. table.Rows.RemoveAt(currRowIndex);
  8488. //cultivateRowIndex++;
  8489. }
  8490. }
  8491. strFileName += "VOUCHER.docx";
  8492. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8493. doc.Save(fileDir);
  8494. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8495. return Ok(JsonView(true, "操作成功!", Url));
  8496. }
  8497. /// <summary>
  8498. /// 酒店预订
  8499. /// 生成 预定成本 Excel
  8500. /// </summary>
  8501. /// <param name="_dto"></param>
  8502. /// <returns></returns>
  8503. [HttpPost]
  8504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8505. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  8506. {
  8507. #region 参数验证
  8508. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  8509. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  8510. if (!vadalitorRes.IsValid)
  8511. {
  8512. var errors = new StringBuilder();
  8513. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  8514. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  8515. }
  8516. #region 团组操作权限验证 76 酒店预定模块
  8517. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8518. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8519. #endregion
  8520. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8521. #region 页面操作权限验证
  8522. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8523. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8524. #endregion
  8525. #endregion
  8526. decimal _rate = 1.00M;
  8527. string _currency = "";
  8528. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  8529. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8530. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  8531. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  8532. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  8533. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  8534. {
  8535. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  8536. }
  8537. _currency = _GroupCostParameter.Currency;
  8538. bool isIntType = int.TryParse(_currency, out int currId);
  8539. if (isIntType)
  8540. {
  8541. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  8542. }
  8543. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  8544. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  8545. if (currInfo == null)
  8546. {
  8547. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  8548. }
  8549. if (!_currency.ToUpper().Equals("CNY"))
  8550. {
  8551. _rate = _GroupCostParameter.Rate;
  8552. }
  8553. _rate = currInfo.Rate;
  8554. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8555. string strFileName = "HotelStatement/";
  8556. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8557. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  8558. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  8559. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  8560. #region 数据处理
  8561. foreach (var item in hrDtas)
  8562. {
  8563. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  8564. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  8565. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  8566. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  8567. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  8568. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  8569. string singleRoomFeeStr = string.Empty,
  8570. doubleRoomFeeStr = string.Empty,
  8571. suiteRoomFeeStr = string.Empty,
  8572. otherRoomFeeStr = string.Empty,
  8573. payMoneyStr = string.Empty,
  8574. cardPriceStr = string.Empty;
  8575. if (roomCurr.Equals(_currency))
  8576. {
  8577. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  8578. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  8579. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  8580. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  8581. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  8582. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  8583. }
  8584. else
  8585. {
  8586. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  8587. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  8588. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  8589. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  8590. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  8591. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  8592. }
  8593. string breakfastPriceStr = string.Empty,
  8594. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  8595. governmentRentStr = string.Empty,
  8596. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  8597. cityTaxStrStr = string.Empty,
  8598. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  8599. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  8600. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  8601. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  8602. pcfds.Add(new HotelReservations_PCFD_View()
  8603. {
  8604. City = item.City,
  8605. HotelName = item.HotelName,
  8606. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  8607. // SingleRoomCount = item.SingleRoomCount,
  8608. SingleRoomPrice = singleRoomFeeStr,
  8609. // DoubleRoomCount = item.DoubleRoomCount,
  8610. DoubleRoomPrice = doubleRoomFeeStr,
  8611. //SuiteRoomCount = item.SuiteRoomCount,
  8612. SuiteRoomPrice = suiteRoomFeeStr,
  8613. OtherRoomPrice = otherRoomFeeStr,
  8614. //OtherRoomCount = item.OtherRoomCount,
  8615. BreakfastPrice = breakfastPriceStr,
  8616. GovernmentRent = governmentRentStr,
  8617. CityTax = cityTaxStrStr,
  8618. RoomExplanation = item.RoomExplanation,
  8619. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  8620. PayTime = roomInfo.ConsumptionDate,
  8621. BankNo = roomInfo.BankNo,
  8622. PayMoney = payMoneyStr,
  8623. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  8624. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  8625. CardPrice = cardPriceStr,
  8626. Remark = ccpInfo.Remark
  8627. });
  8628. }
  8629. #endregion
  8630. //载入模板
  8631. WorkbookDesigner designer = new WorkbookDesigner();
  8632. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  8633. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  8634. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  8635. designer.SetDataSource("TourNo", groupInfo.TourCode);
  8636. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  8637. designer.SetDataSource("Opertor", userInfo.CnName);
  8638. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  8639. dt.TableName = "ViewMyHotelReservations";
  8640. designer.SetDataSource(dt);
  8641. designer.Process();
  8642. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  8643. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  8644. designer.Workbook.Save(serverPath);
  8645. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  8646. #region 删除指定行
  8647. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  8648. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  8649. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  8650. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  8651. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  8652. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  8653. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  8654. cssIndex = dt.Columns["CityTax"].Ordinal,
  8655. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  8656. remarkIndex = dt.Columns["Remark"].Ordinal;
  8657. //删除指定列
  8658. foreach (DataRow item in dt.Rows)
  8659. {
  8660. string singleStr = item["SingleRoomPrice"].ToString();
  8661. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  8662. if (containsDigitButNotZero1) singleDel = false;
  8663. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  8664. string doubleStr = item["DoubleRoomPrice"].ToString();
  8665. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8666. if (containsDigitButNotZero2) doubleDel = false;
  8667. string suiteStr = item["SuiteRoomPrice"].ToString();
  8668. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8669. if (containsDigitButNotZero3) suiteDel = false;
  8670. string otherStr = item["OtherRoomPrice"].ToString();
  8671. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  8672. if (containsDigitButNotZero4) otherDel = false;
  8673. string zcStr = item["BreakfastPrice"].ToString();
  8674. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  8675. if (containsDigitButNotZero5) zcDel = false;
  8676. string dsStr = item["GovernmentRent"].ToString();
  8677. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  8678. if (containsDigitButNotZero6) dsDel = false;
  8679. string cssStr = item["CityTax"].ToString();
  8680. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  8681. if (containsDigitButNotZero7) cssDel = false;
  8682. string cpStr = item["ConsumptionPatterns"].ToString();
  8683. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  8684. string remarkStr = item["Remark"].ToString();
  8685. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  8686. }
  8687. DeleteColumn(serverPath, remarkIndex, remarkDel);
  8688. DeleteColumn(serverPath, cpIndex, cpDel);
  8689. DeleteColumn(serverPath, dsIndex, dsDel);
  8690. DeleteColumn(serverPath, cssIndex, cssDel);
  8691. DeleteColumn(serverPath, zcIndex, zcDel);
  8692. DeleteColumn(serverPath, otherIndex, otherDel);
  8693. DeleteColumn(serverPath, suiteIndex, suiteDel);
  8694. DeleteColumn(serverPath, doubleIndex, doubleDel);
  8695. DeleteColumn(serverPath, singleIndex, singleDel);
  8696. #endregion
  8697. //只保留第一个表格
  8698. DeleteSheet(serverPath);
  8699. return Ok(JsonView(true, "操作成功", url = rst));
  8700. }
  8701. /// <summary>
  8702. /// 删除指定列
  8703. /// </summary>
  8704. /// <param name="file"></param>
  8705. /// <param name="columnIndex"></param>
  8706. /// <param name="isDel"></param>
  8707. private void DeleteColumn(string file, int columnIndex, bool isDel)
  8708. {
  8709. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8710. //wb.Save(file);
  8711. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  8712. if (sheet1 != null)
  8713. {
  8714. if (isDel)
  8715. {
  8716. Cells cells = sheet1.Cells;
  8717. cells.DeleteColumn(columnIndex);
  8718. }
  8719. }
  8720. wb.Save(file);
  8721. }
  8722. /// <summary>
  8723. /// 删除sheet
  8724. /// </summary>
  8725. /// <param name="file"></param>
  8726. /// <param name="sheetName"></param>
  8727. private void DeleteSheet(string file, string sheetName = "")
  8728. {
  8729. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8730. //wb.Save(file);
  8731. List<string> sheets = new List<string>();
  8732. foreach (var item in wb.Worksheets)
  8733. {
  8734. sheets.Add(item.Name);
  8735. }
  8736. if (sheets.Count > 0)
  8737. {
  8738. sheets.RemoveAt(0);//不删除第一个sheet
  8739. foreach (var item in sheets)
  8740. {
  8741. wb.Worksheets.RemoveAt(item);
  8742. }
  8743. }
  8744. wb.Save(file);
  8745. }
  8746. /// <summary>
  8747. /// 酒店预订
  8748. /// 确认单
  8749. /// </summary>
  8750. /// <param name="_dto"></param>
  8751. /// <returns></returns>
  8752. [HttpPost]
  8753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8754. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  8755. {
  8756. try
  8757. {
  8758. #region 参数验证
  8759. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8760. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8761. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8762. #region 团组操作权限验证 76 酒店预定模块
  8763. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8764. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8765. #endregion
  8766. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8767. #region 页面操作权限验证
  8768. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8769. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8770. #endregion
  8771. #endregion
  8772. //团组信息
  8773. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  8774. //酒店数据
  8775. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  8776. if (listhoteldata.Count < 0)
  8777. {
  8778. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  8779. }
  8780. //利datatable存储
  8781. DataTable dt = new DataTable();
  8782. dt.Columns.Add("CheckInDate", typeof(string));
  8783. dt.Columns.Add("City", typeof(string));
  8784. dt.Columns.Add("Hotel", typeof(string));
  8785. dt.Columns.Add("Room", typeof(string));
  8786. for (int i = 0; i < listhoteldata.Count; i++)
  8787. {
  8788. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  8789. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  8790. while (dayStart < dayEnd)
  8791. {
  8792. string temp = "";
  8793. DataRow row = dt.NewRow();
  8794. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  8795. row["City"] = listhoteldata[i].City;
  8796. row["Hotel"] = listhoteldata[i].HotelName;
  8797. if (listhoteldata[i].SingleRoomCount > 0)
  8798. {
  8799. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  8800. }
  8801. if (listhoteldata[i].DoubleRoomCount > 0)
  8802. {
  8803. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  8804. }
  8805. if (listhoteldata[i].SuiteRoomCount > 0)
  8806. {
  8807. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  8808. }
  8809. if (listhoteldata[i].OtherRoomCount > 0)
  8810. {
  8811. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  8812. }
  8813. row["Room"] = temp;
  8814. dt.Rows.Add(row);
  8815. dayStart = dayStart.AddDays(1);
  8816. }
  8817. }
  8818. Dictionary<string, string> dic = new Dictionary<string, string>();
  8819. dic.Add("Dele", di.TeamName);
  8820. dic.Add("City", di.VisitCountry);
  8821. //模板路径
  8822. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  8823. //载入模板
  8824. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  8825. DocumentBuilder builder = new DocumentBuilder(doc);
  8826. foreach (var key in dic.Keys)
  8827. {
  8828. builder.MoveToBookmark(key);
  8829. builder.Write(dic[key]);
  8830. }
  8831. //获取word里所有表格
  8832. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8833. //获取所填表格的序数
  8834. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8835. var rowStart = tableOne.Rows[0]; //获取第1行
  8836. //循环赋值
  8837. for (int i = 0; i < dt.Rows.Count; i++)
  8838. {
  8839. builder.MoveToCell(0, i + 1, 0, 0);
  8840. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  8841. builder.MoveToCell(0, i + 1, 1, 0);
  8842. builder.Write(dt.Rows[i]["City"].ToString());
  8843. builder.MoveToCell(0, i + 1, 2, 0);
  8844. builder.Write(dt.Rows[i]["Hotel"].ToString());
  8845. builder.MoveToCell(0, i + 1, 3, 0);
  8846. builder.Write(dt.Rows[i]["Room"].ToString());
  8847. }
  8848. //删除多余行
  8849. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  8850. {
  8851. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  8852. }
  8853. string strFileName = di.TeamName + "酒店确认单.doc";
  8854. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  8855. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  8856. return Ok(JsonView(true, "成功", url));
  8857. }
  8858. catch (Exception ex)
  8859. {
  8860. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  8861. }
  8862. }
  8863. #endregion
  8864. #region 团组状态
  8865. /// <summary>
  8866. /// 团组状态列表 Page
  8867. /// </summary>
  8868. /// <param name="dto">团组列表请求dto</param>
  8869. /// <returns></returns>
  8870. [HttpPost]
  8871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8872. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  8873. {
  8874. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  8875. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  8876. {
  8877. string sqlWhere = string.Empty;
  8878. if (dto.IsSure == 0) //未完成
  8879. {
  8880. sqlWhere += string.Format(@" And IsSure = 0");
  8881. }
  8882. else if (dto.IsSure == 1) //已完成
  8883. {
  8884. sqlWhere += string.Format(@" And IsSure = 1");
  8885. }
  8886. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  8887. {
  8888. string tj = dto.SearchCriteria;
  8889. 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}%')",
  8890. tj, tj, tj, tj, tj);
  8891. }
  8892. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  8893. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  8894. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  8895. From (
  8896. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  8897. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  8898. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  8899. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  8900. From Grp_DelegationInfo gdi
  8901. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  8902. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  8903. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  8904. Where gdi.IsDel = 0 {0}
  8905. ) temp ", sqlWhere);
  8906. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  8907. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  8908. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  8909. }
  8910. else
  8911. {
  8912. return Ok(JsonView(false, "查询失败"));
  8913. }
  8914. }
  8915. /// <summary>
  8916. /// 团组状态
  8917. /// 设置操作完成
  8918. /// </summary>
  8919. /// <param name="dto">团组列表请求dto</param>
  8920. /// <returns></returns>
  8921. [HttpPost]
  8922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8923. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  8924. {
  8925. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  8926. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  8927. {
  8928. Id = dto.Id,
  8929. IsSure = 1
  8930. };
  8931. var result = await _sqlSugar.Updateable(_DelegationInfo)
  8932. .UpdateColumns(it => new { it.IsSure })
  8933. .WhereColumns(it => new { it.Id })
  8934. .ExecuteCommandAsync();
  8935. if (result > 0)
  8936. {
  8937. return Ok(JsonView(true, "操作完成!"));
  8938. }
  8939. return Ok(JsonView(false, "操作失败!"));
  8940. }
  8941. #endregion
  8942. #region 保险费用录入
  8943. /// <summary>
  8944. /// 根据团组Id查询保险费用列表
  8945. /// </summary>
  8946. /// <param name="dto"></param>
  8947. /// <returns></returns>
  8948. [HttpPost]
  8949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8950. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  8951. {
  8952. try
  8953. {
  8954. Result groupData = await _customersRep.CustomersByDiId(dto);
  8955. if (groupData.Code != 0)
  8956. {
  8957. return Ok(JsonView(false, groupData.Msg));
  8958. }
  8959. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8960. }
  8961. catch (Exception ex)
  8962. {
  8963. return Ok(JsonView(false, ex.Message));
  8964. }
  8965. }
  8966. /// <summary>
  8967. /// 根据保险费用Id查询保险费用详细
  8968. /// </summary>
  8969. /// <param name="dto"></param>
  8970. /// <returns></returns>
  8971. [HttpPost]
  8972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8973. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  8974. {
  8975. try
  8976. {
  8977. Result groupData = await _customersRep.CustomersById(dto);
  8978. if (groupData.Code != 0)
  8979. {
  8980. return Ok(JsonView(false, groupData.Msg));
  8981. }
  8982. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8983. }
  8984. catch (Exception ex)
  8985. {
  8986. return Ok(JsonView(false, ex.Message));
  8987. }
  8988. }
  8989. /// <summary>
  8990. /// 保险费用录入页面初始化绑定
  8991. /// </summary>
  8992. /// <param name="dto"></param>
  8993. /// <returns></returns>
  8994. [HttpPost]
  8995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8996. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  8997. {
  8998. try
  8999. {
  9000. Result groupData = await _customersRep.CustomersInitialize(dto);
  9001. if (groupData.Code != 0)
  9002. {
  9003. return Ok(JsonView(false, groupData.Msg));
  9004. }
  9005. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9006. }
  9007. catch (Exception ex)
  9008. {
  9009. return Ok(JsonView(false, ex.Message));
  9010. }
  9011. }
  9012. /// <summary>
  9013. /// 保险费用操作(Status:1.新增,2.修改)
  9014. /// </summary>
  9015. /// <param name="dto"></param>
  9016. /// <returns></returns>
  9017. [HttpPost]
  9018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9019. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9020. {
  9021. try
  9022. {
  9023. Result groupData = await _customersRep.OpCustomers(dto);
  9024. if (groupData.Code != 0)
  9025. {
  9026. return Ok(JsonView(false, groupData.Msg));
  9027. }
  9028. #region 应用推送
  9029. try
  9030. {
  9031. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9032. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9033. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9034. }
  9035. catch (Exception ex)
  9036. {
  9037. }
  9038. #endregion
  9039. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9040. }
  9041. catch (Exception ex)
  9042. {
  9043. return Ok(JsonView(false, ex.Message));
  9044. }
  9045. }
  9046. /// <summary>
  9047. /// 保险文件上传
  9048. /// </summary>
  9049. /// <param name="file"></param>
  9050. /// <returns></returns>
  9051. [HttpPost]
  9052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9053. public async Task<IActionResult> UploadCus(IFormFile file)
  9054. {
  9055. try
  9056. {
  9057. if (file != null)
  9058. {
  9059. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9060. //文件名称
  9061. string projectFileName = file.FileName;
  9062. //上传的文件的路径
  9063. string filePath = "";
  9064. if (!Directory.Exists(fileDir))
  9065. {
  9066. Directory.CreateDirectory(fileDir);
  9067. }
  9068. //上传的文件的路径
  9069. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9070. using (FileStream fs = System.IO.File.Create(filePath))
  9071. {
  9072. file.CopyTo(fs);
  9073. fs.Flush();
  9074. }
  9075. return Ok(JsonView(true, "上传成功!", projectFileName));
  9076. }
  9077. else
  9078. {
  9079. return Ok(JsonView(false, "上传失败!"));
  9080. }
  9081. }
  9082. catch (Exception ex)
  9083. {
  9084. return Ok(JsonView(false, "程序错误!"));
  9085. throw;
  9086. }
  9087. }
  9088. /// <summary>
  9089. /// 保险删除指定文件
  9090. /// </summary>
  9091. /// <param name="dto"></param>
  9092. /// <returns></returns>
  9093. [HttpPost]
  9094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9095. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9096. {
  9097. try
  9098. {
  9099. string filePath = "";
  9100. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9101. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9102. //int id = 0;
  9103. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9104. // 删除该文件
  9105. try
  9106. {
  9107. System.IO.File.Delete(filePath);
  9108. 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()
  9109. {
  9110. Attachment = "",
  9111. }).ExecuteCommandAsync();
  9112. if (result != 0)
  9113. {
  9114. return Ok(JsonView(true, "成功!"));
  9115. }
  9116. else
  9117. {
  9118. return Ok(JsonView(false, "失败!"));
  9119. }
  9120. }
  9121. catch (Exception)
  9122. {
  9123. 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()
  9124. {
  9125. Attachment = "",
  9126. }).ExecuteCommandAsync();
  9127. if (result != 0)
  9128. {
  9129. return Ok(JsonView(true, "成功!"));
  9130. }
  9131. else
  9132. {
  9133. return Ok(JsonView(false, "失败!"));
  9134. }
  9135. }
  9136. }
  9137. catch (Exception ex)
  9138. {
  9139. return Ok(JsonView(false, "程序错误!"));
  9140. throw;
  9141. }
  9142. }
  9143. /// <summary>
  9144. /// 保险费用操作(删除)
  9145. /// </summary>
  9146. /// <param name="dto"></param>
  9147. /// <returns></returns>
  9148. [HttpPost]
  9149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9150. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9151. {
  9152. try
  9153. {
  9154. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9155. if (!res)
  9156. {
  9157. return Ok(JsonView(false, "删除失败"));
  9158. }
  9159. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9160. {
  9161. IsDel = 1,
  9162. DeleteUserId = dto.DeleteUserId,
  9163. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9164. }).ExecuteCommandAsync();
  9165. return Ok(JsonView(true, "删除成功!"));
  9166. }
  9167. catch (Exception ex)
  9168. {
  9169. return Ok(JsonView(false, "程序错误!"));
  9170. throw;
  9171. }
  9172. }
  9173. #endregion
  9174. #region 接团客户名单 PageId 104
  9175. /// <summary>
  9176. /// 接团客户名单
  9177. /// 迁移数据(慎用!)
  9178. /// </summary>
  9179. /// <param name="dto"></param>
  9180. /// <returns></returns>
  9181. [HttpPost]
  9182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9183. public async Task<IActionResult> PostTourClientListChange()
  9184. {
  9185. try
  9186. {
  9187. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9188. //var groupClinetData1
  9189. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9190. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9191. int updateCount = 0;
  9192. if (oldOAClientList.Count > 0)
  9193. {
  9194. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9195. _sqlSugar.BeginTran();
  9196. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9197. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9198. foreach (var item in oldOAClientList)
  9199. {
  9200. int comId = 0;
  9201. string format = "yyyy-MM-dd HH:mm:ss";
  9202. string data11 = "1990-01-01 00:00";
  9203. var data1 = IsValidDate(item.OPdate, format);
  9204. if (data1) data11 = item.OPdate;
  9205. //客户公司验证
  9206. if (!string.IsNullOrEmpty(item.Company))
  9207. {
  9208. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9209. if (clientComInfo == null) // add
  9210. {
  9211. var addInfo = new Crm_CustomerCompany()
  9212. {
  9213. CompanyAbbreviation = "",
  9214. CompanyFullName = item.Company,
  9215. Address = "",
  9216. PostCodes = "",
  9217. LastedOpUserId = item.OPer,
  9218. LastedOpDt = Convert.ToDateTime(data11),
  9219. CreateUserId = item.OPer,
  9220. CreateTime = Convert.ToDateTime(data11),
  9221. IsDel = 0
  9222. };
  9223. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9224. if (comId1 > 0) comId = comId1;
  9225. }
  9226. else comId = clientComInfo.Id;
  9227. }
  9228. //客户人员验证
  9229. int clientId = 0;
  9230. string name = item.LastName + item.Name;
  9231. if (!string.IsNullOrEmpty(name))
  9232. {
  9233. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9234. if (clientInfo == null)
  9235. {
  9236. DateTime? dateTime = null;
  9237. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9238. if (isDt) dateTime = birthDayDt;
  9239. var addInfo1 = new Crm_DeleClient()
  9240. {
  9241. CrmCompanyId = comId,
  9242. DiId = -1,
  9243. LastName = item.LastName,
  9244. FirstName = item.Name,
  9245. OldName = "",
  9246. Pinyin = item.Pinyin,
  9247. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9248. Marriage = 0,
  9249. Phone = item.Phone,
  9250. Job = item.Job,
  9251. BirthDay = dateTime
  9252. };
  9253. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9254. if (clientId1 > 0) clientId = clientId1;
  9255. }
  9256. else clientId = clientInfo.Id;
  9257. }
  9258. if (clientId < 1)
  9259. {
  9260. continue;
  9261. }
  9262. int airType = 0;
  9263. if (item.AirType == "超经舱") airType = 459;
  9264. else if (item.AirType == "公务舱") airType = 458;
  9265. else if (item.AirType == "经济舱") airType = 460;
  9266. else if (item.AirType == "其他") airType = 565;
  9267. else if (item.AirType == "头等舱") airType = 457;
  9268. var _TourClientListEntity = new Grp_TourClientList()
  9269. {
  9270. DiId = item.Diid,
  9271. ClientId = clientId,
  9272. CreateUserId = item.OPer,
  9273. CreateTime = Convert.ToDateTime(data11),
  9274. Remark = item.Remark,
  9275. IsDel = item.Isdel,
  9276. ShippingSpaceTypeId = airType,
  9277. ShippingSpaceSpecialNeeds = item.AirRemark,
  9278. HotelSpecialNeeds = item.RoomType
  9279. };
  9280. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9281. if (_TourClientList > 0)
  9282. {
  9283. updateCount++;
  9284. }
  9285. }
  9286. _sqlSugar.CommitTran();
  9287. }
  9288. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9289. }
  9290. catch (Exception ex)
  9291. {
  9292. _sqlSugar.RollbackTran();
  9293. return Ok(JsonView(false, ex.Message));
  9294. }
  9295. return Ok(JsonView(true));
  9296. }
  9297. private bool IsValidDate(string dateString, string format)
  9298. {
  9299. DateTime dateValue;
  9300. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9301. return valid;
  9302. }
  9303. /// <summary>
  9304. /// 接团客户名单
  9305. /// 根据团组Id查询List
  9306. /// </summary>
  9307. /// <param name="dto"></param>
  9308. /// <returns></returns>
  9309. [HttpPost]
  9310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9311. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9312. {
  9313. #region 参数验证
  9314. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9315. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9316. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9317. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9318. #region 页面操作权限验证
  9319. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9320. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9321. #endregion
  9322. #endregion
  9323. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9324. if (viewData.Code != 0)
  9325. {
  9326. return Ok(JsonView(false, viewData.Msg));
  9327. }
  9328. return Ok(JsonView(viewData.Data));
  9329. }
  9330. /// <summary>
  9331. /// 接团客户名单
  9332. /// 基础数据 Init
  9333. /// </summary>
  9334. /// <param name="_dto"></param>
  9335. /// <returns></returns>
  9336. [HttpPost]
  9337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9338. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9339. {
  9340. #region 参数验证
  9341. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9342. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9343. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9344. #region 页面操作权限验证
  9345. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9346. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9347. #endregion
  9348. #endregion
  9349. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  9350. if (viewData.Code != 0)
  9351. {
  9352. return Ok(JsonView(false, viewData.Msg));
  9353. }
  9354. return Ok(JsonView(viewData.Data));
  9355. }
  9356. /// <summary>
  9357. /// 接团客户名单
  9358. /// 根据 Id查询 Details
  9359. /// </summary>
  9360. /// <param name="_dto"></param>
  9361. /// <returns></returns>
  9362. [HttpPost]
  9363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9364. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  9365. {
  9366. #region 参数验证
  9367. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9368. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9369. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9370. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9371. #region 页面操作权限验证
  9372. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9373. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9374. #endregion
  9375. #endregion
  9376. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  9377. if (viewData.Code != 0)
  9378. {
  9379. return Ok(JsonView(false, viewData.Msg));
  9380. }
  9381. return Ok(JsonView(viewData.Data));
  9382. }
  9383. /// <summary>
  9384. /// 接团客户名单
  9385. /// Add Or Edit
  9386. /// </summary>
  9387. /// <param name="_dto"></param>
  9388. /// <returns></returns>
  9389. [HttpPost]
  9390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9391. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  9392. {
  9393. #region 参数验证
  9394. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9395. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9396. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9397. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9398. #region 页面操作权限验证
  9399. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9400. if (_dto.Id == 0) //添加
  9401. {
  9402. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9403. }
  9404. else if (_dto.Id >= 0) //修改
  9405. {
  9406. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9407. }
  9408. #endregion
  9409. #endregion
  9410. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  9411. if (viewData.Code != 0)
  9412. {
  9413. return Ok(JsonView(false, viewData.Msg));
  9414. }
  9415. return Ok(JsonView(true));
  9416. }
  9417. /// <summary>
  9418. /// 接团客户名单
  9419. /// AddMultiple(添加多个)
  9420. /// </summary>
  9421. /// <param name="_dto"></param>
  9422. /// <returns></returns>
  9423. [HttpPost]
  9424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9425. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  9426. {
  9427. #region 参数验证
  9428. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9429. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9430. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9431. #region 页面操作权限验证
  9432. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9433. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9434. #endregion
  9435. #endregion
  9436. var viewData = await _tourClientListRep._AddMultiple(_dto);
  9437. if (viewData.Code != 0)
  9438. {
  9439. return Ok(JsonView(false, viewData.Msg));
  9440. }
  9441. return Ok(JsonView(true));
  9442. }
  9443. /// <summary>
  9444. /// 接团客户名单
  9445. /// Del
  9446. /// </summary>
  9447. /// <param name="_dto"></param>
  9448. /// <returns></returns>
  9449. [HttpPost]
  9450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9451. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  9452. {
  9453. #region 参数验证
  9454. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9455. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9456. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9457. #region 页面操作权限验证
  9458. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9459. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9460. #endregion
  9461. #endregion
  9462. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  9463. if (viewData.Code != 0)
  9464. {
  9465. return Ok(JsonView(false, viewData.Msg));
  9466. }
  9467. return Ok(JsonView(true));
  9468. }
  9469. /// <summary>
  9470. /// 接团客户名单
  9471. /// 文件下载 客户名单
  9472. /// </summary>
  9473. /// <param name="_dto"></param>
  9474. /// <returns></returns>
  9475. [HttpPost]
  9476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9477. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  9478. {
  9479. #region 参数验证
  9480. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9481. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9482. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  9483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9484. #region 页面操作权限验证
  9485. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9486. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9487. #endregion
  9488. #endregion
  9489. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9490. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9491. From Grp_TourClientList tcl
  9492. Left Join
  9493. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9494. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9495. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9496. From Crm_DeleClient dc
  9497. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9498. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9499. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9500. Where dc.IsDel = 0) temp
  9501. On temp.DcId =tcl.ClientId
  9502. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  9503. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  9504. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  9505. //载入模板
  9506. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  9507. if (_dto.Language == 1)
  9508. {
  9509. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  9510. }
  9511. //载入模板
  9512. var doc = new Document(tempPath);
  9513. DocumentBuilder builder = new DocumentBuilder(doc);
  9514. //获取word里所有表格
  9515. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9516. //获取所填表格的序数
  9517. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9518. var rowStart = tableOne.Rows[0]; //获取第1行
  9519. if (_dto.Language == 0)
  9520. {
  9521. //循环赋值
  9522. for (int i = 0; i < DcList.Count; i++)
  9523. {
  9524. builder.MoveToCell(0, i + 1, 0, 0);
  9525. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  9526. builder.MoveToCell(0, i + 1, 1, 0);
  9527. int sex = DcList[i].Sex;
  9528. string sexStr = string.Empty;
  9529. if (sex == 0) sexStr = "男";
  9530. else if (sex == 1) sexStr = "女";
  9531. else sexStr = "未设置";
  9532. builder.Write(sexStr);
  9533. builder.MoveToCell(0, i + 1, 2, 0);
  9534. string birthDay = DcList[i].BirthDay;
  9535. string birthDayStr = string.Empty;
  9536. if (!string.IsNullOrEmpty(birthDay))
  9537. {
  9538. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  9539. }
  9540. builder.Write(birthDayStr);
  9541. builder.MoveToCell(0, i + 1, 3, 0);
  9542. string company = "";
  9543. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9544. {
  9545. company = DcList[i].CompanyFullName.ToString();
  9546. }
  9547. builder.Write(company);
  9548. builder.MoveToCell(0, i + 1, 4, 0);
  9549. builder.Write(DcList[i].Job);
  9550. }
  9551. }
  9552. else if (_dto.Language == 1)
  9553. {
  9554. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  9555. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  9556. //循环赋值
  9557. for (int i = 0; i < DcList.Count; i++)
  9558. {
  9559. string PYName = "";
  9560. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  9561. {
  9562. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  9563. string PY_First = DcList[i].Pinyin.Split('/')[1];
  9564. PYName = PY_First + " " + PY_Last;
  9565. }
  9566. else
  9567. {
  9568. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  9569. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  9570. PYName = PY_First + " " + PY_Last;
  9571. }
  9572. builder.MoveToCell(0, i + 1, 0, 0);
  9573. builder.Write(PYName);
  9574. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  9575. builder.MoveToCell(0, i + 1, 1, 0);
  9576. builder.Write(sex);
  9577. DateTime birthDt;
  9578. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  9579. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  9580. builder.MoveToCell(0, i + 1, 2, 0);
  9581. builder.Write(birthday);
  9582. string company = "";
  9583. try
  9584. {
  9585. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9586. {
  9587. //查询对照表
  9588. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  9589. if (tempCec != null)
  9590. {
  9591. company = tempCec.enName;
  9592. }
  9593. //翻译
  9594. else
  9595. {
  9596. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  9597. }
  9598. }
  9599. }
  9600. catch (Exception)
  9601. {
  9602. }
  9603. builder.MoveToCell(0, i + 1, 3, 0);
  9604. builder.Write(company);
  9605. string job = "";
  9606. try
  9607. {
  9608. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  9609. {
  9610. //查询对照表
  9611. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  9612. if (tempPec != null)
  9613. {
  9614. job = tempPec.enName;
  9615. }
  9616. //翻译
  9617. else
  9618. {
  9619. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  9620. }
  9621. }
  9622. }
  9623. catch (Exception ex)
  9624. {
  9625. }
  9626. builder.MoveToCell(0, i + 1, 4, 0);
  9627. builder.Write(job);
  9628. }
  9629. }
  9630. //删除多余行
  9631. while (tableOne.Rows.Count > DcList.Count + 1)
  9632. {
  9633. tableOne.Rows.RemoveAt(DcList.Count + 1);
  9634. }
  9635. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  9636. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  9637. doc.Save(fileDir);
  9638. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  9639. return Ok(JsonView(true, "操作成功!", Url));
  9640. }
  9641. #endregion
  9642. #region 团组倒推表
  9643. /// <summary>
  9644. /// 倒推表基础数据
  9645. /// Init
  9646. /// </summary>
  9647. /// <param name="dto"></param>
  9648. /// <returns></returns>
  9649. [HttpPost]
  9650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9651. public async Task<IActionResult> PostInvertedListInit()
  9652. {
  9653. var viewData = await _invertedListRep._Init();
  9654. if (viewData.Code != 0)
  9655. {
  9656. return Ok(JsonView(false, viewData.Msg));
  9657. }
  9658. return Ok(JsonView(viewData.Data));
  9659. }
  9660. /// <summary>
  9661. /// 倒推表
  9662. /// Info
  9663. /// </summary>
  9664. /// <param name="dto"></param>
  9665. /// <returns></returns>
  9666. [HttpPost]
  9667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9668. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  9669. {
  9670. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  9671. if (viewData.Code != 0)
  9672. {
  9673. return Ok(JsonView(false, viewData.Msg));
  9674. }
  9675. return Ok(JsonView(viewData.Data));
  9676. }
  9677. /// <summary>
  9678. /// 倒推表
  9679. /// Create
  9680. /// </summary>
  9681. /// <param name="dto"></param>
  9682. /// <returns></returns>
  9683. [HttpPost]
  9684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9685. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  9686. {
  9687. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  9688. if (viewData.Code != 0)
  9689. {
  9690. return Ok(JsonView(false, viewData.Msg));
  9691. }
  9692. return Ok(JsonView(viewData.Data));
  9693. }
  9694. /// <summary>
  9695. /// 倒推表
  9696. /// Update
  9697. /// </summary>
  9698. /// <param name="dto"></param>
  9699. /// <returns></returns>
  9700. [HttpPost]
  9701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9702. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  9703. {
  9704. var viewData = await _invertedListRep._Update(dto);
  9705. if (viewData.Code != 0)
  9706. {
  9707. return Ok(JsonView(false, viewData.Msg));
  9708. }
  9709. return Ok(JsonView(viewData.Data));
  9710. }
  9711. /// <summary>
  9712. /// 倒推表
  9713. /// File Download
  9714. /// </summary>
  9715. /// <param name="dto"></param>
  9716. /// <returns></returns>
  9717. [HttpPost]
  9718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9719. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  9720. {
  9721. var info2 = await _invertedListRep._Info(1, dto.DiId);
  9722. if (info2.Code != 0)
  9723. {
  9724. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  9725. }
  9726. var info1 = info2.Data as InvertedListInfoView;
  9727. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  9728. string teamName = "";
  9729. if (info != null) teamName = info.TeamName;
  9730. //载入模板
  9731. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  9732. DocumentBuilder builder = new DocumentBuilder(doc);
  9733. //利用键值对存放数据
  9734. Dictionary<string, string> dic = new Dictionary<string, string>();
  9735. dic.Add("TeamName", teamName);
  9736. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  9737. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  9738. dic.Add("BPRemark", info1.ApprovalDataRemark);
  9739. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  9740. dic.Add("SQRemark", info1.ApprovalRemark);
  9741. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  9742. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  9743. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  9744. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  9745. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  9746. dic.Add("QZRemark", info1.VisaInformationRemark);
  9747. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  9748. dic.Add("SQQZRemark", info1.SendVisaRemark);
  9749. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  9750. dic.Add("CQRemark", info1.IssueVisaRemark);
  9751. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  9752. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  9753. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  9754. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  9755. #region 填充word模板书签内容
  9756. foreach (var key in dic.Keys)
  9757. {
  9758. builder.MoveToBookmark(key);
  9759. builder.Write(dic[key]);
  9760. }
  9761. #endregion
  9762. var fileDir = AppSettingsHelper.Get("WordBasePath");
  9763. string fileName = $"{teamName}团出行准备流程表.doc";
  9764. string filePath = fileDir + $@"InvertedList/{fileName}";
  9765. doc.Save(filePath);
  9766. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  9767. return Ok(JsonView(true, "操作成功!", Url));
  9768. }
  9769. #endregion
  9770. #region 三公签证费用(签证费、代办费)
  9771. /// <summary>
  9772. /// 三公签证费用(签证费、代办费)
  9773. /// List
  9774. /// </summary>
  9775. /// <returns></returns>
  9776. [HttpPost]
  9777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9778. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  9779. {
  9780. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  9781. if (_view.Code != 0)
  9782. {
  9783. return Ok(JsonView(false, _view.Msg));
  9784. }
  9785. return Ok(JsonView(true, "操作成功!", _view.Data));
  9786. }
  9787. /// <summary>
  9788. /// 三公签证费用(签证费、代办费)
  9789. /// Add Or Update
  9790. /// </summary>
  9791. /// <returns></returns>
  9792. [HttpPost]
  9793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9794. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  9795. {
  9796. var _view = await _visaFeeInfoRep._Update(_dto);
  9797. if (_view.Code != 0)
  9798. {
  9799. return Ok(JsonView(false, _view.Msg));
  9800. }
  9801. return Ok(JsonView(true, _view.Msg));
  9802. }
  9803. #endregion
  9804. #region 酒店询价
  9805. /// <summary>
  9806. /// 酒店询价
  9807. /// Init
  9808. /// </summary>
  9809. /// <param name="dto"></param>
  9810. /// <returns></returns>
  9811. [HttpPost]
  9812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9813. public async Task<IActionResult> PostHotelInquiryInit()
  9814. {
  9815. var res = await _hotelInquiryRep._Init();
  9816. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9817. return Ok(JsonView(true, res.Msg, res.Data));
  9818. }
  9819. /// <summary>
  9820. /// 酒店询价
  9821. /// page Item
  9822. /// </summary>
  9823. /// <param name="_dto"></param>
  9824. /// <returns></returns>
  9825. [HttpPost]
  9826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9827. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  9828. {
  9829. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  9830. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9831. var view = res.Data as PageDataViewBase;
  9832. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  9833. }
  9834. /// <summary>
  9835. /// 酒店询价
  9836. /// info
  9837. /// </summary>
  9838. /// <param name="_dto"></param>
  9839. /// <returns></returns>
  9840. [HttpPost]
  9841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9842. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  9843. {
  9844. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  9845. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9846. return Ok(JsonView(true, res.Msg, res.Data));
  9847. }
  9848. /// <summary>
  9849. /// 酒店询价
  9850. /// Add Or Edit
  9851. /// </summary>
  9852. /// <param name="_dto"></param>
  9853. /// <returns></returns>
  9854. [HttpPost]
  9855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9856. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  9857. {
  9858. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  9859. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9860. return Ok(JsonView(true, res.Msg, res.Data));
  9861. }
  9862. /// <summary>
  9863. /// 酒店询价
  9864. /// Del
  9865. /// </summary>
  9866. /// <param name="_dto"></param>
  9867. /// <returns></returns>
  9868. [HttpPost]
  9869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9870. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  9871. {
  9872. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  9873. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  9874. return Ok(JsonView(true, res.Msg, res.Data));
  9875. }
  9876. #endregion
  9877. #region 下载匹配op行程单
  9878. /// <summary>
  9879. /// 匹配op行程单
  9880. /// Init
  9881. /// </summary>
  9882. /// <param name="dto">团组列表请求dto</param>
  9883. /// <returns></returns>
  9884. [HttpPost]
  9885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9886. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  9887. {
  9888. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  9889. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9890. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  9891. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  9892. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  9893. .Where(it => it.IsDel == 0)
  9894. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  9895. .OrderByDescending(it => it.CreateUserId)
  9896. .ToList();
  9897. if (groupInfos.Count < 1) return Ok(JsonView(false,"暂无和你相关的团组信息!"));
  9898. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  9899. var diids = groupInfos.Select(it => it.Id).ToList();
  9900. List<string> countrys = new List<string>();
  9901. foreach (var item in country)
  9902. {
  9903. var data = _groupRepository.FormartTeamName(item);
  9904. var dataArray = _groupRepository.GroupSplitCountry(data);
  9905. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  9906. }
  9907. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  9908. List<string> areaArray = new List<string>(); //GetGroupCityLine
  9909. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  9910. foreach (var item in areaItem)
  9911. {
  9912. string areaStr = item.Value;
  9913. if (!string.IsNullOrEmpty(areaStr))
  9914. {
  9915. string[] str1 = areaStr.Split("-");
  9916. if (str1.Length > 0)
  9917. {
  9918. areaArray.AddRange(str1);
  9919. }
  9920. }
  9921. }
  9922. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  9923. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  9924. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  9925. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  9926. .ToList();
  9927. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  9928. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  9929. .Where(it => countriesIds.Contains(it.Id))
  9930. .Select(it => new { it.Id, Name = it.Name_CN })
  9931. .ToList();
  9932. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName) )
  9933. .Select(it => it.TeamName).ToList();
  9934. stopwatch.Stop();
  9935. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames,countriesDatas, citiesDatas = cityDatas }));
  9936. }
  9937. ///// <summary>
  9938. ///// 匹配op行程单
  9939. ///// Init 查询区域数据
  9940. ///// </summary>
  9941. ///// <param name="dto">团组列表请求dto</param>
  9942. ///// <returns></returns>
  9943. //[HttpPost]
  9944. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9945. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  9946. //{
  9947. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  9948. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  9949. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  9950. // if (string.IsNullOrEmpty(countriesDataStr))
  9951. // {
  9952. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  9953. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  9954. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  9955. // }
  9956. // else
  9957. // {
  9958. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  9959. // }
  9960. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  9961. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  9962. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  9963. // List<dynamic> childList = new List<dynamic>();
  9964. // int parentId = dto.CountriesId;
  9965. // if (provinceData.Count > 1)
  9966. // {
  9967. // foreach (var item1 in provinceData)
  9968. // {
  9969. // List<dynamic> childList1 = new List<dynamic>();
  9970. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  9971. // foreach (var item2 in citiesData1)
  9972. // {
  9973. // List<dynamic> childList2 = new List<dynamic>();
  9974. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  9975. // foreach (var item3 in countiesData1)
  9976. // {
  9977. // childList2.Add(new
  9978. // {
  9979. // id = item3.Id,
  9980. // parentId = item2.Id,
  9981. // level = "district",
  9982. // name = item3.Name_CN,
  9983. // });
  9984. // }
  9985. // childList1.Add(new
  9986. // {
  9987. // id = item2.Id,
  9988. // parentId = item1.Id,
  9989. // level = "city",
  9990. // name = item2.Name_CN,
  9991. // childList = childList2
  9992. // });
  9993. // }
  9994. // childList.Add(new
  9995. // {
  9996. // id = item1.Id,
  9997. // parentId = parentId,
  9998. // level = "province",
  9999. // name = item1.Name_CN,
  10000. // childList = childList1
  10001. // });
  10002. // }
  10003. // //城市
  10004. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10005. // foreach (var item2 in citiesData2)
  10006. // {
  10007. // List<dynamic> childList22 = new List<dynamic>();
  10008. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10009. // foreach (var item3 in countiesData1)
  10010. // {
  10011. // childList22.Add(new
  10012. // {
  10013. // id = item3.Id,
  10014. // parentId = item2.Id,
  10015. // level = "district",
  10016. // name = item3.Name_CN,
  10017. // });
  10018. // }
  10019. // childList.Add(new
  10020. // {
  10021. // id = item2.Id,
  10022. // parentId = parentId,
  10023. // level = "city",
  10024. // name = item2.Name_CN,
  10025. // childList = childList22
  10026. // });
  10027. // }
  10028. // }
  10029. // else
  10030. // {
  10031. // foreach (var item2 in citiesData)
  10032. // {
  10033. // string cname = item2.Name_CN;
  10034. // List<dynamic> childList1 = new List<dynamic>();
  10035. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10036. // foreach (var item3 in countiesData1)
  10037. // {
  10038. // childList1.Add(new
  10039. // {
  10040. // Id = item3.Id,
  10041. // parentId = item2.Id,
  10042. // level = "district",
  10043. // name = item3.Name_CN
  10044. // });
  10045. // }
  10046. // childList.Add(new
  10047. // {
  10048. // id = item2.Id,
  10049. // parentId = parentId,
  10050. // level = "city",
  10051. // name = item2.Name_CN,
  10052. // childList = childList1
  10053. // });
  10054. // }
  10055. // }
  10056. // stopwatch.Stop();
  10057. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10058. //}
  10059. /// <summary>
  10060. /// 匹配op行程单
  10061. /// 接团信息列表 Page
  10062. /// </summary>
  10063. /// <param name="dto">团组列表请求dto</param>
  10064. /// <returns></returns>
  10065. [HttpPost]
  10066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10067. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10068. {
  10069. var swatch = new Stopwatch();
  10070. swatch.Start();
  10071. #region 参数验证
  10072. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10073. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10074. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10075. #region 页面操作权限验证
  10076. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10077. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10078. #endregion
  10079. #endregion
  10080. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10081. {
  10082. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10083. string sqlWhere = "";
  10084. if (!string.IsNullOrEmpty(dto.Country))
  10085. {
  10086. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10087. }
  10088. if (!string.IsNullOrEmpty(dto.Area))
  10089. {
  10090. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10091. }
  10092. if (!string.IsNullOrEmpty(dto.TeamName))
  10093. {
  10094. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10095. }
  10096. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10097. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10098. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10099. swatch.Stop();
  10100. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10101. }
  10102. else
  10103. {
  10104. return Ok(JsonView(false, "查询失败"));
  10105. }
  10106. }
  10107. /// <summary>
  10108. /// 匹配op行程单
  10109. /// 行程单下载
  10110. /// </summary>
  10111. /// <param name="dto">团组列表请求dto</param>
  10112. /// <returns></returns>
  10113. [HttpPost]
  10114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10115. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10116. {
  10117. #region 参数验证
  10118. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10119. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10120. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10121. #region 页面操作权限验证
  10122. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10123. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10124. #endregion
  10125. #endregion
  10126. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10127. {
  10128. var res = ExportTravel(new InitOpTravelDto() { Diid = dto.diId });
  10129. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10130. }
  10131. else
  10132. {
  10133. return Ok(JsonView(false, "下载失败!"));
  10134. }
  10135. }
  10136. #endregion
  10137. #region 国家信息 数据 注释
  10138. //[HttpPost]
  10139. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10140. //{
  10141. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10142. // foreach (var item in dto)
  10143. // {
  10144. // infos.Add(new Grp_GroupsTaskAssignment()
  10145. // {
  10146. // DIId = item,
  10147. // CTId = 82,
  10148. // UId = 248,
  10149. // IsEnable = 1,
  10150. // CreateUserId = 233,
  10151. // CreateTime = DateTime.Now,
  10152. // IsDel = 0
  10153. // });
  10154. // infos.Add(new Grp_GroupsTaskAssignment()
  10155. // {
  10156. // DIId = item,
  10157. // CTId = 82,
  10158. // UId = 286,
  10159. // IsEnable = 1,
  10160. // CreateUserId = 233,
  10161. // CreateTime = DateTime.Now,
  10162. // IsDel = 0
  10163. // });
  10164. // }
  10165. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10166. // return Ok("操作成功");
  10167. //}
  10168. //public class paramJsonDto
  10169. //{
  10170. // public List<CountriesInfo> str { get; set; }
  10171. //}
  10172. //[HttpPost]
  10173. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10174. //{
  10175. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10176. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10177. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10178. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10179. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10180. // _sqlSugar.BeginTran();
  10181. // int countitiesIndex = 0;
  10182. // foreach (var item in dto.str)
  10183. // {
  10184. // dynamic data = item.c;
  10185. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10186. // if (data != null)
  10187. // {
  10188. // countitiesIndex++;
  10189. // foreach (var item1 in data)
  10190. // {
  10191. // string cnname = item1.cn;
  10192. // string enname = item1.en;
  10193. // Sys_Cities provinceInfo = new Sys_Cities()
  10194. // {
  10195. // CountriesId = countriesId,
  10196. // Name_CN = cnname,
  10197. // Name_EN = enname,
  10198. // ParentId = 0,
  10199. // IsCapital = 1,
  10200. // CreateUserId = 208,
  10201. // CreateTime = DateTime.Now,
  10202. // IsDel = 0
  10203. // };
  10204. // if (item1.lv == "province") //省份
  10205. // {
  10206. // provinceInfo.Level = 1;
  10207. // int provinceId = 0;
  10208. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10209. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10210. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10211. // var data1 = item1.c;
  10212. // foreach (var item2 in data1)
  10213. // {
  10214. // if (item2.lv == "city")
  10215. // {
  10216. // string citycnname = item2.cn;
  10217. // string cityenname = item2.en;
  10218. // Sys_Cities cityInfo = new Sys_Cities()
  10219. // {
  10220. // CountriesId = countriesId,
  10221. // ParentId = provinceId,
  10222. // Level = 2,
  10223. // Name_CN = citycnname,
  10224. // Name_EN = cityenname,
  10225. // IsCapital = 1,
  10226. // CreateUserId = 208,
  10227. // CreateTime = DateTime.Now,
  10228. // IsDel = 0
  10229. // };
  10230. // if (item2.c != null)
  10231. // {
  10232. // int cityId = 0;
  10233. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10234. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10235. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10236. // foreach (var item3 in item2.c)
  10237. // {
  10238. // if (item3.lv == "district")
  10239. // {
  10240. // var districtInfo = new Sys_Cities()
  10241. // {
  10242. // CountriesId = countriesId,
  10243. // Name_CN = item3.cn,
  10244. // Name_EN = item3.en,
  10245. // Level = 3,
  10246. // ParentId = cityId,
  10247. // IsCapital = 1,
  10248. // CreateUserId = 208,
  10249. // CreateTime = DateTime.Now,
  10250. // IsDel = 0
  10251. // };
  10252. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10253. // //{
  10254. // districts.Add(districtInfo);
  10255. // //}
  10256. // }
  10257. // }
  10258. // }
  10259. // else
  10260. // {
  10261. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10262. // //{
  10263. // cities.Add(cityInfo);
  10264. // //}
  10265. // }
  10266. // }
  10267. // }
  10268. // }
  10269. // else if (item1.lv == "city")//城市
  10270. // {
  10271. // provinceInfo.Level = 2;
  10272. // if (item1.c != null)
  10273. // {
  10274. // int cityId = 0;
  10275. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10276. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10277. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10278. // foreach (var item3 in item1.c)
  10279. // {
  10280. // if (item3.lv == "district")
  10281. // {
  10282. // var districtInfo = new Sys_Cities()
  10283. // {
  10284. // CountriesId = countriesId,
  10285. // Name_CN = item3.cn,
  10286. // Name_EN = item3.en,
  10287. // Level = 3,
  10288. // ParentId = cityId,
  10289. // IsCapital = 1,
  10290. // CreateUserId = 208,
  10291. // CreateTime = DateTime.Now,
  10292. // IsDel = 0
  10293. // };
  10294. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10295. // //{
  10296. // districts.Add(districtInfo);
  10297. // //}
  10298. // }
  10299. // }
  10300. // }
  10301. // else
  10302. // {
  10303. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10304. // //{
  10305. // cities.Add(provinceInfo);
  10306. // //}
  10307. // }
  10308. // }
  10309. // }
  10310. // }
  10311. // }
  10312. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10313. // cities = cities.Distinct().ToList();
  10314. // districts = districts.Distinct().ToList();
  10315. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10316. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10317. // cities.AddRange(districts);
  10318. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  10319. // //_sqlSugar.RollbackTran();
  10320. // _sqlSugar.CommitTran();
  10321. // return Ok(JsonView(false, "操作成功!"));
  10322. //}
  10323. //[HttpPost]
  10324. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  10325. //{
  10326. // List<CountitiesInfo> infos = dto.MyProperty;
  10327. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  10328. // _sqlSugar.BeginTran();
  10329. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10330. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  10331. // foreach (var item in infos)
  10332. // {
  10333. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  10334. // if (countryInfo != null)
  10335. // {
  10336. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  10337. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  10338. // if (cityInfo1 != null)
  10339. // {
  10340. // cityInfo1.IsCapital = 0;
  10341. // cityInfos.Add(cityInfo1);
  10342. // }
  10343. // }
  10344. // }
  10345. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  10346. // .UpdateColumns(it => it.IsCapital)
  10347. // .WhereColumns(it => it.Id)
  10348. // .ExecuteCommand();
  10349. // //_sqlSugar.RollbackTran();
  10350. // _sqlSugar.CommitTran();
  10351. // return Ok(JsonView(false, "操作成功!"));
  10352. //}
  10353. //public class CounrtiesDto
  10354. //{
  10355. // public List<CountitiesInfo> MyProperty { get; set; }
  10356. //}
  10357. //public class CountitiesInfo
  10358. //{
  10359. // /// <summary>
  10360. // /// 圣约翰
  10361. // /// </summary>
  10362. // public string capital_name_chinese { get; set; }
  10363. // /// <summary>
  10364. // ///
  10365. // /// </summary>
  10366. // public string capital_name { get; set; }
  10367. // /// <summary>
  10368. // ///
  10369. // /// </summary>
  10370. // public string country_type { get; set; }
  10371. // /// <summary>
  10372. // /// 安提瓜和巴布达
  10373. // /// </summary>
  10374. // public string country_name_chinese { get; set; }
  10375. // /// <summary>
  10376. // /// 安提瓜和巴布达
  10377. // /// </summary>
  10378. // public string country_name_chinese_short { get; set; }
  10379. // /// <summary>
  10380. // /// 安提瓜和巴布达
  10381. // /// </summary>
  10382. // public string country_name_chinese_UN { get; set; }
  10383. // /// <summary>
  10384. // ///
  10385. // /// </summary>
  10386. // public string country_name_english_abbreviation { get; set; }
  10387. // /// <summary>
  10388. // ///
  10389. // /// </summary>
  10390. // public string country_name_english_formal { get; set; }
  10391. // /// <summary>
  10392. // ///
  10393. // /// </summary>
  10394. // public string country_name_english_UN { get; set; }
  10395. // /// <summary>
  10396. // ///
  10397. // /// </summary>
  10398. // public string continent_name { get; set; }
  10399. // /// <summary>
  10400. // ///
  10401. // /// </summary>
  10402. // public string subregion_name { get; set; }
  10403. // /// <summary>
  10404. // ///
  10405. // /// </summary>
  10406. // public string country_code2 { get; set; }
  10407. // /// <summary>
  10408. // ///
  10409. // /// </summary>
  10410. // public string country_code3 { get; set; }
  10411. // /// <summary>
  10412. // ///
  10413. // /// </summary>
  10414. // public string phone_code { get; set; }
  10415. //}
  10416. //public class CountriesInfo : BasicInfo
  10417. //{
  10418. // public List<CitiesInfo> c { get; set; }
  10419. //}
  10420. //public class CitiesInfo : BasicInfo
  10421. //{
  10422. // public List<AreaInfo> c { get; set; }
  10423. //}
  10424. //public class AreaInfo : BasicInfo
  10425. //{
  10426. // public List<AreaInfo> c { get; set; }
  10427. //}
  10428. //public class BasicInfo
  10429. //{
  10430. // public string code { get; set; }
  10431. // public string cn { get; set; }
  10432. // public string lv { get; set; }
  10433. // public string en { get; set; }
  10434. //}
  10435. #endregion
  10436. #region 查看邀请方
  10437. /// <summary>
  10438. /// 查看邀请方
  10439. /// 邀请方信息 Init
  10440. /// </summary>
  10441. /// <param name="dto"></param>
  10442. /// <returns></returns>
  10443. [HttpPost]
  10444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10445. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  10446. {
  10447. string sqlWhere = string.Empty;
  10448. if (!string.IsNullOrEmpty(dto.Search))
  10449. {
  10450. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  10451. }
  10452. string sql = string.Format($@"Select
  10453. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  10454. Id,
  10455. UnitName
  10456. From Res_InvitationOfficialActivityData
  10457. Where IsDel = 0
  10458. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  10459. RefAsync<int> total = 0;
  10460. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10461. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  10462. }
  10463. /// <summary>
  10464. /// 查看邀请方
  10465. /// 国家信息 Init
  10466. /// </summary>
  10467. /// <param name="dto"></param>
  10468. /// <returns></returns>
  10469. [HttpPost]
  10470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10471. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  10472. {
  10473. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10474. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10475. var diids = groupInfos.Select(it => it.Id).ToList();
  10476. List<string> countrys = new List<string>();
  10477. foreach (var item in country)
  10478. {
  10479. var data = _groupRepository.FormartTeamName(item);
  10480. var dataArray = _groupRepository.GroupSplitCountry(data);
  10481. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10482. }
  10483. countrys = countrys.Distinct().ToList();
  10484. for (int i = 0; i < countrys.Count; i++)
  10485. {
  10486. string item = countrys[i];
  10487. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10488. {
  10489. countrys.Remove(item);
  10490. i--;
  10491. }
  10492. }
  10493. RefAsync<int> total = 0;
  10494. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10495. .Where(it => countrys.Contains(it.Name_CN))
  10496. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10497. .Select(it => new { id = it.Id, name = it.Name_CN })
  10498. .ToPageListAsync(dto.PageIndex,dto.PageSize, total);
  10499. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10500. }
  10501. /// <summary>
  10502. /// 查看邀请方
  10503. /// 城市信息 Init
  10504. /// </summary>
  10505. /// <param name="dto"></param>
  10506. /// <returns></returns>
  10507. [HttpPost]
  10508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10509. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  10510. {
  10511. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  10512. RefAsync<int> total = 0;
  10513. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  10514. .Where(it => it.CountriesId == dto.CountiesId)
  10515. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10516. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  10517. .Select(it => new { id = it.Id, name = it.Name_CN })
  10518. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10519. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10520. }
  10521. /// <summary>
  10522. /// 查看邀请方
  10523. /// 团组名称 Init
  10524. /// </summary>
  10525. /// <param name="dto"></param>
  10526. /// <returns></returns>
  10527. [HttpPost]
  10528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10529. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  10530. {
  10531. var watch = new Stopwatch();
  10532. watch.Start();
  10533. RefAsync<int> total = 0;
  10534. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  10535. .InnerJoin<Grp_DelegationInfo>((oa,di) => oa.DiId == di.Id)
  10536. .Where((oa, di) => oa.IsDel == 0)
  10537. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  10538. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  10539. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  10540. .Distinct()
  10541. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10542. watch.Stop();
  10543. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  10544. }
  10545. /// <summary>
  10546. /// 查看邀请方
  10547. /// 团组 & 邀请方信息
  10548. /// </summary>
  10549. /// <param name="dto"></param>
  10550. /// <returns></returns>
  10551. [HttpPost]
  10552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10553. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  10554. {
  10555. var watch = new Stopwatch();
  10556. watch.Start();
  10557. RefAsync<int> total = 0;
  10558. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  10559. .AS("Grp_DelegationInfo")
  10560. .Includes(x => x.InvitingInfos)
  10561. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  10562. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  10563. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  10564. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  10565. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  10566. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  10567. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10568. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  10569. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  10570. infos.ForEach(x => {
  10571. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  10572. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  10573. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  10574. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  10575. });
  10576. watch.Stop();
  10577. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  10578. }
  10579. #endregion
  10580. #region 报批行程
  10581. /// <summary>
  10582. /// 报批行程初始化
  10583. /// </summary>
  10584. /// <param name="dto"></param>
  10585. /// <returns></returns>
  10586. [HttpPost]
  10587. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10588. {
  10589. const int chiNumber = 5;
  10590. var jw = JsonView(false);
  10591. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10592. var group = groupList.First();
  10593. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10594. group = groupList.First(x => x.Id == diid);
  10595. if (group == null)
  10596. {
  10597. jw.Msg = "暂无团组!";
  10598. return Ok(jw);
  10599. }
  10600. var resultArr = new ArrayList();
  10601. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  10602. if (content.Count == 0)
  10603. {
  10604. var stay = "-";
  10605. var cityPath = "-";
  10606. //添加城市路径以及住宿地
  10607. //黑屏代码数据
  10608. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10609. DateTime StartDate = (group.VisitStartDate);
  10610. DateTime EndDate = (group.VisitEndDate);
  10611. TimeSpan t3 = EndDate - StartDate; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
  10612. var getDay = t3.Days;
  10613. if (getDay == 0) getDay = 1;
  10614. //获取时间区间
  10615. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10616. _sqlSugar.BeginTran();
  10617. for (int i = 0; i < getDay; i++)
  10618. {
  10619. stay = "-";
  10620. cityPath = "-";
  10621. DateTime NewData = StartDate.AddDays(i);
  10622. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10623. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10624. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10625. if (tbSelect.Length > 0)
  10626. {
  10627. List<string> threeCodeStr = new List<string>();
  10628. foreach (var item in tbSelect)
  10629. {
  10630. var threeCode = item["Three"].ToString() ?? "";
  10631. if (threeCode.Length == 6)
  10632. {
  10633. var start = threeCode.Substring(0, 3);
  10634. var end = threeCode.Substring(3, 3);
  10635. if (threeCodeStr.Count == 0)
  10636. {
  10637. threeCodeStr.Add(start);
  10638. threeCodeStr.Add(end);
  10639. }
  10640. else
  10641. {
  10642. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  10643. {
  10644. threeCodeStr.Add(end);
  10645. }
  10646. else {
  10647. threeCodeStr.Add(start);
  10648. threeCodeStr.Add(end);
  10649. }
  10650. }
  10651. }
  10652. }
  10653. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  10654. var last = threeCodeStr.Last();
  10655. foreach (var item in threeCodeStr)
  10656. {
  10657. cityPath += threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  10658. if(item.Equals(last))
  10659. {
  10660. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  10661. }
  10662. }
  10663. }
  10664. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  10665. appro.Diid = diid ?? -1;
  10666. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  10667. appro.Id = thisId;
  10668. appro.CreateUserId = dto.UserId;
  10669. appro.CreateTime = DateTime.Now;
  10670. content.Add(appro);
  10671. }
  10672. _sqlSugar.CommitTran();
  10673. }
  10674. foreach (var x in content)
  10675. {
  10676. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  10677. if (chiList.Count < chiNumber)
  10678. {
  10679. for (int i = chiList.Count; i < chiNumber; i++)
  10680. {
  10681. chiList.Add(new Grp_ApprovalTravelDetails());
  10682. }
  10683. }
  10684. resultArr.Add(new
  10685. {
  10686. x.Id,
  10687. x.Date,
  10688. x.Diid,
  10689. chiList = chiList.Select(x1 => new
  10690. {
  10691. timeInterval = x1.Time == null ? new string [1] : x1.Time.Split('-'),
  10692. x1.Details,
  10693. x1.ParentId,
  10694. x1.Id
  10695. })
  10696. });
  10697. }
  10698. var data = new
  10699. {
  10700. groupList = groupList.Select(x => new
  10701. {
  10702. x.TeamName,
  10703. x.Id
  10704. }),
  10705. content = resultArr,
  10706. groupInfo = new
  10707. {
  10708. group.VisitDays,
  10709. group.TourCode,
  10710. group.VisitPNumber,
  10711. group.TeamName,
  10712. group.Id,
  10713. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  10714. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  10715. },
  10716. };
  10717. jw = JsonView(true,"获取成功!",data);
  10718. return Ok(jw);
  10719. }
  10720. /// <summary>
  10721. /// 报批行程删除
  10722. /// </summary>
  10723. /// <param name="dto"></param>
  10724. /// <returns></returns>
  10725. [HttpPost]
  10726. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  10727. {
  10728. var jw = JsonView(false);
  10729. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  10730. if (group == null)
  10731. {
  10732. jw.Msg = "团组参数有误!";
  10733. return Ok(jw);
  10734. }
  10735. try
  10736. {
  10737. _sqlSugar.BeginTran();
  10738. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x=>x.Id).ToList();
  10739. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  10740. {
  10741. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10742. DeleteUserId = dto.uesrId,
  10743. IsDel = 1
  10744. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  10745. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  10746. {
  10747. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10748. DeleteUserId = dto.uesrId,
  10749. IsDel = 1
  10750. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  10751. _sqlSugar.CommitTran();
  10752. jw = JsonView(true, "删除成功");
  10753. }
  10754. catch (Exception ex)
  10755. {
  10756. jw = JsonView(false, ex.Message);
  10757. }
  10758. return Ok(jw);
  10759. }
  10760. /// <summary>
  10761. /// 报批行程保存
  10762. /// </summary>
  10763. /// <param name="dto"></param>
  10764. /// <returns></returns>
  10765. [HttpPost]
  10766. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  10767. {
  10768. var jw = JsonView(false);
  10769. var Find = dto.Arr.Find(x => x.id == 0);
  10770. if (Find != null)
  10771. {
  10772. jw.Msg = "生成的ID为0!";
  10773. return Ok(jw);
  10774. }
  10775. foreach (var item in dto.Arr)
  10776. {
  10777. foreach (var chi in item.chiList)
  10778. {
  10779. if (chi.parentId == 0)
  10780. {
  10781. chi.parentId = item.id;
  10782. }
  10783. }
  10784. }
  10785. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  10786. _sqlSugar.BeginTran();
  10787. if (chiArr.Where(x=>x.id == 0).Count() == chiArr.Count)
  10788. {
  10789. var parentIds = dto.Arr.Select(x => x.id).ToList();
  10790. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x=>new Grp_ApprovalTravelDetails
  10791. {
  10792. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10793. DeleteUserId = dto.UserId,
  10794. IsDel = 1
  10795. }).ExecuteCommand();
  10796. }
  10797. try
  10798. {
  10799. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  10800. {
  10801. CreateTime = DateTime.Now,
  10802. CreateUserId = dto.UserId,
  10803. Details = x.details,
  10804. ParentId = x.parentId,
  10805. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  10806. Remark = "",
  10807. IsDel = 0
  10808. }).ToList()).ExecuteCommand();
  10809. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  10810. {
  10811. Id = x.id,
  10812. Details = x.details,
  10813. ParentId = x.parentId,
  10814. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  10815. }).ToList()).UpdateColumns(x=> new Grp_ApprovalTravelDetails
  10816. {
  10817. Details = x.Details,
  10818. ParentId = x.ParentId,
  10819. Time = x.Time
  10820. }).ExecuteCommand();
  10821. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  10822. {
  10823. Id = x.id,
  10824. Date = x.date,
  10825. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  10826. {
  10827. Date = x.Date
  10828. }).ExecuteCommand();
  10829. _sqlSugar.CommitTran();
  10830. jw = JsonView(true, "保存成功!");
  10831. }
  10832. catch (Exception ex)
  10833. {
  10834. _sqlSugar.RollbackTran();
  10835. jw = JsonView(false, "保存失败!" + ex.Message);
  10836. }
  10837. return Ok(jw);
  10838. }
  10839. /// <summary>
  10840. /// 报批行程生成
  10841. /// </summary>
  10842. /// <param name="dto"></param>
  10843. /// <returns></returns>
  10844. [HttpPost]
  10845. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  10846. {
  10847. var jw = JsonView(false);
  10848. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10849. if (group == null)
  10850. {
  10851. jw.Msg = "暂无该团组!";
  10852. return Ok(jw);
  10853. }
  10854. DateTime StartDate = (group.VisitStartDate);
  10855. DateTime EndDate = (group.VisitEndDate);
  10856. TimeSpan t3 = EndDate - StartDate;
  10857. var getDay = t3.Days;
  10858. if (getDay == 0) getDay = 1;
  10859. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10860. var resultArr = new ArrayList();
  10861. if (officialActivitiesArr.Count == 0)
  10862. {
  10863. jw.Msg = "暂无公务出访信息!";
  10864. return Ok(jw);
  10865. }
  10866. try
  10867. {
  10868. _sqlSugar.BeginTran();
  10869. DeleteApprovalJourney(new
  10870. Domain.Dtos.Groups.DeleteApprovalJourney
  10871. {
  10872. Diid = dto.Diid,
  10873. uesrId = dto.Userid
  10874. });
  10875. var stay = "-";
  10876. var cityPath = "-";
  10877. //添加城市路径以及住宿地
  10878. //黑屏代码数据
  10879. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10880. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10881. for (int i = 0; i < getDay; i++)
  10882. {
  10883. DateTime NewData = StartDate.AddDays(i);
  10884. 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();
  10885. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10886. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10887. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  10888. appro.Diid = dto.Diid;
  10889. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  10890. appro.Id = thisId;
  10891. appro.CreateUserId = dto.Userid;
  10892. appro.CreateTime = DateTime.Now;
  10893. var chiarr = new List<Grp_ApprovalTravelDetails>();
  10894. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10895. if (tbSelect.Length > 0)
  10896. {
  10897. }
  10898. foreach (var item in gwinfo)
  10899. {
  10900. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  10901. chi.Details = "拜访" + item.Client;
  10902. chi.ParentId = thisId;
  10903. chi.Time = item.Time;
  10904. chiarr.Add(chi);
  10905. }
  10906. if (chiarr.Count < 5)
  10907. {
  10908. for (int j = chiarr.Count; j < 5; j++)
  10909. {
  10910. chiarr.Add(new
  10911. Grp_ApprovalTravelDetails());
  10912. }
  10913. }
  10914. resultArr.Add(new
  10915. {
  10916. appro.Id,
  10917. appro.Date,
  10918. appro.Diid,
  10919. chiList = chiarr.Select(x1 => new
  10920. {
  10921. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  10922. x1.Details,
  10923. x1.ParentId,
  10924. x1.Id
  10925. })
  10926. });
  10927. }
  10928. _sqlSugar.CommitTran();
  10929. jw = JsonView(true, "生成成功!", resultArr);
  10930. }
  10931. catch (Exception ex)
  10932. {
  10933. jw.Code = 400;
  10934. jw.Msg = "生成失败!" + ex.Message;
  10935. }
  10936. return Ok(jw);
  10937. }
  10938. /// <summary>
  10939. /// 报批行程word导出
  10940. /// </summary>
  10941. /// <param name="dto"></param>
  10942. /// <returns></returns>
  10943. [HttpPost]
  10944. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  10945. {
  10946. var jw = JsonView(false);
  10947. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10948. if (group == null)
  10949. {
  10950. jw.Msg = "暂无该团组!";
  10951. return Ok(jw);
  10952. }
  10953. //模板路径
  10954. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx");
  10955. //载入模板
  10956. Document doc = new Document(tempPath);
  10957. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10958. //获取所填表格的序数
  10959. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10960. Aspose.Words.Tables.Row titleRowClone = null;
  10961. Aspose.Words.Tables.Row CenterRowClone = null;
  10962. int index = 0;
  10963. int indexChi = 0;
  10964. int SetIndex = 0;
  10965. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  10966. //获取数据,放到datatable
  10967. foreach (var item in ApprovalTravelArr)
  10968. {
  10969. if (index > 0)
  10970. {
  10971. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  10972. tableOne.AppendChild(titleRowClone);
  10973. }
  10974. var textTime = item.Date;
  10975. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  10976. SetCells(tableOne, doc, SetIndex, 0, textTime);
  10977. SetIndex++;
  10978. if (ChiRep.Count > 0)
  10979. {
  10980. foreach (var itemChi in ChiRep)
  10981. {
  10982. var txtTime = itemChi.Time;
  10983. var txtDetail = itemChi.Details;
  10984. if (indexChi > 0)
  10985. {
  10986. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  10987. tableOne.AppendChild(CenterRowClone);
  10988. }
  10989. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  10990. {
  10991. SetCells(tableOne, doc, SetIndex, 0, "");
  10992. SetCells(tableOne, doc, SetIndex, 1, "");
  10993. indexChi++;
  10994. SetIndex++;
  10995. break;
  10996. }
  10997. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  10998. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  10999. indexChi++;
  11000. SetIndex++;
  11001. }
  11002. }
  11003. else
  11004. {
  11005. if (indexChi > 0)
  11006. {
  11007. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11008. tableOne.AppendChild(CenterRowClone);
  11009. }
  11010. SetCells(tableOne, doc, SetIndex, 0, "");
  11011. SetCells(tableOne, doc, SetIndex, 1, "");
  11012. indexChi++;
  11013. SetIndex++;
  11014. }
  11015. index++;
  11016. }
  11017. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11018. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);
  11019. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; ;
  11020. jw.Code = 200;
  11021. jw.Msg = "";
  11022. return Ok(jw);
  11023. }
  11024. private string intToString(int numberVal)
  11025. {
  11026. string numberval = numberVal.ToString();
  11027. Dictionary<char, string> Number = new Dictionary<char, string>();
  11028. Number.Add('1', "一");
  11029. Number.Add('2', "二");
  11030. Number.Add('3', "三");
  11031. Number.Add('4', "四");
  11032. Number.Add('5', "五");
  11033. Number.Add('6', "六");
  11034. Number.Add('7', "七");
  11035. Number.Add('8', "八");
  11036. Number.Add('9', "九");
  11037. string stringNumberVal = string.Empty;
  11038. for (int i = 0; i < numberval.Length; i++)
  11039. {
  11040. if (i == 0)
  11041. {
  11042. stringNumberVal += Number[numberval[i]];
  11043. }
  11044. else if (i >= 1)
  11045. {
  11046. if (numberval[i] == '0')
  11047. {
  11048. stringNumberVal = "十";
  11049. }
  11050. else
  11051. {
  11052. stringNumberVal += "十" + Number[numberval[i]];
  11053. }
  11054. }
  11055. }
  11056. return stringNumberVal;
  11057. }
  11058. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11059. {
  11060. //获取table中的某个单元格,从0开始
  11061. Cell lshCell = table.Rows[rows].Cells[cells];
  11062. //将单元格中的第一个段落移除
  11063. lshCell.FirstParagraph.Remove();
  11064. //新建一个段落
  11065. Paragraph p = new Paragraph(doc);
  11066. var r = new Run(doc, val);
  11067. //把设置的值赋给之前新建的段落
  11068. p.AppendChild(r);
  11069. //将此段落加到单元格内
  11070. lshCell.AppendChild(p);
  11071. }
  11072. [HttpPost]
  11073. public async Task<IActionResult> ServerHttp(string paramStr)
  11074. {
  11075. paramStr = paramStr.TrimEnd('\'');
  11076. paramStr = paramStr.TrimStart('\'');
  11077. JsonView jw = JsonView(false);
  11078. JObject param = JObject.Parse(paramStr);
  11079. if (!param.ContainsKey("url"))
  11080. {
  11081. jw.Msg = "url null";
  11082. return Ok(jw);
  11083. }
  11084. string url = param["url"]!.ToString();
  11085. var methon = "get";
  11086. Dictionary<string, string> bodyValues = null;
  11087. Dictionary<string, string> headValues = null;
  11088. if (param.ContainsKey("methon"))
  11089. {
  11090. methon = param["methon"]!.ToString();
  11091. }
  11092. if (param.ContainsKey("header"))
  11093. {
  11094. var header = param["header"]!.ToString();
  11095. JObject headerJobject = JObject.Parse(header);
  11096. headValues = new Dictionary<string, string>();
  11097. foreach (JProperty item in headerJobject.Properties())
  11098. {
  11099. var value = item.Value.ToString();
  11100. var head = item.Path;
  11101. headValues.Add(head, value);
  11102. }
  11103. }
  11104. if (param.ContainsKey("body"))
  11105. {
  11106. var body = param["body"]!.ToString();
  11107. bodyValues = new Dictionary<string, string>();
  11108. JObject bodyJobject = JObject.Parse(body);
  11109. foreach (JProperty item in bodyJobject.Properties())
  11110. {
  11111. var value = item.Value.ToString();
  11112. var head = item.Path;
  11113. bodyValues.Add(head, value);
  11114. }
  11115. }
  11116. HttpClient client = new HttpClient();
  11117. string responseString = string.Empty;
  11118. if (param.ContainsKey("isJson"))
  11119. {
  11120. }
  11121. if (headValues != null)
  11122. {
  11123. foreach (var item in headValues.Keys)
  11124. {
  11125. client.DefaultRequestHeaders.Add(item, headValues[item]);
  11126. }
  11127. }
  11128. try
  11129. {
  11130. if (methon == "get")
  11131. {
  11132. responseString = await client.GetStringAsync(url);
  11133. }
  11134. else if (methon == "post")
  11135. {
  11136. if (bodyValues == null)
  11137. {
  11138. jw.Msg = "methon post body null";
  11139. return Ok(jw);
  11140. }
  11141. // 数据转化为 key=val 格式
  11142. var content = new FormUrlEncodedContent(bodyValues);
  11143. var response = await client.PostAsync(url, content);
  11144. // 获取数据
  11145. responseString = await response.Content.ReadAsStringAsync();
  11146. }
  11147. else
  11148. {
  11149. jw.Msg = "methon error";
  11150. }
  11151. jw = JsonView(true, "success", responseString);
  11152. }
  11153. catch (Exception ex)
  11154. {
  11155. jw.Msg = "error " + ex.Message;
  11156. jw.Data = ex.StackTrace;
  11157. }
  11158. finally
  11159. {
  11160. client.Dispose();
  11161. }
  11162. return Ok(jw);
  11163. }
  11164. #endregion
  11165. // /// <summary>
  11166. // ///
  11167. // /// </summary>
  11168. // /// <param name="_dto"></param>
  11169. // /// <returns></returns>
  11170. // [HttpPost]
  11171. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11172. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11173. // {
  11174. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11175. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11176. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11177. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11178. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11179. // dic_psg.Add("客人", 974);
  11180. // dic_psg.Add("司机", 975);
  11181. // dic_psg.Add("导游", 976);
  11182. // dic_psg.Add("公司内部人员", 977);
  11183. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11184. // foreach (var item in list_visa)
  11185. // {
  11186. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11187. // temp.Id = item.Id;
  11188. // temp.DIId = item.DIId;
  11189. // temp.VisaClient = item.VisaClient;
  11190. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11191. // temp.VisaCurrency = item.VisaCurrency;
  11192. // temp.IsThird = item.IsThird;
  11193. // if (dic_psg.ContainsKey(item.PassengerType))
  11194. // {
  11195. // temp.PassengerType = dic_psg[item.PassengerType];
  11196. // }
  11197. // else {
  11198. // temp.PassengerType = -1;
  11199. // }
  11200. // temp.VisaNumber = item.VisaNumber;
  11201. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11202. // temp.CreateUserId = item.Operators;
  11203. // DateTime dt_ct;
  11204. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11205. // if (b_ct)
  11206. // {
  11207. // temp.CreateTime = dt_ct;
  11208. // }
  11209. // else
  11210. // {
  11211. // temp.CreateTime = DateTime.Now;
  11212. // }
  11213. // temp.DeleteTime = "";
  11214. // temp.DeleteUserId = 0;
  11215. // temp.Remark = item.Remark;
  11216. // if (string.IsNullOrEmpty(temp.Remark)) {
  11217. // temp.Remark = "";
  11218. // }
  11219. // temp.IsDel = item.IsDel;
  11220. // temp.VisaDescription = item.VisaAttachment;
  11221. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11222. //([Id]
  11223. // ,[DIId]
  11224. // ,[VisaClient]
  11225. // ,[VisaPrice]
  11226. // ,[VisaCurrency]
  11227. // ,[IsThird]
  11228. // ,[PassengerType]
  11229. // ,[VisaNumber]
  11230. // ,[VisaFreeNumber]
  11231. // ,[CreateUserId]
  11232. // ,[CreateTime]
  11233. // ,[DeleteTime]
  11234. // ,[DeleteUserId]
  11235. // ,[Remark]
  11236. // ,[IsDel]
  11237. // ,[visaDescription])
  11238. // VALUES
  11239. // ({0},{1},'{2}',{3},{4}
  11240. //,{5},{6},{7},{8},{9}
  11241. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11242. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11243. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11244. //);
  11245. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11246. // }
  11247. // return Ok(JsonView(true, "操作成功!"));
  11248. // }
  11249. /// <summary>
  11250. /// 123132123
  11251. /// </summary>
  11252. /// <param name="_dto"></param>
  11253. /// <returns></returns>
  11254. [HttpPost]
  11255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11256. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11257. {
  11258. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11259. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11260. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11261. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11262. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11263. dicDetail.Add(789, 1034);
  11264. dicDetail.Add(790, 1035);
  11265. dicDetail.Add(791, 1036);
  11266. dicDetail.Add(792, 1037);
  11267. dicDetail.Add(793, 1038);
  11268. dicDetail.Add(794, 1039);
  11269. dicDetail.Add(795, 1040);
  11270. dicDetail.Add(796, 1041);
  11271. dicDetail.Add(797, 1042);
  11272. dicDetail.Add(798, 1043);
  11273. dicDetail.Add(801, 1044);
  11274. dicDetail.Add(802, 1045);
  11275. dicDetail.Add(803, 1046);
  11276. Dictionary<int, int> dic = new Dictionary<int, int>();
  11277. dic.Add(806, 1027);
  11278. dic.Add(807, 1028);
  11279. dic.Add(808, 1029);
  11280. dic.Add(809, 1030);
  11281. dic.Add(810, 1031);
  11282. dic.Add(811, 1032);
  11283. dic.Add(812, 1033);
  11284. foreach (var item in list_visa)
  11285. {
  11286. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11287. temp.Coefficient = item.coefficient;
  11288. DateTime dtCrt;
  11289. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11290. if (b1)
  11291. {
  11292. temp.CreateTime = dtCrt;
  11293. }
  11294. else
  11295. {
  11296. temp.CreateTime = DateTime.Now;
  11297. }
  11298. temp.CreateUserId = item.Operators;
  11299. temp.DeleteTime = "";
  11300. temp.DeleteUserId = 0;
  11301. temp.DiId = int.Parse(item.DIID);
  11302. temp.FilePath = item.FilePath;
  11303. temp.IsDel = item.IsDel;
  11304. temp.Price = item.Price;
  11305. temp.PriceCount = 1;
  11306. temp.PriceCurrency = item.Currency;
  11307. int detailId = 0;
  11308. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11309. {
  11310. detailId = dicDetail[item.PriceTypeDetail];
  11311. }
  11312. temp.PriceDetailType = detailId;
  11313. temp.PriceDt = DateTime.Now;
  11314. temp.PriceName = item.PriceName;
  11315. temp.PriceSum = item.Price;
  11316. int tid = 0;
  11317. if (dic.ContainsKey(item.PriceType))
  11318. {
  11319. tid = dic[item.PriceType];
  11320. }
  11321. temp.PriceType = tid;
  11322. temp.Remark = item.Remark;
  11323. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11324. }
  11325. return Ok(JsonView(true, "操作成功!"));
  11326. }
  11327. }
  11328. }