GroupsController.cs 717 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using EyeSoft.IO;
  6. using Microsoft.AspNetCore.SignalR;
  7. using MySqlX.XDevAPI.Relational;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.Format;
  10. using NPOI.SS.UserModel;
  11. using NPOI.SS.Util;
  12. using NPOI.XSSF.UserModel;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  19. using OASystem.Domain.Dtos.CRM;
  20. using OASystem.Domain.Dtos.FileDto;
  21. using OASystem.Domain.Dtos.Financial;
  22. using OASystem.Domain.Dtos.Groups;
  23. using OASystem.Domain.Entities.Customer;
  24. using OASystem.Domain.Entities.Financial;
  25. using OASystem.Domain.Entities.Groups;
  26. using OASystem.Domain.ViewModels;
  27. using OASystem.Domain.ViewModels.Groups;
  28. using OASystem.Domain.ViewModels.Statistics;
  29. using OASystem.Infrastructure.Repositories.Financial;
  30. using OASystem.Infrastructure.Repositories.Groups;
  31. using Quartz.Util;
  32. using SqlSugar;
  33. using SqlSugar.Extensions;
  34. using System.Collections;
  35. using System.Data;
  36. using System.Diagnostics;
  37. using System.Globalization;
  38. using System.IO;
  39. using System.IO.Compression;
  40. using System.Net.Http;
  41. using System.Reflection.PortableExecutable;
  42. using Ubiety.Dns.Core;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using Bookmark = Aspose.Words.Bookmark;
  46. using Cell = Aspose.Words.Tables.Cell;
  47. using Table = Aspose.Words.Tables.Table;
  48. namespace OASystem.API.Controllers
  49. {
  50. /// <summary>
  51. /// 团组相关
  52. /// </summary>
  53. //[Authorize]
  54. [Route("api/[controller]/[action]")]
  55. public class GroupsController : ControllerBase
  56. {
  57. private readonly ILogger<GroupsController> _logger;
  58. private readonly GrpScheduleRepository _grpScheduleRep;
  59. private readonly IMapper _mapper;
  60. private readonly DelegationInfoRepository _groupRepository;
  61. private readonly TaskAssignmentRepository _taskAssignmentRep;
  62. private readonly AirTicketResRepository _airTicketResRep;
  63. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  64. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  65. private readonly DelegationEnDataRepository _delegationEnDataRep;
  66. private readonly DelegationVisaRepository _delegationVisaRep;
  67. private readonly VisaPriceRepository _visaPriceRep;
  68. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  69. private readonly HotelPriceRepository _hotelPriceRep;
  70. private readonly CustomersRepository _customersRep;
  71. private readonly MessageRepository _message;
  72. private readonly SqlSugarClient _sqlSugar;
  73. private readonly TourClientListRepository _tourClientListRep;
  74. private readonly TeamRateRepository _teamRateRep;
  75. #region 成本相关
  76. private readonly CheckBoxsRepository _checkBoxs;
  77. private readonly GroupCostRepository _GroupCostRepository;
  78. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  79. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  80. #endregion
  81. private readonly SetDataRepository _setDataRep;
  82. private string url;
  83. private string path;
  84. private readonly EnterExitCostRepository _enterExitCostRep;
  85. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  86. private readonly UsersRepository _usersRep;
  87. private readonly IJuHeApiService _juHeApi;
  88. private readonly InvertedListRepository _invertedListRep;
  89. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  90. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  91. private readonly ThreeCodeRepository _threeCodeRepository;
  92. private readonly HotelInquiryRepository _hotelInquiryRep;
  93. private readonly FeeAuditRepository _feeAuditRep;
  94. private readonly VisaCommissionRepository _visaCommissionRep;
  95. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  96. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  97. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  98. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  99. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  100. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  101. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  102. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  103. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  104. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  105. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep,
  106. OpinionaireRepository opinionaireRep)
  107. {
  108. _logger = logger;
  109. _mapper = mapper;
  110. _grpScheduleRep = grpScheduleRep;
  111. _groupRepository = groupRepository;
  112. _taskAssignmentRep = taskAssignmentRep;
  113. _airTicketResRep = airTicketResRep;
  114. _sqlSugar = sqlSugar;
  115. url = AppSettingsHelper.Get("ExcelBaseUrl");
  116. path = AppSettingsHelper.Get("ExcelBasePath");
  117. if (!System.IO.Directory.Exists(path))
  118. {
  119. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  120. }
  121. _decreasePaymentsRep = decreasePaymentsRep;
  122. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  123. _delegationEnDataRep = delegationEnDataRep;
  124. _enterExitCostRep = enterExitCostRep;
  125. _delegationVisaRep = delegationVisaRep;
  126. _message = message;
  127. _visaPriceRep = visaPriceRep;
  128. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  129. _checkBoxs = checkBoxs;
  130. _GroupCostRepository = GroupCostRepository;
  131. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  132. _GroupCostParameterRepository = GroupCostParameterRepository;
  133. _hotelPriceRep = hotelPriceRep;
  134. _customersRep = customersRep;
  135. _setDataRep = setDataRep;
  136. _tourClientListRep = tourClientListRep;
  137. _teamRateRep = teamRateRep;
  138. _hubContext = hubContext;
  139. _usersRep = usersRep;
  140. _juHeApi = juHeApi;
  141. _invertedListRep = invertedListRep;
  142. _visaFeeInfoRep = visaFeeInfoRep;
  143. _ticketBlackCodeRep = ticketBlackCodeRep;
  144. _hotelInquiryRep = hotelInquiryRep;
  145. _threeCodeRepository = threeCodeRepository;
  146. _feeAuditRep = feeAuditRep;
  147. _visaCommissionRep = visaCommissionRep;
  148. _ffrRep = ffrRep;
  149. _opinionaireRep = opinionaireRep;
  150. }
  151. #region 流程管控
  152. /// <summary>
  153. /// 获取团组流程管控信息
  154. /// </summary>
  155. /// <param name="paras">参数Json字符串</param>
  156. /// <returns></returns>
  157. [HttpPost]
  158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  159. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  160. {
  161. if (string.IsNullOrEmpty(_jsonDto.Paras))
  162. {
  163. return Ok(JsonView(false, "参数为空"));
  164. }
  165. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  166. if (_ScheduleDto != null)
  167. {
  168. if (_ScheduleDto.SearchType == 2)//获取列表
  169. {
  170. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  171. return Ok(JsonView(_grpScheduleViewList));
  172. }
  173. else//获取对象
  174. {
  175. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  176. if (_grpScheduleView != null)
  177. {
  178. return Ok(JsonView(_grpScheduleView));
  179. }
  180. }
  181. }
  182. else
  183. {
  184. return Ok(JsonView(false, "参数反序列化失败"));
  185. }
  186. return Ok(JsonView(false, "暂无数据!"));
  187. }
  188. /// <summary>
  189. /// 修改团组流程管控详细表数据
  190. /// </summary>
  191. /// <param name="paras"></param>
  192. /// <returns></returns>
  193. [HttpPost]
  194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  195. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  196. {
  197. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  198. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  199. .SetColumns(it => it.Duty == _detail.Duty)
  200. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  201. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  202. .SetColumns(it => it.JobContent == _detail.JobContent)
  203. .SetColumns(it => it.Remark == _detail.Remark)
  204. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  205. .Where(s => s.Id == dto.Id)
  206. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  207. .ExecuteCommandAsync();
  208. if (result > 0)
  209. {
  210. return Ok(JsonView(true, "保存成功!"));
  211. }
  212. return Ok(JsonView(false, "保存失败!"));
  213. }
  214. /// <summary>
  215. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  216. /// </summary>
  217. /// <param name="dto"></param>
  218. /// <returns></returns>
  219. [HttpPost]
  220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  221. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  222. {
  223. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  224. _detail.IsDel = 1;
  225. _detail.DeleteUserId = dto.Duty;
  226. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  227. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  228. .SetColumns(it => it.IsDel == _detail.IsDel)
  229. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  230. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  231. .Where(it => it.Id == dto.Id)
  232. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  233. //.WhereColumns(s => s.Id == dto.Id)
  234. .ExecuteCommandAsync();
  235. if (result > 0)
  236. {
  237. return Ok(JsonView(true, "删除成功!"));
  238. }
  239. return Ok(JsonView(false, "删除失败!"));
  240. }
  241. /// <summary>
  242. /// 增加团组流程管控详细表数据
  243. /// </summary>
  244. /// <param name="dto"></param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  249. {
  250. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  251. if (DateTime.Now < _detail.ExpectBeginDt)
  252. {
  253. _detail.StepStatus = 0;
  254. }
  255. else
  256. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  257. _detail.StepStatus = 1;
  258. }
  259. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  260. if (result > 0)
  261. {
  262. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  263. return Ok(JsonView(true, "添加成功!", _result));
  264. }
  265. return Ok(JsonView(false, "添加失败!"));
  266. }
  267. #endregion
  268. #region 团组基本信息
  269. /// <summary>
  270. /// 接团信息列表
  271. /// </summary>
  272. /// <param name="dto">团组列表请求dto</param>
  273. /// <returns></returns>
  274. [HttpPost]
  275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  276. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  277. {
  278. var groupData = await _groupRepository.GetGroupList(dto);
  279. if (groupData.Code != 0)
  280. {
  281. return Ok(JsonView(false, groupData.Msg));
  282. }
  283. return Ok(JsonView(groupData.Data));
  284. }
  285. /// <summary>
  286. /// 分页查询团组列表
  287. /// </summary>
  288. /// <param name="dto"></param>
  289. /// <returns></returns>
  290. [HttpPost]
  291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  292. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  293. {
  294. var watch = new Stopwatch();
  295. watch.Start();
  296. RefAsync<int> total = 0;
  297. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  298. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  299. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  300. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  301. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  302. .Distinct()
  303. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  304. watch.Stop();
  305. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  306. }
  307. /// <summary>
  308. /// 接团信息列表 Page
  309. /// </summary>
  310. /// <param name="dto">团组列表请求dto</param>
  311. /// <returns></returns>
  312. [HttpPost]
  313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  314. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  315. {
  316. #region 参数验证
  317. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  318. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  320. #region 页面操作权限验证
  321. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  322. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  323. #endregion
  324. #endregion
  325. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  326. {
  327. string sqlWhere = string.Empty;
  328. if (dto.IsSure == 0) //未完成
  329. {
  330. sqlWhere += string.Format(@" And IsSure = 0");
  331. }
  332. else if (dto.IsSure == 1) //已完成
  333. {
  334. sqlWhere += string.Format(@" And IsSure = 1");
  335. }
  336. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  337. {
  338. string tj = dto.SearchCriteria;
  339. 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}%')",
  340. tj, tj, tj, tj, tj);
  341. }
  342. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  343. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  344. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  345. JietuanOperator,IsSure,CreateTime,IsBid
  346. From (
  347. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  348. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  349. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  350. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  351. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  352. From Grp_DelegationInfo gdi
  353. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  354. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  355. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  356. Where gdi.IsDel = 0 {0}
  357. ) temp", sqlWhere);
  358. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  359. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  360. #region 处理所属部门
  361. /*
  362. * 1.sq 和 gyy 等显示 市场部
  363. * 2.王鸽和主管及张总还有管理员号统一国交部
  364. * 2-1. 4 管理员 ,21 张海麟
  365. */
  366. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  367. List<int> userIds1 = new List<int>() { 4, 21 };
  368. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  369. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  370. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  371. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  372. .ToList();
  373. foreach (var item in _DelegationList)
  374. {
  375. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  376. }
  377. #endregion
  378. var _view = new
  379. {
  380. PageFuncAuth = pageFunAuthView,
  381. Data = _DelegationList
  382. };
  383. return Ok(JsonView(true, "查询成功!", _view, total));
  384. }
  385. else
  386. {
  387. return Ok(JsonView(false, "查询失败"));
  388. }
  389. }
  390. /// <summary>
  391. /// 团组列表
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpPost]
  395. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  396. {
  397. #region 参数验证
  398. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  399. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  400. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  401. #region 页面操作权限验证
  402. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  403. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  404. #endregion
  405. #endregion
  406. if (dto.PortType != 1 && dto.PortType != 2)
  407. {
  408. return Ok(JsonView(false, "查询失败!"));
  409. }
  410. string orderbyStr = "order by gdi.CreateTime Desc";
  411. string sqlWhere = string.Empty;
  412. if (dto.IsSure == 0) //未完成
  413. {
  414. sqlWhere += string.Format(@" And IsSure = 0");
  415. }
  416. else if (dto.IsSure == 1) //已完成
  417. {
  418. sqlWhere += string.Format(@" And IsSure = 1");
  419. }
  420. //团组类型
  421. if (dto.TeamDid > 0)
  422. {
  423. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  424. }
  425. //团组名称
  426. if (!string.IsNullOrEmpty(dto.TeamName))
  427. {
  428. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  429. }
  430. //客户名称
  431. if (!string.IsNullOrEmpty(dto.ClientName))
  432. {
  433. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  434. }
  435. //客户单位
  436. if (!string.IsNullOrEmpty(dto.ClientUnit))
  437. {
  438. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  439. }
  440. //出访时间
  441. if (!string.IsNullOrEmpty(dto.visitDataTime))
  442. {
  443. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  444. orderbyStr = "order by gdi.VisitDate";
  445. }
  446. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  447. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  448. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  449. JietuanOperator,IsSure,CreateTime
  450. From (
  451. Select row_number() over({0}) as Row_Number,
  452. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  453. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  454. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  455. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  456. From Grp_DelegationInfo gdi
  457. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  458. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  459. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  460. Where gdi.IsDel = 0 {1}
  461. ) temp ", orderbyStr, sqlWhere);
  462. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  463. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  464. #region 处理所属部门
  465. /*
  466. * 1.sq 和 gyy 等显示 市场部
  467. * 2.王鸽和主管及张总还有管理员号统一国交部
  468. * 2-1. 4 管理员 ,21 张海麟
  469. */
  470. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  471. List<int> userIds1 = new List<int>() { 4, 21 };
  472. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  473. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  474. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  475. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  476. .ToList();
  477. foreach (var item in _DelegationList)
  478. {
  479. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  480. }
  481. #endregion
  482. var _view = new
  483. {
  484. PageFuncAuth = pageFunAuthView,
  485. Data = _DelegationList
  486. };
  487. return Ok(JsonView(true, "查询成功!", _view, total));
  488. }
  489. /// <summary>
  490. /// 接团信息详情
  491. /// </summary>
  492. /// <param name="dto">团组info请求dto</param>
  493. /// <returns></returns>
  494. [HttpPost]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  497. {
  498. var groupData = await _groupRepository.GetGroupInfo(dto);
  499. if (groupData.Code != 0)
  500. {
  501. return Ok(JsonView(false, groupData.Msg));
  502. }
  503. return Ok(JsonView(groupData.Data));
  504. }
  505. /// <summary>
  506. /// 接团信息 编辑添加
  507. /// 基础信息数据源
  508. /// </summary>
  509. /// <param name="dto"></param>
  510. /// <returns></returns>
  511. [HttpPost]
  512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  513. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  514. {
  515. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  516. if (groupData.Code != 0)
  517. {
  518. return Ok(JsonView(false, groupData.Msg));
  519. }
  520. return Ok(JsonView(groupData.Data));
  521. }
  522. /// <summary>
  523. /// 接团信息 操作(增改)
  524. /// </summary>
  525. /// <param name="dto"></param>
  526. /// <returns></returns>
  527. [HttpPost]
  528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  529. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  530. {
  531. try
  532. {
  533. decimal ffrPrice = 0.00M;
  534. DateTime? visitDt = null;
  535. if (dto.Status == 2)
  536. {
  537. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  538. if (groupInfo != null)
  539. {
  540. ffrPrice = groupInfo.PaymentMoney;
  541. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  542. }
  543. }
  544. var groupData = await _groupRepository.GroupOperation(dto);
  545. if (groupData.Code != 0)
  546. {
  547. return Ok(JsonView(false, groupData.Msg));
  548. }
  549. int diId = 0;
  550. //添加时 默认加入团组汇率
  551. if (dto.Status == 1) //添加
  552. {
  553. diId = groupData.Data;
  554. //添加默认币种
  555. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  556. //默认分配权限
  557. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  558. //消息提示 王鸽 主管号
  559. List<int> _managerIds = new List<int>() { 22, 32 };
  560. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  561. if (userIds.Count > 0)
  562. {
  563. userIds.Add(208);
  564. //创建团组管控
  565. GroupStepForDelegation.CreateWorkStep(diId);
  566. //发送消息
  567. string groupName = dto.TeamName;
  568. string createGroupUser = string.Empty;
  569. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  570. if (userInfo != null) createGroupUser = userInfo.CnName;
  571. string title = $"系统通知";
  572. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  573. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  574. }
  575. //默认创建倒推表
  576. await _invertedListRep._Create(dto.UserId, diId);
  577. }
  578. else if (dto.Status == 2)
  579. {
  580. diId = dto.Id;
  581. }
  582. #region 签证人员团组时间通知
  583. #region 计算出访起止时间
  584. var startTime = new DateTime();
  585. var endTime = new DateTime();
  586. if (DateTime.TryParse(dto.VisitDate, out startTime))
  587. {
  588. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  589. }
  590. #endregion
  591. if (diId > 0)
  592. {
  593. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  594. }
  595. #endregion
  596. #region 团组操作默认添加/修改收款账单
  597. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  598. {
  599. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  600. .Where(x => x.IsDel == 0 &&
  601. x.Diid == diId &&
  602. x.Remark.Equals("预付款")
  603. )
  604. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  605. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  606. .FirstAsync();
  607. ffrInfo = new Fin_ForeignReceivables()
  608. {
  609. Diid = diId,
  610. PriceName = dto.ClientUnit,
  611. Price = dto.PaymentMoney,
  612. Count = 1,
  613. Unit = $"元",
  614. ItemSumPrice = dto.PaymentMoney,
  615. Rate = 1.0000M,
  616. Currency = 836,
  617. AddingWay = 0,
  618. CreateUserId = dto.UserId,
  619. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  620. Remark = $"预付款"
  621. };
  622. if (ffrInfo == null) //Add
  623. {
  624. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  625. }
  626. else //修改
  627. {
  628. await _sqlSugar.Updateable(ffrInfo)
  629. .UpdateColumns(x => new
  630. {
  631. x.PriceName,
  632. x.Price,
  633. x.ItemSumPrice,
  634. x.CreateTime,
  635. x.CreateUserId
  636. })
  637. .WhereColumns(x => x.Id)
  638. .ExecuteCommandAsync();
  639. }
  640. }
  641. #endregion
  642. return Ok(JsonView(true, "操作成功!", diId));
  643. }
  644. catch (Exception ex)
  645. {
  646. Logs("[response]" + JsonConvert.SerializeObject(dto));
  647. Logs(ex.Message);
  648. return Ok(JsonView(false, ex.Message));
  649. }
  650. }
  651. /// <summary>
  652. /// 接团流程操作(增改)
  653. /// 安卓端使用 建团时添加客户名单
  654. /// </summary>
  655. /// <param name="dto"></param>
  656. /// <returns></returns>
  657. [HttpPost]
  658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  659. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  660. {
  661. try
  662. {
  663. #region 参数验证
  664. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  665. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  666. #region 页面操作权限验证
  667. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  668. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  669. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  670. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  671. #endregion
  672. #endregion
  673. _sqlSugar.BeginTran();
  674. decimal ffrPrice = 0.00M;
  675. DateTime? visitDt = null;
  676. if (dto.Status == 2)
  677. {
  678. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  679. if (groupInfo != null)
  680. {
  681. ffrPrice = groupInfo.PaymentMoney;
  682. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  683. }
  684. }
  685. var _dto = new GroupOperationDto();
  686. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  687. var groupData = await _groupRepository.GroupOperation(_dto);
  688. if (groupData.Code != 0)
  689. {
  690. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  691. }
  692. int diId = 0;
  693. //添加时 默认加入团组汇率
  694. if (dto.Status == 1) //添加
  695. {
  696. diId = groupData.Data;
  697. //添加默认币种
  698. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  699. //默认分配权限
  700. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  701. //消息提示 王鸽 主管号
  702. List<int> _managerIds = new List<int>() { 22, 32 };
  703. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  704. if (userIds.Count > 0)
  705. {
  706. userIds.Add(208);
  707. //创建团组管控
  708. GroupStepForDelegation.CreateWorkStep(diId);
  709. //发送消息
  710. string groupName = dto.TeamName;
  711. string createGroupUser = string.Empty;
  712. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  713. if (userInfo != null) createGroupUser = userInfo.CnName;
  714. string title = $"系统通知";
  715. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  716. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  717. }
  718. #region 应用推送
  719. try
  720. {
  721. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  722. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  723. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  724. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  725. {
  726. List<string> userList = new List<string>() { users.QiyeChatUserId };
  727. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  728. }
  729. }
  730. catch (Exception ex)
  731. {
  732. }
  733. #endregion
  734. //默认创建倒推表
  735. await _invertedListRep._Create(dto.UserId, diId);
  736. }
  737. if (dto.Status == 2)
  738. {
  739. diId = dto.Id;
  740. if (diId == 0)
  741. {
  742. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  743. }
  744. }
  745. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  746. if (viewData.Code != 0)
  747. {
  748. _sqlSugar.RollbackTran();
  749. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  750. }
  751. #region 团组操作默认添加/修改收款账单
  752. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  753. {
  754. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  755. .Where(x => x.IsDel == 0 &&
  756. x.Diid == diId &&
  757. x.Remark.Equals("预付款")
  758. )
  759. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  760. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  761. .FirstAsync();
  762. ffrInfo = new Fin_ForeignReceivables()
  763. {
  764. Diid = diId,
  765. PriceName = dto.ClientUnit,
  766. Price = dto.PaymentMoney,
  767. Count = 1,
  768. Unit = $"元",
  769. ItemSumPrice = dto.PaymentMoney,
  770. Rate = 1.0000M,
  771. Currency = 836,
  772. AddingWay = 0,
  773. CreateUserId = dto.UserId,
  774. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  775. Remark = $"预付款"
  776. };
  777. if (ffrInfo == null) //Add
  778. {
  779. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  780. }
  781. else //修改
  782. {
  783. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  784. .UpdateColumns(x => new
  785. {
  786. x.PriceName,
  787. x.Price,
  788. x.ItemSumPrice,
  789. x.CreateTime,
  790. x.CreateUserId
  791. })
  792. .WhereColumns(x => x.Id)
  793. .ExecuteCommandAsync();
  794. }
  795. }
  796. #endregion
  797. #region 签证人员团组时间通知
  798. #region 计算出访起止时间
  799. var startTime = new DateTime();
  800. var endTime = new DateTime();
  801. if (DateTime.TryParse(dto.VisitDate, out startTime))
  802. {
  803. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  804. }
  805. #endregion
  806. if (diId > 0)
  807. {
  808. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  809. }
  810. #endregion
  811. _sqlSugar.CommitTran();
  812. return Ok(JsonView(true, "添加成功"));
  813. }
  814. catch (Exception ex)
  815. {
  816. _sqlSugar.RollbackTran();
  817. return Ok(JsonView(false, ex.Message));
  818. }
  819. }
  820. /// <summary>
  821. /// 接团信息 操作(删除)
  822. /// </summary>
  823. /// <param name="dto"></param>
  824. /// <returns></returns>
  825. [HttpPost]
  826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  827. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  828. {
  829. try
  830. {
  831. var groupData = await _groupRepository.GroupDel(dto);
  832. if (groupData.Code != 0)
  833. {
  834. return Ok(JsonView(false, groupData.Msg));
  835. }
  836. return Ok(JsonView(true));
  837. }
  838. catch (Exception ex)
  839. {
  840. Logs("[response]" + JsonConvert.SerializeObject(dto));
  841. Logs(ex.Message);
  842. return Ok(JsonView(false, ex.Message));
  843. }
  844. }
  845. /// <summary>
  846. /// 获取团组销售报价号
  847. /// 团组添加时 使用
  848. /// </summary>
  849. /// <returns></returns>
  850. [HttpPost]
  851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  852. public async Task<IActionResult> GetGroupSalesQuoteNo()
  853. {
  854. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  855. if (groupData.Code != 0)
  856. {
  857. return Ok(JsonView(false, groupData.Msg));
  858. }
  859. object salesQuoteNo = new
  860. {
  861. SalesQuoteNo = groupData.Data
  862. };
  863. return Ok(JsonView(salesQuoteNo));
  864. }
  865. /// <summary>
  866. /// 设置确认出团
  867. /// </summary>
  868. /// <param name="dto"></param>
  869. /// <returns></returns>
  870. [HttpPost]
  871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  872. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  873. {
  874. var groupData = await _groupRepository.ConfirmationGroup(dto);
  875. if (groupData.Code != 0)
  876. {
  877. return Ok(JsonView(false, groupData.Msg));
  878. }
  879. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  880. #region OA消息推送
  881. try
  882. {
  883. string groupName = groupInfo.TeamName;
  884. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  885. List<int> userIds = new List<int>();
  886. listUser.ForEach(s => userIds.Add(s.Id));
  887. string title = $"系统通知";
  888. string content = $"团组[{groupName}]已确认出团!";
  889. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  890. }
  891. catch (Exception ex)
  892. {
  893. }
  894. #endregion
  895. #region 应用推送
  896. try
  897. {
  898. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  899. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  900. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  901. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  902. {
  903. List<string> userList = new List<string>() { users.QiyeChatUserId };
  904. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  905. }
  906. }
  907. catch (Exception ex)
  908. {
  909. }
  910. #endregion
  911. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  912. return Ok(JsonView(true, "操作成功!", groupData.Data));
  913. }
  914. /// <summary>
  915. /// 获取团组名称data And 签证国别Data
  916. /// </summary>
  917. /// <param name="dto"></param>
  918. /// <returns></returns>
  919. [HttpPost]
  920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  921. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  922. {
  923. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  924. if (groupData.Code != 0)
  925. {
  926. return Ok(JsonView(false, groupData.Msg));
  927. }
  928. return Ok(JsonView(groupData.Data));
  929. }
  930. /// <summary>
  931. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  932. /// </summary>
  933. /// <returns></returns>
  934. [HttpPost]
  935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  936. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  937. {
  938. try
  939. {
  940. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  941. if (groupData.Code != 0)
  942. {
  943. return Ok(JsonView(false, groupData.Msg));
  944. }
  945. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  946. }
  947. catch (Exception ex)
  948. {
  949. return Ok(JsonView(false, "程序错误!"));
  950. throw;
  951. }
  952. }
  953. /// <summary>
  954. /// 团组清单 Excel
  955. /// </summary>
  956. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  957. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  958. /// <returns></returns>
  959. [HttpGet]
  960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  961. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  962. {
  963. DateTime _beginDt, _endDt;
  964. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  965. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  966. if (!beginBool && !endBool)
  967. {
  968. return Ok(JsonView(false, "开始或结束时间不正确!"));
  969. }
  970. string sql = string.Format(@"
  971. SELECT
  972. ROW_NUMBER,
  973. Id,
  974. SalesQuoteNo,
  975. TourCode,
  976. TeamTypeId,
  977. TeamType,
  978. TeamLevId,
  979. TeamLev,
  980. TeamName,
  981. ClientName,
  982. ClientUnit,
  983. VisitDate,
  984. VisitDays,
  985. VisitPNumber,
  986. JietuanOperatorId,
  987. JietuanOperator,
  988. IsSure,
  989. CreateTime,
  990. IsBid
  991. FROM
  992. (
  993. SELECT
  994. ROW_NUMBER() OVER(
  995. ORDER BY
  996. gdi.CreateTime Desc
  997. ) AS ROW_NUMBER,
  998. gdi.Id,
  999. SalesQuoteNo,
  1000. TourCode,
  1001. ssd.Id TeamTypeId,
  1002. ssd.Name TeamType,
  1003. ssd1.Id TeamLevId,
  1004. ssd1.Name TeamLev,
  1005. TeamName,
  1006. ClientName,
  1007. ClientUnit,
  1008. VisitDate,
  1009. VisitDays,
  1010. VisitPNumber,
  1011. JietuanOperator JietuanOperatorId,
  1012. su.CnName JietuanOperator,
  1013. IsSure,
  1014. gdi.CreateTime,
  1015. gdi.IsBid
  1016. FROM
  1017. Grp_DelegationInfo gdi
  1018. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1019. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1020. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1021. WHERE
  1022. gdi.IsDel = 0
  1023. AND gdi.IsBid = 0
  1024. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1025. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1026. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1027. #region 处理所属部门
  1028. /*
  1029. * 1.sq 和 gyy 等显示 市场部
  1030. * 2.王鸽和主管及张总还有管理员号统一国交部
  1031. * 2-1. 4 管理员 ,21 张海麟
  1032. */
  1033. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1034. List<int> userIds1 = new List<int>() { 4, 21 };
  1035. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1036. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1037. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1038. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1039. .ToListAsync();
  1040. foreach (var item in groupList)
  1041. {
  1042. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1043. }
  1044. #endregion
  1045. #region Excel
  1046. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1047. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1048. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1049. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1050. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1051. //载入模板
  1052. WorkbookDesigner designer = new WorkbookDesigner();
  1053. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1054. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1055. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1056. dt.TableName = "GroupList";
  1057. designer.SetDataSource(dt);
  1058. designer.Process();
  1059. if (!Directory.Exists(savePath))
  1060. {
  1061. Directory.CreateDirectory(savePath);
  1062. }
  1063. string serverPath = $"{savePath}{fileName}";
  1064. designer.Workbook.Save(serverPath);
  1065. string rst = $"{servicePath}{ftpPath}{fileName}";
  1066. #endregion
  1067. return Ok(JsonView(true, "操作成功!", rst));
  1068. }
  1069. #endregion
  1070. #region 团组&签证
  1071. /// <summary>
  1072. /// 根据团组Id获取签证客户信息List
  1073. /// </summary>
  1074. /// <param name="dto">请求dto</param>
  1075. /// <returns></returns>
  1076. [HttpPost]
  1077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1078. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1079. {
  1080. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1081. if (groupData.Code != 0)
  1082. {
  1083. return Ok(JsonView(false, groupData.Msg));
  1084. }
  1085. return Ok(JsonView(groupData.Data));
  1086. }
  1087. /// <summary>
  1088. /// IOS获取团组签证拍照上传进度01(团组列表)
  1089. /// </summary>
  1090. /// <param name="dto">请求dto</param>
  1091. /// <returns></returns>
  1092. [HttpPost]
  1093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1094. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1095. {
  1096. if (dto == null)
  1097. {
  1098. return Ok(JsonView(false, "参数为空"));
  1099. }
  1100. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1101. return Ok(JsonView(visaList));
  1102. }
  1103. /// <summary>
  1104. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1105. /// </summary>
  1106. /// <returns></returns>
  1107. [HttpPost]
  1108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1109. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1110. {
  1111. if (dto == null)
  1112. {
  1113. return Ok(JsonView(false, "请求错误:"));
  1114. }
  1115. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1116. return Ok(JsonView(list));
  1117. }
  1118. /// <summary>
  1119. /// IOS获取团组签证拍照上传进度03(相册)
  1120. /// </summary>
  1121. /// <returns></returns>
  1122. [HttpPost]
  1123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1124. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1125. {
  1126. if (dto == null)
  1127. {
  1128. return Ok(JsonView(false, "请求错误:"));
  1129. }
  1130. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1131. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1132. list.ForEach(s => s.url = url);
  1133. return Ok(JsonView(list));
  1134. }
  1135. /// <summary>
  1136. /// IOS获取团组签证拍照上传进度04(图片上传)
  1137. /// </summary>
  1138. /// <param name="dto"></param>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1143. {
  1144. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1145. //if (!string.IsNullOrEmpty(result))
  1146. //{
  1147. //}
  1148. //else {
  1149. // return Ok(JsonView(false, "上传失败"));
  1150. //}
  1151. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1152. int sucNum = 0;
  1153. try
  1154. {
  1155. foreach (var item in dto.base64DataList)
  1156. {
  1157. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1158. string result = decodeBase64ToImage(item, imageName);
  1159. if (!string.IsNullOrEmpty(result))
  1160. {
  1161. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1162. pic.CreateUserId = dto.CreateUserId;
  1163. pic.PicName = imageName;
  1164. pic.PicPath = result;
  1165. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1166. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1167. if (insertResult > 0)
  1168. {
  1169. sucNum++;
  1170. }
  1171. }
  1172. }
  1173. }
  1174. catch (Exception ex)
  1175. {
  1176. return Ok(JsonView(false, ex.Message));
  1177. }
  1178. string msg = string.Format(@"成功上传{0}张", sucNum);
  1179. return Ok(JsonView(true, msg));
  1180. }
  1181. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1182. {
  1183. string filename = "";//声明一个string类型的相对路径
  1184. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1185. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1186. try//会有异常抛出,try,catch一下
  1187. {
  1188. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1189. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1190. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1191. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1192. //文件名称
  1193. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1194. //上传的文件的路径
  1195. string filePath = "";
  1196. if (!Directory.Exists(fileDir))
  1197. {
  1198. Directory.CreateDirectory(fileDir);
  1199. }
  1200. //上传的文件的路径
  1201. filePath = fileDir + filename;
  1202. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1203. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1204. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1205. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1206. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1207. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1208. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1209. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1210. bitmap.Dispose();
  1211. }
  1212. catch (Exception e)
  1213. {
  1214. string massage = e.Message;
  1215. Logs("IOS图片上传Error:" + massage);
  1216. //filename = e.Message;
  1217. }
  1218. return filename;//返回相对路径
  1219. }
  1220. /// <summary>
  1221. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1222. /// </summary>
  1223. /// <param name="dto"></param>
  1224. /// <returns></returns>
  1225. [HttpPost]
  1226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1227. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1228. {
  1229. if (dto == null)
  1230. {
  1231. return Ok(JsonView(false, "请求错误:"));
  1232. }
  1233. string msg = "参数错误";
  1234. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1235. {
  1236. try
  1237. {
  1238. //_delegationVisaRep.BeginTran();
  1239. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1240. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1241. .Where(s => s.Id == dto.visaProgressCustomerId)
  1242. .ExecuteCommandAsync();
  1243. if (updCount > 0 && dto.publishCode == 1)
  1244. {
  1245. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1246. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1247. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1248. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1249. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1250. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1251. if (groupData == null)
  1252. {
  1253. _delegationVisaRep.RollbackTran();
  1254. }
  1255. string title = string.Format(@"[签证进度更新]");
  1256. string content = string.Format(@"测试文本");
  1257. bool rst = await _message.AddMsg(new MessageDto()
  1258. {
  1259. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1260. IssuerId = dto.publisher,
  1261. Title = title,
  1262. Content = content,
  1263. ReleaseTime = DateTime.Now,
  1264. UIdList = new List<int> {
  1265. 234
  1266. }
  1267. });
  1268. if (rst)
  1269. {
  1270. return Ok(JsonView(true, "发送通知成功"));
  1271. }
  1272. }
  1273. //_delegationVisaRep.CommitTran();
  1274. }
  1275. catch (Exception)
  1276. {
  1277. //_delegationVisaRep.RollbackTran();
  1278. }
  1279. }
  1280. return Ok(JsonView(true, msg));
  1281. }
  1282. #endregion
  1283. #region 团组任务分配
  1284. /// <summary>
  1285. /// 团组任务分配初始化
  1286. /// </summary>
  1287. /// <param name="dto"></param>
  1288. /// <returns></returns>
  1289. [HttpPost]
  1290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1291. public async Task<IActionResult> GetTaskAssignmen()
  1292. {
  1293. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1294. if (groupData.Code != 0)
  1295. {
  1296. return Ok(JsonView(false, groupData.Msg));
  1297. }
  1298. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1299. }
  1300. /// <summary>
  1301. /// 团组任务分配查询
  1302. /// </summary>
  1303. /// <param name="dto"></param>
  1304. /// <returns></returns>
  1305. [HttpPost]
  1306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1307. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1308. {
  1309. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1310. if (groupData.Code != 0)
  1311. {
  1312. return Ok(JsonView(false, groupData.Msg));
  1313. }
  1314. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1315. }
  1316. /// <summary>
  1317. /// 团组任务分配操作
  1318. /// </summary>
  1319. /// <param name="dto"></param>
  1320. /// <returns></returns>
  1321. [HttpPost]
  1322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1323. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1324. {
  1325. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1326. if (groupData.Code != 0)
  1327. {
  1328. return Ok(JsonView(false, groupData.Msg));
  1329. }
  1330. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1331. }
  1332. /// <summary>
  1333. /// 团组任务分配
  1334. /// 批量分配
  1335. /// 查询团组
  1336. /// </summary>
  1337. /// <param name="dto"></param>
  1338. /// <returns></returns>
  1339. [HttpPost]
  1340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1341. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1342. {
  1343. //参数验证
  1344. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1345. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1346. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1347. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1348. }
  1349. /// <summary>
  1350. /// 团组任务分配
  1351. /// 批量分配
  1352. /// </summary>
  1353. /// <param name="dto"></param>
  1354. /// <returns></returns>
  1355. [HttpPost]
  1356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1357. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1358. {
  1359. //参数验证
  1360. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1361. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1362. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1363. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1364. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1365. }
  1366. #endregion
  1367. #region 团组费用审核
  1368. /// <summary>
  1369. /// 费用审核
  1370. /// 团组列表 Page
  1371. /// </summary>
  1372. /// <param name="_dto">团组列表请求dto</param>
  1373. /// <returns></returns>
  1374. [HttpPost]
  1375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1376. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1377. {
  1378. #region 参数验证
  1379. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1380. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1381. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1382. #region 页面操作权限验证
  1383. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1384. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1385. #endregion
  1386. #endregion
  1387. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1388. {
  1389. string sqlWhere = string.Empty;
  1390. if (_dto.IsSure == 0) //未完成
  1391. {
  1392. sqlWhere += string.Format(@" And IsSure = 0");
  1393. }
  1394. else if (_dto.IsSure == 1) //已完成
  1395. {
  1396. sqlWhere += string.Format(@" And IsSure = 1");
  1397. }
  1398. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1399. {
  1400. string tj = _dto.SearchCriteria;
  1401. 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}%')",
  1402. tj, tj, tj, tj, tj);
  1403. }
  1404. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1405. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1406. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1407. From (
  1408. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1409. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1410. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1411. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1412. From Grp_DelegationInfo gdi
  1413. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1414. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1415. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1416. Where gdi.IsDel = 0 {0}
  1417. ) temp ", sqlWhere);
  1418. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1419. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1420. var _view = new
  1421. {
  1422. PageFuncAuth = pageFunAuthView,
  1423. Data = _DelegationList
  1424. };
  1425. return Ok(JsonView(true, "查询成功!", _view, total));
  1426. }
  1427. else
  1428. {
  1429. return Ok(JsonView(false, "查询失败"));
  1430. }
  1431. }
  1432. /// <summary>
  1433. /// 获取团组费用审核
  1434. /// </summary>
  1435. /// <param name="paras">参数Json字符串</param>
  1436. /// <returns></returns>
  1437. [HttpPost]
  1438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1439. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1440. {
  1441. try
  1442. {
  1443. #region 参数验证
  1444. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1445. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1446. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1447. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1448. #region 页面操作权限验证
  1449. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1450. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1451. #endregion
  1452. #endregion
  1453. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1454. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1455. #region 费用清单
  1456. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1457. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1458. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1459. List<Grp_CreditCardPayment> entityList = _groupRepository
  1460. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1461. .Where(exp.ToExpression())
  1462. .ToList();
  1463. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1464. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1465. /*
  1466. * 76://酒店预订
  1467. */
  1468. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1469. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1470. .ToListAsync();
  1471. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1472. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1473. .ToListAsync();
  1474. /*
  1475. * 79://车/导游地接
  1476. */
  1477. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1478. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1479. .ToListAsync();
  1480. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1481. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1482. .ToListAsync();
  1483. /*
  1484. * 80: //签证
  1485. */
  1486. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1487. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1488. .ToListAsync();
  1489. /*
  1490. *81: //邀请/公务活动
  1491. */
  1492. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1493. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1494. .ToListAsync();
  1495. /*
  1496. * 82: //团组客户保险
  1497. */
  1498. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1499. /*
  1500. * Lable = 85 机票预订
  1501. */
  1502. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1503. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1504. .ToListAsync();
  1505. /*
  1506. * 85 机票预定
  1507. */
  1508. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1509. /*
  1510. * 98 其他款项
  1511. */
  1512. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1513. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1514. .ToListAsync();
  1515. /*
  1516. * 285:收款退还
  1517. */
  1518. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1519. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1520. .ToListAsync();
  1521. /*
  1522. * 1015: //超支费用
  1523. */
  1524. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1525. /*
  1526. * 币种信息
  1527. */
  1528. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1529. /*
  1530. * 车/导游地接 费用类型
  1531. */
  1532. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1533. /*
  1534. * 车/导游地接 费用类型
  1535. */
  1536. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1537. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1538. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1539. /*
  1540. * 用户信息
  1541. */
  1542. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1543. /*
  1544. * 费用模块
  1545. */
  1546. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1547. string priceModule = string.Empty;
  1548. if (sdPriceName != null)
  1549. {
  1550. priceModule = sdPriceName.Name;
  1551. }
  1552. /*
  1553. * 成本信息
  1554. */
  1555. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1556. decimal _groupRate = 0.0000M;
  1557. string _groupCurrencyCode = "-";
  1558. if (groupCost != null)
  1559. {
  1560. _groupRate = groupCost.Rate;
  1561. if (int.TryParse(groupCost.Currency, out int _currency))
  1562. {
  1563. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1564. }
  1565. else _groupCurrencyCode = groupCost.Currency;
  1566. }
  1567. string costContentSql = $"Select * From Grp_GroupCost";
  1568. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1569. //处理日期为空的天数
  1570. for (int i = 0; i < groupCostDetails.Count; i++)
  1571. if (i != 0)
  1572. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1573. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1574. /*
  1575. * 处理详情数据
  1576. */
  1577. foreach (var entity in entityList)
  1578. {
  1579. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1580. _detail.Id = entity.Id;
  1581. _detail.PriceName = priceModule;
  1582. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1583. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1584. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1585. //处理金额
  1586. if (entity.CTable == 1015)
  1587. {
  1588. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1589. if (czInfo != null)
  1590. {
  1591. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1592. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1593. }
  1594. }
  1595. /*
  1596. * 应付款金额
  1597. */
  1598. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1599. string PaymentCurrency_WaitPay = "Unknown";
  1600. string hotelCurrncyCode = "Unknown";
  1601. string hotelCurrncyName = "Unknown";
  1602. if (sdPaymentCurrency_WaitPay != null)
  1603. {
  1604. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1605. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1606. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1607. if (hotelCurrncyCode.Equals("CNY"))
  1608. {
  1609. entity.DayRate = 1.0000M;
  1610. }
  1611. }
  1612. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1613. /*
  1614. * 此次付款金额
  1615. */
  1616. decimal CurrPayStr = 0.00M,
  1617. OriginalCurrPay = 0.00M;
  1618. if (entity.PayPercentage == 0)
  1619. {
  1620. if (entity.PayThenMoney != 0)
  1621. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1622. }
  1623. else
  1624. {
  1625. if (entity.PayMoney != 0)
  1626. {
  1627. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1628. }
  1629. }
  1630. if (_dto.Label == 79)
  1631. {
  1632. string original = string.Empty;
  1633. if (hotelCurrncyCode.Equals("CNY"))
  1634. {
  1635. OriginalCurrPay = CurrPayStr;
  1636. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1637. }
  1638. else
  1639. {
  1640. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1641. //760 EUR(7600.00 CNY)
  1642. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1643. }
  1644. }
  1645. else
  1646. {
  1647. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1648. }
  1649. /*
  1650. * 剩余尾款
  1651. */
  1652. decimal BalanceStr = 0;
  1653. if (CurrPayStr != 0)
  1654. {
  1655. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1656. BalanceStr = 0;
  1657. else
  1658. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1659. }
  1660. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1661. /*
  1662. * Bus名称
  1663. */
  1664. _detail.BusName = "待增加";
  1665. /*
  1666. *费用所属
  1667. */
  1668. switch (entity.CTable)
  1669. {
  1670. case 76://酒店预订
  1671. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1672. if (hotelReservations != null)
  1673. {
  1674. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1675. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1676. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1677. string roomFeeStr = "", roomFeestr1 = "";
  1678. //是否比较房型价格
  1679. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1680. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1681. roomFeeStr += $"<br/>";
  1682. if (hotelReservations.SingleRoomPrice > 0)
  1683. {
  1684. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1685. __isSingle = true;
  1686. }
  1687. if (hotelReservations.DoubleRoomPrice > 0)
  1688. {
  1689. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1690. __isDouble = true;
  1691. }
  1692. if (hotelReservations.SuiteRoomPrice > 0)
  1693. {
  1694. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1695. __isSuite = true;
  1696. }
  1697. if (hotelReservations.OtherRoomPrice > 0)
  1698. {
  1699. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1700. __isOther = true;
  1701. }
  1702. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1703. else roomFeeStr += " 0.00 * 0";
  1704. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1705. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1706. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1707. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1708. /*
  1709. * 费用类型
  1710. * 1:房费
  1711. * 2:早餐
  1712. * 3:地税
  1713. * 4:城市税
  1714. * </summary>
  1715. */
  1716. //地税
  1717. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1718. if (governmentRentData != null)
  1719. {
  1720. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1721. governmentRentFee = governmentRentData.Price;
  1722. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1723. if (governmentRentCurrData != null)
  1724. {
  1725. governmentRentCode = governmentRentCurrData.Name;
  1726. governmentRentName = $"({governmentRentCurrData.Remark})";
  1727. }
  1728. }
  1729. //城市税
  1730. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1731. if (cityTaxData != null)
  1732. {
  1733. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1734. cityTaxFee = cityTaxData.Price;
  1735. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1736. if (cityTaxCurrData != null)
  1737. {
  1738. cityTaxCode = cityTaxCurrData.Name;
  1739. cityTaxName = $"({cityTaxCurrData.Remark})";
  1740. }
  1741. }
  1742. //酒店早餐
  1743. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1744. if (breakfastData != null)
  1745. {
  1746. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1747. breakfastFee = breakfastData.Price;
  1748. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1749. if (breakfastCurrData != null)
  1750. {
  1751. breakfastCode = breakfastCurrData.Name;
  1752. breakfastName = $"({breakfastCurrData.Remark})";
  1753. }
  1754. }
  1755. //房间费用
  1756. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1757. if (roomData != null)
  1758. {
  1759. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1760. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1761. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1762. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1763. roomFee = roomData.Price;
  1764. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1765. if (roomCurrData != null)
  1766. {
  1767. roomCode = roomCurrData.Name;
  1768. roomName = $"({roomCurrData.Remark})";
  1769. }
  1770. }
  1771. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1772. string hotelCostStr = "";
  1773. decimal hotelCsotTotal = 0.00M;
  1774. if (groupCost != null)
  1775. {
  1776. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1777. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1778. }
  1779. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1780. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1781. string hotelCost_day = "";
  1782. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1783. foreach (var item in hotelCostDetails1)
  1784. {
  1785. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1786. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1787. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1788. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1789. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1790. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1791. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1792. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1793. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1794. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1795. hotelCost_day += @$"</br>";
  1796. }
  1797. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1798. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1799. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1800. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1801. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1802. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1803. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1804. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1805. $"房间说明: {hotelReservations.Remark} <br/>" +
  1806. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1807. $"{hotelBreakfastStr}" +
  1808. $"{hotelGovernmentRentStr}" +
  1809. $"{hotelCityTaxStr}";
  1810. _detail.PriceNameContent = hotelReservations.HotelName;
  1811. }
  1812. break;
  1813. case 79://车/导游地接
  1814. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1815. if (touristGuideGroundReservations != null)
  1816. {
  1817. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1818. {
  1819. _detail.BusName = touristGuideGroundReservations.BusName;
  1820. }
  1821. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1822. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1823. //if (isInt)
  1824. //{
  1825. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1826. // if (cityInfo != null)
  1827. // {
  1828. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1829. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1830. // if (carFeeItem != null)
  1831. // {
  1832. // nameContent += $@"({carFeeItem.Name})";
  1833. // }
  1834. // _detail.PriceNameContent = nameContent;
  1835. // }
  1836. //}
  1837. //else
  1838. //{
  1839. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1840. //}
  1841. var touristGuideGroundReservationsContents =
  1842. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1843. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1844. foreach (var item in touristGuideGroundReservationsContents)
  1845. {
  1846. string typeName = "Unknown";
  1847. string carCurrencyCode = "Unknown";
  1848. string carCurrencyName = "Unknown";
  1849. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1850. if (carTypeData != null) typeName = carTypeData.Name;
  1851. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1852. if (currencyData != null)
  1853. {
  1854. carCurrencyCode = currencyData.Name;
  1855. carCurrencyName = currencyData.Remark;
  1856. }
  1857. //op、成本 币种是否一致
  1858. bool IsCurrencyAgreement = false;
  1859. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1860. string opCostStr = string.Empty;
  1861. decimal opCostTypePrice = 0.00M;
  1862. #region 处理成本各项费用
  1863. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1864. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1865. if (opCost.Count > 0)
  1866. {
  1867. switch (item.SId)
  1868. {
  1869. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1870. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1871. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1872. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1873. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1874. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1875. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1876. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1877. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1878. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1879. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1880. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1881. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1882. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1883. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1884. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1885. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1886. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1887. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1888. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1889. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1890. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1891. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1892. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1893. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1894. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1895. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1896. }
  1897. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1898. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1899. }
  1900. #endregion
  1901. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1902. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1903. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1904. $"{opTypeStr} {opCostStr}<br/>" +
  1905. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1906. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1907. }
  1908. _detail.PriceMsgContent = priceMsg;
  1909. }
  1910. break;
  1911. case 80: //签证
  1912. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1913. if (visaInfo != null)
  1914. {
  1915. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1916. _detail.PriceNameContent = visaInfo.VisaDescription;
  1917. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1918. }
  1919. break;
  1920. case 81: //邀请/公务活动
  1921. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1922. if (_ioa != null)
  1923. {
  1924. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1925. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1926. sendCurrName = "Unknown", //快递费用币种 Name
  1927. sendCurrCode = "Unknown", //快递费用币种 Code
  1928. eventsCurrName = "Unknown", //公务活动费币种 Name
  1929. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1930. translateCurrName = "Unknown", //公务翻译费 Name
  1931. translateCurrCode = "Unknown"; //公务翻译费 Code
  1932. #region 处理费用币种
  1933. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1934. if (inviteCurrData != null)
  1935. {
  1936. inviteCurrName = inviteCurrData.Remark;
  1937. inviteCurrCode = inviteCurrData.Name;
  1938. }
  1939. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1940. if (sendCurrData != null)
  1941. {
  1942. sendCurrName = sendCurrData.Remark;
  1943. sendCurrCode = sendCurrData.Name;
  1944. }
  1945. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1946. if (eventsCurrData != null)
  1947. {
  1948. eventsCurrName = eventsCurrData.Remark;
  1949. eventsCurrCode = eventsCurrData.Name;
  1950. }
  1951. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1952. if (translateCurrData != null)
  1953. {
  1954. translateCurrName = translateCurrData.Remark;
  1955. translateCurrCode = translateCurrData.Name;
  1956. }
  1957. #endregion
  1958. _detail.PriceNameContent = _ioa.InviterArea;
  1959. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1960. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1961. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1962. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1963. $@"备注:" + _ioa.Remark + "<br/>";
  1964. }
  1965. break;
  1966. case 82: //团组客户保险
  1967. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1968. if (customers != null)
  1969. {
  1970. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1971. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1972. }
  1973. break;
  1974. case 85: //机票预订
  1975. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1976. if (jpRes != null)
  1977. {
  1978. string FlightsDescription = jpRes.FlightsDescription;
  1979. string PriceDescription = jpRes.PriceDescription;
  1980. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1981. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1982. }
  1983. break;
  1984. case 98://其他款项
  1985. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1986. if (gdpRes != null)
  1987. {
  1988. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1989. _detail.PriceNameContent = gdpRes.PriceName;
  1990. }
  1991. break;
  1992. case 285://收款退还
  1993. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1994. if (refundAndOtherMoney != null)
  1995. {
  1996. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1997. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1998. }
  1999. break;
  2000. case 751://酒店早餐
  2001. break;
  2002. case 1015://超支费用
  2003. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2004. if (groupExtraCost != null)
  2005. {
  2006. _detail.PriceNameContent = groupExtraCost.PriceName;
  2007. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2008. }
  2009. break;
  2010. default:
  2011. break;
  2012. }
  2013. /*
  2014. * 申请人
  2015. */
  2016. string operatorName = " - ";
  2017. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2018. if (_opUser != null)
  2019. {
  2020. operatorName = _opUser.CnName;
  2021. }
  2022. _detail.OperatorName = operatorName;
  2023. /*
  2024. * 审核人
  2025. */
  2026. string auditOperatorName = "Unknown";
  2027. if (entity.AuditGMOperate == 0)
  2028. auditOperatorName = " - ";
  2029. else if (entity.AuditGMOperate == 4)
  2030. auditOperatorName = "自动审核";
  2031. else
  2032. {
  2033. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2034. if (_adUser != null)
  2035. {
  2036. auditOperatorName = _adUser.CnName;
  2037. }
  2038. }
  2039. _detail.AuditOperatorName = auditOperatorName;
  2040. /*
  2041. * 超预算比例
  2042. */
  2043. string overBudgetStr = "";
  2044. if (entity.ExceedBudget == -1)
  2045. overBudgetStr = sdPriceName.Name + "尚无预算";
  2046. else if (entity.ExceedBudget == 0)
  2047. {
  2048. if (entity.CTable == 76 || entity.CTable == 79)
  2049. {
  2050. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2051. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2052. }
  2053. else
  2054. {
  2055. overBudgetStr = "未超预算";
  2056. }
  2057. }
  2058. else
  2059. overBudgetStr = entity.ExceedBudget.ToString("P");
  2060. _detail.OverBudget = overBudgetStr;
  2061. /*
  2062. * 已审核金额
  2063. */
  2064. decimal auditFee = 0.00M;
  2065. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2066. /*
  2067. * 费用总计
  2068. */
  2069. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2070. {
  2071. CurrencyId = entity.PaymentCurrency,
  2072. CurrencyName = PaymentCurrency_WaitPay,
  2073. AmountPayable = entity.PayMoney,
  2074. ThisPayment = OriginalCurrPay,
  2075. BalancePayment = BalanceStr,
  2076. AuditedFunds = auditFee
  2077. });
  2078. _detail.IsAuditGM = entity.IsAuditGM;
  2079. detailList.Add(_detail);
  2080. }
  2081. #endregion
  2082. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2083. /*
  2084. * 下方描述处理
  2085. */
  2086. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2087. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2088. if (ccpCurrencyPrice != null)
  2089. {
  2090. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2091. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2092. }
  2093. else
  2094. {
  2095. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2096. }
  2097. string amountPayableStr = string.Format(@"应付款总金额: ");
  2098. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2099. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2100. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2101. foreach (var item in nonDuplicat)
  2102. {
  2103. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2104. if (strs.Count > 0)
  2105. {
  2106. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2107. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2108. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2109. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2110. //单独处理此次付款金额
  2111. if (item.CurrencyId == 836) //人民币
  2112. {
  2113. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2114. }
  2115. else
  2116. {
  2117. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2118. }
  2119. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2120. //单独处理已审核费用
  2121. if (item.CurrencyId == 836) //人民币
  2122. {
  2123. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2124. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2125. }
  2126. else
  2127. {
  2128. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2129. }
  2130. }
  2131. }
  2132. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2133. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2134. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2135. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2136. var _view1 = new
  2137. {
  2138. PageFuncAuth = pageFunAuthView,
  2139. Data = _view
  2140. };
  2141. return Ok(JsonView(_view1));
  2142. }
  2143. catch (Exception ex)
  2144. {
  2145. return Ok(JsonView(false, ex.Message));
  2146. }
  2147. }
  2148. /// <summary>
  2149. /// 费用审核
  2150. /// 修改团组费用审核状态
  2151. /// </summary>
  2152. /// <param name="_dto">参数Json字符串</param>
  2153. /// <returns></returns>
  2154. [HttpPost]
  2155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2156. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2157. {
  2158. #region 参数验证
  2159. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2160. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2161. #endregion
  2162. #region 页面操作权限验证
  2163. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2164. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2165. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2166. #endregion
  2167. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2168. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2169. DateTime dtNow = DateTime.Now;
  2170. _groupRepository.BeginTran();
  2171. int rst = 0;
  2172. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2173. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2174. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2175. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2176. List<dynamic> msgDatas = new List<dynamic>();
  2177. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2178. foreach (var item in idList)
  2179. {
  2180. int CreditId = int.Parse(item);
  2181. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2182. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2183. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2184. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2185. .Where(s => s.Id == CreditId)
  2186. .ExecuteCommandAsync();
  2187. if (result < 1)
  2188. {
  2189. rst = -1;
  2190. _groupRepository.RollbackTran();
  2191. return Ok(JsonView(false, "操作失败并回滚!"));
  2192. }
  2193. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2194. if (creditData != null)
  2195. {
  2196. #region 应用通知配置
  2197. try
  2198. {
  2199. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2200. }
  2201. catch (Exception ex)
  2202. {
  2203. }
  2204. #endregion
  2205. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2206. string groupNameStr = string.Empty;
  2207. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2208. if (groupData != null) groupNameStr = groupData.TeamName;
  2209. string creditTypeStr = string.Empty;
  2210. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2211. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2212. string creditCurrency = string.Empty;
  2213. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2214. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2215. if (creditCurrency.Equals("CNY"))
  2216. {
  2217. creditData.DayRate = 1.0000M;
  2218. }
  2219. if (creditData.PayPercentage == 0.00M)
  2220. {
  2221. creditData.PayPercentage = 100M;
  2222. }
  2223. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2224. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2225. string msgContent = "";
  2226. if (creditCurrency.Equals("CNY"))
  2227. {
  2228. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2229. }
  2230. else
  2231. {
  2232. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2233. }
  2234. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2235. }
  2236. }
  2237. if (rst == 0)
  2238. {
  2239. _groupRepository.CommitTran();
  2240. foreach (var item in msgDatas)
  2241. {
  2242. //发送消息
  2243. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2244. }
  2245. #region 应用推送
  2246. try
  2247. {
  2248. foreach (var ccpId in dic_ccp_user.Keys)
  2249. {
  2250. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2251. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2252. }
  2253. }
  2254. catch (Exception)
  2255. {
  2256. }
  2257. #endregion
  2258. return Ok(JsonView(true, "操作成功!"));
  2259. }
  2260. return Ok(JsonView(false, "操作失败!"));
  2261. }
  2262. #endregion
  2263. #region 机票费用录入
  2264. /// <summary>
  2265. /// 机票录入当前登录人可操作团组
  2266. /// </summary>
  2267. /// <param name="dto"></param>
  2268. /// <returns></returns>
  2269. [HttpPost]
  2270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2271. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2272. {
  2273. try
  2274. {
  2275. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2276. if (groupData.Code != 0)
  2277. {
  2278. return Ok(JsonView(false, groupData.Msg));
  2279. }
  2280. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2281. }
  2282. catch (Exception ex)
  2283. {
  2284. return Ok(JsonView(false, "程序错误!"));
  2285. throw;
  2286. }
  2287. }
  2288. /// <summary>
  2289. /// 机票费用录入列表
  2290. /// </summary>
  2291. /// <param name="dto"></param>
  2292. /// <returns></returns>
  2293. [HttpPost]
  2294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2295. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2296. {
  2297. try
  2298. {
  2299. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2300. if (groupData.Code != 0)
  2301. {
  2302. return Ok(JsonView(false, groupData.Msg));
  2303. }
  2304. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2305. }
  2306. catch (Exception ex)
  2307. {
  2308. return Ok(JsonView(false, ex.Message));
  2309. throw;
  2310. }
  2311. }
  2312. /// <summary>
  2313. /// 根据id查询费用录入信息
  2314. /// </summary>
  2315. /// <param name="dto"></param>
  2316. /// <returns></returns>
  2317. [HttpPost]
  2318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2319. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2320. {
  2321. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2322. if (groupData.Code != 0)
  2323. {
  2324. return Ok(JsonView(false, groupData.Msg));
  2325. }
  2326. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2327. }
  2328. /// <summary>
  2329. /// 机票费用录入操作(Status:1.新增,2.修改)
  2330. /// </summary>
  2331. /// <param name="dto"></param>
  2332. /// <returns></returns>
  2333. [HttpPost]
  2334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2335. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2336. {
  2337. try
  2338. {
  2339. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2340. if (groupData.Code != 0)
  2341. {
  2342. return Ok(JsonView(false, groupData.Msg));
  2343. }
  2344. #region 应用推送
  2345. try
  2346. {
  2347. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2348. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2349. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2350. }
  2351. catch (Exception ex)
  2352. {
  2353. }
  2354. #endregion
  2355. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2356. }
  2357. catch (Exception ex)
  2358. {
  2359. return Ok(JsonView(false, "程序错误!"));
  2360. throw;
  2361. }
  2362. }
  2363. /// <summary>
  2364. /// 根据舱位类型查询接团客户名单信息
  2365. /// </summary>
  2366. /// <param name="dto"></param>
  2367. /// <returns></returns>
  2368. [HttpPost]
  2369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2370. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2371. {
  2372. try
  2373. {
  2374. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2375. if (crm_Groups.Count != 0)
  2376. {
  2377. List<dynamic> Customer = new List<dynamic>();
  2378. foreach (var item in crm_Groups)
  2379. {
  2380. var data = new
  2381. {
  2382. Id = item.Id,
  2383. Pinyin = item.Pinyin,
  2384. Name = item.LastName + item.FirstName
  2385. };
  2386. Customer.Add(data);
  2387. }
  2388. return Ok(JsonView(true, "查询成功!", Customer));
  2389. }
  2390. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2391. }
  2392. catch (Exception ex)
  2393. {
  2394. return Ok(JsonView(false, "程序错误!"));
  2395. throw;
  2396. }
  2397. }
  2398. /// <summary>
  2399. /// 根据团号获取客户信息
  2400. /// </summary>
  2401. /// <param name="dto"></param>
  2402. /// <returns></returns>
  2403. [HttpPost]
  2404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2405. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2406. {
  2407. var jw = JsonView(false);
  2408. if (dto.DIID < 1)
  2409. {
  2410. jw.Msg += "请输入正确的diid";
  2411. return Ok(jw);
  2412. }
  2413. var arr = getSimplClientList(dto.DIID);
  2414. jw = JsonView(true, "获取成功!", arr);
  2415. return Ok(jw);
  2416. }
  2417. private List<SimplClientInfo> getSimplClientList(int diId)
  2418. {
  2419. 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);
  2420. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2421. return arr;
  2422. }
  2423. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2424. {
  2425. string result = origin;
  2426. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2427. {
  2428. string[] temparr = origin.Split(',');
  2429. string fistrStr = temparr[0];
  2430. int count = temparr.Count();
  2431. int tempId;
  2432. bool success = int.TryParse(fistrStr, out tempId);
  2433. if (success)
  2434. {
  2435. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2436. if (tempInfo != null)
  2437. {
  2438. if (count > 1)
  2439. {
  2440. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2441. }
  2442. else
  2443. {
  2444. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2445. }
  2446. }
  2447. }
  2448. }
  2449. return result;
  2450. }
  2451. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2452. {
  2453. string result = origin;
  2454. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2455. {
  2456. string[] temparr = origin.Split(',');
  2457. result = "";
  2458. foreach (var item in temparr)
  2459. {
  2460. int tempId;
  2461. bool success = int.TryParse(item, out tempId);
  2462. if (success)
  2463. {
  2464. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2465. if (tempInfo != null)
  2466. {
  2467. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2468. }
  2469. }
  2470. }
  2471. }
  2472. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2473. return result;
  2474. }
  2475. /// <summary>
  2476. /// 机票费用录入,删除
  2477. /// </summary>
  2478. /// <param name="dto"></param>
  2479. /// <returns></returns>
  2480. [HttpPost]
  2481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2482. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2483. {
  2484. try
  2485. {
  2486. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2487. if (res)
  2488. {
  2489. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2490. {
  2491. IsDel = 1,
  2492. DeleteUserId = dto.DeleteUserId,
  2493. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2494. }).ExecuteCommandAsync();
  2495. return Ok(JsonView(true, "删除成功!"));
  2496. }
  2497. return Ok(JsonView(false, "删除失败!"));
  2498. }
  2499. catch (Exception ex)
  2500. {
  2501. return Ok(JsonView(false, "程序错误!"));
  2502. throw;
  2503. }
  2504. }
  2505. /// <summary>
  2506. /// 导出机票录入报表
  2507. /// </summary>
  2508. /// <param name="dto"></param>
  2509. /// <returns></returns>
  2510. [HttpPost]
  2511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2512. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2513. {
  2514. try
  2515. {
  2516. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2517. if (groupData.Code != 0)
  2518. {
  2519. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2520. }
  2521. else
  2522. {
  2523. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2524. if (AirTicketReservations.Count != 0)
  2525. {
  2526. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2527. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2528. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2529. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2530. WorkbookDesigner designer = new WorkbookDesigner();
  2531. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2532. decimal countCost = 0;
  2533. foreach (var item in AirTicketReservations)
  2534. {
  2535. #region 处理客人姓名
  2536. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2537. item.ClientName = clientNames;
  2538. #endregion
  2539. if (item.BankType == "其他")
  2540. {
  2541. item.BankNo = "--";
  2542. }
  2543. else
  2544. {
  2545. if (!string.IsNullOrEmpty(item.BankType))
  2546. {
  2547. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2548. }
  2549. }
  2550. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2551. item.Price = System.Decimal.Round(item.Price, 2);
  2552. countCost += Convert.ToDecimal(item.Price);
  2553. }
  2554. designer.SetDataSource("Export", AirTicketReservations);
  2555. designer.SetDataSource("ExportDiCode", diCode);
  2556. designer.SetDataSource("ExportDiName", diName);
  2557. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2558. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2559. designer.Process();
  2560. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2561. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2562. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2563. return Ok(JsonView(true, "成功", url = rst));
  2564. }
  2565. else
  2566. {
  2567. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2568. }
  2569. }
  2570. }
  2571. catch (Exception ex)
  2572. {
  2573. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2574. throw;
  2575. }
  2576. }
  2577. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2578. /// <summary>
  2579. /// 行程单导出
  2580. /// </summary>
  2581. /// <param name="dto"></param>
  2582. /// <returns></returns>
  2583. [HttpPost]
  2584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2585. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2586. {
  2587. try
  2588. {
  2589. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2590. if (groupData.Code != 0)
  2591. {
  2592. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2593. }
  2594. else
  2595. {
  2596. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2597. if (dto.Language == "CN")
  2598. {
  2599. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2600. DocumentBuilder builder = new DocumentBuilder(doc);
  2601. int tableIndex = 0;//表格索引
  2602. //得到文档中的第一个表格
  2603. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2604. foreach (var item in _AirTicketReservations)
  2605. {
  2606. #region 处理固定数据
  2607. string[] FlightsCode = item.FlightsCode.Split('/');
  2608. if (FlightsCode.Length != 0)
  2609. {
  2610. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2611. if (_AirCompany != null)
  2612. {
  2613. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2614. }
  2615. else
  2616. {
  2617. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2618. }
  2619. }
  2620. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2621. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2622. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2623. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2624. string name = "";
  2625. foreach (string clientName in nameArray)
  2626. {
  2627. if (!name.Contains(clientName))
  2628. {
  2629. name += clientName + ",";
  2630. }
  2631. }
  2632. if (!string.IsNullOrWhiteSpace(name))
  2633. {
  2634. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2635. }
  2636. else
  2637. {
  2638. table.Range.Bookmarks["ClientName"].Text = "--";
  2639. }
  2640. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2641. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2642. table.Range.Bookmarks["JointTicket"].Text = "--";
  2643. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2644. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2645. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2646. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2647. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2648. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2649. #endregion
  2650. #region 循环数据处理
  2651. List<AirInfo> airs = new List<AirInfo>();
  2652. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2653. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2654. for (int i = 0; i < FlightsCode.Length; i++)
  2655. {
  2656. AirInfo air = new AirInfo();
  2657. string[] tempstr = DayArray[i]
  2658. .Replace("\r\n", string.Empty)
  2659. .Replace("\\r\\n", string.Empty)
  2660. .TrimStart().TrimEnd()
  2661. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2662. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2663. string starCity = "";
  2664. if (star_Three != null)
  2665. {
  2666. starCity = star_Three.AirPort;
  2667. }
  2668. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2669. string EndCity = "";
  2670. if (End_Three != null)
  2671. {
  2672. EndCity = End_Three.AirPort;
  2673. }
  2674. air.Destination = starCity + "/" + EndCity;
  2675. air.Flight = FlightsCode[i];
  2676. air.SeatingClass = item.CTypeName;
  2677. string dateTime = tempstr[2];
  2678. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2679. air.FlightDate = DateTemp;
  2680. air.DepartureTime = tempstr[5];
  2681. air.LandingTime = tempstr[6];
  2682. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2683. air.TicketStatus = "--";
  2684. air.Luggage = "--";
  2685. air.DepartureTerminal = "--";
  2686. air.LandingTerminal = "--";
  2687. airs.Add(air);
  2688. }
  2689. int row = 13;
  2690. for (int i = 0; i < airs.Count; i++)
  2691. {
  2692. if (airs.Count > 2)
  2693. {
  2694. for (int j = 0; j < airs.Count - 2; j++)
  2695. {
  2696. var CopyRow = table.Rows[12].Clone(true);
  2697. table.Rows.Add(CopyRow);
  2698. }
  2699. }
  2700. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2701. int index = 0;
  2702. foreach (PropertyInfo property in properties)
  2703. {
  2704. string value = property.GetValue(airs[i]).ToString();
  2705. Cell ishcel0 = table.Rows[row].Cells[index];
  2706. Paragraph p = new Paragraph(doc);
  2707. string s = value;
  2708. p.AppendChild(new Run(doc, s));
  2709. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2710. ishcel0.AppendChild(p);
  2711. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2712. index++;
  2713. }
  2714. row++;
  2715. }
  2716. #endregion
  2717. Paragraph lastParagraph = new Paragraph(doc);
  2718. //第一个表格末尾加段落
  2719. table.ParentNode.InsertAfter(lastParagraph, table);
  2720. //复制第一个表格
  2721. Table cloneTable = (Table)table.Clone(true);
  2722. //在文档末尾段落后面加入复制的表格
  2723. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2724. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2725. {
  2726. int rownewsIndex = 13;
  2727. for (int i = 0; i < 2; i++)
  2728. {
  2729. var CopyRow = table.Rows[12].Clone(true);
  2730. table.Rows.RemoveAt(13);
  2731. table.Rows.Add(CopyRow);
  2732. rownewsIndex++;
  2733. }
  2734. }
  2735. else
  2736. {
  2737. table.Rows.RemoveAt(12);
  2738. }
  2739. cloneTable.Rows.RemoveAt(12);
  2740. }
  2741. if (_AirTicketReservations.Count != 0)
  2742. {
  2743. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2744. if (FlightsCode.Length != 0)
  2745. {
  2746. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2747. if (_AirCompany != null)
  2748. {
  2749. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2750. }
  2751. else
  2752. {
  2753. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2754. }
  2755. }
  2756. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2757. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2758. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2759. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2760. string name = "";
  2761. foreach (string clientName in nameArray)
  2762. {
  2763. if (!name.Contains(clientName))
  2764. {
  2765. name += clientName + ",";
  2766. }
  2767. }
  2768. if (!string.IsNullOrWhiteSpace(name))
  2769. {
  2770. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2771. }
  2772. else
  2773. {
  2774. table.Range.Bookmarks["ClientName"].Text = "--";
  2775. }
  2776. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2777. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2778. table.Range.Bookmarks["JointTicket"].Text = "--";
  2779. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2780. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2781. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2782. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2783. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2784. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2785. }
  2786. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2787. //保存合并后的文档
  2788. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2789. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2790. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2791. return Ok(JsonView(true, "成功!", rst));
  2792. }
  2793. else
  2794. {
  2795. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2796. DocumentBuilder builder = new DocumentBuilder(doc);
  2797. int tableIndex = 0;//表格索引
  2798. //得到文档中的第一个表格
  2799. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2800. List<string> texts = new List<string>();
  2801. foreach (var item in _AirTicketReservations)
  2802. {
  2803. string[] FlightsCode = item.FlightsCode.Split('/');
  2804. if (FlightsCode.Length != 0)
  2805. {
  2806. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2807. if (_AirCompany != null)
  2808. {
  2809. if (!transDic.ContainsKey(_AirCompany.CnName))
  2810. {
  2811. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2812. }
  2813. }
  2814. else
  2815. {
  2816. if (!transDic.ContainsKey("--"))
  2817. {
  2818. transDic.Add("--", "--");
  2819. }
  2820. }
  2821. }
  2822. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2823. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2824. string name = "";
  2825. foreach (string clientName in nameArray)
  2826. {
  2827. name += clientName + ",";
  2828. }
  2829. if (!texts.Contains(name))
  2830. {
  2831. texts.Add(name);
  2832. }
  2833. List<AirInfo> airs = new List<AirInfo>();
  2834. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2835. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2836. for (int i = 0; i < FlightsCode.Length; i++)
  2837. {
  2838. AirInfo air = new AirInfo();
  2839. string[] tempstr = DayArray[i]
  2840. .Replace("\r\n", string.Empty)
  2841. .Replace("\\r\\n", string.Empty)
  2842. .TrimStart().TrimEnd()
  2843. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2844. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2845. if (star_Three != null)
  2846. {
  2847. if (!transDic.ContainsKey(star_Three.AirPort))
  2848. {
  2849. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2850. }
  2851. }
  2852. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2853. if (End_Three != null)
  2854. {
  2855. if (!transDic.ContainsKey(End_Three.AirPort))
  2856. {
  2857. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2858. }
  2859. }
  2860. if (!texts.Contains(item.CTypeName))
  2861. {
  2862. texts.Add(item.CTypeName);
  2863. }
  2864. }
  2865. }
  2866. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2867. if (transData.Count > 0)
  2868. {
  2869. foreach (TranslateResult item in transData)
  2870. {
  2871. if (!transDic.ContainsKey(item.Query))
  2872. {
  2873. transDic.Add(item.Query, item.Translation);
  2874. }
  2875. }
  2876. }
  2877. foreach (var item in _AirTicketReservations)
  2878. {
  2879. #region 处理固定数据
  2880. string[] FlightsCode = item.FlightsCode.Split('/');
  2881. if (FlightsCode.Length != 0)
  2882. {
  2883. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2884. if (_AirCompany != null)
  2885. {
  2886. string str = "--";
  2887. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2888. if (!string.IsNullOrEmpty(translateResult))
  2889. {
  2890. str = translateResult;
  2891. str = _airTicketResRep.Processing(str);
  2892. }
  2893. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2894. }
  2895. else
  2896. {
  2897. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2898. }
  2899. }
  2900. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2901. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2902. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2903. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2904. string names = "";
  2905. foreach (string clientName in nameArray)
  2906. {
  2907. names += clientName + ",";
  2908. }
  2909. if (!string.IsNullOrWhiteSpace(names))
  2910. {
  2911. string str = "--";
  2912. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2913. if (!string.IsNullOrEmpty(translateResult))
  2914. {
  2915. str = translateResult;
  2916. str = _airTicketResRep.Processing(str);
  2917. }
  2918. table.Range.Bookmarks["ClientName"].Text = str;
  2919. }
  2920. else
  2921. {
  2922. table.Range.Bookmarks["ClientName"].Text = "--";
  2923. }
  2924. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2925. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2926. table.Range.Bookmarks["JointTicket"].Text = "--";
  2927. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2928. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2929. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2930. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2931. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2932. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2933. #endregion
  2934. #region 循环数据处理
  2935. List<AirInfo> airs = new List<AirInfo>();
  2936. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2937. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2938. for (int i = 0; i < FlightsCode.Length; i++)
  2939. {
  2940. AirInfo air = new AirInfo();
  2941. string[] tempstr = DayArray[i]
  2942. .Replace("\r\n", string.Empty)
  2943. .Replace("\\r\\n", string.Empty)
  2944. .TrimStart().TrimEnd()
  2945. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2946. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2947. string starCity = "";
  2948. if (star_Three != null)
  2949. {
  2950. string str2 = "--";
  2951. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2952. if (!string.IsNullOrEmpty(translateResult2))
  2953. {
  2954. str2 = translateResult2;
  2955. str2 = _airTicketResRep.Processing(str2);
  2956. }
  2957. starCity = str2;
  2958. }
  2959. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2960. string EndCity = "";
  2961. if (End_Three != null)
  2962. {
  2963. string str1 = "--";
  2964. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2965. if (!string.IsNullOrEmpty(translateResult1))
  2966. {
  2967. str1 = translateResult1;
  2968. str1 = _airTicketResRep.Processing(str1);
  2969. }
  2970. EndCity = str1;
  2971. }
  2972. air.Destination = starCity + "/" + EndCity;
  2973. air.Flight = FlightsCode[i];
  2974. string str = "--";
  2975. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2976. if (!string.IsNullOrEmpty(translateResult))
  2977. {
  2978. str = translateResult;
  2979. str = _airTicketResRep.Processing(str);
  2980. }
  2981. air.SeatingClass = str;
  2982. string dateTime = tempstr[2];
  2983. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2984. air.FlightDate = DateTemp;
  2985. air.DepartureTime = tempstr[5];
  2986. air.LandingTime = tempstr[6];
  2987. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2988. air.TicketStatus = "--";
  2989. air.Luggage = "--";
  2990. air.DepartureTerminal = "--";
  2991. air.LandingTerminal = "--";
  2992. airs.Add(air);
  2993. }
  2994. int row = 13;
  2995. for (int i = 0; i < airs.Count; i++)
  2996. {
  2997. if (airs.Count > 2)
  2998. {
  2999. for (int j = 0; j < airs.Count - 2; j++)
  3000. {
  3001. var CopyRow = table.Rows[12].Clone(true);
  3002. table.Rows.Add(CopyRow);
  3003. }
  3004. }
  3005. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3006. int index = 0;
  3007. foreach (PropertyInfo property in properties)
  3008. {
  3009. string value = property.GetValue(airs[i]).ToString();
  3010. Cell ishcel0 = table.Rows[row].Cells[index];
  3011. Paragraph p = new Paragraph(doc);
  3012. string s = value;
  3013. p.AppendChild(new Run(doc, s));
  3014. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3015. ishcel0.AppendChild(p);
  3016. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3017. //ishcel0.CellFormat.VerticalAlignment=
  3018. index++;
  3019. }
  3020. row++;
  3021. }
  3022. #endregion
  3023. Paragraph lastParagraph = new Paragraph(doc);
  3024. //第一个表格末尾加段落
  3025. table.ParentNode.InsertAfter(lastParagraph, table);
  3026. //复制第一个表格
  3027. Table cloneTable = (Table)table.Clone(true);
  3028. //在文档末尾段落后面加入复制的表格
  3029. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3030. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3031. {
  3032. int rownewsIndex = 13;
  3033. for (int i = 0; i < 2; i++)
  3034. {
  3035. var CopyRow = table.Rows[12].Clone(true);
  3036. table.Rows.RemoveAt(13);
  3037. table.Rows.Add(CopyRow);
  3038. rownewsIndex++;
  3039. }
  3040. }
  3041. else
  3042. {
  3043. table.Rows.RemoveAt(12);
  3044. }
  3045. cloneTable.Rows.RemoveAt(12);
  3046. }
  3047. if (_AirTicketReservations.Count != 0)
  3048. {
  3049. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3050. if (FlightsCode.Length != 0)
  3051. {
  3052. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3053. if (_AirCompany != null)
  3054. {
  3055. string str = "--";
  3056. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3057. if (!string.IsNullOrEmpty(translateResult))
  3058. {
  3059. str = translateResult;
  3060. str = _airTicketResRep.Processing(str);
  3061. }
  3062. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3063. }
  3064. else
  3065. {
  3066. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3067. }
  3068. }
  3069. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3070. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3071. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3072. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3073. string names = "";
  3074. foreach (string clientName in nameArray)
  3075. {
  3076. names += clientName + ",";
  3077. }
  3078. if (!string.IsNullOrWhiteSpace(names))
  3079. {
  3080. string str = "--";
  3081. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3082. if (!string.IsNullOrEmpty(translateResult))
  3083. {
  3084. str = translateResult;
  3085. str = _airTicketResRep.Processing(str);
  3086. }
  3087. table.Range.Bookmarks["ClientName"].Text = str;
  3088. }
  3089. else
  3090. {
  3091. table.Range.Bookmarks["ClientName"].Text = "--";
  3092. }
  3093. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3094. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3095. table.Range.Bookmarks["JointTicket"].Text = "--";
  3096. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3097. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3098. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3099. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3100. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3101. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3102. }
  3103. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3104. //保存合并后的文档
  3105. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3106. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3107. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3108. return Ok(JsonView(true, "成功!", rst));
  3109. }
  3110. }
  3111. }
  3112. catch (Exception ex)
  3113. {
  3114. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3115. throw;
  3116. }
  3117. }
  3118. #endregion
  3119. #region 团组增减款项 --> 其他款项
  3120. /// <summary>
  3121. /// 团组增减款项下拉框绑定
  3122. /// </summary>
  3123. /// <param name="dto"></param>
  3124. /// <returns></returns>
  3125. [HttpPost]
  3126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3127. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3128. {
  3129. #region 参数验证
  3130. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3131. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3132. #endregion
  3133. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3134. }
  3135. /// <summary>
  3136. /// 根据团组Id查询团组增减款项
  3137. /// </summary>
  3138. /// <param name="dto"></param>
  3139. /// <returns></returns>
  3140. [HttpPost]
  3141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3142. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3143. {
  3144. #region 参数验证
  3145. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3146. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3147. #endregion
  3148. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3149. }
  3150. /// <summary>
  3151. /// 团组增减款项操作(Status:1.新增,2.修改)
  3152. /// </summary>
  3153. /// <param name="dto"></param>
  3154. /// <returns></returns>
  3155. [HttpPost]
  3156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3157. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3158. {
  3159. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3160. if (groupData.Code != 200)
  3161. {
  3162. return Ok(JsonView(false, groupData.Msg));
  3163. }
  3164. #region 应用推送
  3165. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3166. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3167. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3168. #endregion
  3169. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3170. }
  3171. /// <summary>
  3172. /// 团组增减款项操作 删除
  3173. /// </summary>
  3174. /// <param name="dto"></param>
  3175. /// <returns></returns>
  3176. [HttpPost]
  3177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3178. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3179. {
  3180. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3181. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3182. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3183. if (res.Code == 0)
  3184. {
  3185. return Ok(JsonView(true, "删除成功!"));
  3186. }
  3187. return Ok(JsonView(false, "删除失败!"));
  3188. }
  3189. /// <summary>
  3190. /// 根据团组增减款项Id查询
  3191. /// </summary>
  3192. /// <param name="dto"></param>
  3193. /// <returns></returns>
  3194. [HttpPost]
  3195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3196. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3197. {
  3198. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3199. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3200. }
  3201. /// <summary>
  3202. /// 查询供应商名称
  3203. /// </summary>
  3204. /// <param name="dto"></param>
  3205. /// <returns></returns>
  3206. [HttpPost]
  3207. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3208. {
  3209. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3210. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3211. ?? new List<Grp_DecreasePayments>();
  3212. dbResult = dbResult.Distinct(new
  3213. ProductComparer()).ToList();
  3214. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3215. {
  3216. x.Id,
  3217. x.SupplierAddress,
  3218. x.SupplierArea,
  3219. x.SupplierContact,
  3220. x.SupplierContactNumber,
  3221. x.SupplierEmail,
  3222. x.SupplierName,
  3223. x.SupplierSocialAccount,
  3224. x.SupplierTypeId,
  3225. }).ToList());
  3226. return Ok(jw);
  3227. }
  3228. #endregion
  3229. #region 文件上传、删除
  3230. /// <summary>
  3231. /// region 文件上传 可以带参数
  3232. /// </summary>
  3233. /// <param name="file"></param>
  3234. /// <returns></returns>
  3235. [HttpPost]
  3236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3237. public async Task<IActionResult> UploadProject(IFormFile file)
  3238. {
  3239. //var TypeName = Request.Headers["TypeName"].ToString();
  3240. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3241. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3242. ////文件名称
  3243. //string projectFileName = file.FileName;
  3244. ////上传的文件的路径
  3245. //string filePath = $"{fileDir}/{projectFileName}";
  3246. //if (TypeName == "A")//A代表团组增减款项
  3247. //{
  3248. // filePath = fileDir + $@"\团组增减款项相关文件";
  3249. // if (!Directory.Exists(filePath))
  3250. // {
  3251. // Directory.CreateDirectory(filePath);
  3252. // }
  3253. // //上传的文件的路径
  3254. // filePath += $@"\{projectFileName}";
  3255. //}
  3256. //else if (TypeName == "B")//B代表商邀相关文件
  3257. //{
  3258. // //上传的文件的路径
  3259. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3260. // if (!Directory.Exists(filePath))
  3261. // {
  3262. // Directory.CreateDirectory(filePath);
  3263. // }
  3264. // //上传的文件的路径
  3265. // filePath = $@"\{projectFileName}";
  3266. //}
  3267. //try
  3268. //{
  3269. // using (FileStream fs = System.IO.File.Create(filePath))
  3270. // {
  3271. // file.CopyTo(fs);
  3272. // fs.Flush();
  3273. // }
  3274. //}
  3275. //catch (Exception ex)
  3276. //{
  3277. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3278. //}
  3279. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3280. try
  3281. {
  3282. var TypeName = Request.Headers["TypeName"].ToString();
  3283. if (file != null)
  3284. {
  3285. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3286. //文件名称
  3287. string projectFileName = file.FileName;
  3288. //上传的文件的路径
  3289. string filePath = $"{fileDir}/{projectFileName}";
  3290. if (TypeName == "A")//A代表团组增减款项
  3291. {
  3292. if (!Directory.Exists(fileDir))
  3293. {
  3294. Directory.CreateDirectory(fileDir);
  3295. }
  3296. //上传的文件的路径
  3297. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3298. }
  3299. else if (TypeName == "B")//B代表商邀相关文件
  3300. {
  3301. if (!Directory.Exists(fileDir))
  3302. {
  3303. Directory.CreateDirectory(fileDir);
  3304. }
  3305. //上传的文件的路径
  3306. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3307. }
  3308. using (FileStream fs = System.IO.File.Create(filePath))
  3309. {
  3310. file.CopyTo(fs);
  3311. fs.Flush();
  3312. }
  3313. return Ok(JsonView(true, "上传成功!", projectFileName));
  3314. }
  3315. else
  3316. {
  3317. return Ok(JsonView(false, "上传失败!"));
  3318. }
  3319. }
  3320. catch (Exception ex)
  3321. {
  3322. return Ok(JsonView(false, "程序错误!"));
  3323. }
  3324. }
  3325. /// <summary>
  3326. /// 删除指定文件
  3327. /// </summary>
  3328. /// <param name="dto"></param>
  3329. /// <returns></returns>
  3330. [HttpPost]
  3331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3332. public async Task<IActionResult> DelFile(DelFileDto dto)
  3333. {
  3334. try
  3335. {
  3336. var TypeName = Request.Headers["TypeName"].ToString();
  3337. string filePath = "";
  3338. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3339. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3340. int id = 0;
  3341. if (TypeName == "A")
  3342. {
  3343. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3344. // 删除该文件
  3345. System.IO.File.Delete(filePath);
  3346. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  3347. }
  3348. else if (TypeName == "B")
  3349. {
  3350. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3351. // 删除该文件
  3352. System.IO.File.Delete(filePath);
  3353. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  3354. }
  3355. if (id != 0)
  3356. {
  3357. return Ok(JsonView(true, "成功!"));
  3358. }
  3359. else
  3360. {
  3361. return Ok(JsonView(false, "失败!"));
  3362. }
  3363. }
  3364. catch (Exception ex)
  3365. {
  3366. return Ok(JsonView(false, "程序错误!"));
  3367. throw;
  3368. }
  3369. }
  3370. #endregion
  3371. #region 商邀费用录入
  3372. /// <summary>
  3373. /// 根据团组Id查询商邀费用列表
  3374. /// </summary>
  3375. /// <param name="dto"></param>
  3376. /// <returns></returns>
  3377. [HttpPost]
  3378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3379. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3380. {
  3381. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3382. if (groupData.Code != 0)
  3383. {
  3384. return Ok(JsonView(false, groupData.Msg));
  3385. }
  3386. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3387. }
  3388. /// <summary>
  3389. /// 商邀费用 Info Page 基础数据源
  3390. /// </summary>
  3391. /// <param name="dto"></param>
  3392. /// <returns></returns>
  3393. [HttpPost]
  3394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3395. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3396. {
  3397. try
  3398. {
  3399. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3400. if (groupData.Code != 0)
  3401. {
  3402. return Ok(JsonView(false, groupData.Msg));
  3403. }
  3404. return Ok(JsonView(true, "操作成功", groupData.Data));
  3405. }
  3406. catch (Exception ex)
  3407. {
  3408. return Ok(JsonView(false, ex.Message));
  3409. throw;
  3410. }
  3411. }
  3412. /// <summary>
  3413. /// 根据商邀费用ID查询C表和商邀费用数据
  3414. /// </summary>
  3415. /// <param name="dto"></param>
  3416. /// <returns></returns>
  3417. [HttpPost]
  3418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3419. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3420. {
  3421. try
  3422. {
  3423. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3424. if (groupData.Code != 0)
  3425. {
  3426. return Ok(JsonView(false, groupData.Msg));
  3427. }
  3428. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3429. }
  3430. catch (Exception ex)
  3431. {
  3432. return Ok(JsonView(false, ex.Message));
  3433. throw;
  3434. }
  3435. }
  3436. /// <summary>
  3437. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3438. /// </summary>
  3439. /// <param name="dto"></param>
  3440. /// <returns></returns>
  3441. [HttpPost]
  3442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3443. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3444. {
  3445. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3446. if (groupData.Code != 0)
  3447. {
  3448. return Ok(JsonView(false, groupData.Msg));
  3449. }
  3450. #region 应用推送
  3451. try
  3452. {
  3453. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3454. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3455. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3456. }
  3457. catch (Exception ex)
  3458. {
  3459. }
  3460. #endregion
  3461. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3462. }
  3463. /// <summary>
  3464. /// 商邀删除
  3465. /// </summary>
  3466. /// <param name="dto"></param>
  3467. /// <returns></returns>
  3468. [HttpPost]
  3469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3470. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3471. {
  3472. try
  3473. {
  3474. _sqlSugar.BeginTran();
  3475. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3476. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3477. {
  3478. IsDel = 1,
  3479. DeleteUserId = dto.DeleteUserId,
  3480. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3481. })
  3482. .Where(it => it.Id == dto.Id)
  3483. .ExecuteCommand();
  3484. if (res1 > 0)
  3485. {
  3486. int _diId = 0;
  3487. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3488. if (_ioaInfo != null)
  3489. {
  3490. _diId = _ioaInfo.DiId;
  3491. }
  3492. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3493. .SetColumns(a => new Grp_CreditCardPayment()
  3494. {
  3495. IsDel = 1,
  3496. DeleteUserId = dto.DeleteUserId,
  3497. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3498. })
  3499. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3500. .ExecuteCommand();
  3501. if (res2 > 0)
  3502. {
  3503. _sqlSugar.CommitTran();
  3504. return Ok(JsonView(true, "删除成功!"));
  3505. }
  3506. }
  3507. _sqlSugar.RollbackTran();
  3508. return Ok(JsonView(false, "删除失败"));
  3509. }
  3510. catch (Exception ex)
  3511. {
  3512. _sqlSugar.RollbackTran();
  3513. return Ok(JsonView(false, ex.Message));
  3514. }
  3515. }
  3516. /// <summary>
  3517. /// 团组模块文件上传
  3518. /// </summary>
  3519. /// <param name="dto"></param>
  3520. /// <returns></returns>
  3521. [HttpPost]
  3522. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3523. {
  3524. var jw = JsonView(false);
  3525. long M = 1024 * 1024;
  3526. if (dto.Files == null || dto.Files.Count == 0)
  3527. {
  3528. jw.Msg = "无文件信息!";
  3529. return Ok(jw);
  3530. }
  3531. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3532. {
  3533. jw.Msg = "文件大小超过20M!";
  3534. return Ok(jw);
  3535. }
  3536. //var nameSp = dto.File.FileName.Split(".");
  3537. //if (nameSp.Length < 2)
  3538. //{
  3539. // jw.Msg = "拓展名称有误!";
  3540. // return Ok(jw);
  3541. //}
  3542. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3543. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3544. //{
  3545. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3546. // return Ok(jw);
  3547. //}
  3548. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3549. if (Ctable == null)
  3550. {
  3551. jw.Msg = "Ctable指向有误!";
  3552. return Ok(jw);
  3553. }
  3554. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3555. if (groupInfo == null)
  3556. {
  3557. jw.Msg = "团组信息不存在!";
  3558. return Ok(jw);
  3559. }
  3560. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3561. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3562. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3563. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3564. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3565. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3566. try
  3567. {
  3568. if (!Directory.Exists(fileBase))
  3569. {
  3570. Directory.CreateDirectory(fileBase);
  3571. }
  3572. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3573. foreach (var fileStream in dto.Files)
  3574. {
  3575. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3576. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3577. {
  3578. Cid = dto.Cid,
  3579. CreateTime = DateTime.Now,
  3580. CreateUserId = dto.Userid,
  3581. Ctable = dto.Ctable,
  3582. Diid = dto.Diid,
  3583. IsDel = 0,
  3584. FilePath = saveFilePath,
  3585. FileName = fileStream.FileName
  3586. };
  3587. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3588. {
  3589. fileStream.CopyTo(fs);
  3590. fs.Flush();
  3591. }
  3592. saveArr.Add(file);
  3593. }
  3594. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3595. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3596. jw = JsonView(true, "保存成功!", new
  3597. {
  3598. count = addResult,
  3599. filesName = saveArr.Select(x => x.FileName)
  3600. });
  3601. }
  3602. catch (Exception ex)
  3603. {
  3604. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3605. {
  3606. count = 0,
  3607. filesName = new string[0],
  3608. });
  3609. }
  3610. return Ok(jw);
  3611. }
  3612. /// <summary>
  3613. /// 查询各模块已保存文件
  3614. /// </summary>
  3615. /// <param name="dto"></param>
  3616. /// <returns></returns>
  3617. [HttpPost]
  3618. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3619. {
  3620. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3621. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3622. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3623. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3624. {
  3625. expression = Expressionable.Create<Grp_GroupModelFile>()
  3626. .And(x => visaIds.Contains(x.CreateUserId));
  3627. }
  3628. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3629. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3630. .Where(expression.ToExpression())
  3631. .ToList();
  3632. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3633. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3634. {
  3635. x.FileName,
  3636. x.Id,
  3637. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3638. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3639. })));
  3640. }
  3641. /// <summary>
  3642. /// 下载该团组下的所有文件
  3643. /// </summary>
  3644. /// <param name="dto"></param>
  3645. /// <returns></returns>
  3646. [HttpPost]
  3647. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3648. {
  3649. var jw = JsonView(false);
  3650. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3651. if (groupInfo == null)
  3652. {
  3653. jw.Msg = "团组信息不存在!";
  3654. return Ok(jw);
  3655. }
  3656. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3657. var isModule = Convert.ToBoolean(dto.isModule);
  3658. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3659. IOOperatorHelper io = new IOOperatorHelper();
  3660. if (isModule)
  3661. {
  3662. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3663. foreach (var moduleArr in moduleGroup)
  3664. {
  3665. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3666. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3667. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3668. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3669. foreach (var item in moduleArr)
  3670. {
  3671. if (System.IO.File.Exists(item.FilePath))
  3672. {
  3673. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3674. {
  3675. byte[] bytes = new byte[fileStream.Length];
  3676. fileStream.Read(bytes, 0, bytes.Length);
  3677. fileStream.Close();
  3678. Stream stream = new MemoryStream(bytes);
  3679. chiZips.Add(item.FileName, stream);
  3680. }
  3681. }
  3682. }
  3683. if (chiZips.Count > 0)
  3684. {
  3685. var byts = io.ConvertZipStream(chiZips);
  3686. Stream stream = new MemoryStream(byts);
  3687. Zips.Add(key.Name + "_.zip", stream);
  3688. }
  3689. }
  3690. }
  3691. else
  3692. {
  3693. foreach (var item in dbQuery)
  3694. {
  3695. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3696. {
  3697. byte[] bytes = new byte[fileStream.Length];
  3698. fileStream.Read(bytes, 0, bytes.Length);
  3699. fileStream.Close();
  3700. Stream stream = new MemoryStream(bytes);
  3701. while (Zips.Keys.Contains(item.FileName))
  3702. {
  3703. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3704. }
  3705. Zips.Add(item.FileName, stream);
  3706. }
  3707. }
  3708. }
  3709. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3710. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3711. if (Zips.Count > 0)
  3712. {
  3713. var byts = io.ConvertZipStream(Zips);
  3714. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3715. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3716. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3717. }
  3718. else
  3719. {
  3720. jw.Msg = "暂无生成文件!";
  3721. }
  3722. return Ok(jw);
  3723. }
  3724. /// <summary>
  3725. /// 下载该团组下此模块的所有文件
  3726. /// </summary>
  3727. /// <param name="dto"></param>
  3728. /// <returns></returns>
  3729. [HttpPost]
  3730. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3731. {
  3732. var jw = JsonView(false);
  3733. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3734. if (groupInfo == null)
  3735. {
  3736. jw.Msg = "团组信息不存在!";
  3737. return Ok(jw);
  3738. }
  3739. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3740. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3741. && x.IsDel == 0);
  3742. if (key == null)
  3743. {
  3744. jw.Msg = "Ctable指向错误!";
  3745. return Ok(jw);
  3746. }
  3747. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3748. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3749. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3750. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3751. IOOperatorHelper io = new IOOperatorHelper();
  3752. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3753. foreach (var item in dbQuery)
  3754. {
  3755. if (System.IO.File.Exists(item.FilePath))
  3756. {
  3757. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3758. {
  3759. byte[] bytes = new byte[fileStream.Length];
  3760. fileStream.Read(bytes, 0, bytes.Length);
  3761. fileStream.Close();
  3762. Stream stream = new MemoryStream(bytes);
  3763. while (Zips.Keys.Contains(item.FileName))
  3764. {
  3765. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3766. }
  3767. Zips.Add(item.FileName, stream);
  3768. }
  3769. }
  3770. }
  3771. if (Zips.Count > 0)
  3772. {
  3773. var byts = io.ConvertZipStream(Zips);
  3774. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3775. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3776. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3777. }
  3778. else
  3779. {
  3780. jw.Msg = "暂无生成文件!";
  3781. }
  3782. return Ok(jw);
  3783. }
  3784. /// <summary>
  3785. /// 删除该团组下的指定文件
  3786. /// </summary>
  3787. /// <param name="dto"></param>
  3788. /// <returns></returns>
  3789. [HttpPost]
  3790. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3791. {
  3792. var jw = JsonView(false);
  3793. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3794. if (sing == null)
  3795. {
  3796. jw.Msg = "暂无";
  3797. return Ok(jw);
  3798. }
  3799. if (System.IO.File.Exists(sing.FilePath))
  3800. {
  3801. try
  3802. {
  3803. System.IO.File.Delete(sing.FilePath);
  3804. }
  3805. catch (Exception ex)
  3806. {
  3807. jw.Msg = "删除失败!" + ex.Message;
  3808. return Ok(jw);
  3809. }
  3810. }
  3811. sing.IsDel = 1;
  3812. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3813. sing.DeleteUserId = dto.UserId;
  3814. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3815. jw = JsonView(true, "删除成功!");
  3816. return Ok(jw);
  3817. }
  3818. #endregion
  3819. #region 团组英文资料
  3820. /// <summary>
  3821. /// 查询团组英文所有资料
  3822. /// </summary>
  3823. /// <param name="dto"></param>
  3824. /// <returns></returns>
  3825. [HttpPost]
  3826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3827. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3828. {
  3829. try
  3830. {
  3831. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3832. if (groupData.Code != 0)
  3833. {
  3834. return Ok(JsonView(false, groupData.Msg));
  3835. }
  3836. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3837. }
  3838. catch (Exception ex)
  3839. {
  3840. return Ok(JsonView(false, "程序错误!"));
  3841. throw;
  3842. }
  3843. }
  3844. /// <summary>
  3845. /// 团组英文资料操作(Status:1.新增,2.修改)
  3846. /// </summary>
  3847. /// <param name="dto"></param>
  3848. /// <returns></returns>
  3849. [HttpPost]
  3850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3851. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3852. {
  3853. try
  3854. {
  3855. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3856. if (groupData.Code != 0)
  3857. {
  3858. return Ok(JsonView(false, groupData.Msg));
  3859. }
  3860. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3861. }
  3862. catch (Exception ex)
  3863. {
  3864. return Ok(JsonView(false, "程序错误!"));
  3865. throw;
  3866. }
  3867. }
  3868. /// <summary>
  3869. /// 团组英文资料Id查询数据
  3870. /// </summary>
  3871. /// <param name="dto"></param>
  3872. /// <returns></returns>
  3873. [HttpPost]
  3874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3875. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3876. {
  3877. try
  3878. {
  3879. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3880. if (_DelegationEnData != null)
  3881. {
  3882. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3883. }
  3884. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3885. }
  3886. catch (Exception ex)
  3887. {
  3888. return Ok(JsonView(false, "程序错误!"));
  3889. throw;
  3890. }
  3891. }
  3892. /// <summary>
  3893. /// 团组英文资料删除
  3894. /// </summary>
  3895. /// <param name="dto"></param>
  3896. /// <returns></returns>
  3897. [HttpPost]
  3898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3899. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3900. {
  3901. try
  3902. {
  3903. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3904. if (!res)
  3905. {
  3906. return Ok(JsonView(false, "删除失败"));
  3907. }
  3908. return Ok(JsonView(true, "删除成功!"));
  3909. }
  3910. catch (Exception ex)
  3911. {
  3912. return Ok(JsonView(false, "程序错误!"));
  3913. throw;
  3914. }
  3915. }
  3916. #endregion
  3917. #region 导出邀请函
  3918. /// <summary>
  3919. /// 导出邀请函页面初始化
  3920. /// </summary>
  3921. /// <param name="dto"></param>
  3922. /// <returns></returns>
  3923. [HttpPost]
  3924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3925. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3926. {
  3927. try
  3928. {
  3929. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3930. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3931. if (dto.DiId == 0)
  3932. {
  3933. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3934. }
  3935. else
  3936. {
  3937. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3938. }
  3939. return Ok(JsonView(true, "查询成功!", new
  3940. {
  3941. deleClient = crm_Deles,
  3942. delegations = grp_Delegations
  3943. }));
  3944. }
  3945. catch (Exception ex)
  3946. {
  3947. return Ok(JsonView(false, "程序错误!"));
  3948. throw;
  3949. }
  3950. }
  3951. /// <summary>
  3952. /// 导出邀请函
  3953. /// </summary>
  3954. /// <param name="dto"></param>
  3955. /// <returns></returns>
  3956. [HttpPost]
  3957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3958. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3959. {
  3960. #region 参数验证
  3961. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3962. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3963. #endregion
  3964. try
  3965. {
  3966. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3967. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3968. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3969. From Grp_TourClientList tcl
  3970. Left Join
  3971. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3972. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3973. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3974. From Crm_DeleClient dc
  3975. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3976. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3977. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3978. Where dc.IsDel = 0) temp
  3979. On temp.DcId =tcl.ClientId
  3980. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3981. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3982. List<string> texts = new List<string>();
  3983. if (datas.Count != 0)
  3984. {
  3985. foreach (TourClientListDetailsView item in datas)
  3986. {
  3987. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3988. {
  3989. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3990. }
  3991. else
  3992. {
  3993. string name = item.LastName + item.FirstName;
  3994. texts.Add(name);
  3995. }
  3996. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3997. {
  3998. if (!transDic.ContainsKey(item.Job))
  3999. {
  4000. texts.Add(item.Job);
  4001. }
  4002. }
  4003. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4004. {
  4005. texts.Add(item.CompanyFullName);
  4006. }
  4007. }
  4008. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4009. if (transData.Count > 0)
  4010. {
  4011. foreach (TranslateResult item in transData)
  4012. {
  4013. if (!transDic.ContainsKey(item.Query))
  4014. {
  4015. transDic.Add(item.Query, item.Translation);
  4016. }
  4017. }
  4018. }
  4019. List<GuestList> list = new List<GuestList>();
  4020. foreach (TourClientListDetailsView dele in datas)
  4021. {
  4022. GuestList guestList = new GuestList();
  4023. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4024. {
  4025. guestList.Name = dele.Pinyin;
  4026. }
  4027. else
  4028. {
  4029. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4030. guestList.Name = Name;
  4031. }
  4032. if (dele.Sex == 0)
  4033. {
  4034. guestList.Sex = "Male";
  4035. }
  4036. else if (dele.Sex == 1)
  4037. {
  4038. guestList.Sex = "Female";
  4039. }
  4040. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4041. if (!string.IsNullOrEmpty(dele.Job))
  4042. {
  4043. guestList.Job = dele.Job;
  4044. }
  4045. list.Add(guestList);
  4046. }
  4047. //载入模板
  4048. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4049. DocumentBuilder builder = new DocumentBuilder(doc);
  4050. //获取word里所有表格
  4051. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4052. //获取所填表格的序数
  4053. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4054. var rowStart = tableOne.Rows[0]; //获取第1行
  4055. //循环赋值
  4056. for (int i = 0; i < list.Count; i++)
  4057. {
  4058. builder.MoveToCell(0, i + 1, 0, 0);
  4059. builder.Write(list[i].Name.ToString());
  4060. builder.MoveToCell(0, i + 1, 1, 0);
  4061. builder.Write(list[i].Sex.ToString());
  4062. builder.MoveToCell(0, i + 1, 2, 0);
  4063. builder.Write(list[i].DOB.ToString());
  4064. builder.MoveToCell(0, i + 1, 3, 0);
  4065. builder.Write(list[i].Job.ToString());
  4066. }
  4067. //删除多余行
  4068. while (tableOne.Rows.Count > list.Count + 1)
  4069. {
  4070. tableOne.Rows.RemoveAt(list.Count + 1);
  4071. }
  4072. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4073. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4074. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4075. doc.Save(filePath);
  4076. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4077. return Ok(JsonView(true, "操作成功!", Url));
  4078. }
  4079. else
  4080. {
  4081. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4082. }
  4083. }
  4084. catch (Exception ex)
  4085. {
  4086. return Ok(JsonView(false, ex.Message));
  4087. throw;
  4088. }
  4089. }
  4090. #endregion
  4091. #region 团组经理模块 出入境费用
  4092. ///// <summary>
  4093. ///// 团组模块 - 出入境费用
  4094. ///// </summary>
  4095. ///// <returns></returns>
  4096. //[HttpPost]
  4097. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4098. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4099. //{
  4100. // try
  4101. // {
  4102. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4103. // if (data.Code != 0)
  4104. // {
  4105. // return Ok(JsonView(false, data.Msg));
  4106. // }
  4107. // return Ok(JsonView(true, "查询成功!"));
  4108. // }
  4109. // catch (Exception ex)
  4110. // {
  4111. // return Ok(JsonView(false, ex.Message));
  4112. // throw;
  4113. // }
  4114. //}
  4115. /// <summary>
  4116. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4117. /// </summary>
  4118. /// <returns></returns>
  4119. [HttpPost]
  4120. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4121. public async Task<IActionResult> SetDayAndCostAreaChange()
  4122. {
  4123. try
  4124. {
  4125. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4126. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4127. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4128. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4129. foreach (var item in unite) //处理交集数据
  4130. {
  4131. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4132. }
  4133. foreach (var item in merge) //处理差集数据
  4134. {
  4135. int nationalTravelFeeId = 0;
  4136. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4137. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4138. else
  4139. {
  4140. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4141. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4142. }
  4143. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4144. }
  4145. //只更新dayAndCost 的 nationalTravelFeeId;
  4146. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4147. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4148. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4149. }
  4150. catch (Exception ex)
  4151. {
  4152. return Ok(JsonView(false, ex.Message));
  4153. throw;
  4154. }
  4155. }
  4156. /// <summary>
  4157. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4158. /// </summary>
  4159. /// <returns></returns>
  4160. [HttpPost]
  4161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4162. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4163. {
  4164. try
  4165. {
  4166. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4167. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4168. //SetDataInfoView
  4169. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4170. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4171. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4172. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4173. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4174. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4175. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4176. //默认币种显示
  4177. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4178. {
  4179. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4180. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4181. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4182. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4183. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4184. };
  4185. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4186. if (_currencyRate.Count > 0)
  4187. {
  4188. foreach (var item in _currencyInfos)
  4189. {
  4190. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4191. if (rateInfo != null)
  4192. {
  4193. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4194. rate1 *= 1.035M;
  4195. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4196. }
  4197. }
  4198. }
  4199. return Ok(JsonView(true, "查询成功!", new
  4200. {
  4201. GroupNameData = groupNameData.Data,
  4202. CurrencyData = _CurrencyData,
  4203. WordTypeData = _WordTypeData,
  4204. ExcelTypeData = _ExcelTypeData,
  4205. CurrencyInit = _currencyInfos
  4206. }));
  4207. }
  4208. catch (Exception ex)
  4209. {
  4210. return Ok(JsonView(false, ex.Message));
  4211. throw;
  4212. }
  4213. }
  4214. /// <summary>
  4215. /// 团组模块 - 出入境费用
  4216. /// 实时汇率 tips
  4217. /// 签证费用 tips
  4218. /// </summary>
  4219. /// <returns></returns>
  4220. [HttpPost]
  4221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4222. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4223. {
  4224. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4225. //默认币种显示
  4226. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4227. {
  4228. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4229. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4230. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4231. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4232. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4233. };
  4234. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4235. List<dynamic> reteInfos = new List<dynamic>();
  4236. if (_currencyRate.Count > 0)
  4237. {
  4238. foreach (var item in _currencyInfos)
  4239. {
  4240. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4241. if (rateInfo != null)
  4242. {
  4243. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4244. decimal rate1 = item.Rate;
  4245. rate1 *= 1.03M;
  4246. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4247. reteInfos.Add(new
  4248. {
  4249. currCode = item.CurrencyCode,
  4250. currName = item.CurrencyName,
  4251. rate = rate2,
  4252. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4253. });
  4254. }
  4255. }
  4256. }
  4257. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4258. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4259. return Ok(JsonView(true, "查询成功!", new
  4260. {
  4261. //GroupNameData = groupNameData.Data,
  4262. visaData = visaData.Data,
  4263. airData = airData.Data,
  4264. reteInfos = reteInfos
  4265. }));
  4266. }
  4267. /// <summary>
  4268. /// 团组模块 - 出入境费用 - Info
  4269. /// </summary>
  4270. /// <returns></returns>
  4271. [HttpPost]
  4272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4273. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4274. {
  4275. try
  4276. {
  4277. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4278. if (data.Code != 0)
  4279. {
  4280. return Ok(JsonView(false, data.Msg));
  4281. }
  4282. return Ok(JsonView(true, "查询成功!", data.Data));
  4283. }
  4284. catch (Exception ex)
  4285. {
  4286. return Ok(JsonView(false, ex.Message));
  4287. }
  4288. }
  4289. /// <summary>
  4290. /// 团组模块 - 出入境费用 - Add And Update
  4291. /// </summary>
  4292. /// <returns></returns>
  4293. [HttpPost]
  4294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4295. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4296. {
  4297. try
  4298. {
  4299. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4300. if (data.Code != 0)
  4301. {
  4302. return Ok(JsonView(false, data.Msg));
  4303. }
  4304. //生成默认文件pdf并且通知人员
  4305. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4306. {
  4307. DiId = dto.DiId,
  4308. ExportType = 1,
  4309. SubTypeId = 1005
  4310. }, "pdf");
  4311. //发送通知
  4312. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4313. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4314. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4315. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4316. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4317. //汇率信息记录
  4318. await GeneralMethod.RateRecordSave(dto.UserId,sign,"出入境费用");
  4319. return Ok(JsonView(true, data.Msg, data.Data));
  4320. }
  4321. catch (Exception ex)
  4322. {
  4323. return Ok(JsonView(false, ex.Message));
  4324. }
  4325. }
  4326. /// <summary>
  4327. /// 团组模块 - 出入境费用 - Confirm 费用
  4328. /// </summary>
  4329. /// <returns></returns>
  4330. [HttpPost]
  4331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4332. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4333. {
  4334. //TODO:测试完毕需把对应的用户ID更改
  4335. //1、数据表添加字段
  4336. //2、更改字段接口()
  4337. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4338. //3、确认成功 给财务发送消息
  4339. if (_view.Code == 200)
  4340. {
  4341. if (dto.Type == 1)
  4342. {
  4343. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4344. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4345. }
  4346. }
  4347. return Ok(_view);
  4348. }
  4349. /// <summary>
  4350. /// 团组模块 - 出入境费用 - File downlaod
  4351. /// </summary>
  4352. /// <param name="dto"></param>
  4353. /// <returns></returns>
  4354. [HttpPost]
  4355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4356. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4357. {
  4358. try
  4359. {
  4360. if (dto.DiId < 1)
  4361. {
  4362. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4363. }
  4364. if (dto.ExportType < 1)
  4365. {
  4366. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4367. }
  4368. if (dto.SubTypeId < 1)
  4369. {
  4370. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4371. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4372. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4373. 3 团组成员名单 1 团组成员名单"));
  4374. }
  4375. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4376. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4377. if (_EnterExitCosts == null)
  4378. {
  4379. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4380. }
  4381. //数据源
  4382. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4383. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4384. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4385. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4386. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4387. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4388. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4389. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4390. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4391. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4392. .Select((tcl, dc, cc) => new
  4393. {
  4394. Name = dc.LastName + dc.FirstName,
  4395. Sex = dc.Sex,
  4396. Birthday = dc.BirthDay,
  4397. Company = cc.CompanyFullName,
  4398. Job = dc.Job
  4399. })
  4400. .ToList();
  4401. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4402. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4403. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4404. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4405. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4406. if (dto.ExportType == 1) //明细表
  4407. {
  4408. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4409. {
  4410. //获取模板
  4411. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4412. //载入模板
  4413. Document doc = new Document(tempPath);
  4414. DocumentBuilder builder = new DocumentBuilder(doc);
  4415. //利用键值对存放数据
  4416. Dictionary<string, string> dic = new Dictionary<string, string>();
  4417. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4418. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4419. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4420. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4421. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4422. //境内费用(其他费用)
  4423. if (_EnterExitCosts.ChoiceOne == 1)
  4424. {
  4425. string row1_1 = "";
  4426. if (_EnterExitCosts.Visa > 0)
  4427. {
  4428. //insidePayTotal += _EnterExitCosts.Visa;
  4429. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4430. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4431. {
  4432. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4433. }
  4434. }
  4435. string row1_2 = "";
  4436. if (_EnterExitCosts.YiMiao > 0)
  4437. {
  4438. //insidePayTotal += _EnterExitCosts.YiMiao;
  4439. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4440. }
  4441. if (_EnterExitCosts.HeSuan > 0)
  4442. {
  4443. //insidePayTotal += _EnterExitCosts.HeSuan;
  4444. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4445. }
  4446. if (_EnterExitCosts.Service > 0)
  4447. {
  4448. //insidePayTotal += _EnterExitCosts.Service;
  4449. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4450. }
  4451. string row1_3 = "";
  4452. if (_EnterExitCosts.Safe > 0)
  4453. {
  4454. //insidePayTotal += _EnterExitCosts.Safe;
  4455. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4456. }
  4457. if (_EnterExitCosts.Ticket > 0)
  4458. {
  4459. //insidePayTotal += _EnterExitCosts.Ticket;
  4460. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4461. }
  4462. string row1 = "";
  4463. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4464. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4465. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4466. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4467. dic.Add("Row1Str", row1);
  4468. }
  4469. string airTotalStr = string.Empty,
  4470. airPriceStr = string.Empty;
  4471. //经济舱
  4472. if (_EnterExitCosts.SumJJC == 1)
  4473. {
  4474. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4475. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4476. }
  4477. //公务舱
  4478. if (_EnterExitCosts.SumGWC == 1)
  4479. {
  4480. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4481. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4482. }
  4483. //头等舱
  4484. if (_EnterExitCosts.SumTDC == 1)
  4485. {
  4486. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4487. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4488. }
  4489. dic.Add("AirTotalStr", airTotalStr);
  4490. dic.Add("AirPriceStr", airPriceStr);
  4491. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4492. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4493. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4494. int table1Row = 0,
  4495. table2Row = 0,
  4496. table3Row = 0,
  4497. table4Row = 0;
  4498. //住宿费
  4499. if (_EnterExitCosts.ChoiceThree == 1)
  4500. {
  4501. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4502. table1Row = dac1.Count;
  4503. #region 填充word表格内容
  4504. for (int i = 0; i < dac1.Count; i++)
  4505. {
  4506. Grp_DayAndCost dac = dac1[i];
  4507. if (dac == null) continue;
  4508. builder.MoveToCell(0, i, 0, 0);
  4509. builder.Write("第" + dac.Days.ToString() + "晚:");
  4510. builder.MoveToCell(0, i, 1, 0);
  4511. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4512. //builder.Write(dac.Place == null ? "" : dac.Place);
  4513. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4514. builder.MoveToCell(0, i, 2, 0);
  4515. builder.Write("费用标准:");
  4516. string curr = "";
  4517. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4518. if (currData != null)
  4519. {
  4520. curr = currData.Name;
  4521. }
  4522. builder.MoveToCell(0, i, 3, 0);
  4523. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4524. builder.MoveToCell(0, i, 4, 0);
  4525. builder.Write("费用小计:");
  4526. builder.MoveToCell(0, i, 5, 0);
  4527. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4528. }
  4529. #endregion
  4530. }
  4531. else dic.Add("SubZS", "0.00");
  4532. //删除多余行
  4533. while (table1.Rows.Count > table1Row)
  4534. {
  4535. table1.Rows.RemoveAt(table1Row);
  4536. }
  4537. //伙食费
  4538. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4539. if (_EnterExitCosts.ChoiceFour == 1)
  4540. {
  4541. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4542. table2Row = dac2.Count;
  4543. #region 填充word表格内容
  4544. for (int i = 0; i < dac2.Count; i++)
  4545. {
  4546. Grp_DayAndCost dac = dac2[i];
  4547. if (dac == null) continue;
  4548. builder.MoveToCell(1, i, 0, 0);
  4549. builder.Write("第" + dac.Days.ToString() + "天:");
  4550. builder.MoveToCell(1, i, 1, 0);
  4551. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4552. builder.MoveToCell(1, i, 2, 0);
  4553. builder.Write("费用标准:");
  4554. string curr = "";
  4555. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4556. if (currData != null)
  4557. {
  4558. curr = currData.Name;
  4559. }
  4560. builder.MoveToCell(1, i, 3, 0);
  4561. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4562. builder.MoveToCell(1, i, 4, 0);
  4563. builder.Write("费用小计:");
  4564. builder.MoveToCell(1, i, 5, 0);
  4565. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4566. }
  4567. #endregion
  4568. }
  4569. else dic.Add("SubHS", "0.00");
  4570. //删除多余行
  4571. while (table2.Rows.Count > table2Row)
  4572. {
  4573. table2.Rows.RemoveAt(table2Row);
  4574. }
  4575. //公杂费
  4576. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4577. if (_EnterExitCosts.ChoiceFive == 1)
  4578. {
  4579. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4580. table3Row = dac3.Count;
  4581. #region 填充word表格内容
  4582. for (int i = 0; i < dac3.Count; i++)
  4583. {
  4584. Grp_DayAndCost dac = dac3[i];
  4585. if (dac == null) continue;
  4586. builder.MoveToCell(2, i, 0, 0);
  4587. builder.Write("第" + dac.Days.ToString() + "天:");
  4588. builder.MoveToCell(2, i, 1, 0);
  4589. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4590. builder.MoveToCell(2, i, 2, 0);
  4591. builder.Write("费用标准:");
  4592. string curr = "";
  4593. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4594. if (currData != null)
  4595. {
  4596. curr = currData.Name;
  4597. }
  4598. builder.MoveToCell(2, i, 3, 0);
  4599. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4600. builder.MoveToCell(2, i, 4, 0);
  4601. builder.Write("费用小计:");
  4602. builder.MoveToCell(2, i, 5, 0);
  4603. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4604. }
  4605. //删除多余行
  4606. while (table3.Rows.Count > table3Row)
  4607. {
  4608. table3.Rows.RemoveAt(table3Row);
  4609. }
  4610. #endregion
  4611. }
  4612. else dic.Add("SubGZF", "0.00");
  4613. //删除多余行
  4614. while (table3.Rows.Count > table3Row)
  4615. {
  4616. table3.Rows.RemoveAt(table3Row);
  4617. }
  4618. //培训费
  4619. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4620. if (_EnterExitCosts.ChoiceSix == 1)
  4621. {
  4622. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4623. dic.Add("SubPX", pxStr);
  4624. table4Row = dac4.Count;
  4625. #region 填充word表格内容
  4626. for (int i = 0; i < dac4.Count; i++)
  4627. {
  4628. Grp_DayAndCost dac = dac4[i];
  4629. if (dac == null) continue;
  4630. builder.MoveToCell(3, i, 0, 0);
  4631. builder.Write("第" + dac.Days.ToString() + "天:");
  4632. builder.MoveToCell(3, i, 1, 0);
  4633. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4634. builder.MoveToCell(3, i, 2, 0);
  4635. builder.Write("费用标准:");
  4636. string curr = "";
  4637. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4638. if (currData != null)
  4639. {
  4640. curr = currData.Name;
  4641. }
  4642. builder.MoveToCell(3, i, 3, 0);
  4643. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4644. builder.MoveToCell(3, i, 4, 0);
  4645. builder.Write("费用小计:");
  4646. builder.MoveToCell(3, i, 5, 0);
  4647. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4648. }
  4649. #endregion
  4650. }
  4651. //else dic.Add("SubPX","0.00");
  4652. //删除多余行
  4653. while (table4.Rows.Count > table4Row)
  4654. {
  4655. table4.Rows.RemoveAt(table4Row);
  4656. }
  4657. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4658. decimal subJJC = 0.00M,
  4659. subGWC = 0.00M,
  4660. subTDC = 0.00M;
  4661. //经济舱
  4662. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4663. //公务舱
  4664. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4665. //头等舱
  4666. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4667. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4668. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4669. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4670. #region 填充word模板书签内容
  4671. foreach (var key in dic.Keys)
  4672. {
  4673. builder.MoveToBookmark(key);
  4674. builder.Write(dic[key]);
  4675. }
  4676. #endregion
  4677. //文件名
  4678. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4679. AsposeHelper.removewatermark_v2180();
  4680. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4681. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4682. return Ok(JsonView(true, "成功", new { Url = url }));
  4683. }
  4684. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4685. {
  4686. //获取模板
  4687. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4688. //载入模板
  4689. Document doc = new Document(tempPath);
  4690. DocumentBuilder builder = new DocumentBuilder(doc);
  4691. Dictionary<string, string> dic = new Dictionary<string, string>();
  4692. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4693. {
  4694. List<string> list = new List<string>();
  4695. try
  4696. {
  4697. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4698. foreach (var item in spilitArr)
  4699. {
  4700. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4701. var depCode = spDotandEmpty[2].Substring(0, 3);
  4702. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4703. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4704. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4705. list.Add(depName);
  4706. list.Add(arrName);
  4707. }
  4708. list = list.Distinct().ToList();
  4709. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4710. }
  4711. catch (Exception)
  4712. {
  4713. dic.Add("ReturnCode", "行程录入不正确!");
  4714. }
  4715. }
  4716. else
  4717. {
  4718. dic.Add("ReturnCode", "未录入行程!");
  4719. }
  4720. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4721. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4722. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4723. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4724. {
  4725. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4726. dic.Add("Day", sp.Days.ToString());
  4727. }
  4728. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4729. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4730. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4731. //dic.Add("Names", Names);
  4732. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4733. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4734. decimal dac1totalPrice = 0.00M;
  4735. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4736. foreach (var dac in dac1)
  4737. {
  4738. if (dac.SubTotal == 0.00M)
  4739. {
  4740. continue;
  4741. }
  4742. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4743. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4744. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4745. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4746. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4747. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4748. builder.Write(currency);//币种
  4749. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4750. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4751. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4752. builder.Write("");//人数
  4753. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4754. builder.Write("");//天数
  4755. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4756. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4757. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4758. decimal rate = 0.00M;
  4759. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4760. builder.Write(rate.ToString("#0.0000"));//汇率
  4761. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4762. decimal rbmPrice = dac.SubTotal;
  4763. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4764. accommodationStartIndex++;
  4765. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4766. }
  4767. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4768. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4769. {
  4770. table1.Rows.RemoveAt(i - 1);
  4771. foodandotherStartIndex--;
  4772. }
  4773. if (dac2.Count == dac3.Count)//国家 币种 金额
  4774. {
  4775. for (int i = 0; i < dac2.Count; i++)
  4776. {
  4777. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4778. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4779. }
  4780. }
  4781. decimal dac2totalPrice = 0.00M;
  4782. foreach (var dac in dac2)
  4783. {
  4784. if (dac.SubTotal == 0)
  4785. {
  4786. continue;
  4787. }
  4788. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4789. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4790. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4791. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4792. builder.Write(currency);//币种
  4793. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4794. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4795. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4796. builder.Write("");//人数
  4797. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4798. builder.Write("");//天数
  4799. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4800. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4801. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4802. decimal rate = 0.00M;
  4803. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4804. builder.Write(rate.ToString("#0.0000"));//汇率
  4805. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4806. decimal rbmPrice = dac.SubTotal;
  4807. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4808. foodandotherStartIndex++;
  4809. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4810. }
  4811. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4812. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4813. {
  4814. table1.Rows.RemoveAt(i - 1);
  4815. }
  4816. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4817. string otherFeeStr = "";
  4818. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4819. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4820. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4821. if (otherFeeStr.Length > 0)
  4822. {
  4823. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4824. otherFeeStr = $"({otherFeeStr})";
  4825. dic.Add("OtherFeeStr", otherFeeStr);
  4826. }
  4827. //总计
  4828. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4829. //国际旅费
  4830. string outsideAir = string.Empty;
  4831. string allPriceAir = string.Empty;
  4832. if (_EnterExitCosts.SumJJC == 1)
  4833. {
  4834. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4835. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4836. }
  4837. if (_EnterExitCosts.SumGWC == 1)
  4838. {
  4839. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4840. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4841. }
  4842. if (_EnterExitCosts.SumTDC == 1)
  4843. {
  4844. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4845. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4846. }
  4847. dic.Add("InTravelPrice", $"({outsideAir})");
  4848. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4849. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4850. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4851. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4852. foreach (var key in dic.Keys)
  4853. {
  4854. builder.MoveToBookmark(key);
  4855. builder.Write(dic[key]);
  4856. }
  4857. //模板文件名
  4858. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4859. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4860. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4861. return Ok(JsonView(true, "成功", new { Url = url }));
  4862. }
  4863. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4864. {
  4865. //获取模板
  4866. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4867. //载入模板
  4868. WorkbookDesigner designer = new WorkbookDesigner();
  4869. designer.Workbook = new Workbook(tempPath);
  4870. Dictionary<string, string> dic = new Dictionary<string, string>();
  4871. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4872. {
  4873. List<string> list = new List<string>();
  4874. try
  4875. {
  4876. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4877. foreach (var item in spilitArr)
  4878. {
  4879. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4880. var depCode = spDotandEmpty[2].Substring(0, 3);
  4881. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4882. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4883. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4884. list.Add(depName);
  4885. list.Add(arrName);
  4886. }
  4887. list = list.Distinct().ToList();
  4888. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4889. }
  4890. catch (Exception)
  4891. {
  4892. dic.Add("ReturnCode", "行程录入不正确!");
  4893. }
  4894. }
  4895. else
  4896. {
  4897. dic.Add("ReturnCode", "未录入行程!");
  4898. }
  4899. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4900. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4901. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4902. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4903. {
  4904. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4905. dic.Add("Day", sp.Days.ToString());
  4906. }
  4907. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4908. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4909. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4910. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4911. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4912. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4913. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4914. designer.SetDataSource("Name", Names);
  4915. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4916. designer.SetDataSource("Day", dic["Day"] + "天");
  4917. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4918. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4919. int startIndex = 10;
  4920. const int startIndexcopy = 10;
  4921. if (dac2.Count == dac3.Count)//国家 币种 金额
  4922. {
  4923. for (int i = 0; i < dac2.Count; i++)
  4924. {
  4925. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4926. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4927. }
  4928. }
  4929. DataTable dtdac1 = new DataTable();
  4930. List<string> place = new List<string>();
  4931. dtdac1.Columns.AddRange(new DataColumn[] {
  4932. new DataColumn(){ ColumnName = "city"},
  4933. new DataColumn(){ ColumnName = "curr"},
  4934. new DataColumn(){ ColumnName = "criterion"},
  4935. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4936. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4937. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4938. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4939. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4940. });
  4941. DataTable dtdac2 = new DataTable();
  4942. dtdac2.Columns.AddRange(new DataColumn[] {
  4943. new DataColumn(){ ColumnName = "city"},
  4944. new DataColumn(){ ColumnName = "curr"},
  4945. new DataColumn(){ ColumnName = "criterion"},
  4946. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4947. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4948. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4949. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4950. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4951. });
  4952. dtdac1.TableName = "tb1";
  4953. dtdac2.TableName = "tb2";
  4954. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4955. foreach (var item in dac1)
  4956. {
  4957. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4958. if (place.Contains(item.Place))
  4959. {
  4960. continue;
  4961. }
  4962. DataRow row = dtdac1.NewRow();
  4963. row["city"] = item.Place;
  4964. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4965. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4966. row["curr"] = currency;
  4967. row["rate"] = rate.ToString("#0.0000");
  4968. row["criterion"] = item.Cost.ToString("#0.00");
  4969. row["number"] = 1;
  4970. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4971. //row["costRMB"] = rbmPrice;
  4972. dtdac1.Rows.Add(row);
  4973. place.Add(item.Place);
  4974. }
  4975. place = new List<string>();
  4976. foreach (var item in dac2)
  4977. {
  4978. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4979. if (place.Contains(item.Place))
  4980. {
  4981. continue;
  4982. }
  4983. DataRow row = dtdac2.NewRow();
  4984. row["city"] = item.Place;
  4985. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4986. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4987. row["curr"] = currency;
  4988. row["rate"] = rate.ToString("#0.0000");
  4989. row["criterion"] = item.Cost.ToString("#0.00");
  4990. row["number"] = 1;
  4991. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4992. //row["cost"] = item.SubTotal;
  4993. //row["costRMB"] = rbmPrice;
  4994. dtdac2.Rows.Add(row);
  4995. place.Add(item.Place);
  4996. //dac2totalPrice += rbmPrice;
  4997. }
  4998. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4999. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5000. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5001. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5002. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5003. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5004. string cell4Str1 = string.Empty;
  5005. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5006. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5007. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5008. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5009. string cellStr = $" 5.其他费用(";
  5010. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5011. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5012. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5013. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5014. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5015. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5016. if (cellStr.Length > 8)
  5017. {
  5018. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5019. }
  5020. cellStr += ")";
  5021. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5022. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5023. decimal pxFee = dac4.Sum(it => it.Cost);
  5024. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5025. string celllastStr1 = "";
  5026. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5027. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5028. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5029. celllastStr1 += $",国际旅费 元";
  5030. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5031. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5032. designer.SetDataSource("cell4Str", cell4Str);
  5033. designer.SetDataSource("cellStr", cellStr);
  5034. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5035. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5036. designer.SetDataSource("celllastStr", celllastStr);
  5037. Workbook wb = designer.Workbook;
  5038. var sheet = wb.Worksheets[0];
  5039. //绑定datatable数据集
  5040. designer.SetDataSource(dtdac1);
  5041. designer.SetDataSource(dtdac2);
  5042. designer.Process();
  5043. var rowStart = dtdac1.Rows.Count;
  5044. while (rowStart > 0)
  5045. {
  5046. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5047. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5048. startIndex++;
  5049. rowStart--;
  5050. }
  5051. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5052. startIndex += 1; //总计行
  5053. rowStart = dtdac2.Rows.Count;
  5054. while (rowStart > 0)
  5055. {
  5056. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5057. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5058. startIndex++;
  5059. rowStart--;
  5060. }
  5061. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5062. wb.CalculateFormula(true);
  5063. //模板文件名
  5064. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5065. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5066. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5067. return Ok(JsonView(true, "成功", new { Url = url }));
  5068. }
  5069. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5070. {
  5071. //获取模板
  5072. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5073. //载入模板
  5074. Document doc = new Document(tempPath);
  5075. DocumentBuilder builder = new DocumentBuilder(doc);
  5076. Dictionary<string, string> dic = new Dictionary<string, string>();
  5077. dic.Add("GroupName", _DelegationInfo.TeamName);
  5078. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5079. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5080. string missionLeaderJob = "";//负责人job
  5081. int groupNumber = 0; //团人数
  5082. if (DeleClientList.Count > 0)
  5083. {
  5084. missionLeader = DeleClientList[0]?.Name ?? "";
  5085. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5086. }
  5087. dic.Add("MissionLeader", missionLeader); //团负责人
  5088. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5089. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5090. #region MyRegion
  5091. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5092. //{
  5093. // List<string> list = new List<string>();
  5094. // try
  5095. // {
  5096. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5097. // foreach (var item in spilitArr)
  5098. // {
  5099. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5100. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5101. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5102. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5103. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5104. // list.Add(depName);
  5105. // list.Add(arrName);
  5106. // }
  5107. // list = list.Distinct().ToList();
  5108. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5109. // }
  5110. // catch (Exception)
  5111. // {
  5112. // dic.Add("ReturnCode", "行程录入不正确!");
  5113. // }
  5114. //}
  5115. //else
  5116. //{
  5117. // dic.Add("ReturnCode", "未录入行程!");
  5118. //}
  5119. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5120. dic.Add("ReturnCode", string.Join("、", countrys));
  5121. #endregion
  5122. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5123. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5124. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5125. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5126. //{
  5127. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5128. // dic.Add("Day", sp.Days.ToString());
  5129. //}
  5130. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5131. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5132. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5133. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5134. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5135. //培训人员名单
  5136. int cultivateRowIndex = 7;
  5137. foreach (var item in DeleClientList)
  5138. {
  5139. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5140. builder.Write(item.Name);
  5141. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5142. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5143. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5144. string birthDay = "";
  5145. if (item.Birthday != null)
  5146. {
  5147. DateTime dt = Convert.ToDateTime(item.Birthday);
  5148. birthDay = $"{dt.Year}.{dt.Month}";
  5149. }
  5150. builder.Write(birthDay);
  5151. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5152. builder.Write(item.Company);
  5153. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5154. builder.Write(item.Job);
  5155. cultivateRowIndex++;
  5156. }
  5157. //删除多余行
  5158. //cultivateRowIndex -= 2;
  5159. int delRows = 10 + 7 - cultivateRowIndex;
  5160. if (delRows > 0)
  5161. {
  5162. for (int i = 0; i < delRows; i++)
  5163. {
  5164. table1.Rows.RemoveAt(cultivateRowIndex);
  5165. //cultivateRowIndex++;
  5166. }
  5167. }
  5168. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5169. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5170. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5171. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5172. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5173. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5174. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5175. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5176. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5177. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5178. //其他费用
  5179. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5180. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5181. //其他费用合计
  5182. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5183. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5184. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5185. //公务舱合计
  5186. //国际旅费
  5187. string outsideJJ = "";
  5188. string allPriceJJ = "";
  5189. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5190. {
  5191. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5192. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5193. }
  5194. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5195. {
  5196. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5197. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5198. }
  5199. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5200. {
  5201. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5202. dic.Add("AirFeeTotal", airFeeTotalStr);
  5203. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5204. dic.Add("FeeTotal", feeTotalStr);
  5205. }
  5206. foreach (var key in dic.Keys)
  5207. {
  5208. builder.MoveToBookmark(key);
  5209. builder.Write(dic[key]);
  5210. }
  5211. //模板文件名
  5212. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5213. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5214. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5215. return Ok(JsonView(true, "成功", new { Url = url }));
  5216. }
  5217. }
  5218. else if (dto.ExportType == 2) //表格
  5219. {
  5220. //利用键值对存放数据
  5221. Dictionary<string, string> dic = new Dictionary<string, string>();
  5222. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5223. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5224. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5225. dic.Add("Day", sp.Days.ToString());
  5226. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5227. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5228. {
  5229. //获取模板
  5230. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5231. //载入模板
  5232. Document doc = new Document(tempPath);
  5233. DocumentBuilder builder = new DocumentBuilder(doc);
  5234. dic.Add("TeamName", _DelegationInfo.TeamName);
  5235. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5236. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5237. string missionLeaderName = "",
  5238. missionLeaderJob = "";
  5239. if (DeleClientList.Count > 0)
  5240. {
  5241. missionLeaderName = DeleClientList[0].Name;
  5242. missionLeaderJob = DeleClientList[0].Job;
  5243. }
  5244. dic.Add("MissionLeaderName", missionLeaderName);
  5245. dic.Add("MissionLeaderJob", missionLeaderJob);
  5246. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5247. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5248. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5249. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5250. int rowCount = 10;//总人数行
  5251. int startRowIndex = 7; //起始行
  5252. for (int i = 0; i < DeleClientList.Count; i++)
  5253. {
  5254. builder.MoveToCell(0, startRowIndex, 0, 0);
  5255. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5256. builder.MoveToCell(0, startRowIndex, 1, 0);
  5257. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5258. builder.Write(sex);//性别
  5259. builder.MoveToCell(0, startRowIndex, 2, 0);
  5260. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5261. builder.MoveToCell(0, startRowIndex, 3, 0);
  5262. builder.Write(DeleClientList[i].Company);//工作单位
  5263. builder.MoveToCell(0, startRowIndex, 4, 0);
  5264. builder.Write(DeleClientList[i].Job);//职务及级别
  5265. builder.MoveToCell(0, startRowIndex, 5, 0);
  5266. builder.Write("");//人员属性
  5267. builder.MoveToCell(0, startRowIndex, 6, 0);
  5268. builder.Write("");//上次出国时间
  5269. startRowIndex++;
  5270. }
  5271. int nullRow = rowCount - DeleClientList.Count;//空行
  5272. for (int i = 0; i < nullRow; i++)
  5273. {
  5274. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5275. }
  5276. foreach (var key in dic.Keys)
  5277. {
  5278. builder.MoveToBookmark(key);
  5279. builder.Write(dic[key]);
  5280. }
  5281. //模板文件名
  5282. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5283. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5284. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5285. return Ok(JsonView(true, "成功", new { Url = url }));
  5286. }
  5287. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5288. {
  5289. //获取模板
  5290. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5291. //载入模板
  5292. Document doc = new Document(tempPath);
  5293. DocumentBuilder builder = new DocumentBuilder(doc);
  5294. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5295. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5296. dic.Add("Names", Names);
  5297. int accommodationRows = 12, foodandotherRows = 12;
  5298. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5299. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5300. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5301. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5302. int accommodationStartIndex = 6;
  5303. decimal dac1totalPrice = 0.00M;
  5304. foreach (var dac in dac1)
  5305. {
  5306. if (dac.SubTotal == 0)
  5307. {
  5308. continue;
  5309. }
  5310. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5311. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5312. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5313. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5314. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5315. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5316. builder.Write(currency);//币种
  5317. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5318. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5319. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5320. builder.Write("");//人数
  5321. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5322. builder.Write("");//天数
  5323. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5324. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5325. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5326. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5327. builder.Write(rate.ToString("#0.0000"));//汇率
  5328. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5329. decimal rbmPrice = rate * dac.SubTotal;
  5330. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5331. accommodationStartIndex++;
  5332. dac1totalPrice += rbmPrice;
  5333. }
  5334. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5335. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5336. builder.Write("小计");
  5337. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5338. builder.Write(dac1totalPrice.ToString("#0.00"));
  5339. accommodationStartIndex++;
  5340. int nullRow = accommodationRows - dac1.Count;
  5341. //删除空行
  5342. //if (nullRow > 0)
  5343. //{
  5344. // int rowIndex = accommodationStartIndex;
  5345. // for (int i = 0; i < nullRow; i++)
  5346. // {
  5347. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5348. // row.Remove();
  5349. // rowIndex++;
  5350. // }
  5351. //}
  5352. if (dac2.Count == dac3.Count)//国家 币种 金额
  5353. {
  5354. for (int i = 0; i < dac2.Count; i++)
  5355. {
  5356. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5357. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5358. }
  5359. }
  5360. int foodandotherStartIndex = 19;//
  5361. decimal dac2totalPrice = 0.00M;
  5362. foreach (var dac in dac2)
  5363. {
  5364. if (dac.SubTotal == 0)
  5365. {
  5366. continue;
  5367. }
  5368. //foodandotherStartIndex = 12;
  5369. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5370. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5371. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5372. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5373. builder.Write(currency);//币种
  5374. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5375. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5376. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5377. builder.Write("");//人数
  5378. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5379. builder.Write("");//天数
  5380. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5381. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5382. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5383. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5384. builder.Write(rate.ToString("#0.0000"));//汇率
  5385. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5386. decimal rbmPrice = rate * dac.SubTotal;
  5387. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5388. foodandotherStartIndex++;
  5389. dac2totalPrice += rbmPrice;
  5390. }
  5391. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5392. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5393. //删除空行
  5394. //if (dac2.Count < foodandotherRows)
  5395. //{
  5396. // while (table2.Rows.Count > dac2.Count)
  5397. // {
  5398. // table2.Rows.RemoveAt(dac2.Count);
  5399. // }
  5400. //}
  5401. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5402. string otherFeeStr = "";
  5403. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5404. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5405. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5406. if (otherFeeStr.Length > 0)
  5407. {
  5408. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5409. otherFeeStr = $"({otherFeeStr})";
  5410. dic.Add("OtherFeeStr", otherFeeStr);
  5411. }
  5412. foreach (var key in dic.Keys)
  5413. {
  5414. builder.MoveToBookmark(key);
  5415. builder.Write(dic[key]);
  5416. }
  5417. //模板文件名
  5418. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5419. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5420. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5421. return Ok(JsonView(true, "成功", new { Url = url }));
  5422. }
  5423. }
  5424. else if (dto.ExportType == 3)
  5425. {
  5426. if (dto.SubTypeId == 1) //团组成员名单
  5427. {
  5428. if (DeleClientList.Count < 1)
  5429. {
  5430. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5431. }
  5432. //获取模板
  5433. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5434. //载入模板
  5435. Document doc = new Document(tempPath);
  5436. DocumentBuilder builder = new DocumentBuilder(doc);
  5437. //获取word里所有表格
  5438. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5439. //获取所填表格的序数
  5440. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5441. var rowStart = tableOne.Rows[0]; //获取第1行
  5442. //循环赋值
  5443. for (int i = 0; i < DeleClientList.Count; i++)
  5444. {
  5445. builder.MoveToCell(0, i + 1, 0, 0);
  5446. builder.Write(DeleClientList[i].Name);
  5447. builder.MoveToCell(0, i + 1, 1, 0);
  5448. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5449. builder.Write(sex);
  5450. builder.MoveToCell(0, i + 1, 2, 0);
  5451. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5452. builder.MoveToCell(0, i + 1, 3, 0);
  5453. builder.Write(DeleClientList[i].Company);
  5454. builder.MoveToCell(0, i + 1, 4, 0);
  5455. builder.Write(DeleClientList[i].Job);
  5456. }
  5457. //删除多余行
  5458. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5459. {
  5460. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5461. }
  5462. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5463. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5464. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5465. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5466. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5467. return Ok(JsonView(true, "成功", new { Url = url }));
  5468. }
  5469. }
  5470. return Ok(JsonView(false, "操作失败!"));
  5471. }
  5472. catch (Exception ex)
  5473. {
  5474. return Ok(JsonView(false, ex.Message));
  5475. }
  5476. }
  5477. /// <summary>
  5478. /// 获取三公费用标准city
  5479. /// </summary>
  5480. /// <param name="placeData"></param>
  5481. /// <param name="nationalTravelFeeId"></param>
  5482. /// <returns></returns>
  5483. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5484. {
  5485. string _city = string.Empty;
  5486. if (placeData.Count < 1) return _city;
  5487. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5488. if (data == null) return _city;
  5489. string country = data.Country;
  5490. string city = data.City;
  5491. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5492. else _city = city;
  5493. return _city;
  5494. }
  5495. /// <summary>
  5496. /// 团组模块 - 出入境费用 - 明细表导出
  5497. /// </summary>
  5498. /// <returns></returns>
  5499. [HttpPost]
  5500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5501. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5502. {
  5503. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5504. if (data.Code != 0)
  5505. {
  5506. return Ok(JsonView(false, data.Msg));
  5507. }
  5508. return Ok(JsonView(true, data.Msg, data.Data));
  5509. }
  5510. /// <summary>
  5511. /// 团组模块 - 出入境费用 - 一键清空
  5512. /// </summary>
  5513. /// <returns></returns>
  5514. [HttpPost]
  5515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5516. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5517. {
  5518. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5519. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5520. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5521. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5522. if (_view.Code == 0)
  5523. {
  5524. return Ok(JsonView(true, "操作成功"));
  5525. }
  5526. return Ok(JsonView(false, "操作失败"));
  5527. }
  5528. /// <summary>
  5529. /// 团组模块 - 出入境费用 - 子项删除
  5530. /// </summary>
  5531. /// <returns></returns>
  5532. [HttpPost]
  5533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5534. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5535. {
  5536. try
  5537. {
  5538. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5539. if (data.Code != 0)
  5540. {
  5541. return Ok(JsonView(false, data.Msg));
  5542. }
  5543. return Ok(JsonView(true, "操作成功!", data.Data));
  5544. }
  5545. catch (Exception ex)
  5546. {
  5547. return Ok(JsonView(false, ex.Message));
  5548. }
  5549. }
  5550. /// <summary>
  5551. /// 团组模块 - 出入境国家费用标准 List
  5552. /// </summary>
  5553. /// <returns></returns>
  5554. [HttpPost]
  5555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5556. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5557. {
  5558. try
  5559. {
  5560. Stopwatch sw = new Stopwatch();
  5561. sw.Start();
  5562. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5563. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5564. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5565. Where gntf.Isdel = 0");
  5566. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5567. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5568. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5569. //foreach (var item in nationalTravel)
  5570. //{
  5571. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5572. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5573. // if (otherData != null)
  5574. // {
  5575. // cityData.Remove(otherData);
  5576. // cityData.Add(otherData);
  5577. // }
  5578. // nationalTravelFeeData1.Add(new
  5579. // {
  5580. // Country = item.Country,
  5581. // CityData = cityData
  5582. // });
  5583. //}
  5584. sw.Stop();
  5585. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5586. }
  5587. catch (Exception ex)
  5588. {
  5589. return Ok(JsonView(false, ex.Message));
  5590. throw;
  5591. }
  5592. }
  5593. /// <summary>
  5594. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5595. /// </summary>
  5596. /// <returns></returns>
  5597. [HttpPost]
  5598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5599. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5600. {
  5601. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5602. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5603. List<string> countryData = new List<string>();
  5604. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5605. countryData = countryData.Distinct().ToList();
  5606. List<dynamic> dataSource = new List<dynamic>();
  5607. foreach (var item in countryData)
  5608. {
  5609. List<string> cityData1 = new List<string>();
  5610. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5611. var countryData2 = new
  5612. {
  5613. CountryName = item,
  5614. CityData = cityData1
  5615. };
  5616. dataSource.Add(countryData2);
  5617. }
  5618. return Ok(JsonView(true, "查询成功!", dataSource));
  5619. }
  5620. /// <summary>
  5621. /// 团组模块 - 出入境国家费用标准 Page List
  5622. /// </summary>
  5623. /// <returns></returns>
  5624. [HttpPost]
  5625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5626. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5627. {
  5628. int portId = dto.PortType;
  5629. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5630. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5631. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5632. string whereSql = string.Empty;
  5633. if (!string.IsNullOrEmpty(dto.Country))
  5634. {
  5635. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5636. }
  5637. if (!string.IsNullOrEmpty(dto.City))
  5638. {
  5639. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5640. }
  5641. string pageSql = string.Format(@"Select * From (
  5642. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5643. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5644. From Grp_NationalTravelFee gntf
  5645. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5646. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5647. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5648. RefAsync<int> total = 0;
  5649. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5650. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5651. }
  5652. /// <summary>
  5653. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5654. /// </summary>
  5655. /// <returns></returns>
  5656. [HttpPost]
  5657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5658. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5659. {
  5660. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5661. int portId = dto.PortType;
  5662. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5663. string whereSql = string.Empty;
  5664. if (!string.IsNullOrEmpty(dto.Country))
  5665. {
  5666. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5667. }
  5668. if (!string.IsNullOrEmpty(dto.City))
  5669. {
  5670. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5671. }
  5672. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5673. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5674. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5675. From Grp_NationalTravelFee gntf
  5676. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5677. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5678. Where gntf.Isdel = 0 {0} ", whereSql);
  5679. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5680. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5681. }
  5682. /// <summary>
  5683. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5684. /// </summary>
  5685. /// <returns></returns>
  5686. [HttpPost]
  5687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5688. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5689. {
  5690. try
  5691. {
  5692. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5693. if (data.Code != 0)
  5694. {
  5695. return Ok(JsonView(false, data.Msg));
  5696. }
  5697. return Ok(JsonView(true, "操作成功!", data.Data));
  5698. }
  5699. catch (Exception ex)
  5700. {
  5701. return Ok(JsonView(false, ex.Message));
  5702. }
  5703. }
  5704. /// <summary>
  5705. /// 团组模块 - 出入境国家费用标准 - Del
  5706. /// </summary>
  5707. /// <returns></returns>
  5708. [HttpPost]
  5709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5710. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5711. {
  5712. try
  5713. {
  5714. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5715. {
  5716. Id = dto.Id,
  5717. DeleteUserId = dto.DeleteUserId,
  5718. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5719. IsDel = 1
  5720. };
  5721. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5722. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5723. .WhereColumns(it => new { it.Id })
  5724. .ExecuteCommandAsync();
  5725. if (delStatus <= 0)
  5726. {
  5727. return Ok(JsonView(false, "删除失败!"));
  5728. }
  5729. return Ok(JsonView(true, "操作成功!"));
  5730. }
  5731. catch (Exception ex)
  5732. {
  5733. return Ok(JsonView(false, ex.Message));
  5734. }
  5735. }
  5736. /// <summary>
  5737. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  5738. /// 注:Get 请求Headers 加 Token
  5739. /// </summary>
  5740. /// <param name="groupId"></param>
  5741. /// <returns></returns>
  5742. [HttpGet("{groupId}")]
  5743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5744. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  5745. {
  5746. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5747. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  5748. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  5749. data.ForEach(x =>
  5750. {
  5751. x.CreateUserId = _currUserInfo.UserId;
  5752. });
  5753. if (data.Count > 0)
  5754. {
  5755. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  5756. if (add > 0)
  5757. {
  5758. return Ok(JsonView(true, "操作成功!"));
  5759. }
  5760. }
  5761. return Ok(JsonView(false, "未操作!"));
  5762. }
  5763. #endregion
  5764. #region 签证费用录入
  5765. /// <summary>
  5766. /// 根据diid查询签证费用列表
  5767. /// </summary>
  5768. /// <param name="dto"></param>
  5769. /// <returns></returns>
  5770. [HttpPost]
  5771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5772. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5773. {
  5774. try
  5775. {
  5776. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5777. if (groupData.Code != 0)
  5778. {
  5779. return Ok(JsonView(false, groupData.Msg));
  5780. }
  5781. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5782. }
  5783. catch (Exception ex)
  5784. {
  5785. return Ok(JsonView(false, ex.Message));
  5786. }
  5787. }
  5788. /// <summary>
  5789. /// 根据签证费用Id查询单条数据及c表数据
  5790. /// </summary>
  5791. /// <param name="dto"></param>
  5792. /// <returns></returns>
  5793. [HttpPost]
  5794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5795. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5796. {
  5797. try
  5798. {
  5799. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5800. if (groupData.Code != 0)
  5801. {
  5802. return Ok(JsonView(false, groupData.Msg));
  5803. }
  5804. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5805. }
  5806. catch (Exception ex)
  5807. {
  5808. return Ok(JsonView(false, ex.Message));
  5809. }
  5810. }
  5811. /// <summary>
  5812. /// 签证费用删除
  5813. /// </summary>
  5814. /// <param name="dto"></param>
  5815. /// <returns></returns>
  5816. [HttpPost]
  5817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5818. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5819. {
  5820. _sqlSugar.BeginTran();
  5821. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5822. if (!res)
  5823. {
  5824. _sqlSugar.RollbackTran();
  5825. return Ok(JsonView(false, "删除失败"));
  5826. }
  5827. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5828. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5829. .SetColumns(a => new Grp_CreditCardPayment()
  5830. {
  5831. IsDel = 1,
  5832. DeleteUserId = dto.DeleteUserId,
  5833. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5834. })
  5835. .ExecuteCommand();
  5836. if (resSub < 1)
  5837. {
  5838. _sqlSugar.RollbackTran();
  5839. return Ok(JsonView(false, "删除失败"));
  5840. }
  5841. _sqlSugar.CommitTran();
  5842. return Ok(JsonView(true, "删除成功!"));
  5843. }
  5844. /// <summary>
  5845. /// 签证费用录入下拉框初始化
  5846. /// </summary>
  5847. /// <returns></returns>
  5848. [HttpPost]
  5849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5850. public async Task<IActionResult> VisaPriceAddSelect()
  5851. {
  5852. //支付方式
  5853. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5854. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5855. //币种
  5856. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5857. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5858. //乘客类型
  5859. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5860. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5861. //卡类型
  5862. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5863. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5864. var data = new
  5865. {
  5866. Payment = _Payment,
  5867. CurrencyList = _CurrencyList,
  5868. PassengerType = _PassengerType,
  5869. BankCard = _BankCard
  5870. };
  5871. return Ok(JsonView(true, "查询成功!", data));
  5872. }
  5873. /// <summary>
  5874. /// 签证费用录入操作(Status:1.新增,2.修改)
  5875. /// </summary>
  5876. /// <param name="dto"></param>
  5877. /// <returns></returns>
  5878. [HttpPost]
  5879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5880. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5881. {
  5882. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5883. if (groupData.Code != 0)
  5884. {
  5885. return Ok(JsonView(false, groupData.Msg));
  5886. }
  5887. #region 应用推送
  5888. try
  5889. {
  5890. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5891. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5892. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5893. }
  5894. catch (Exception ex)
  5895. {
  5896. }
  5897. #endregion
  5898. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5899. }
  5900. #endregion
  5901. #region 签证提成录入
  5902. /// <summary>
  5903. /// 签证提成录入
  5904. /// 基础数据
  5905. /// </summary>
  5906. /// <param name="_dto"></param>
  5907. /// <returns></returns>
  5908. [HttpGet]
  5909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5910. public async Task<IActionResult> VisaCommissionInit()
  5911. {
  5912. return Ok(await _visaCommissionRep.Init());
  5913. }
  5914. /// <summary>
  5915. /// 签证提成录入
  5916. /// Item
  5917. /// </summary>
  5918. /// <param name="_dto"></param>
  5919. /// <returns></returns>
  5920. [HttpPost]
  5921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5922. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5923. {
  5924. var validator = new VisaCommissionItemDtoValidator();
  5925. var validatorRes = await validator.ValidateAsync(_dto);
  5926. if (!validatorRes.IsValid)
  5927. {
  5928. StringBuilder sb = new StringBuilder();
  5929. foreach (var item in validatorRes.Errors)
  5930. {
  5931. sb.AppendLine(item.ErrorMessage);
  5932. }
  5933. return Ok(JsonView(false, sb.ToString()));
  5934. }
  5935. return Ok(await _visaCommissionRep.Item(_dto));
  5936. }
  5937. /// <summary>
  5938. /// 签证提成录入
  5939. /// Save
  5940. /// </summary>
  5941. /// <param name="_dto"></param>
  5942. /// <returns></returns>
  5943. [HttpPost]
  5944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5945. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  5946. {
  5947. //参数验证
  5948. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  5949. foreach (var item in _dto.Items)
  5950. {
  5951. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  5952. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  5953. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  5954. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  5955. }
  5956. return Ok(await _visaCommissionRep.Save(_dto));
  5957. }
  5958. /// <summary>
  5959. /// 签证提成录入
  5960. /// Create
  5961. /// </summary>
  5962. /// <param name="_dto"></param>
  5963. /// <returns></returns>
  5964. [HttpPost]
  5965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5966. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  5967. {
  5968. var validator = new VisaCommissionCreateDtoValidator();
  5969. var validatorRes = await validator.ValidateAsync(_dto);
  5970. if (!validatorRes.IsValid)
  5971. {
  5972. StringBuilder sb = new StringBuilder();
  5973. foreach (var item in validatorRes.Errors)
  5974. {
  5975. sb.AppendLine(item.ErrorMessage);
  5976. }
  5977. return Ok(JsonView(false, sb.ToString()));
  5978. }
  5979. return Ok(await _visaCommissionRep.Create(_dto));
  5980. }
  5981. /// <summary>
  5982. /// 签证提成录入
  5983. /// Put(编辑)
  5984. /// </summary>
  5985. /// <param name="id"></param>
  5986. /// <param name="_dto"></param>
  5987. /// <returns></returns>
  5988. [HttpPut]
  5989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5990. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  5991. {
  5992. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5993. var validator = new VisaCommissionCreateDtoValidator();
  5994. var validatorRes = await validator.ValidateAsync(_dto);
  5995. if (!validatorRes.IsValid)
  5996. {
  5997. StringBuilder sb = new StringBuilder();
  5998. foreach (var item in validatorRes.Errors)
  5999. {
  6000. sb.AppendLine(item.ErrorMessage);
  6001. }
  6002. return Ok(JsonView(false, sb.ToString()));
  6003. }
  6004. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6005. }
  6006. /// <summary>
  6007. /// 签证提成录入
  6008. /// Del
  6009. /// </summary>
  6010. /// <param name="id"></param>
  6011. /// <param name="currUserId"></param>
  6012. /// <returns></returns>
  6013. [HttpPost]
  6014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6015. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6016. {
  6017. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6018. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6019. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6020. }
  6021. #endregion
  6022. #region op费用录入
  6023. /// <summary>
  6024. /// 根据diid查询op费用列表
  6025. /// </summary>
  6026. /// <param name="dto"></param>
  6027. /// <returns></returns>
  6028. [HttpPost]
  6029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6030. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6031. {
  6032. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6033. if (groupData.Code != 0)
  6034. {
  6035. return Ok(JsonView(false, groupData.Msg));
  6036. }
  6037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6038. }
  6039. /// <summary>
  6040. /// 根据op费用Id查询单条数据及c表数据
  6041. /// </summary>
  6042. /// <param name="dto"></param>
  6043. /// <returns></returns>
  6044. [HttpPost]
  6045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6046. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6047. {
  6048. try
  6049. {
  6050. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6051. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6052. var data = new
  6053. {
  6054. CarTouristGuideGround = _groupData,
  6055. CreditCardPayment = _creditCardPayment
  6056. };
  6057. return Ok(JsonView(true, "查询成功!", data));
  6058. }
  6059. catch (Exception ex)
  6060. {
  6061. return Ok(JsonView(false, "程序错误!"));
  6062. }
  6063. }
  6064. /// <summary>
  6065. /// op费用删除
  6066. /// </summary>
  6067. /// <param name="dto"></param>
  6068. /// <returns></returns>
  6069. [HttpPost]
  6070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6071. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6072. {
  6073. try
  6074. {
  6075. _sqlSugar.BeginTran();
  6076. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6077. if (!res)
  6078. {
  6079. return Ok(JsonView(false, "删除失败"));
  6080. }
  6081. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6082. {
  6083. IsDel = 1,
  6084. DeleteUserId = dto.DeleteUserId,
  6085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6086. }).ExecuteCommandAsync();
  6087. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6088. {
  6089. IsDel = 1,
  6090. DeleteUserId = dto.DeleteUserId,
  6091. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6092. }).ExecuteCommandAsync();
  6093. #region 删除超支相关数据
  6094. //删除导入的超支数据
  6095. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6096. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6097. {
  6098. IsDel = 1,
  6099. DeleteUserId = dto.DeleteUserId,
  6100. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6101. }).ExecuteCommand();
  6102. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6103. {
  6104. IsDel = 1,
  6105. DeleteUserId = dto.DeleteUserId,
  6106. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6107. }).ExecuteCommand();
  6108. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6109. {
  6110. IsDel = 1,
  6111. DeleteUserId = dto.DeleteUserId,
  6112. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6113. }).ExecuteCommand();
  6114. #endregion
  6115. _sqlSugar.CommitTran();
  6116. return Ok(JsonView(true, "删除成功!"));
  6117. }
  6118. catch (Exception ex)
  6119. {
  6120. _sqlSugar.RollbackTran();
  6121. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6122. }
  6123. }
  6124. /// <summary>
  6125. /// op费用录入操作(Status:1.新增,2.修改)
  6126. /// </summary>
  6127. /// <param name="dto"></param>
  6128. /// <returns></returns>
  6129. [HttpPost]
  6130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6131. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6132. {
  6133. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6134. if (groupData.Code != 0)
  6135. {
  6136. return Ok(JsonView(false, groupData.Msg));
  6137. }
  6138. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6139. }
  6140. /// <summary>
  6141. /// 填写费用详细页面初始化绑定
  6142. /// </summary>
  6143. /// <param name="dto"></param>
  6144. /// <returns></returns>
  6145. [HttpPost]
  6146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6147. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6148. {
  6149. try
  6150. {
  6151. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6152. if (groupData.Code != 0)
  6153. {
  6154. return Ok(JsonView(false, groupData.Msg));
  6155. }
  6156. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6157. }
  6158. catch (Exception ex)
  6159. {
  6160. return Ok(JsonView(false, ex.Message));
  6161. }
  6162. }
  6163. /// <summary>
  6164. /// 根据op费用Id查询详细数据
  6165. /// </summary>
  6166. /// <param name="dto"></param>
  6167. /// <returns></returns>
  6168. [HttpPost]
  6169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6170. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6171. {
  6172. try
  6173. {
  6174. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6175. if (groupData.Code != 0)
  6176. {
  6177. return Ok(JsonView(false, groupData.Msg));
  6178. }
  6179. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6180. }
  6181. catch (Exception ex)
  6182. {
  6183. return Ok(JsonView(false, ex.Message));
  6184. }
  6185. }
  6186. /// <summary>
  6187. /// OP费用录入填写详情
  6188. /// </summary>
  6189. /// <param name="dto"></param>
  6190. /// <returns></returns>
  6191. [HttpPost]
  6192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6193. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6194. {
  6195. try
  6196. {
  6197. #region 参数校验
  6198. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6199. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6200. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6201. #endregion
  6202. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6203. if (groupData.Code != 0)
  6204. {
  6205. return Ok(JsonView(false, groupData.Msg));
  6206. }
  6207. //自动审核
  6208. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6209. #region 应用推送
  6210. try
  6211. {
  6212. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6213. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6214. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6215. }
  6216. catch (Exception ex)
  6217. {
  6218. }
  6219. #endregion
  6220. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6221. }
  6222. catch (Exception ex)
  6223. {
  6224. return Ok(JsonView(false, ex.Message));
  6225. }
  6226. }
  6227. /// <summary>
  6228. /// 获取三公详细所有城市
  6229. /// </summary>
  6230. /// <returns></returns>
  6231. [HttpGet]
  6232. public IActionResult OpCarCityResult()
  6233. {
  6234. var jw = JsonView(false);
  6235. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6236. {
  6237. x.Id,
  6238. x.Country,
  6239. x.City,
  6240. }).ToList();
  6241. if (data.Count > 0)
  6242. {
  6243. jw = JsonView(true, "获取成功!", data);
  6244. }
  6245. else
  6246. {
  6247. jw.Msg = "城市数据为空!";
  6248. jw.Data = new string[0];
  6249. }
  6250. return Ok(jw);
  6251. }
  6252. /// <summary>
  6253. /// 导出地接费用明细
  6254. /// </summary>
  6255. /// <param name="dto"></param>
  6256. /// <returns></returns>
  6257. [HttpPost]
  6258. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6259. {
  6260. var jw = JsonView(false);
  6261. if (dto.Diid < 1)
  6262. {
  6263. jw.Msg = "请输入正确的diid!";
  6264. return Ok(jw);
  6265. }
  6266. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6267. if (group == null)
  6268. {
  6269. jw.Msg = "未找到团组信息!";
  6270. return Ok(jw);
  6271. }
  6272. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6273. if (localGuideArr.Count == 0)
  6274. {
  6275. jw.Msg = "该团组暂无地接信息!";
  6276. return Ok(jw);
  6277. }
  6278. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6279. var overspendSoure = new Dictionary<int, int>
  6280. {
  6281. { 91, 982 }, //车
  6282. { 92 , 1059} ,//导游
  6283. { 994 , 1073}, //翻译
  6284. { 988 , 1074 }, //早餐
  6285. { 93 , 1075 }, //午餐
  6286. { 989 , 1076 }, //晚餐
  6287. };
  6288. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6289. foreach (var groupArr in localGroup)
  6290. {
  6291. var keyValue = groupArr.Key;
  6292. if (int.TryParse(keyValue, out int cityid))
  6293. {
  6294. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6295. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6296. }
  6297. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6298. foreach (var item in groupArr)
  6299. {
  6300. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6301. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6302. new Grp_CarTouristGuideGroundReservationsContentExtend
  6303. {
  6304. Count = a.Count,
  6305. CreateTime = a.CreateTime,
  6306. CreateUserId = a.CreateUserId,
  6307. CTGGRId = a.CTGGRId,
  6308. Currency = a.Currency,
  6309. DatePrice = a.DatePrice,
  6310. DeleteTime = a.DeleteTime,
  6311. DeleteUserId = a.DeleteUserId,
  6312. DiId = a.DiId,
  6313. Id = a.Id,
  6314. IsDel = a.IsDel,
  6315. Price = a.Price,
  6316. PriceContent = a.PriceContent,
  6317. Remark = a.Remark,
  6318. SId = a.SId,
  6319. SidName = b.Name,
  6320. Units = a.Units,
  6321. }
  6322. ).ToList();
  6323. if (content.Count > 0)
  6324. {
  6325. contentArr.Add(content);
  6326. }
  6327. }
  6328. //open excel
  6329. //set excel
  6330. //save excel
  6331. try
  6332. {
  6333. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6334. IWorkbook workbook;
  6335. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6336. {
  6337. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6338. }
  6339. else
  6340. {
  6341. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6342. }
  6343. ISheet sheet = workbook.GetSheetAt(0);
  6344. var rowStartIndex = 2;
  6345. var clounmCount = 10;
  6346. var initStyleRow = sheet.GetRow(2);
  6347. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6348. //var overspendArrDetail =
  6349. var existsId = new List<CarCompare>();
  6350. var lastElem = arr.Last();
  6351. var thisSid = -1;
  6352. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6353. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6354. {
  6355. Name = "未知币种!",
  6356. Remark = "未知币种!",
  6357. };
  6358. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6359. Action cloneRowFn = () =>
  6360. {
  6361. rowStartIndex++;
  6362. var cloneRow = sheet.CreateRow(rowStartIndex);
  6363. // 复制样式
  6364. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6365. {
  6366. ICell sourceCell = initStyleRow.GetCell(i);
  6367. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6368. // 确保单元格存在样式
  6369. if (sourceCell.CellStyle != null)
  6370. {
  6371. targetCell.CellStyle = sourceCell.CellStyle;
  6372. }
  6373. }
  6374. };
  6375. var mergeRow = () =>
  6376. {
  6377. for (int i = 2; i < sheet.LastRowNum; i++)
  6378. {
  6379. var row = sheet.GetRow(i);
  6380. var cellFirst = row.GetCell(0);
  6381. var thisIndex = i + 1;
  6382. while (thisIndex < sheet.LastRowNum)
  6383. {
  6384. var nextRow = sheet.GetRow(thisIndex);
  6385. var nextCellFirst = nextRow.GetCell(0);
  6386. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6387. {
  6388. thisIndex++;
  6389. }
  6390. else
  6391. {
  6392. break;
  6393. }
  6394. }
  6395. thisIndex--;
  6396. if (thisIndex != i)
  6397. {
  6398. //合并row
  6399. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6400. i, // 起始行索引(0-based)
  6401. thisIndex, // 结束行索引(0-based)
  6402. 0, // 起始列索引(0-based)
  6403. 0 // 结束列索引(0-based)
  6404. );
  6405. sheet.AddMergedRegion(cellRangeAddress);
  6406. i = thisIndex;
  6407. }
  6408. }
  6409. };
  6410. var chaoshiNumber = 0;
  6411. var totalNumber = 0.00M;
  6412. string lastStr = "";
  6413. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6414. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6415. {
  6416. b.IsAuditGM,
  6417. x.Id,
  6418. x.Area,
  6419. b.PayPercentage,
  6420. b.PayMoney,
  6421. }).ToList();
  6422. string yesPayment = "", noPayment = "";
  6423. foreach (var item in queryCarArrByCityAndDiid)
  6424. {
  6425. if (item.IsAuditGM == 1)
  6426. {
  6427. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6428. }
  6429. else
  6430. {
  6431. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6432. }
  6433. }
  6434. lastStr = yesPayment + noPayment;
  6435. foreach (var item in arr)
  6436. {
  6437. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6438. {
  6439. if (thisSid != item.SId)
  6440. {
  6441. if (thisSid == -1)
  6442. {
  6443. thisSid = item.SId;
  6444. }
  6445. else
  6446. {
  6447. //合并小计行
  6448. //创建合并区域的实例
  6449. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6450. rowStartIndex, // 起始行索引(0-based)
  6451. rowStartIndex, // 结束行索引(0-based)
  6452. 0, // 起始列索引(0-based)
  6453. 3 // 结束列索引(0-based)
  6454. );
  6455. sheet.AddMergedRegion(cellRangeAddress);
  6456. var CellStyle = workbook.CreateCellStyle();
  6457. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6458. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6459. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6460. for (int i = 0; i <= clounmCount; i++)
  6461. {
  6462. if (i > 6)
  6463. {
  6464. var CellStyle1 = workbook.CreateCellStyle();
  6465. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6466. IFont Font = workbook.CreateFont(); // 创建字体
  6467. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6468. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6469. CellStyle1.SetFont(Font);
  6470. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6471. }
  6472. else
  6473. {
  6474. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6475. }
  6476. }
  6477. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6478. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6479. //超时合计
  6480. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6481. //超时数
  6482. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6483. //超时合计费用
  6484. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6485. thisSid = item.SId;
  6486. cloneRowFn();
  6487. chaoshiNumber = 0;
  6488. totalNumber = 0;
  6489. }
  6490. }
  6491. IRow row = sheet.GetRow(rowStartIndex);
  6492. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6493. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6494. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6495. if (isOpenOverspendSoure)
  6496. {
  6497. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6498. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6499. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6500. }
  6501. for (int i = 0; i <= clounmCount; i++)
  6502. {
  6503. var cell = row.GetCell(i);
  6504. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6505. if (cell == null)
  6506. {
  6507. cell = row.CreateCell(i);
  6508. }
  6509. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6510. fontRed.CloneStyleFrom(cell.CellStyle);
  6511. IFont Font = workbook.CreateFont(); // 创建字体
  6512. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6513. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6514. fontRed.SetFont(Font);
  6515. byte[] rgb = new byte[3] { 255, 242, 204 };
  6516. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6517. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6518. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6519. if (workbook is XSSFWorkbook)
  6520. {
  6521. BackgroundColor255_242_204.FillForegroundColor = 0;
  6522. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6523. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6524. }
  6525. else
  6526. {
  6527. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6528. }
  6529. if (i == 1 || i > 6)
  6530. {
  6531. if (i > 6)
  6532. {
  6533. fontRed.FillForegroundColor = 0;
  6534. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6535. fontRed.FillPattern = FillPattern.SolidForeground;
  6536. }
  6537. cell.CellStyle = fontRed;
  6538. }
  6539. if (i > 2 && i < 7)
  6540. {
  6541. cell.CellStyle = BackgroundColor255_242_204;
  6542. }
  6543. cell.SetCellValue(setCellValue); //写入单元格
  6544. }
  6545. if (overspendSoure.ContainsKey(thisSid))
  6546. {
  6547. var overspendId = overspendSoure[thisSid];
  6548. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6549. }
  6550. cloneRowFn();
  6551. existsId.Add(new CarCompare
  6552. {
  6553. DataPrice = item.DatePrice.ObjToDate(),
  6554. Sid = item.SId
  6555. });
  6556. }
  6557. if (item.Equals(lastElem))
  6558. {
  6559. //合并小计行
  6560. //创建合并区域的实例
  6561. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6562. rowStartIndex, // 起始行索引(0-based)
  6563. rowStartIndex, // 结束行索引(0-based)
  6564. 0, // 起始列索引(0-based)
  6565. 3 // 结束列索引(0-based)
  6566. );
  6567. sheet.AddMergedRegion(cellRangeAddress);
  6568. var CellStyle = workbook.CreateCellStyle();
  6569. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6570. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6571. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6572. for (int i = 0; i <= clounmCount; i++)
  6573. {
  6574. if (i > 6)
  6575. {
  6576. var CellStyle1 = workbook.CreateCellStyle();
  6577. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6578. IFont Font = workbook.CreateFont(); // 创建字体
  6579. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6580. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6581. CellStyle1.SetFont(Font);
  6582. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6583. }
  6584. else
  6585. {
  6586. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6587. }
  6588. }
  6589. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6590. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6591. //超时合计
  6592. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6593. //超时数
  6594. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6595. //超时合计费用
  6596. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6597. cloneRowFn();
  6598. // 创建合并区域的实例
  6599. cellRangeAddress = new CellRangeAddress(
  6600. rowStartIndex, // 起始行索引(0-based)
  6601. rowStartIndex, // 结束行索引(0-based)
  6602. 0, // 起始列索引(0-based)
  6603. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6604. );
  6605. // 添加合并区域
  6606. sheet.AddMergedRegion(cellRangeAddress);
  6607. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6608. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6609. }
  6610. }
  6611. mergeRow();
  6612. // 保存修改后的Excel文件到新文件
  6613. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6614. // new FileStream(newFilePath, FileMode.CreateNew)
  6615. using (var stream = new MemoryStream())
  6616. {
  6617. workbook.Write(stream, true);
  6618. stream.Flush();
  6619. stream.Seek(0, SeekOrigin.Begin);
  6620. MemoryStream memoryStream = new MemoryStream();
  6621. stream.CopyTo(memoryStream);
  6622. memoryStream.Seek(0, SeekOrigin.Begin);
  6623. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6624. }
  6625. workbook.Close();
  6626. workbook.Dispose();
  6627. }
  6628. catch (Exception ex)
  6629. {
  6630. jw.Msg = "出现异常!" + ex.Message;
  6631. return Ok(jw);
  6632. }
  6633. }
  6634. if (Zips.Count > 0)
  6635. {
  6636. IOOperatorHelper io = new IOOperatorHelper();
  6637. var byts = io.ConvertZipStream(Zips);
  6638. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6639. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6640. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6641. }
  6642. else
  6643. {
  6644. jw.Msg = "暂无生成文件!";
  6645. }
  6646. return Ok(jw);
  6647. }
  6648. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6649. {
  6650. string outStr = string.Empty;
  6651. switch (i)
  6652. {
  6653. case 0:
  6654. outStr = arr[0].SidName;
  6655. break;
  6656. case 1:
  6657. outStr = arr[0].DataPriceStr;
  6658. break;
  6659. case 2:
  6660. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6661. break;
  6662. case 4:
  6663. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6664. break;
  6665. case 7:
  6666. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6667. {
  6668. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6669. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6670. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6671. }
  6672. break;
  6673. case 8:
  6674. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6675. {
  6676. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6677. }
  6678. break;
  6679. case 9:
  6680. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6681. {
  6682. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6683. }
  6684. break;
  6685. case 10:
  6686. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6687. {
  6688. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6689. }
  6690. break;
  6691. }
  6692. return outStr;
  6693. }
  6694. #region OP行程单
  6695. /// <summary>
  6696. /// OP行程单初始化
  6697. /// </summary>
  6698. /// <param name="dto"></param>
  6699. /// <returns></returns>
  6700. [HttpPost]
  6701. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6702. {
  6703. var jw = JsonView(false);
  6704. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6705. var group = groupList.First();
  6706. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6707. if (group == null)
  6708. {
  6709. jw.Msg = "暂无团组!";
  6710. return Ok(jw);
  6711. }
  6712. group = groupList.Find(x => x.Id == diid);
  6713. if (group == null)
  6714. {
  6715. jw.Msg = "请输入正确的团组ID!";
  6716. return Ok(jw);
  6717. }
  6718. string city = string.Empty;
  6719. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6720. if (blackCode.Count > 0)
  6721. {
  6722. var black = blackCode.First();
  6723. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6724. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6725. if (blackSp.Length > 0)
  6726. {
  6727. try
  6728. {
  6729. var cityArrCode = new List<string>(20);
  6730. foreach (var item in blackSp)
  6731. {
  6732. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6733. var IndexSelect = itemSp[2];
  6734. var cityArrCodeLength = cityArrCode.Count - 1;
  6735. var startCity = IndexSelect.Substring(0, 3);
  6736. if (cityArrCodeLength > 0)
  6737. {
  6738. var arrEndCity = cityArrCode[cityArrCodeLength];
  6739. if (arrEndCity != startCity)
  6740. {
  6741. cityArrCode.Add(startCity.ToUpper());
  6742. }
  6743. }
  6744. else
  6745. {
  6746. cityArrCode.Add(startCity.ToUpper());
  6747. }
  6748. var endCity = IndexSelect.Substring(3, 3);
  6749. cityArrCode.Add(endCity.ToUpper());
  6750. }
  6751. var cityThree = string.Empty;
  6752. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6753. cityThree = cityThree.TrimEnd(',');
  6754. if (string.IsNullOrWhiteSpace(cityThree))
  6755. {
  6756. throw new
  6757. Exception("error");
  6758. }
  6759. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6760. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6761. foreach (var item in cityArrCode)
  6762. {
  6763. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6764. if (find != null)
  6765. {
  6766. city += find.City + "/";
  6767. }
  6768. else
  6769. {
  6770. city += item + "三字码未收入/";
  6771. }
  6772. }
  6773. city = city.TrimEnd('/');
  6774. }
  6775. catch (Exception e)
  6776. {
  6777. city = "黑屏代码格式不正确!";
  6778. }
  6779. }
  6780. }
  6781. else
  6782. {
  6783. city = "未录入黑屏代码";
  6784. }
  6785. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6786. {
  6787. Date = x.Date,
  6788. Days = x.Days,
  6789. Diffgroup = x.Diffgroup,
  6790. Diid = x.Diid,
  6791. Traffic_First = x.Traffic_First,
  6792. Traffic_Second = x.Traffic_Second,
  6793. Trip = x.Trip,
  6794. WeekDay = x.WeekDay,
  6795. Id = x.Id
  6796. }).ToList();
  6797. jw.Data = new
  6798. {
  6799. groupList = groupList.Select(x => new
  6800. {
  6801. x.Id,
  6802. x.TeamName,
  6803. x.TourCode
  6804. }).ToList(),
  6805. groupInfo = new
  6806. {
  6807. group.VisitDays,
  6808. group.TourCode,
  6809. group.VisitPNumber,
  6810. group.TeamName,
  6811. city
  6812. },
  6813. OpTravelList
  6814. };
  6815. jw.Code = 200;
  6816. jw.Msg = "操作成功!";
  6817. return Ok(jw);
  6818. }
  6819. /// <summary>
  6820. /// 删除团组行程单
  6821. /// </summary>
  6822. /// <returns></returns>
  6823. [HttpPost]
  6824. public IActionResult DelTravel(DelOpTravelDto dto)
  6825. {
  6826. var jw = JsonView(false);
  6827. if (dto.UserId <= 0 || dto.Diid <= 0)
  6828. {
  6829. jw.Msg = "请输入正确的参数!";
  6830. return Ok(jw);
  6831. }
  6832. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6833. .SetColumns(x => new Grp_TravelList
  6834. {
  6835. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6836. DeleteUserId = dto.UserId,
  6837. IsDel = 1,
  6838. }).ExecuteCommand();
  6839. jw = JsonView(true);
  6840. return Ok(jw);
  6841. }
  6842. /// <summary>
  6843. /// 行程单保存
  6844. /// </summary>
  6845. /// <returns></returns>
  6846. [HttpPost]
  6847. public IActionResult TravelSave(TravelSaveDto dto)
  6848. {
  6849. var jw = JsonView(false);
  6850. if (dto.Arr.Count > 0)
  6851. {
  6852. try
  6853. {
  6854. _sqlSugar.BeginTran();
  6855. foreach (var item in dto.Arr)
  6856. {
  6857. if (item.Id == 0)
  6858. {
  6859. throw new Exception("请传入正确的Id");
  6860. }
  6861. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6862. .SetColumns(x => new Grp_TravelList
  6863. {
  6864. Trip = item.Trip
  6865. }).ExecuteCommand();
  6866. }
  6867. _sqlSugar.CommitTran();
  6868. jw = JsonView(true);
  6869. }
  6870. catch (Exception ex)
  6871. {
  6872. _sqlSugar.RollbackTran();
  6873. jw.Msg = "程序异常!" + ex.Message;
  6874. }
  6875. }
  6876. else
  6877. {
  6878. jw.Msg = "请传入正确的参数!";
  6879. }
  6880. return Ok(jw);
  6881. }
  6882. /// <summary>
  6883. /// 导出行程单
  6884. /// </summary>
  6885. /// <param name="dto"></param>
  6886. /// <returns></returns>
  6887. [HttpPost]
  6888. public IActionResult ExportTravel(ExportTravelDto dto)
  6889. {
  6890. var jw = JsonView(false);
  6891. jw.Data = "";
  6892. int diid = 0;
  6893. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6894. if (Find == null)
  6895. {
  6896. jw.Msg = "请选择正确的团组!";
  6897. return Ok(jw);
  6898. }
  6899. else
  6900. {
  6901. diid = Find.Id;
  6902. }
  6903. //数据源
  6904. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6905. DataTable dtBlack = null;
  6906. try
  6907. {
  6908. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6909. }
  6910. catch (Exception)
  6911. {
  6912. jw.Msg = "机票黑屏代码有误!";
  6913. return Ok(jw);
  6914. }
  6915. string CityStr = string.Empty;
  6916. if (dtBlack.Rows.Count == 0)
  6917. {
  6918. jw.Msg = "机票黑屏代码有误!";
  6919. return Ok(jw);
  6920. }
  6921. else
  6922. {
  6923. foreach (DataRow row in dtBlack.Rows)
  6924. {
  6925. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6926. {
  6927. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6928. return Ok(jw);
  6929. }
  6930. }
  6931. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6932. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6933. }
  6934. //创建数据源Table
  6935. DataTable dtSource = new DataTable();
  6936. dtSource.Columns.Add("Days", typeof(string));
  6937. dtSource.Columns.Add("Date", typeof(string));
  6938. dtSource.Columns.Add("Week", typeof(string));
  6939. dtSource.Columns.Add("Traffic", typeof(string));
  6940. dtSource.Columns.Add("Trip", typeof(string));
  6941. //获取数据,放到datatable
  6942. foreach (var item in _travelList)
  6943. {
  6944. DataRow dr = dtSource.NewRow();
  6945. dr["Days"] = item.Days;
  6946. dr["Date"] = item.Date;
  6947. dr["Week"] = item.WeekDay;
  6948. dr["Traffic"] = item.Traffic_First
  6949. + "\r\n"
  6950. + item.Traffic_Second;
  6951. dr["Trip"] = item.Trip;
  6952. dtSource.Rows.Add(dr);
  6953. }
  6954. Dictionary<string, string> dic = new Dictionary<string, string>();
  6955. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6956. dic.Add("City", CityStr);
  6957. dic.Add("Days", Find.VisitDays.ToString());
  6958. dic.Add("DeleCode", Find.TourCode);
  6959. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6960. //模板路径
  6961. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6962. //载入模板
  6963. Document doc = null;
  6964. DocumentBuilder builder = null;
  6965. try
  6966. {
  6967. //载入模板
  6968. doc = new Document(tempPath);
  6969. builder = new DocumentBuilder(doc);
  6970. }
  6971. catch (Exception)
  6972. {
  6973. jw.Msg = "模板位置不存在!";
  6974. return Ok(jw);
  6975. }
  6976. foreach (var key in dic.Keys)
  6977. {
  6978. Bookmark bookmark = doc.Range.Bookmarks[key];
  6979. if (bookmark != null)
  6980. {
  6981. builder.MoveToBookmark(key);
  6982. builder.Write(dic[key]);
  6983. }
  6984. }
  6985. //获取word里所有表格
  6986. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6987. //获取所填表格的序数
  6988. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6989. try
  6990. {
  6991. //循环赋值
  6992. for (int i = 0; i < dtSource.Rows.Count; i++)
  6993. {
  6994. builder.MoveToCell(0, i + 1, 0, 0);
  6995. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6996. builder.MoveToCell(0, i + 1, 1, 0);
  6997. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6998. builder.MoveToCell(0, i + 1, 2, 0);
  6999. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7000. var trip = dtSource.Rows[i]["Trip"].ToString();
  7001. builder.MoveToCell(0, i + 1, 3, 0);
  7002. builder.Write(trip);
  7003. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7004. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7005. // 获取特定索引的段落
  7006. Paragraph paragraph = (Paragraph)paragraphs[0];
  7007. Run run = paragraph.Runs[0];
  7008. Aspose.Words.Font font = run.Font;
  7009. font.Name = "黑体";
  7010. //设置双休红色
  7011. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7012. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7013. paragraph = (Paragraph)paragraphs[1];
  7014. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7015. {
  7016. run = paragraph.Runs[0];
  7017. font = run.Font;
  7018. font.Color = Color.Red;
  7019. }
  7020. }
  7021. }
  7022. catch (Exception ex)
  7023. {
  7024. }
  7025. //删除多余行
  7026. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7027. {
  7028. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7029. }
  7030. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7031. if (!Directory.Exists(savePath))
  7032. {
  7033. try
  7034. {
  7035. Directory.CreateDirectory(savePath);
  7036. }
  7037. catch
  7038. {
  7039. }
  7040. }
  7041. string path = savePath + Find.TeamName + "出访日程";
  7042. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7043. try
  7044. {
  7045. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7046. string postfix = ".docx";
  7047. if (dto.IsPDF == 1)
  7048. {
  7049. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7050. postfix = ".pdf";
  7051. }
  7052. doc.Save(path + postfix, saveFormat);
  7053. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7054. }
  7055. catch (Exception)
  7056. {
  7057. jw = JsonView(false);
  7058. }
  7059. return Ok(jw);
  7060. }
  7061. /// <summary>
  7062. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7063. /// </summary>
  7064. /// <param name="num"></param>
  7065. /// <returns></returns>
  7066. string GetNum(string num)
  7067. {
  7068. string str = "";
  7069. switch (num)
  7070. {
  7071. case "1":
  7072. str = "一";
  7073. break;
  7074. case "2":
  7075. str = "二";
  7076. break;
  7077. case "3":
  7078. str = "三";
  7079. break;
  7080. case "4":
  7081. str = "四";
  7082. break;
  7083. case "5":
  7084. str = "五";
  7085. break;
  7086. case "6":
  7087. str = "六";
  7088. break;
  7089. case "7":
  7090. str = "七";
  7091. break;
  7092. case "8":
  7093. str = "八";
  7094. break;
  7095. case "9":
  7096. str = "九";
  7097. break;
  7098. case "10":
  7099. str = "十";
  7100. break;
  7101. case "11":
  7102. str = "十一";
  7103. break;
  7104. case "12":
  7105. str = "十二";
  7106. break;
  7107. case "一":
  7108. str = "1";
  7109. break;
  7110. case "二":
  7111. str = "2";
  7112. break;
  7113. case "三":
  7114. str = "3";
  7115. break;
  7116. case "四":
  7117. str = "4";
  7118. break;
  7119. case "五":
  7120. str = "5";
  7121. break;
  7122. case "六":
  7123. str = "6";
  7124. break;
  7125. case "七":
  7126. str = "7";
  7127. break;
  7128. case "八":
  7129. str = "8";
  7130. break;
  7131. case "九":
  7132. str = "9";
  7133. break;
  7134. case "十":
  7135. str = "10";
  7136. break;
  7137. case "十一":
  7138. str = "11";
  7139. break;
  7140. case "十二":
  7141. str = "12";
  7142. break;
  7143. }
  7144. return str;
  7145. }
  7146. #endregion
  7147. #endregion
  7148. #region 团组成本
  7149. /// <summary>
  7150. /// 团组成本数据初始化
  7151. /// </summary>
  7152. /// <param name="dto"></param>
  7153. /// <returns></returns>
  7154. [HttpPost]
  7155. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7156. {
  7157. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7158. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7159. WHEN COUNT(*) >= 0 THEN 'True'
  7160. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7161. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7162. ").ToList(); //团组列表
  7163. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7164. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7165. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7166. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7167. if (groupinfoValue != null)
  7168. {
  7169. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7170. var spArr = new string[1] { countryArr };
  7171. if (countryArr.Contains("|"))
  7172. {
  7173. spArr = countryArr.Split("|");
  7174. }
  7175. else if (countryArr.Contains("、"))
  7176. {
  7177. spArr = countryArr.Split("、");
  7178. }
  7179. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7180. {
  7181. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7182. if (dbQueryCountry != null)
  7183. {
  7184. visaCountryInfoArr.Add(dbQueryCountry);
  7185. }
  7186. }
  7187. }
  7188. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7189. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7190. var create = _GroupCostRepository.
  7191. CreateGroupCostByBlackCode(dto.Diid);
  7192. if (groupCost.Count == 0 && create.Code == 0)
  7193. {
  7194. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7195. }
  7196. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7197. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7198. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7199. groupCostMap = groupCostMap.Select(x =>
  7200. {
  7201. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7202. {
  7203. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7204. }
  7205. return x;
  7206. }).ToList();
  7207. //GroupCostParameter.Add(new
  7208. // Grp_GroupCostParameter());
  7209. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7210. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7211. return Ok(JsonView(new
  7212. {
  7213. groupList,
  7214. groupInfo,
  7215. groupChecks,
  7216. groupCost = groupCostMap,
  7217. hotelNumber,
  7218. GroupCostParameter = GroupCostParameterMap,
  7219. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7220. {
  7221. x.VisaCountry,
  7222. x.VisaPrice,
  7223. x.Id,
  7224. }).ToList(),
  7225. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7226. blackCodeIsTrue = create.Code == 0 ? true : false,
  7227. hotelIsTrue = hotelIsTrue,
  7228. }));
  7229. }
  7230. /// <summary>
  7231. /// 团组成本信息保存
  7232. /// </summary>
  7233. /// <param name="dto"></param>
  7234. /// <returns></returns>
  7235. [HttpPost]
  7236. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7237. {
  7238. if (dto.Diid <= 0 || dto.Userid <= 0)
  7239. {
  7240. return Ok(JsonView(false));
  7241. }
  7242. JsonView jw = null;
  7243. bool isTrue = false;
  7244. #region 复制团组成本
  7245. //if (dto.Diid == 2581)
  7246. //{
  7247. // dto.Diid = 2599;
  7248. // dto.CheckBoxs.ForEach(x =>
  7249. // {
  7250. // x.Diid = 2599;
  7251. // });
  7252. // dto.GroupCosts.ForEach(x =>
  7253. // {
  7254. // x.Diid = 2599;
  7255. // });
  7256. // dto.CostTypeHotelNumbers.ForEach(x =>
  7257. // {
  7258. // x.Diid = 2599;
  7259. // });
  7260. // dto.GroupCostParameters.ForEach(x =>
  7261. // {
  7262. // x.DiId = 2599;
  7263. // });
  7264. //}
  7265. #endregion
  7266. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7267. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7268. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7269. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7270. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7271. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7272. try
  7273. {
  7274. _sqlSugar.BeginTran();
  7275. isTrue = await _GroupCostRepository.
  7276. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7277. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7278. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7279. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7280. _sqlSugar.CommitTran();
  7281. jw = JsonView(true, "保存成功!", isTrue);
  7282. }
  7283. catch (Exception)
  7284. {
  7285. _sqlSugar.RollbackTran();
  7286. jw = JsonView(false);
  7287. }
  7288. return Ok(jw);
  7289. }
  7290. /// <summary>
  7291. /// 司兼导数据
  7292. /// </summary>
  7293. /// <param name="dto"></param>
  7294. /// <returns></returns>
  7295. [HttpPost]
  7296. public IActionResult GetCarGuides(CarGuidesDto dto)
  7297. {
  7298. JsonView jw = null;
  7299. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7300. jw = JsonView(true, "获取成功!", Data);
  7301. return Ok(jw);
  7302. }
  7303. /// <summary>
  7304. /// 导游数据
  7305. /// </summary>
  7306. /// <param name="dto"></param>
  7307. /// <returns></returns>
  7308. [HttpPost]
  7309. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7310. {
  7311. JsonView jw = null;
  7312. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7313. // 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
  7314. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7315. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7316. jw = JsonView(true, "获取成功!", Data);
  7317. return Ok(jw);
  7318. }
  7319. /// <summary>
  7320. /// 成本车数据
  7321. /// </summary>
  7322. /// <param name="dto"></param>
  7323. /// <returns></returns>
  7324. [HttpPost]
  7325. public IActionResult GetCarInfo(CarGuidesDto dto)
  7326. {
  7327. JsonView jw = null;
  7328. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7329. jw = JsonView(true, "获取成功!", Data);
  7330. return Ok(jw);
  7331. }
  7332. /// <summary>
  7333. /// 景点数据
  7334. /// </summary>
  7335. /// <param name="dto"></param>
  7336. /// <returns></returns>
  7337. [HttpPost]
  7338. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7339. {
  7340. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7341. return Ok(JsonView(true, "获取成功!", Data));
  7342. }
  7343. /// <summary>
  7344. /// 成本通知
  7345. /// </summary>
  7346. /// <param name="dto"></param>
  7347. /// <returns></returns>
  7348. [HttpPost]
  7349. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7350. {
  7351. if (dto.Diid < 0)
  7352. {
  7353. return Ok(JsonView(false));
  7354. }
  7355. JsonView jw = null;
  7356. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7357. if (GroupCostParameter != null)
  7358. {
  7359. int IsShare = 0;
  7360. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7361. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7362. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7363. string msg = string.Empty;
  7364. if (isTrue)
  7365. {
  7366. if (IsShare == 0)
  7367. {
  7368. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7369. }
  7370. else
  7371. {
  7372. #region 企微通知对应岗位用户
  7373. try
  7374. {
  7375. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7376. }
  7377. catch (Exception ex)
  7378. {
  7379. }
  7380. #endregion
  7381. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7382. }
  7383. jw = JsonView(isTrue, msg, new { IsShare });
  7384. }
  7385. else
  7386. {
  7387. msg = "修改失败!";
  7388. jw = JsonView(isTrue, msg);
  7389. }
  7390. }
  7391. else
  7392. {
  7393. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7394. }
  7395. return Ok(jw);
  7396. }
  7397. /// <summary>
  7398. /// 导出报价单
  7399. /// </summary>
  7400. /// <param name="dto"></param>
  7401. /// <returns></returns>
  7402. [HttpPost]
  7403. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7404. {
  7405. if (dto.Diid == 0)
  7406. {
  7407. return Ok(JsonView(false, "请传递团组id"));
  7408. }
  7409. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7410. if (deleInfo.Code != 0)
  7411. {
  7412. return Ok(JsonView(false, "团组信息查询失败!"));
  7413. }
  7414. var di = deleInfo.Data as DelegationInfoWebView;
  7415. if (di != null)
  7416. {
  7417. di.TeamName = di.TeamName.Replace("|", "、");
  7418. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7419. //文件名
  7420. string strFileName = di.TeamName + "-收款账单.doc";
  7421. //获取模板
  7422. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7423. //载入模板
  7424. Document doc = new Document(tmppath);
  7425. decimal TotalPrice = 0.00M;
  7426. string itemStr = string.Empty;
  7427. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7428. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7429. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7430. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7431. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7432. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7433. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7434. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7435. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7436. foreach (var cost in groupCostType)
  7437. {
  7438. var List = cost.ToList();
  7439. if (cost.Key == "A")
  7440. {
  7441. foreach (var ListItem in List)
  7442. {
  7443. if (ListItem.number > 0)
  7444. {
  7445. if (ListItem.code.Contains("TBR"))
  7446. {
  7447. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7448. }
  7449. else
  7450. {
  7451. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7452. }
  7453. TotalPrice += (ListItem.number * ListItem.price);
  7454. }
  7455. }
  7456. }
  7457. else
  7458. {
  7459. itemStr = itemStr.Insert(0, "A段\r\n");
  7460. itemStr += "B段\r\n";
  7461. foreach (var ListItem in List)
  7462. {
  7463. if (ListItem.number > 0)
  7464. {
  7465. if (ListItem.code.Contains("TBR"))
  7466. {
  7467. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7468. }
  7469. else
  7470. {
  7471. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7472. }
  7473. TotalPrice += (ListItem.number * ListItem.price);
  7474. }
  7475. }
  7476. }
  7477. }
  7478. #region 替换Word模板书签内容
  7479. Dictionary<string, string> marks = new Dictionary<string, string>();
  7480. marks.Add("To", di.ClientUnit);//付款方
  7481. marks.Add("ToTel", di.TellPhone);//付款方电话
  7482. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7483. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7484. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7485. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7486. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7487. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7488. marks.Add("PayItemContent", itemStr);//详细信息
  7489. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7490. #endregion
  7491. ////注
  7492. //if (doc.Range.Bookmarks["Attention"] != null)
  7493. //{
  7494. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7495. // mark.Text = frList[0].Attention;
  7496. //}
  7497. foreach (var item in marks.Keys)
  7498. {
  7499. if (doc.Range.Bookmarks[item] != null)
  7500. {
  7501. Bookmark mark = doc.Range.Bookmarks[item];
  7502. mark.Text = marks[item];
  7503. }
  7504. }
  7505. byte[] bytes = null;
  7506. using (MemoryStream stream = new MemoryStream())
  7507. {
  7508. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7509. bytes = stream.ToArray();
  7510. }
  7511. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7512. return Ok(JsonView(true, "", new
  7513. {
  7514. Data = bytes,
  7515. strFileName,
  7516. }));
  7517. }
  7518. else
  7519. {
  7520. return Ok(JsonView(false, "团组信息不存在!"));
  7521. }
  7522. }
  7523. /// <summary>
  7524. /// 导出团组成本
  7525. /// </summary>
  7526. /// <param name="dto"></param>
  7527. /// <returns></returns>
  7528. [HttpPost]
  7529. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7530. {
  7531. var jw = JsonView(false);
  7532. if (dto.Diid == 0)
  7533. {
  7534. return Ok(JsonView(false, "请传递团组id"));
  7535. }
  7536. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7537. if (deleInfo.Code != 0)
  7538. {
  7539. return Ok(JsonView(false, "团组信息查询失败!"));
  7540. }
  7541. var di = deleInfo.Data as DelegationInfoWebView;
  7542. if (di == null)
  7543. {
  7544. return Ok(JsonView(false, "团组信息查询失败!"));
  7545. }
  7546. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7547. WorkbookDesigner designer = new WorkbookDesigner();
  7548. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7549. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7550. for (int i = 0; i < List_GC.Count; i++)
  7551. {
  7552. GroupCost_Excel gc = new GroupCost_Excel();
  7553. gc.Id = List_GC[i].Id;
  7554. gc.Diid = List_GC[i].Diid.ToString();
  7555. gc.DAY = List_GC[i].DAY;
  7556. string week = "";
  7557. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7558. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7559. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7560. gc.ITIN = List_GC[i].ITIN;
  7561. gc.CarType = List_GC[i].CarType;
  7562. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7563. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7564. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7565. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7566. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7567. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7568. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7569. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7570. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7571. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7572. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7573. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7574. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7575. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7576. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7577. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7578. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7579. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7580. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7581. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7582. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7583. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7584. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7585. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7586. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7587. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7588. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7589. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7590. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7591. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7592. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7593. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7594. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7595. List_GC1.Add(gc);
  7596. }
  7597. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7598. dt.TableName = "TB";
  7599. //报表标题等不用dt的值
  7600. designer.SetDataSource("TeamName", dto.title.TeamName);
  7601. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7602. designer.SetDataSource("Tax", dto.title.Tax);
  7603. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7604. designer.SetDataSource("Currency", dto.title.Currency);
  7605. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7606. designer.SetDataSource("Rate", dto.title.Rate);
  7607. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7608. var Aparams = hotels.Find(x => x.Type == "Default");
  7609. if (Aparams == null)
  7610. {
  7611. return Ok(jw);
  7612. }
  7613. //酒店数量
  7614. var txtSGRNumber = Aparams.SGR.ToString();
  7615. var txtTBRNumber = Aparams.TBR.ToString();
  7616. var txtJSESNumber = Aparams.JSES.ToString();
  7617. var txtSUITENumbe = Aparams.SUITE.ToString();
  7618. if (dto.costType == "B")
  7619. {
  7620. Aparams = hotels.Find(x => x.Type == "A");
  7621. var Bparams = hotels.Find(x => x.Type == "B");
  7622. if (Aparams == null || Bparams == null)
  7623. {
  7624. return Ok(jw);
  7625. }
  7626. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7627. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7628. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7629. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7630. }
  7631. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7632. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7633. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7634. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7635. var ws = designer.Workbook.Worksheets[0];
  7636. int Row = List_GC.Count;
  7637. int startIndex = 11;
  7638. int HideRows = 0;
  7639. List<int> hideRowsList = new List<int>();
  7640. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7641. #region A段left数据
  7642. var left = dto.leftInfo.Find(x => x.Type == "A");
  7643. if (left == null)
  7644. {
  7645. return Ok(jw);
  7646. }
  7647. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7648. if (leftBindData != null)
  7649. {
  7650. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7651. designer.SetDataSource("VisaRS", leftBindData.rs);
  7652. designer.SetDataSource("VisaXS", leftBindData.xs);
  7653. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7654. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7655. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7656. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7657. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7658. }
  7659. else
  7660. {
  7661. hideRowsList.Add(Row + startIndex + HideRows);
  7662. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7663. }
  7664. HideRows += 2;
  7665. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7666. if (leftBindData != null)
  7667. {
  7668. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7669. designer.SetDataSource("BXRS", leftBindData.rs);
  7670. designer.SetDataSource("BXXS", leftBindData.xs);
  7671. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7672. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7673. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7674. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7675. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7676. }
  7677. else
  7678. {
  7679. hideRowsList.Add(Row + startIndex + HideRows);
  7680. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7681. }
  7682. HideRows += 2;
  7683. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7684. if (leftBindData != null)
  7685. {
  7686. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7687. designer.SetDataSource("HSRS", leftBindData.rs);
  7688. designer.SetDataSource("HSXS", leftBindData.xs);
  7689. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7690. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7691. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7692. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7693. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7694. }
  7695. else
  7696. {
  7697. hideRowsList.Add(Row + startIndex + HideRows);
  7698. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7699. }
  7700. HideRows += 2;
  7701. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7702. if (leftBindData != null)
  7703. {
  7704. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7705. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7706. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7707. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7708. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7709. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7710. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7711. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7712. }
  7713. else
  7714. {
  7715. hideRowsList.Add(Row + startIndex + HideRows);
  7716. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7717. }
  7718. HideRows += 2;
  7719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7720. if (leftBindData != null)
  7721. {
  7722. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7723. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7724. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7725. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7726. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7727. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7728. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7729. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7730. }
  7731. else
  7732. {
  7733. hideRowsList.Add(Row + startIndex + HideRows);
  7734. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7735. }
  7736. HideRows += 2;
  7737. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7738. if (leftBindData != null)
  7739. {
  7740. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7741. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7742. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7743. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7744. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7745. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7746. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7747. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7748. }
  7749. else
  7750. {
  7751. hideRowsList.Add(Row + startIndex + HideRows);
  7752. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7753. }
  7754. HideRows += 2;
  7755. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7756. if (leftBindData != null)
  7757. {
  7758. ////TBR
  7759. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7760. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7761. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7762. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7763. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7764. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7765. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7766. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7767. }
  7768. else
  7769. {
  7770. hideRowsList.Add(Row + startIndex + HideRows);
  7771. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7772. }
  7773. HideRows += 2;
  7774. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7775. if (leftBindData != null)
  7776. {
  7777. ////SGR
  7778. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7779. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7780. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7781. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7782. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7783. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7784. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7785. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7786. }
  7787. else
  7788. {
  7789. hideRowsList.Add(Row + startIndex + HideRows);
  7790. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7791. }
  7792. HideRows += 2;
  7793. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7794. if (leftBindData != null)
  7795. {
  7796. ////JS/ES
  7797. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7798. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7799. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7800. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7801. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7802. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7803. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7804. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7805. }
  7806. else
  7807. {
  7808. hideRowsList.Add(Row + startIndex + HideRows);
  7809. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7810. }
  7811. HideRows += 2;
  7812. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7813. if (leftBindData != null)
  7814. {
  7815. ////SUITE
  7816. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7817. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7818. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7819. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7820. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7821. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7822. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7823. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7824. }
  7825. else
  7826. {
  7827. hideRowsList.Add(Row + startIndex + HideRows);
  7828. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7829. }
  7830. HideRows += 2;
  7831. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7832. if (leftBindData != null)
  7833. {
  7834. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7835. designer.SetDataSource("DJRS", leftBindData.rs);
  7836. designer.SetDataSource("DJXS", leftBindData.xs);
  7837. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7838. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7839. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7840. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7841. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7842. }
  7843. else
  7844. {
  7845. hideRowsList.Add(Row + startIndex + HideRows);
  7846. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7847. }
  7848. HideRows += 2;
  7849. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7850. if (leftBindData != null)
  7851. {
  7852. designer.SetDataSource("HCPCB", leftBindData.cb);
  7853. designer.SetDataSource("HCPRS", leftBindData.rs);
  7854. designer.SetDataSource("HCPXS", leftBindData.xs);
  7855. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7856. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7857. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7858. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7859. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7860. }
  7861. else
  7862. {
  7863. hideRowsList.Add(Row + startIndex + HideRows);
  7864. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7865. }
  7866. HideRows += 2;
  7867. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7868. if (leftBindData != null)
  7869. {
  7870. designer.SetDataSource("CPCB", leftBindData.cb);
  7871. designer.SetDataSource("CPRS", leftBindData.rs);
  7872. designer.SetDataSource("CPXS", leftBindData.xs);
  7873. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7874. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7875. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7876. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7877. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7878. }
  7879. else
  7880. {
  7881. hideRowsList.Add(Row + startIndex + HideRows);
  7882. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7883. }
  7884. HideRows += 2;
  7885. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7886. if (leftBindData != null)
  7887. {
  7888. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7889. designer.SetDataSource("GWRS", leftBindData.rs);
  7890. designer.SetDataSource("GWXS", leftBindData.xs);
  7891. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7892. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7893. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7894. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7895. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7896. }
  7897. else
  7898. {
  7899. hideRowsList.Add(Row + startIndex + HideRows);
  7900. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7901. }
  7902. HideRows += 2;
  7903. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7904. if (leftBindData != null)
  7905. {
  7906. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7907. designer.SetDataSource("LYJRS", leftBindData.rs);
  7908. designer.SetDataSource("LYJXS", leftBindData.xs);
  7909. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7910. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7911. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7912. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7913. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7914. }
  7915. else
  7916. {
  7917. hideRowsList.Add(Row + startIndex + HideRows);
  7918. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7919. }
  7920. #endregion
  7921. #region A段Right信息
  7922. var right = dto.rightInfo.Find(x => x.Type == "A");
  7923. if (right == null)
  7924. {
  7925. return Ok(jw);
  7926. }
  7927. HideRows += 4;
  7928. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7929. if (rightBindData != null)
  7930. {
  7931. //经济舱 + 双人间 TBR
  7932. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7933. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7934. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7935. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7936. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7937. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7938. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7939. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7940. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7941. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7942. }
  7943. else
  7944. {
  7945. hideRowsList.Add(Row + startIndex + HideRows);
  7946. }
  7947. HideRows += 2;
  7948. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7949. if (rightBindData != null)
  7950. {
  7951. //经济舱 + 单人间 SGR
  7952. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7953. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7954. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7955. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7956. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7957. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7958. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7959. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7960. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7961. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7962. }
  7963. else
  7964. {
  7965. hideRowsList.Add(Row + startIndex + HideRows);
  7966. }
  7967. HideRows += 2;
  7968. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7969. if (rightBindData != null)
  7970. {
  7971. //公务舱 + 单人间 SGR
  7972. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7973. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7974. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7975. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7976. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7977. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7978. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7979. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7980. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7981. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7982. }
  7983. else
  7984. {
  7985. hideRowsList.Add(Row + startIndex + HideRows);
  7986. }
  7987. HideRows += 2;
  7988. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7989. if (rightBindData != null)
  7990. {
  7991. //公务舱 + 小套房 JSES
  7992. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7993. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7994. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7995. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7996. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7997. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7998. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7999. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8000. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8001. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8002. }
  8003. else
  8004. {
  8005. hideRowsList.Add(Row + startIndex + HideRows);
  8006. }
  8007. HideRows += 2;
  8008. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8009. if (rightBindData != null)
  8010. {
  8011. //公务舱 + 小套房 JSES
  8012. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8013. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8014. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8015. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8016. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8017. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8018. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8019. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8020. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8021. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8022. }
  8023. else
  8024. {
  8025. hideRowsList.Add(Row + startIndex + HideRows);
  8026. }
  8027. HideRows += 2;
  8028. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8029. if (rightBindData != null)
  8030. {
  8031. //经济舱 + 大套房
  8032. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8033. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8034. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8035. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8036. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8037. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8038. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8039. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8040. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8041. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8042. }
  8043. else
  8044. {
  8045. hideRowsList.Add(Row + startIndex + HideRows);
  8046. }
  8047. HideRows += 2;
  8048. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8049. if (rightBindData != null)
  8050. {
  8051. //头等舱 + 小套房 JSES
  8052. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8053. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8054. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8055. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8056. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8057. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8058. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8059. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8060. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8061. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8062. }
  8063. else
  8064. {
  8065. hideRowsList.Add(Row + startIndex + HideRows);
  8066. }
  8067. HideRows += 2;
  8068. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8069. if (rightBindData != null)
  8070. {
  8071. //头等舱 + 大套房
  8072. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8073. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8074. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8075. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8076. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8077. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8078. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8079. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8080. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8081. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8082. }
  8083. else
  8084. {
  8085. hideRowsList.Add(Row + startIndex + HideRows);
  8086. }
  8087. #endregion
  8088. #region B段标题清空
  8089. designer.SetDataSource("CostBDRCB", "");
  8090. designer.SetDataSource("CostBRS", "");
  8091. designer.SetDataSource("CostBXS", "");
  8092. designer.SetDataSource("CostBZCB", "");
  8093. designer.SetDataSource("CostBDRBJ", "");
  8094. designer.SetDataSource("CostBZBJ", "");
  8095. designer.SetDataSource("CostBDRLR", "");
  8096. designer.SetDataSource("CostBZLR", "");
  8097. designer.SetDataSource("CostBDRCBOM", "");
  8098. designer.SetDataSource("CostBRSOM", "");
  8099. designer.SetDataSource("CostBZCBOM", "");
  8100. designer.SetDataSource("CostBDRBJOM", "");
  8101. designer.SetDataSource("CostBZBJOM", "");
  8102. designer.SetDataSource("CostBDRLROM", "");
  8103. designer.SetDataSource("CostBZLROM", "");
  8104. #endregion
  8105. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8106. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8107. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8108. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8109. designer.SetDataSource("DJName", "地接(CNY)");
  8110. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8111. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8112. designer.SetDataSource("GWName", "公务(CNY)");
  8113. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8114. designer.SetDataSource("LYJName", "零用金(CNY)");
  8115. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8116. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8117. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8118. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8119. designer.SetDataSource("BXName", "保险(CNY)");
  8120. designer.SetDataSource("VisaName", "签证(CNY)");
  8121. #region B段基本数据
  8122. if (dto.costType == "B")
  8123. {
  8124. left = dto.leftInfo.Find(x => x.Type == "B");
  8125. if (left == null)
  8126. {
  8127. return Ok(jw);
  8128. }
  8129. #region B段left数据
  8130. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8131. if (leftBindData != null)
  8132. {
  8133. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8134. designer.SetDataSource("BHSRS", leftBindData.rs);
  8135. designer.SetDataSource("BHSXS", leftBindData.xs);
  8136. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8137. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8138. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8139. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8140. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8141. }
  8142. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8143. if (leftBindData != null)
  8144. {
  8145. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8146. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8147. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8148. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8149. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8150. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8151. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8152. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8153. }
  8154. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8155. if (leftBindData != null)
  8156. {
  8157. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8158. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8159. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8160. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8161. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8162. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8163. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8164. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8165. }
  8166. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8167. if (leftBindData != null)
  8168. {
  8169. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8170. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8171. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8172. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8173. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8174. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8175. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8176. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8177. }
  8178. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8179. if (leftBindData != null)
  8180. {
  8181. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8182. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8183. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8184. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8185. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8186. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8187. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8188. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8189. }
  8190. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8191. if (leftBindData != null)
  8192. {
  8193. designer.SetDataSource("BCPCB", leftBindData.cb);
  8194. designer.SetDataSource("BCPRS", leftBindData.rs);
  8195. designer.SetDataSource("BCPXS", leftBindData.xs);
  8196. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8197. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8198. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8199. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8200. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8201. }
  8202. //TBR
  8203. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8204. if (leftBindData != null)
  8205. {
  8206. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8207. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8208. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8209. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8210. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8211. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8212. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8213. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8214. }
  8215. //SGR
  8216. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8217. if (leftBindData != null)
  8218. {
  8219. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8220. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8221. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8222. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8223. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8224. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8225. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8226. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8227. }
  8228. //JS/ES
  8229. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8230. if (leftBindData != null)
  8231. {
  8232. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8233. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8234. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8235. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8236. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8237. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8238. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8239. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8240. }
  8241. //SUITE
  8242. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8243. if (leftBindData != null)
  8244. {
  8245. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8246. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8247. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8248. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8249. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8250. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8251. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8252. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8253. }
  8254. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8255. if (leftBindData != null)
  8256. {
  8257. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8258. designer.SetDataSource("BDJRS", leftBindData.rs);
  8259. designer.SetDataSource("BDJXS", leftBindData.xs);
  8260. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8261. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8262. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8263. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8264. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8265. }
  8266. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8267. if (leftBindData != null)
  8268. {
  8269. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8270. designer.SetDataSource("BGWRS", leftBindData.rs);
  8271. designer.SetDataSource("BGWXS", leftBindData.xs);
  8272. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8273. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8274. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8275. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8276. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8277. }
  8278. #region 优化方案
  8279. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8280. //excelBind.Add("零用金", new {
  8281. //cb="",
  8282. //rs="",
  8283. //xs ="",
  8284. //zcb = "",
  8285. //});
  8286. #endregion
  8287. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8288. if (leftBindData != null)
  8289. {
  8290. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8291. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8292. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8293. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8294. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8295. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8296. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8297. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8298. }
  8299. #endregion
  8300. #region B段Right信息
  8301. right = dto.rightInfo.Find(x => x.Type == "B");
  8302. if (right == null)
  8303. {
  8304. return Ok(jw);
  8305. }
  8306. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8307. if (rightBindData != null)
  8308. {
  8309. //经济舱 + 双人间 TBR
  8310. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8311. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8312. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8313. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8314. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8315. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8316. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8317. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8318. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8319. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8320. }
  8321. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8322. if (rightBindData != null)
  8323. {
  8324. //经济舱 + 单人间 SGR
  8325. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8326. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8327. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8328. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8329. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8330. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8331. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8332. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8333. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8334. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8335. }
  8336. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8337. if (rightBindData != null)
  8338. {
  8339. //公务舱 + 单人间 SGR
  8340. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8341. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8342. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8343. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8344. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8345. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8346. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8347. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8348. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8349. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8350. }
  8351. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8352. if (rightBindData != null)
  8353. {
  8354. //公务舱 + 小套房 JSES
  8355. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8356. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8357. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8358. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8359. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8360. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8361. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8362. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8363. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8364. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8365. }
  8366. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8367. if (rightBindData != null)
  8368. {
  8369. //公务舱 + 小套房 JSES
  8370. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8371. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8372. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8373. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8374. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8375. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8376. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8377. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8378. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8379. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8380. }
  8381. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8382. if (rightBindData != null)
  8383. {
  8384. //经济舱 + 大套房
  8385. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8386. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8387. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8388. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8389. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8390. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8391. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8392. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8393. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8394. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8395. }
  8396. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8397. if (rightBindData != null)
  8398. {
  8399. //头等舱 + 小套房 JSES
  8400. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8401. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8402. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8403. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8404. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8405. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8406. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8407. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8408. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8409. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8410. }
  8411. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8412. if (rightBindData != null)
  8413. {
  8414. //头等舱 + 大套房
  8415. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8416. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8417. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8418. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8419. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8420. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8421. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8422. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8423. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8424. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8425. }
  8426. #endregion
  8427. #region 标题
  8428. designer.SetDataSource("CostBDRCB", "单人成本");
  8429. designer.SetDataSource("CostBRS", "人数");
  8430. designer.SetDataSource("CostBXS", "系数");
  8431. designer.SetDataSource("CostBZCB", "总成本");
  8432. designer.SetDataSource("CostBDRBJ", "单人报价");
  8433. designer.SetDataSource("CostBZBJ", "总报价");
  8434. designer.SetDataSource("CostBDRLR", "单人利润");
  8435. designer.SetDataSource("CostBZLR", "总利润");
  8436. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8437. designer.SetDataSource("CostBRSOM", "人数");
  8438. designer.SetDataSource("CostBZCBOM", "总成本");
  8439. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8440. designer.SetDataSource("CostBZBJOM", "总报价");
  8441. designer.SetDataSource("CostBDRLROM", "单人利润");
  8442. designer.SetDataSource("CostBZLROM", "总利润");
  8443. #endregion
  8444. }
  8445. #endregion
  8446. designer.SetDataSource("TzZCB2", TzZCB2);
  8447. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8448. designer.SetDataSource("TzZLR2", TzZLR2);
  8449. string[] dataSourceKeys = new string[]
  8450. {
  8451. "VF",
  8452. "TGS",
  8453. "TGOF",
  8454. "TGM",
  8455. "TGA",
  8456. "TGTF",
  8457. "TGEF",
  8458. "CFM",
  8459. "CFOF",
  8460. "B",
  8461. "L",
  8462. "D",
  8463. "TBR",
  8464. "SGR",
  8465. "JSES",
  8466. "Suite",
  8467. "TV",
  8468. "1L",
  8469. "IF",
  8470. "EF",
  8471. "BRF",
  8472. "TE",
  8473. "TGT",
  8474. "DRVT",
  8475. "PC",
  8476. "TLF",
  8477. "ECT"
  8478. };
  8479. foreach (var item in dataSourceKeys)
  8480. {
  8481. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8482. if (find != null)
  8483. {
  8484. designer.SetDataSource(item, find.text);
  8485. }
  8486. else
  8487. {
  8488. designer.SetDataSource(item, 0);
  8489. }
  8490. }
  8491. designer.SetDataSource(dt);
  8492. //根据数据源处理生成报表内容
  8493. designer.Process();
  8494. designer.Workbook.Worksheets[0].Name = "清单";
  8495. Worksheet sheet = designer.Workbook.Worksheets[0];
  8496. foreach (var Rowindex in hideRowsList)
  8497. {
  8498. ws.Cells.HideRows(Rowindex, 2);
  8499. }
  8500. byte[] bytes = null;
  8501. string strFileName = di.TeamName + "-团组-成本.xls";
  8502. using (MemoryStream stream = new MemoryStream())
  8503. {
  8504. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8505. bytes = stream.ToArray();
  8506. }
  8507. return Ok(JsonView(true, "", new
  8508. {
  8509. Data = bytes,
  8510. strFileName,
  8511. }));
  8512. }
  8513. /// <summary>
  8514. /// 导出客户报表
  8515. /// </summary>
  8516. /// <returns></returns>
  8517. [HttpPost]
  8518. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8519. {
  8520. var jw = JsonView(false);
  8521. if (dto.Diid == 0)
  8522. {
  8523. return Ok(JsonView(false, "请传递团组id"));
  8524. }
  8525. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8526. if (deleInfo.Code != 0)
  8527. {
  8528. return Ok(JsonView(false, "团组信息查询失败!"));
  8529. }
  8530. var di = deleInfo.Data as DelegationInfoWebView;
  8531. if (di == null)
  8532. {
  8533. return Ok(JsonView(false, "团组信息查询失败!"));
  8534. }
  8535. //文件名
  8536. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8537. //获取模板
  8538. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8539. //载入模板
  8540. Document doc = new Document(tmppath);
  8541. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8542. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8543. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8544. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8545. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8546. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8547. if (AParameter == null)
  8548. {
  8549. return Ok(JsonView(false, "系数不存在!"));
  8550. }
  8551. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8552. , TzAirDesc, TzZCost;
  8553. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8554. = TzAirDesc = TzZCost = string.Empty;
  8555. TzNumber = AParameter.CostTypenumber.ToString();
  8556. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8557. CarGuides1 = dto.CarGuides1;
  8558. Meal = dto.Meal;
  8559. SubsidizedMeals = dto.SubsidizedMeals;
  8560. NightRepair = dto.NightRepair;
  8561. AttractionsTickets = dto.AttractionsTickets;
  8562. MiscellaneousFees = dto.MiscellaneousFees;
  8563. ATip = dto.ATip;
  8564. TzHotelDesc = "";
  8565. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8566. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8567. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8568. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8569. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8570. TzAirDesc = "";
  8571. TzZCost = dto.TzZCost;
  8572. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8573. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8574. var index = 1;
  8575. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8576. foreach (var item in TzHotelDescArr)
  8577. {
  8578. if (AinfoArr != null)
  8579. {
  8580. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8581. if (Ainfo != null)
  8582. {
  8583. if (int.Parse(Ainfo.rs) <= 0)
  8584. {
  8585. continue;
  8586. }
  8587. var hotelText = string.Empty;
  8588. switch (item)
  8589. {
  8590. case "SGR":
  8591. hotelText = "单人间";
  8592. break;
  8593. case "JSES":
  8594. hotelText = "小套房";
  8595. break;
  8596. case "SUITE":
  8597. hotelText = "套房";
  8598. break;
  8599. case "TBR":
  8600. hotelText = "双人间";
  8601. break;
  8602. }
  8603. if (item != "TBR")
  8604. {
  8605. 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";
  8606. }
  8607. else
  8608. {
  8609. 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";
  8610. }
  8611. index++;
  8612. }
  8613. }
  8614. }
  8615. index = 1;
  8616. foreach (var item in TzAirDescArr)
  8617. {
  8618. if (AinfoArr != null)
  8619. {
  8620. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8621. if (Ainfo != null)
  8622. {
  8623. if (int.Parse(Ainfo.rs) <= 0)
  8624. {
  8625. continue;
  8626. }
  8627. 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";
  8628. index++;
  8629. }
  8630. }
  8631. }
  8632. if (dto.costType == "B")
  8633. {
  8634. if (BParameter == null)
  8635. {
  8636. return Ok(JsonView(false, "B段系数不存在!"));
  8637. }
  8638. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8639. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8640. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8641. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8642. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8643. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8644. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8645. foreach (var item in TzHotelDescArr)
  8646. {
  8647. if (AinfoArr != null)
  8648. {
  8649. TzHotelDesc += "B段信息 \r\n";
  8650. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8651. if (Ainfo != null)
  8652. {
  8653. if (int.Parse(Ainfo.rs) <= 0)
  8654. {
  8655. continue;
  8656. }
  8657. var hotelText = string.Empty;
  8658. switch (item)
  8659. {
  8660. case "SGR":
  8661. hotelText = "单人间";
  8662. break;
  8663. case "JSES":
  8664. hotelText = "小套房";
  8665. break;
  8666. case "SUITE":
  8667. hotelText = "套房";
  8668. break;
  8669. case "TBR":
  8670. hotelText = "双人间";
  8671. break;
  8672. }
  8673. if (item != "TBR")
  8674. {
  8675. 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";
  8676. }
  8677. else
  8678. {
  8679. 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";
  8680. }
  8681. index++;
  8682. }
  8683. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8684. }
  8685. }
  8686. index = 1;
  8687. foreach (var item in TzAirDescArr)
  8688. {
  8689. if (AinfoArr != null)
  8690. {
  8691. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8692. if (Ainfo != null)
  8693. {
  8694. if (int.Parse(Ainfo.rs) <= 0)
  8695. {
  8696. continue;
  8697. }
  8698. 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";
  8699. index++;
  8700. }
  8701. }
  8702. }
  8703. }
  8704. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8705. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8706. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8707. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8708. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8709. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8710. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8711. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8712. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8713. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8714. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8715. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8716. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8717. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8718. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8719. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8720. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8721. DickeyValue.Add("TzZCost", TzZCost);
  8722. foreach (var key in DickeyValue.Keys)
  8723. {
  8724. if (doc.Range.Bookmarks[key] != null)
  8725. {
  8726. Bookmark mark = doc.Range.Bookmarks[key];
  8727. mark.Text = DickeyValue[key];
  8728. }
  8729. }
  8730. byte[] bytes = null;
  8731. string strFileName = di.TeamName + "-客户报价.doc";
  8732. using (MemoryStream stream = new MemoryStream())
  8733. {
  8734. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8735. bytes = stream.ToArray();
  8736. }
  8737. return Ok(JsonView(true, "", new
  8738. {
  8739. Data = bytes,
  8740. strFileName,
  8741. }));
  8742. }
  8743. /// <summary>
  8744. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8745. /// </summary>
  8746. /// <param name="dto"></param>
  8747. /// <returns></returns>
  8748. [HttpPost]
  8749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8750. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8751. {
  8752. try
  8753. {
  8754. #region 参数验证
  8755. if (dto.DiId < 0)
  8756. {
  8757. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8758. }
  8759. List<int> cTableIds = new List<int>() {
  8760. 76 ,//酒店预订
  8761. 77 ,//行程
  8762. 79 ,//车/导游地接
  8763. 80 ,//签证
  8764. 81 ,//邀请/公务活
  8765. 82 ,//团组客户保险
  8766. 85 ,//机票预订
  8767. 98 ,//其他款项
  8768. 285 ,//收款退还
  8769. 751 ,//酒店早餐
  8770. 1015 // 超支费用
  8771. };
  8772. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8773. {
  8774. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8775. }
  8776. #endregion
  8777. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8778. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8779. if (_GroupCostParameters.Count <= 0)
  8780. {
  8781. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8782. }
  8783. if (_GroupCostParameters[0].IsShare == 0)
  8784. {
  8785. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8786. }
  8787. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8788. //处理date为空问题
  8789. if (_GroupCosts.Count > 0)
  8790. {
  8791. for (int i = 0; i < _GroupCosts.Count; i++)
  8792. {
  8793. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8794. {
  8795. if (i > 0)
  8796. {
  8797. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8798. }
  8799. }
  8800. }
  8801. }
  8802. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8803. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8804. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8805. string currCode = "";
  8806. #region currCode 验证
  8807. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8808. if (isInt)
  8809. {
  8810. var currData = currDatas.Find(it => it.Id == intCurrency);
  8811. if (currData != null)
  8812. {
  8813. currCode = currData.Name;
  8814. }
  8815. }
  8816. else
  8817. {
  8818. currCode = _GroupCostParameters[0].Currency.Trim();
  8819. }
  8820. #endregion
  8821. //op,酒店单段模式存储
  8822. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8823. {
  8824. CurrencyCode = currCode,
  8825. Rate = _GroupCostParameters[0].Rate,
  8826. CostType = _GroupCostParameters[0].CostType,
  8827. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8828. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8829. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8830. };
  8831. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8832. if (_GroupCostParameters.Count == 2)
  8833. {
  8834. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8835. }
  8836. foreach (var item in _GroupCostParameters)
  8837. {
  8838. decimal _rate = 1;
  8839. decimal _rate1 = item.Rate;
  8840. decimal _scale = 1;
  8841. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8842. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8843. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8844. //if (userInfo != null)
  8845. //{
  8846. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8847. // {
  8848. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8849. // {
  8850. // _scale = 1.00M;
  8851. // }
  8852. // }
  8853. //}
  8854. #endregion
  8855. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8856. {
  8857. CurrencyCode = currCode,
  8858. Rate = _rate1,
  8859. CostType = item.CostType,
  8860. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8861. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8862. CostTypeNumber = item.CostTypenumber
  8863. };
  8864. if (_GroupCostParameters.Count > 1)
  8865. {
  8866. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8867. }
  8868. else
  8869. {
  8870. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8871. }
  8872. if (dto.CTable == 79)//
  8873. {
  8874. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8875. modulePromptInfo.TotalCost = item.DJCB;
  8876. }
  8877. List<string> costTypes = new List<string>() { "A", "B" };
  8878. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8879. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8880. if (_GroupCostsDuplicates.Count() == 1)
  8881. {
  8882. _GroupCostsTypeData = _GroupCosts;
  8883. }
  8884. else
  8885. {
  8886. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8887. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8888. }
  8889. /*
  8890. * 76 酒店预订
  8891. * 77 行程
  8892. * 79 车/导游地接
  8893. * 80 签证
  8894. * 81 邀请/公务活动
  8895. * 82 团组客户保险
  8896. * 85 机票预订
  8897. * 98 其他款项
  8898. * 285 收款退还
  8899. * 751 酒店早餐
  8900. * 1015 超支费用
  8901. */
  8902. switch (dto.CTable)
  8903. {
  8904. case 76: // 酒店预订
  8905. _ModuleSubPromptInfo.AddRange(
  8906. _GroupCostsTypeData.Select(it => new
  8907. {
  8908. it.DAY,
  8909. it.Date,
  8910. it.ACCON,
  8911. it.ITIN,
  8912. it.SGR,
  8913. it.TBR,
  8914. it.JS_ES,
  8915. it.Suite
  8916. })
  8917. );
  8918. break;
  8919. case 79: // 车/导游地接
  8920. _ModuleSubPromptInfo.AddRange(
  8921. _GroupCostsTypeData.Select(it => new
  8922. {
  8923. Date = it.Date, //日期
  8924. CarFee = it.CarCost * _rate * _scale, //车费用
  8925. CarType = it.CarType, //车型
  8926. DriverFee = it.CFS * _rate * _scale, //司机工资
  8927. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8928. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8929. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8930. GuideFee = it.TGS * _rate * _scale, //导游费用
  8931. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8932. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8933. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8934. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8935. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8936. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8937. Breakfast = it.B * _rate * _scale, //早餐费
  8938. Lunch = it.L * _rate * _scale, //午餐费
  8939. Dinner = it.D * _rate * _scale, //晚餐费
  8940. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8941. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8942. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8943. TicketFee = it.EF * _rate * _scale, //门票费
  8944. TicketRemark = it.EFR, //门票费描述
  8945. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8946. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8947. SpentCash = it.PC * _rate * _scale, //零用金
  8948. LeadersFee = it.TLF * _rate * _scale, //领队费
  8949. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8950. })
  8951. );
  8952. break;
  8953. case 85: // 机票
  8954. List<dynamic> datas = new List<dynamic>();
  8955. datas.Add(
  8956. new
  8957. {
  8958. AirType = "经济舱",
  8959. AirNum = item.JJCRS,
  8960. AirDRCB = item.JJCCB,
  8961. AirZCB = (item.JJCRS * item.JJCCB)
  8962. }
  8963. );
  8964. datas.Add(
  8965. new
  8966. {
  8967. AirType = "公务舱",
  8968. AirNum = item.GWCRS,
  8969. AirDRCB = item.GWCCB,
  8970. AirZCB = (item.GWCRS * item.GWCCB)
  8971. }
  8972. );
  8973. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8974. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8975. modulePromptInfo.Data = new
  8976. {
  8977. airFeeData = datas,
  8978. airInitData = initDatas
  8979. };
  8980. _ModulePromptInfos.Add(modulePromptInfo);
  8981. break;
  8982. default:
  8983. break;
  8984. }
  8985. }
  8986. if (dto.CTable != 85)
  8987. {
  8988. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8989. _ModulePromptInfos.Add(_ModulePromptInfo);
  8990. }
  8991. _view.ModulePromptInfos = _ModulePromptInfos;
  8992. return Ok(JsonView(true, "操作成功!", _view));
  8993. }
  8994. catch (Exception ex)
  8995. {
  8996. return Ok(JsonView(false, ex.Message));
  8997. }
  8998. }
  8999. /// <summary>
  9000. /// 根据黑屏代码重新生成行程
  9001. /// </summary>
  9002. /// <param name="dto"></param>
  9003. /// <returns></returns>
  9004. [HttpPost]
  9005. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9006. {
  9007. var jw = JsonView(false);
  9008. var Create = _GroupCostRepository.
  9009. CreateGroupCostByBlackCode(dto.Diid);
  9010. jw.Msg = Create.Msg;
  9011. if (Create.Code == 0)
  9012. {
  9013. jw.Code = 200;
  9014. jw.Data = new
  9015. {
  9016. groupCost = Create.Data,
  9017. blackCodeIsTrue = true
  9018. };
  9019. }
  9020. else
  9021. {
  9022. jw.Code = 400;
  9023. jw.Data = new
  9024. {
  9025. groupCost = Create.Data,
  9026. blackCodeIsTrue = false,
  9027. };
  9028. }
  9029. return Ok(jw);
  9030. }
  9031. /// <summary>
  9032. /// 成本获取OP历史车费用
  9033. /// </summary>
  9034. /// <param name="dto"></param>
  9035. /// <returns></returns>
  9036. [HttpPost]
  9037. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9038. {
  9039. var jw = JsonView(false);
  9040. try
  9041. {
  9042. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9043. //获取现有所有车的数据
  9044. if (!dto.Param.IsNullOrWhiteSpace())
  9045. {
  9046. string sql = $@"
  9047. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9048. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9049. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9050. 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
  9051. AND gctggr.ServiceEndTime is not NULL
  9052. ORDER by gctggrc.id DESC
  9053. ";
  9054. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9055. var numeberResult = await Task.Run(() =>
  9056. {
  9057. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9058. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9059. return numberArr;
  9060. });
  9061. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9062. foreach (var item in numeberResult)
  9063. {
  9064. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9065. {
  9066. Country = "数据异常!",
  9067. City = string.Empty,
  9068. };
  9069. item.Area = find.Country + " " + find.City;
  9070. }
  9071. dbResult.AddRange(numeberResult);
  9072. if (dto.Param.Contains("、"))
  9073. {
  9074. var sp = dto.Param.Split("、");
  9075. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9076. .Where(x =>
  9077. {
  9078. return System.Array.Exists(sp, e =>
  9079. {
  9080. bool where = false;
  9081. if (x.Area != null)
  9082. {
  9083. where = x.Area.Contains(e);
  9084. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9085. {
  9086. return false;
  9087. }
  9088. }
  9089. if (x.PriceName != null && !where)
  9090. {
  9091. where = x.PriceName.Contains(e);
  9092. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9093. {
  9094. return false;
  9095. }
  9096. }
  9097. return where;
  9098. });
  9099. }).ToList();
  9100. }
  9101. else
  9102. {
  9103. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9104. .Where(x =>
  9105. {
  9106. bool where = false;
  9107. if (x.Area != null)
  9108. {
  9109. where = x.Area.Contains(dto.Param);
  9110. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9111. {
  9112. return false;
  9113. }
  9114. }
  9115. if (x.PriceName != null && !where)
  9116. {
  9117. where = x.PriceName.Contains(dto.Param);
  9118. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9119. {
  9120. return false;
  9121. }
  9122. }
  9123. return where;
  9124. }
  9125. )
  9126. .ToList();
  9127. }
  9128. }
  9129. var view = dbResult.Select(x =>
  9130. {
  9131. decimal dp = 0.00M;
  9132. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9133. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9134. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9135. {
  9136. if (startB && endB)
  9137. {
  9138. var timesp = endD.Subtract(startD);
  9139. if ((timesp.Days + 1) != 0)
  9140. {
  9141. dp = x.Price / (timesp.Days + 1);
  9142. }
  9143. }
  9144. }
  9145. else
  9146. {
  9147. dp = x.Price;
  9148. }
  9149. return new
  9150. {
  9151. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9152. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9153. x.Area,
  9154. x.id,
  9155. price = x.Price.ToString("F2"),
  9156. x.PriceName,
  9157. x.PriceContent,
  9158. x.TeamName,
  9159. x.DatePrice,
  9160. dayPrice = dp.ToString("F2"),
  9161. };
  9162. }).OrderByDescending(x => x.id).ToList();
  9163. jw = JsonView(true, "获取成功!", view);
  9164. }
  9165. catch (Exception e)
  9166. {
  9167. jw = JsonView(false, e.Message);
  9168. }
  9169. return Ok(jw);
  9170. }
  9171. #endregion
  9172. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9173. /// <summary>
  9174. /// 酒店预订
  9175. /// 酒店费用列表 根据团组Id查询
  9176. /// </summary>
  9177. /// <param name="_dto"></param>
  9178. /// <returns></returns>
  9179. [HttpPost]
  9180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9181. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9182. {
  9183. #region 参数验证
  9184. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9185. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9186. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9187. #region 团组操作权限验证 76 酒店预定模块
  9188. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9189. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9190. #endregion
  9191. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9192. #region 页面操作权限验证
  9193. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9194. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9195. #endregion
  9196. #endregion
  9197. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9198. }
  9199. /// <summary>
  9200. /// 酒店预订
  9201. /// 基础数据
  9202. /// </summary>
  9203. /// <param name="_dto"></param>
  9204. /// <returns></returns>
  9205. [HttpPost]
  9206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9207. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9208. {
  9209. #region 参数验证
  9210. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9211. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9212. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9213. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9214. #region 页面操作权限验证
  9215. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9216. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9217. #endregion
  9218. #region 团组操作权限验证 76 酒店预定模块
  9219. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9220. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9221. #endregion
  9222. #endregion
  9223. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9224. }
  9225. /// <summary>
  9226. /// 酒店预订
  9227. /// 创建 入住卷号码
  9228. /// </summary>
  9229. /// <param name="_dto"></param>
  9230. /// <returns></returns>
  9231. [HttpPost]
  9232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9233. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9234. {
  9235. #region 参数验证
  9236. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9237. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9238. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9239. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9240. #region 页面操作权限验证
  9241. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9242. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9243. #endregion
  9244. #region 团组操作权限验证 76 酒店预定模块
  9245. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9246. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9247. #endregion
  9248. #endregion
  9249. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9250. if (data.Code != 0)
  9251. {
  9252. return Ok(JsonView(false, data.Msg));
  9253. }
  9254. return Ok(JsonView(true, data.Msg, data.Data));
  9255. }
  9256. /// <summary>
  9257. /// 酒店预订
  9258. /// 详情
  9259. /// </summary>
  9260. /// <param name="_dto"></param>
  9261. /// <returns></returns>
  9262. [HttpPost]
  9263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9264. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9265. {
  9266. #region 参数验证
  9267. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9268. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9269. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9270. #region 团组操作权限验证 76 酒店预定模块
  9271. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9272. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9273. #endregion
  9274. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9275. #region 页面操作权限验证
  9276. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9277. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9278. #endregion
  9279. #endregion
  9280. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9281. }
  9282. /// <summary>
  9283. /// 酒店预订
  9284. /// Add Or Edit
  9285. /// </summary>
  9286. /// <param name="_dto"></param>
  9287. /// <returns></returns>
  9288. [HttpPost]
  9289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9290. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9291. {
  9292. #region 参数验证
  9293. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9294. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9295. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9296. #region 团组操作权限验证 76 酒店预定模块
  9297. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9298. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9299. #endregion
  9300. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9301. #region 页面操作权限验证
  9302. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9303. if (_dto.Id == 0) // Add
  9304. {
  9305. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9306. }
  9307. else if (_dto.Id > 1) // Edit
  9308. {
  9309. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9310. }
  9311. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9312. #endregion
  9313. #endregion
  9314. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9315. if (_view.Code != 200)
  9316. {
  9317. return Ok(_view);
  9318. }
  9319. #region 应用推送
  9320. try
  9321. {
  9322. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9323. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9324. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9325. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9326. //自动审核
  9327. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9328. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9329. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9330. }
  9331. catch (Exception ex)
  9332. {
  9333. }
  9334. #endregion
  9335. return Ok(_view);
  9336. }
  9337. /// <summary>
  9338. /// 酒店自动审核测试
  9339. /// Add Or Edit
  9340. /// </summary>
  9341. /// <param name="_dto"></param>
  9342. /// <returns></returns>
  9343. [HttpPost]
  9344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9345. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9346. {
  9347. #region 应用推送
  9348. try
  9349. {
  9350. //自动审核
  9351. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9352. }
  9353. catch (Exception ex)
  9354. {
  9355. return Ok(JsonView(false, "操作失败"));
  9356. }
  9357. #endregion
  9358. return Ok(JsonView(false, "操作成功"));
  9359. }
  9360. /// <summary>
  9361. /// 酒店预订
  9362. /// Del
  9363. /// </summary>
  9364. /// <param name="_dto"></param>
  9365. /// <returns></returns>
  9366. [HttpPost]
  9367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9368. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9369. {
  9370. #region 参数验证
  9371. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9372. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9373. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9374. #region 团组操作权限验证 76 酒店预定模块
  9375. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9376. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9377. #endregion
  9378. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9379. #region 页面操作权限验证
  9380. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9381. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9382. #endregion
  9383. #endregion
  9384. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9385. }
  9386. /// <summary>
  9387. /// 酒店预订
  9388. /// 生成VOUCHER
  9389. /// 2024.05.06 之前版本
  9390. /// </summary>
  9391. /// <param name="_dto"></param>
  9392. /// <returns></returns>
  9393. [HttpPost]
  9394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9395. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9396. {
  9397. try
  9398. {
  9399. #region 参数验证
  9400. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9401. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9402. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9403. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9404. #region 团组操作权限验证 76 酒店预定模块
  9405. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9406. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9407. #endregion
  9408. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9409. #region 页面操作权限验证
  9410. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9411. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9412. #endregion
  9413. #endregion
  9414. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9415. //判断数据是否完整
  9416. if (hr != null)
  9417. {
  9418. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9419. {
  9420. string strFileName = "HotelStatement/";
  9421. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9422. if (dele != null)
  9423. strFileName += dele.TourCode;
  9424. //载入模板
  9425. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9426. Document doc = new Document(sss);
  9427. DocumentBuilder builder = new DocumentBuilder(doc);
  9428. #region 替换Word模板书签内容
  9429. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9430. //入住卷预定号码
  9431. if (doc.Range.Bookmarks["VNO"] != null)
  9432. {
  9433. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9434. mark.Text = hr.CheckNumber;
  9435. }
  9436. //酒店时间
  9437. if (doc.Range.Bookmarks["Date"] != null)
  9438. {
  9439. Bookmark mark = doc.Range.Bookmarks["Date"];
  9440. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9441. }
  9442. //团号
  9443. if (doc.Range.Bookmarks["TNo"] != null)
  9444. {
  9445. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9446. mark.Text = dele.TourCode;
  9447. }
  9448. //预定号码
  9449. if (doc.Range.Bookmarks["BookingId"] != null)
  9450. {
  9451. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9452. mark.Text = hr.ReservationsNo;
  9453. }
  9454. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9455. {
  9456. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9457. mark.Text = hr.DetermineNo;
  9458. }
  9459. //酒店城市
  9460. if (doc.Range.Bookmarks["City"] != null)
  9461. {
  9462. Bookmark mark = doc.Range.Bookmarks["City"];
  9463. mark.Text = hr.City;
  9464. }
  9465. //酒店名称
  9466. if (doc.Range.Bookmarks["HName"] != null)
  9467. {
  9468. Bookmark mark = doc.Range.Bookmarks["HName"];
  9469. mark.Text = hr.HotelName;
  9470. }
  9471. //酒店地址
  9472. if (doc.Range.Bookmarks["Address"] != null)
  9473. {
  9474. Bookmark mark = doc.Range.Bookmarks["Address"];
  9475. mark.Text = hr.HotelAddress;
  9476. }
  9477. //酒店电话
  9478. if (doc.Range.Bookmarks["Tel"] != null)
  9479. {
  9480. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9481. mark.Text = hr.HotelTel;
  9482. }
  9483. //酒店传真
  9484. if (doc.Range.Bookmarks["Fax"] != null)
  9485. {
  9486. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9487. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9488. {
  9489. mark.Text = hr.HotelFax;
  9490. }
  9491. }
  9492. //入住时间
  9493. if (doc.Range.Bookmarks["CIn"] != null)
  9494. {
  9495. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9496. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9497. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9498. }
  9499. //退房时间
  9500. if (doc.Range.Bookmarks["COut"] != null)
  9501. {
  9502. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9503. Bookmark mark = doc.Range.Bookmarks["COut"];
  9504. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9505. }
  9506. //客户名称
  9507. if (doc.Range.Bookmarks["GName"] != null)
  9508. {
  9509. string guestName = "";
  9510. string[] clients = new string[] { };
  9511. if (hr.GuestName.Contains(","))
  9512. {
  9513. clients = hr.GuestName.Split(",");
  9514. }
  9515. else
  9516. {
  9517. clients = new string[] { hr.GuestName };
  9518. }
  9519. List<int> clientIds_int = new List<int>();
  9520. if (clients.Length > 0)
  9521. {
  9522. foreach (var item in clients)
  9523. {
  9524. if (item.IsNumeric())
  9525. {
  9526. clientIds_int.Add(int.Parse(item));
  9527. }
  9528. }
  9529. }
  9530. if (clientIds_int.Count > 0)
  9531. {
  9532. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9533. foreach (var client in _clientDatas)
  9534. {
  9535. //男
  9536. if (client.Sex == 0) guestName += $"Mr.";
  9537. //女
  9538. else if (client.Sex == 1) guestName += $"Ms.";
  9539. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9540. {
  9541. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9542. }
  9543. //guestName += $"{client.Pinyin},";
  9544. }
  9545. if (guestName.Length > 0)
  9546. {
  9547. guestName = guestName.Substring(0, guestName.Length - 1);
  9548. }
  9549. }
  9550. else
  9551. {
  9552. guestName = hr.GuestName;
  9553. }
  9554. Bookmark mark = doc.Range.Bookmarks["GName"];
  9555. mark.Text = guestName;
  9556. }
  9557. //房间介绍
  9558. if (doc.Range.Bookmarks["ROOM"] != null)
  9559. {
  9560. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9561. mark.Text = hr.RoomExplanation;
  9562. }
  9563. //报价描述
  9564. if (doc.Range.Bookmarks["NOTE"] != null)
  9565. {
  9566. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9567. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9568. if (ss != null)
  9569. mark.Text = ss.Name;
  9570. }
  9571. //入住时间
  9572. if (doc.Range.Bookmarks["CheckIn"] != null)
  9573. {
  9574. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9575. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9576. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9577. }
  9578. //退房时间
  9579. if (doc.Range.Bookmarks["CheckOut"] != null)
  9580. {
  9581. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9582. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9583. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9584. }
  9585. //日期
  9586. if (doc.Range.Bookmarks["DT"] != null)
  9587. {
  9588. Bookmark mark = doc.Range.Bookmarks["DT"];
  9589. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9590. }
  9591. //名称
  9592. if (doc.Range.Bookmarks["VName"] != null)
  9593. {
  9594. Bookmark mark = doc.Range.Bookmarks["VName"];
  9595. mark.Text = hr.HotelName;
  9596. }
  9597. //号码
  9598. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9599. {
  9600. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9601. mark.Text = hr.CheckNumber;
  9602. }
  9603. #endregion
  9604. strFileName += "VOUCHER.doc";
  9605. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9606. doc.Save(fileDir);
  9607. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9608. return Ok(JsonView(true, "操作成功!", Url));
  9609. }
  9610. else
  9611. {
  9612. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9613. }
  9614. }
  9615. else
  9616. {
  9617. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9618. }
  9619. }
  9620. catch (Exception ex)
  9621. {
  9622. return Ok(JsonView(false, ex.Message));
  9623. }
  9624. }
  9625. /// <summary>
  9626. /// 酒店预订
  9627. /// 生成VOUCHER
  9628. /// 2024.05.06 之后版本
  9629. /// </summary>
  9630. /// <param name="_dto"></param>
  9631. /// <returns></returns>
  9632. [HttpPost]
  9633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9634. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9635. {
  9636. #region 参数验证
  9637. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9638. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9639. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9640. #region 团组操作权限验证 76 酒店预定模块
  9641. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9642. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9643. #endregion
  9644. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9645. #region 页面操作权限验证
  9646. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9647. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9648. #endregion
  9649. #endregion
  9650. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9651. //判断数据是否完整
  9652. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9653. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9654. string strFileName = "HotelStatement/";
  9655. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9656. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9657. #region 数据处理
  9658. List<int> guestIds = new List<int>();
  9659. int index = 0;
  9660. foreach (var item in hrDtas)
  9661. {
  9662. if (item.GuestName.Contains(","))
  9663. {
  9664. string[] guestIdArr = item.GuestName.Split(',');
  9665. foreach (var guestIdStr in guestIdArr)
  9666. {
  9667. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9668. if (guestBool)
  9669. {
  9670. guestIds.Add(guestId);
  9671. }
  9672. }
  9673. }
  9674. else guestNames += item.GuestName;
  9675. var voucherInfo = new HotelVoucherInfoView()
  9676. {
  9677. HotelName = item.HotelName,
  9678. CheckInDate = item.CheckInDate,
  9679. CheckOutDate = item.CheckOutDate,
  9680. ConfirmationNumber = item.DetermineNo.Trim(),
  9681. RoomType = item.RoomExplanation
  9682. };
  9683. vouchers.Add(voucherInfo);
  9684. }
  9685. if (guestIds.Count > 0)
  9686. {
  9687. guestIds = guestIds.Distinct().ToList();
  9688. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9689. if (guestDatas.Count > 0)
  9690. {
  9691. guestNames = "";
  9692. foreach (var guest in guestDatas)
  9693. {
  9694. string guestName = "";
  9695. if (guest.Sex == 0) guestName += @"MR.";
  9696. else if (guest.Sex == 1) guestName += @"MS.";
  9697. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9698. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9699. guestNames += @$"{guestName.Trim()}、";
  9700. }
  9701. if (guestNames.Length > 0)
  9702. {
  9703. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9704. }
  9705. }
  9706. }
  9707. #endregion
  9708. //载入模板
  9709. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9710. Document doc = new Document(sss);
  9711. DocumentBuilder builder = new DocumentBuilder(doc);
  9712. if (doc.Range.Bookmarks["GuestName"] != null)
  9713. {
  9714. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9715. mark.Text = guestNames;
  9716. }
  9717. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9718. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9719. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9720. for (int i = 1; i <= vouchers.Count; i++)
  9721. {
  9722. HotelVoucherInfoView hviv = vouchers[i - 1];
  9723. builder.MoveToCell(0, i, 0, 0);
  9724. builder.Write(hviv.HotelName);
  9725. builder.MoveToCell(0, i, 1, 0);
  9726. builder.Write(hviv.CheckInDate);
  9727. builder.MoveToCell(0, i, 2, 0);
  9728. builder.Write(hviv.CheckOutDate);
  9729. builder.MoveToCell(0, i, 3, 0);
  9730. builder.Write(hviv.RoomType);
  9731. builder.MoveToCell(0, i, 4, 0);
  9732. builder.Write(hviv.ConfirmationNumber);
  9733. }
  9734. //删除多余行
  9735. int currRowIndex = vouchers.Count + 1;
  9736. int delRows = 21 - currRowIndex;
  9737. if (delRows > 0)
  9738. {
  9739. for (int i = 0; i < delRows; i++)
  9740. {
  9741. table.Rows.RemoveAt(currRowIndex);
  9742. //cultivateRowIndex++;
  9743. }
  9744. }
  9745. strFileName += "VOUCHER.docx";
  9746. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9747. doc.Save(fileDir);
  9748. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9749. return Ok(JsonView(true, "操作成功!", Url));
  9750. }
  9751. /// <summary>
  9752. /// 酒店预订
  9753. /// 生成VOUCHER 批量生成
  9754. /// New
  9755. /// </summary>
  9756. /// <param name="_dto"></param>
  9757. /// <returns></returns>
  9758. [HttpPost]
  9759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9760. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9761. {
  9762. #region 参数验证
  9763. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9764. if (_dto.PageId < 1) _dto.PageId = 28;
  9765. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9766. #region 团组操作权限验证 76 酒店预定模块
  9767. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9768. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9769. #endregion
  9770. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9771. #region 页面操作权限验证
  9772. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9773. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9774. #endregion
  9775. #endregion
  9776. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9777. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9778. .OrderBy(x => x.CheckInDate)
  9779. .ToListAsync();
  9780. //判断数据是否完整
  9781. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9782. string strFileName = "HotelStatement/";
  9783. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9784. if (dele != null)
  9785. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9786. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9787. for (int i = 0; i < hrDtas.Count; i++)
  9788. {
  9789. string guestNames = string.Empty;
  9790. List<int> guestIds = new List<int>();
  9791. var item = hrDtas[i];
  9792. //处理客户姓名
  9793. if (item.GuestName.Contains(","))
  9794. {
  9795. string[] guestIdArr = item.GuestName.Split(',');
  9796. foreach (var guestIdStr in guestIdArr)
  9797. if (int.TryParse(guestIdStr, out int guestId))
  9798. guestIds.Add(guestId);
  9799. }
  9800. else
  9801. {
  9802. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  9803. if (guestIdBool)
  9804. {
  9805. guestIds.Add(guestId);
  9806. }
  9807. //NaN
  9808. if (item.GuestName.Contains("NaN"))
  9809. {
  9810. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9811. }
  9812. }
  9813. if (guestIds.Count > 0)
  9814. {
  9815. guestIds = guestIds.Distinct().ToList();
  9816. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9817. if (guestDatas1.Count > 0)
  9818. {
  9819. guestNames = "";
  9820. foreach (var guest in guestDatas1)
  9821. {
  9822. string guestName = "";
  9823. if (guest.Sex == 0) guestName += @"MR.";
  9824. else if (guest.Sex == 1) guestName += @"MS.";
  9825. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9826. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9827. guestNames += @$"{guestName.Trim()}、";
  9828. }
  9829. if (guestNames.Length > 0)
  9830. {
  9831. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9832. }
  9833. }
  9834. }
  9835. //if (!string.IsNullOrEmpty(guestNames))
  9836. //{
  9837. hrDtas[i].GuestName = guestNames;
  9838. //}
  9839. }
  9840. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9841. Document doc = new Document();
  9842. DocumentBuilder builder = new DocumentBuilder(doc);
  9843. try
  9844. {
  9845. builder.MoveToDocumentStart();
  9846. foreach (var item in hrDtas)
  9847. {
  9848. //标题
  9849. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9850. builder.ParagraphFormat.LineSpacing = 1;
  9851. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9852. builder.ParagraphFormat.Style.Font.Size = 9;
  9853. builder.ParagraphFormat.Style.Font.Bold = true;
  9854. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9855. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9856. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9857. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9858. builder.ParagraphFormat.LineSpacing = 1;
  9859. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9860. builder.ParagraphFormat.Style.Font.Size = 9;
  9861. builder.ParagraphFormat.Style.Font.Bold = true;
  9862. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9863. builder.StartTable();
  9864. // 设置边框颜色
  9865. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9866. //设置边框样式
  9867. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9868. //表格
  9869. #region 第一行
  9870. builder.InsertCell();
  9871. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9872. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9873. //builder.CellFormat.AllowAutoFit = false;
  9874. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9875. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9876. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9877. builder.CellFormat.WrapText = true; //自动换行
  9878. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9879. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  9880. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9881. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9882. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9883. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9884. builder.Write("TOUR NO:");
  9885. builder.InsertCell();
  9886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9887. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9888. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9889. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9890. builder.ParagraphFormat.Style.Font.Bold = false;
  9891. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9892. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9893. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9894. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9895. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9896. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9897. builder.Write($"{dele?.TourCode ?? "-"}");
  9898. builder.InsertCell();
  9899. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9900. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9901. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9902. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9903. builder.ParagraphFormat.Style.Font.Bold = false;
  9904. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9905. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9906. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9907. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9908. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9909. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9910. builder.Write($"CITY:");
  9911. builder.InsertCell();
  9912. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9913. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9914. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9915. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9916. builder.ParagraphFormat.Style.Font.Bold = false;
  9917. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9918. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9919. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9920. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9921. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9922. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9923. builder.Write($"{item.City}");
  9924. builder.EndRow();
  9925. #endregion
  9926. #region 第二行
  9927. builder.InsertCell();
  9928. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9929. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9930. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9931. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9932. builder.ParagraphFormat.Style.Font.Bold = false;
  9933. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9934. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9935. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9936. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9937. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9938. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9939. builder.Write("CONFIRMATION NO:");
  9940. builder.InsertCell();
  9941. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9942. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9943. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9944. builder.ParagraphFormat.Style.Font.Bold = false;
  9945. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9946. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9947. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9948. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9949. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9950. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9951. builder.CellFormat.VerticalMerge = CellMerge.None;
  9952. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9953. builder.Write($"{item.DetermineNo}");
  9954. builder.InsertCell();
  9955. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9956. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9957. builder.InsertCell();
  9958. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9959. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9960. builder.EndRow();
  9961. #endregion
  9962. #region 第三行
  9963. builder.InsertCell();
  9964. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9965. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9966. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9967. builder.ParagraphFormat.Style.Font.Bold = false;
  9968. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9969. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9970. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9971. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9972. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9973. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9974. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9975. builder.Write($"HOTEL NAME:");
  9976. builder.InsertCell();
  9977. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9978. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9979. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9980. builder.ParagraphFormat.Style.Font.Bold = false;
  9981. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9982. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9983. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9984. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9985. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9986. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9987. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9988. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9989. builder.Write($"{item.HotelName}");
  9990. builder.InsertCell();
  9991. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9992. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9993. builder.InsertCell();
  9994. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9995. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9996. builder.EndRow();
  9997. #endregion
  9998. #region 第四行
  9999. builder.InsertCell();
  10000. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10001. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10002. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10003. builder.ParagraphFormat.Style.Font.Bold = false;
  10004. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10005. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10006. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10007. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10008. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10009. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10010. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10011. builder.Write($"HOTEL ADDRESS:");
  10012. builder.InsertCell();
  10013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10014. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10015. builder.ParagraphFormat.Style.Font.Size = 8;
  10016. builder.ParagraphFormat.Style.Font.Bold = false;
  10017. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10018. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10019. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10020. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10021. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10022. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10023. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10024. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10025. builder.Write($"{item.HotelAddress}");
  10026. builder.InsertCell();
  10027. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10028. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10029. builder.InsertCell();
  10030. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10031. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10032. builder.EndRow();
  10033. #endregion
  10034. #region 第五行
  10035. builder.InsertCell();
  10036. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10037. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10038. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10039. builder.ParagraphFormat.Style.Font.Bold = false;
  10040. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10041. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10042. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10043. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10044. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10045. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10046. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10047. builder.Write("TEL:");
  10048. builder.InsertCell();
  10049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10050. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10051. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10052. builder.ParagraphFormat.Style.Font.Bold = false;
  10053. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10054. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10055. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10056. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10057. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10058. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10059. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10060. builder.Write($"{item.HotelTel}");
  10061. builder.InsertCell();
  10062. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10063. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10064. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10065. builder.ParagraphFormat.Style.Font.Bold = false;
  10066. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10067. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10068. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10069. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10070. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10071. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10072. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10073. builder.Write($"FAX:");
  10074. builder.InsertCell();
  10075. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10076. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10077. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10078. builder.ParagraphFormat.Style.Font.Bold = false;
  10079. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10080. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10081. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10082. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10083. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10084. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10085. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10086. builder.Write($"{item.HotelFax}");
  10087. builder.EndRow();
  10088. #endregion
  10089. #region 第六行
  10090. builder.InsertCell();
  10091. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10092. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10093. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10094. builder.ParagraphFormat.Style.Font.Bold = false;
  10095. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10096. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10097. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10098. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10099. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10100. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10101. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10102. builder.Write("CHECK IN:");
  10103. builder.InsertCell();
  10104. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10105. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10106. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10107. builder.ParagraphFormat.Style.Font.Bold = false;
  10108. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10109. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10110. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10111. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10112. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10113. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10114. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10115. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10116. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10117. builder.Write($"{checkInStr}");
  10118. builder.InsertCell();
  10119. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10120. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10121. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10122. builder.ParagraphFormat.Style.Font.Bold = false;
  10123. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10124. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10125. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10126. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10127. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10128. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10129. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10130. builder.Write($"CHECK OUT:");
  10131. builder.InsertCell();
  10132. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10133. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10134. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10135. builder.ParagraphFormat.Style.Font.Bold = false;
  10136. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10137. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10138. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10139. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10140. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10141. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10142. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10143. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10144. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10145. builder.Write($"{checkOutStr}");
  10146. builder.EndRow();
  10147. #endregion
  10148. #region 第七行
  10149. builder.InsertCell();
  10150. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10151. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10152. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10153. builder.ParagraphFormat.Style.Font.Bold = false;
  10154. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10155. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10156. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10157. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10158. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10159. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10160. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10161. builder.Write($"GUEST NAME:");
  10162. builder.InsertCell();
  10163. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10164. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10165. builder.ParagraphFormat.Style.Font.Size = 8;
  10166. builder.ParagraphFormat.Style.Font.Bold = false;
  10167. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10168. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10169. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10170. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10171. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10172. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10173. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10174. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10175. builder.Write($"{item.GuestName}");
  10176. builder.InsertCell();
  10177. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10178. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10179. builder.InsertCell();
  10180. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10181. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10182. builder.EndRow();
  10183. #endregion
  10184. #region 第八行
  10185. builder.InsertCell();
  10186. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10187. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10188. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10189. builder.ParagraphFormat.Style.Font.Bold = false;
  10190. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10191. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10192. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10193. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10194. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10195. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10196. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10197. builder.Write($"ROOM TYPE:");
  10198. builder.InsertCell();
  10199. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10200. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10201. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10202. builder.ParagraphFormat.Style.Font.Bold = false;
  10203. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10204. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10205. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10206. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10207. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10208. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10209. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10210. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10211. builder.Write($"{item.RoomExplanation}");
  10212. builder.InsertCell();
  10213. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10214. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10215. builder.InsertCell();
  10216. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10217. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10218. builder.EndRow();
  10219. #endregion
  10220. #region 第九行
  10221. builder.InsertCell();
  10222. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10223. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10224. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10225. builder.ParagraphFormat.Style.Font.Bold = false;
  10226. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10227. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10228. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10229. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10230. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10231. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10232. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10233. builder.Write($"NOTE:");
  10234. builder.InsertCell();
  10235. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10236. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10237. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10238. builder.ParagraphFormat.Style.Font.Bold = false;
  10239. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10240. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10241. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10242. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10243. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  10244. builder.InsertCell();
  10245. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10246. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10247. builder.InsertCell();
  10248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10249. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10250. builder.EndRow();
  10251. #endregion
  10252. builder.EndTable();
  10253. //换行
  10254. builder.Writeln("");
  10255. builder.Writeln("");
  10256. }
  10257. #region 获取文档中的所有表格 设置文字自适应
  10258. // 获取文档中的所有表格。
  10259. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10260. {
  10261. // 遍历表格中的所有行。
  10262. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10263. {
  10264. foreach (Cell cell in row.Cells)
  10265. {
  10266. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10267. cellFormat.Width = 0;
  10268. }
  10269. }
  10270. }
  10271. #endregion
  10272. #region 设置页眉
  10273. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10274. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10275. if (System.IO.File.Exists(voucherHeaderPath))
  10276. {
  10277. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10278. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10279. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10280. Shape shape = builder.InsertImage(imageBytes);
  10281. // 调整图片位置
  10282. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10283. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10284. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10285. shape.Left = 0; // 将图片距离页面左边缘的距离
  10286. shape.Width = 81; // 设置图片宽度
  10287. shape.Height = 36; // 设置图片高度
  10288. }
  10289. //靠右
  10290. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10291. //// 设置页脚上下边距
  10292. //builder.PageSetup.HeaderDistance = 42;
  10293. // 添加页眉线
  10294. Aspose.Words.Border borderHeader = null;
  10295. try
  10296. {
  10297. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10298. }
  10299. catch (Exception e)
  10300. {
  10301. // TODO Auto-generated catch block
  10302. //e.printStackTrace();
  10303. }
  10304. borderHeader.Shadow = true;
  10305. borderHeader.DistanceFromText = 2;
  10306. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10307. #endregion
  10308. }
  10309. catch (Exception ex)
  10310. {
  10311. }
  10312. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10313. doc.Save(fileDir);
  10314. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10315. return Ok(JsonView(true, "操作成功!", Url));
  10316. }
  10317. /// <summary>
  10318. /// 酒店预订
  10319. /// 生成 预定成本 Excel
  10320. /// </summary>
  10321. /// <param name="_dto"></param>
  10322. /// <returns></returns>
  10323. [HttpPost]
  10324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10325. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10326. {
  10327. #region 参数验证
  10328. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10329. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10330. if (!vadalitorRes.IsValid)
  10331. {
  10332. var errors = new StringBuilder();
  10333. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10334. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10335. }
  10336. #region 团组操作权限验证 76 酒店预定模块
  10337. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10338. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10339. #endregion
  10340. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10341. #region 页面操作权限验证
  10342. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10343. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10344. #endregion
  10345. #endregion
  10346. decimal _rate = 1.00M;
  10347. string _currency = "";
  10348. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10349. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10350. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10351. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10352. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10353. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10354. {
  10355. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10356. }
  10357. _currency = _GroupCostParameter.Currency;
  10358. bool isIntType = int.TryParse(_currency, out int currId);
  10359. if (isIntType)
  10360. {
  10361. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10362. }
  10363. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10364. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10365. if (currInfo == null)
  10366. {
  10367. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10368. }
  10369. if (!_currency.ToUpper().Equals("CNY"))
  10370. {
  10371. _rate = _GroupCostParameter.Rate;
  10372. }
  10373. _rate = currInfo.Rate;
  10374. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10375. string strFileName = "HotelStatement/";
  10376. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10377. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10378. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10379. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10380. #region 数据处理
  10381. foreach (var item in hrDtas)
  10382. {
  10383. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10384. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10385. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10386. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10387. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10388. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10389. string singleRoomFeeStr = string.Empty,
  10390. doubleRoomFeeStr = string.Empty,
  10391. suiteRoomFeeStr = string.Empty,
  10392. otherRoomFeeStr = string.Empty,
  10393. payMoneyStr = string.Empty,
  10394. cardPriceStr = string.Empty;
  10395. if (roomCurr.Equals(_currency))
  10396. {
  10397. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10398. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10399. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10400. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10401. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10402. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10403. }
  10404. else
  10405. {
  10406. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10407. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10408. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10409. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10410. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10411. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10412. }
  10413. string breakfastPriceStr = string.Empty,
  10414. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10415. governmentRentStr = string.Empty,
  10416. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10417. cityTaxStrStr = string.Empty,
  10418. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10419. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10420. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10421. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10422. int payDId = roomInfo?.PayDId ?? 0;
  10423. pcfds.Add(new HotelReservations_PCFD_View()
  10424. {
  10425. City = item.City,
  10426. HotelName = item.HotelName,
  10427. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10428. // SingleRoomCount = item.SingleRoomCount,
  10429. SingleRoomPrice = singleRoomFeeStr,
  10430. // DoubleRoomCount = item.DoubleRoomCount,
  10431. DoubleRoomPrice = doubleRoomFeeStr,
  10432. //SuiteRoomCount = item.SuiteRoomCount,
  10433. SuiteRoomPrice = suiteRoomFeeStr,
  10434. OtherRoomPrice = otherRoomFeeStr,
  10435. //OtherRoomCount = item.OtherRoomCount,
  10436. BreakfastPrice = breakfastPriceStr,
  10437. GovernmentRent = governmentRentStr,
  10438. CityTax = cityTaxStrStr,
  10439. RoomExplanation = item.RoomExplanation,
  10440. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10441. PayTime = roomInfo?.ConsumptionDate,
  10442. BankNo = roomInfo?.BankNo,
  10443. PayMoney = payMoneyStr,
  10444. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10445. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10446. CardPrice = cardPriceStr,
  10447. Remark = ccpInfo.Remark
  10448. });
  10449. }
  10450. #endregion
  10451. //载入模板
  10452. WorkbookDesigner designer = new WorkbookDesigner();
  10453. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10454. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10455. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10456. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10457. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10458. designer.SetDataSource("Opertor", userInfo.CnName);
  10459. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10460. dt.TableName = "ViewMyHotelReservations";
  10461. designer.SetDataSource(dt);
  10462. designer.Process();
  10463. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10464. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10465. designer.Workbook.Save(serverPath);
  10466. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10467. #region 删除指定行
  10468. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10469. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10470. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10471. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10472. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10473. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10474. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10475. cssIndex = dt.Columns["CityTax"].Ordinal,
  10476. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10477. remarkIndex = dt.Columns["Remark"].Ordinal;
  10478. //删除指定列
  10479. foreach (DataRow item in dt.Rows)
  10480. {
  10481. string singleStr = item["SingleRoomPrice"].ToString();
  10482. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10483. if (containsDigitButNotZero1) singleDel = false;
  10484. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10485. string doubleStr = item["DoubleRoomPrice"].ToString();
  10486. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10487. if (containsDigitButNotZero2) doubleDel = false;
  10488. string suiteStr = item["SuiteRoomPrice"].ToString();
  10489. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10490. if (containsDigitButNotZero3) suiteDel = false;
  10491. string otherStr = item["OtherRoomPrice"].ToString();
  10492. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10493. if (containsDigitButNotZero4) otherDel = false;
  10494. string zcStr = item["BreakfastPrice"].ToString();
  10495. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10496. if (containsDigitButNotZero5) zcDel = false;
  10497. string dsStr = item["GovernmentRent"].ToString();
  10498. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10499. if (containsDigitButNotZero6) dsDel = false;
  10500. string cssStr = item["CityTax"].ToString();
  10501. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10502. if (containsDigitButNotZero7) cssDel = false;
  10503. string cpStr = item["ConsumptionPatterns"].ToString();
  10504. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10505. string remarkStr = item["Remark"].ToString();
  10506. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10507. }
  10508. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10509. DeleteColumn(serverPath, cpIndex, cpDel);
  10510. DeleteColumn(serverPath, dsIndex, dsDel);
  10511. DeleteColumn(serverPath, cssIndex, cssDel);
  10512. DeleteColumn(serverPath, zcIndex, zcDel);
  10513. DeleteColumn(serverPath, otherIndex, otherDel);
  10514. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10515. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10516. DeleteColumn(serverPath, singleIndex, singleDel);
  10517. #endregion
  10518. //只保留第一个表格
  10519. DeleteSheet(serverPath);
  10520. return Ok(JsonView(true, "操作成功", url = rst));
  10521. }
  10522. /// <summary>
  10523. /// 删除指定列
  10524. /// </summary>
  10525. /// <param name="file"></param>
  10526. /// <param name="columnIndex"></param>
  10527. /// <param name="isDel"></param>
  10528. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10529. {
  10530. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10531. //wb.Save(file);
  10532. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10533. if (sheet1 != null)
  10534. {
  10535. if (isDel)
  10536. {
  10537. Cells cells = sheet1.Cells;
  10538. cells.DeleteColumn(columnIndex);
  10539. }
  10540. }
  10541. wb.Save(file);
  10542. }
  10543. /// <summary>
  10544. /// 删除sheet
  10545. /// </summary>
  10546. /// <param name="file"></param>
  10547. /// <param name="sheetName"></param>
  10548. private void DeleteSheet(string file, string sheetName = "")
  10549. {
  10550. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10551. //wb.Save(file);
  10552. List<string> sheets = new List<string>();
  10553. foreach (var item in wb.Worksheets)
  10554. {
  10555. sheets.Add(item.Name);
  10556. }
  10557. if (sheets.Count > 0)
  10558. {
  10559. sheets.RemoveAt(0);//不删除第一个sheet
  10560. foreach (var item in sheets)
  10561. {
  10562. wb.Worksheets.RemoveAt(item);
  10563. }
  10564. }
  10565. wb.Save(file);
  10566. }
  10567. /// <summary>
  10568. /// 酒店预订
  10569. /// 确认单
  10570. /// </summary>
  10571. /// <param name="_dto"></param>
  10572. /// <returns></returns>
  10573. [HttpPost]
  10574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10575. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10576. {
  10577. try
  10578. {
  10579. #region 参数验证
  10580. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10581. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10582. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10583. #region 团组操作权限验证 76 酒店预定模块
  10584. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10585. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10586. #endregion
  10587. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10588. #region 页面操作权限验证
  10589. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10590. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10591. #endregion
  10592. #endregion
  10593. //团组信息
  10594. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10595. //酒店数据
  10596. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10597. if (listhoteldata.Count < 0)
  10598. {
  10599. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10600. }
  10601. //利datatable存储
  10602. DataTable dt = new DataTable();
  10603. dt.Columns.Add("CheckInDate", typeof(string));
  10604. dt.Columns.Add("City", typeof(string));
  10605. dt.Columns.Add("Hotel", typeof(string));
  10606. dt.Columns.Add("Room", typeof(string));
  10607. for (int i = 0; i < listhoteldata.Count; i++)
  10608. {
  10609. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10610. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10611. while (dayStart < dayEnd)
  10612. {
  10613. string temp = "";
  10614. DataRow row = dt.NewRow();
  10615. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10616. row["City"] = listhoteldata[i].City;
  10617. row["Hotel"] = listhoteldata[i].HotelName;
  10618. if (listhoteldata[i].SingleRoomCount > 0)
  10619. {
  10620. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10621. }
  10622. if (listhoteldata[i].DoubleRoomCount > 0)
  10623. {
  10624. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10625. }
  10626. if (listhoteldata[i].SuiteRoomCount > 0)
  10627. {
  10628. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10629. }
  10630. if (listhoteldata[i].OtherRoomCount > 0)
  10631. {
  10632. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10633. }
  10634. row["Room"] = temp;
  10635. dt.Rows.Add(row);
  10636. dayStart = dayStart.AddDays(1);
  10637. }
  10638. }
  10639. Dictionary<string, string> dic = new Dictionary<string, string>();
  10640. dic.Add("Dele", di.TeamName);
  10641. dic.Add("City", di.VisitCountry);
  10642. //模板路径
  10643. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10644. //载入模板
  10645. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10646. DocumentBuilder builder = new DocumentBuilder(doc);
  10647. foreach (var key in dic.Keys)
  10648. {
  10649. builder.MoveToBookmark(key);
  10650. builder.Write(dic[key]);
  10651. }
  10652. //获取word里所有表格
  10653. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10654. //获取所填表格的序数
  10655. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10656. var rowStart = tableOne.Rows[0]; //获取第1行
  10657. //循环赋值
  10658. for (int i = 0; i < dt.Rows.Count; i++)
  10659. {
  10660. builder.MoveToCell(0, i + 1, 0, 0);
  10661. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10662. builder.MoveToCell(0, i + 1, 1, 0);
  10663. builder.Write(dt.Rows[i]["City"].ToString());
  10664. builder.MoveToCell(0, i + 1, 2, 0);
  10665. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10666. builder.MoveToCell(0, i + 1, 3, 0);
  10667. builder.Write(dt.Rows[i]["Room"].ToString());
  10668. }
  10669. //删除多余行
  10670. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10671. {
  10672. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10673. }
  10674. string strFileName = di.TeamName + "酒店确认单.doc";
  10675. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10676. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10677. return Ok(JsonView(true, "成功", url));
  10678. }
  10679. catch (Exception ex)
  10680. {
  10681. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10682. }
  10683. }
  10684. #endregion
  10685. #region 团组状态
  10686. /// <summary>
  10687. /// 团组状态列表 Page
  10688. /// </summary>
  10689. /// <param name="dto">团组列表请求dto</param>
  10690. /// <returns></returns>
  10691. [HttpPost]
  10692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10693. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10694. {
  10695. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10696. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10697. {
  10698. string sqlWhere = string.Empty;
  10699. if (dto.IsSure == 0) //未完成
  10700. {
  10701. sqlWhere += string.Format(@" And IsSure = 0");
  10702. }
  10703. else if (dto.IsSure == 1) //已完成
  10704. {
  10705. sqlWhere += string.Format(@" And IsSure = 1");
  10706. }
  10707. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10708. {
  10709. string tj = dto.SearchCriteria;
  10710. 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}%')",
  10711. tj, tj, tj, tj, tj);
  10712. }
  10713. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10714. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10715. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10716. From (
  10717. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10718. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10719. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10720. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10721. From Grp_DelegationInfo gdi
  10722. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10723. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10724. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10725. Where gdi.IsDel = 0 {0}
  10726. ) temp ", sqlWhere);
  10727. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10728. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10729. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10730. }
  10731. else
  10732. {
  10733. return Ok(JsonView(false, "查询失败"));
  10734. }
  10735. }
  10736. /// <summary>
  10737. /// 团组状态
  10738. /// 设置操作完成
  10739. /// </summary>
  10740. /// <param name="dto">团组列表请求dto</param>
  10741. /// <returns></returns>
  10742. [HttpPost]
  10743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10744. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10745. {
  10746. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10747. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10748. {
  10749. Id = dto.Id,
  10750. IsSure = 1
  10751. };
  10752. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10753. .UpdateColumns(it => new { it.IsSure })
  10754. .WhereColumns(it => new { it.Id })
  10755. .ExecuteCommandAsync();
  10756. if (result > 0)
  10757. {
  10758. return Ok(JsonView(true, "操作完成!"));
  10759. }
  10760. return Ok(JsonView(false, "操作失败!"));
  10761. }
  10762. #endregion
  10763. #region 保险费用录入
  10764. /// <summary>
  10765. /// 根据团组Id查询保险费用列表
  10766. /// </summary>
  10767. /// <param name="dto"></param>
  10768. /// <returns></returns>
  10769. [HttpPost]
  10770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10771. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10772. {
  10773. try
  10774. {
  10775. Result groupData = await _customersRep.CustomersByDiId(dto);
  10776. if (groupData.Code != 0)
  10777. {
  10778. return Ok(JsonView(false, groupData.Msg));
  10779. }
  10780. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10781. }
  10782. catch (Exception ex)
  10783. {
  10784. return Ok(JsonView(false, ex.Message));
  10785. }
  10786. }
  10787. /// <summary>
  10788. /// 根据保险费用Id查询保险费用详细
  10789. /// </summary>
  10790. /// <param name="dto"></param>
  10791. /// <returns></returns>
  10792. [HttpPost]
  10793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10794. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10795. {
  10796. try
  10797. {
  10798. Result groupData = await _customersRep.CustomersById(dto);
  10799. if (groupData.Code != 0)
  10800. {
  10801. return Ok(JsonView(false, groupData.Msg));
  10802. }
  10803. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10804. }
  10805. catch (Exception ex)
  10806. {
  10807. return Ok(JsonView(false, ex.Message));
  10808. }
  10809. }
  10810. /// <summary>
  10811. /// 保险费用录入页面初始化绑定
  10812. /// </summary>
  10813. /// <param name="dto"></param>
  10814. /// <returns></returns>
  10815. [HttpPost]
  10816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10817. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10818. {
  10819. try
  10820. {
  10821. Result groupData = await _customersRep.CustomersInitialize(dto);
  10822. if (groupData.Code != 0)
  10823. {
  10824. return Ok(JsonView(false, groupData.Msg));
  10825. }
  10826. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10827. }
  10828. catch (Exception ex)
  10829. {
  10830. return Ok(JsonView(false, ex.Message));
  10831. }
  10832. }
  10833. /// <summary>
  10834. /// 保险费用操作(Status:1.新增,2.修改)
  10835. /// </summary>
  10836. /// <param name="dto"></param>
  10837. /// <returns></returns>
  10838. [HttpPost]
  10839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10840. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10841. {
  10842. Result groupData = await _customersRep.OpCustomers(dto);
  10843. if (groupData.Code != 0)
  10844. {
  10845. return Ok(JsonView(false, groupData.Msg));
  10846. }
  10847. #region 应用推送
  10848. try
  10849. {
  10850. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10851. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10852. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10853. }
  10854. catch (Exception ex)
  10855. {
  10856. }
  10857. #endregion
  10858. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10859. }
  10860. /// <summary>
  10861. /// 保险文件上传
  10862. /// </summary>
  10863. /// <param name="file"></param>
  10864. /// <returns></returns>
  10865. [HttpPost]
  10866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10867. public async Task<IActionResult> UploadCus(IFormFile file)
  10868. {
  10869. try
  10870. {
  10871. if (file != null)
  10872. {
  10873. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10874. //文件名称
  10875. string projectFileName = file.FileName;
  10876. //上传的文件的路径
  10877. string filePath = "";
  10878. if (!Directory.Exists(fileDir))
  10879. {
  10880. Directory.CreateDirectory(fileDir);
  10881. }
  10882. //上传的文件的路径
  10883. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10884. using (FileStream fs = System.IO.File.Create(filePath))
  10885. {
  10886. file.CopyTo(fs);
  10887. fs.Flush();
  10888. }
  10889. return Ok(JsonView(true, "上传成功!", projectFileName));
  10890. }
  10891. else
  10892. {
  10893. return Ok(JsonView(false, "上传失败!"));
  10894. }
  10895. }
  10896. catch (Exception ex)
  10897. {
  10898. return Ok(JsonView(false, "程序错误!"));
  10899. throw;
  10900. }
  10901. }
  10902. /// <summary>
  10903. /// 保险删除指定文件
  10904. /// </summary>
  10905. /// <param name="dto"></param>
  10906. /// <returns></returns>
  10907. [HttpPost]
  10908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10909. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10910. {
  10911. try
  10912. {
  10913. string filePath = "";
  10914. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10915. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10916. //int id = 0;
  10917. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10918. // 删除该文件
  10919. try
  10920. {
  10921. System.IO.File.Delete(filePath);
  10922. 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()
  10923. {
  10924. Attachment = "",
  10925. }).ExecuteCommandAsync();
  10926. if (result != 0)
  10927. {
  10928. return Ok(JsonView(true, "成功!"));
  10929. }
  10930. else
  10931. {
  10932. return Ok(JsonView(false, "失败!"));
  10933. }
  10934. }
  10935. catch (Exception)
  10936. {
  10937. 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()
  10938. {
  10939. Attachment = "",
  10940. }).ExecuteCommandAsync();
  10941. if (result != 0)
  10942. {
  10943. return Ok(JsonView(true, "成功!"));
  10944. }
  10945. else
  10946. {
  10947. return Ok(JsonView(false, "失败!"));
  10948. }
  10949. }
  10950. }
  10951. catch (Exception ex)
  10952. {
  10953. return Ok(JsonView(false, "程序错误!"));
  10954. throw;
  10955. }
  10956. }
  10957. /// <summary>
  10958. /// 保险费用操作(删除)
  10959. /// </summary>
  10960. /// <param name="dto"></param>
  10961. /// <returns></returns>
  10962. [HttpPost]
  10963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10964. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10965. {
  10966. try
  10967. {
  10968. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10969. if (!res)
  10970. {
  10971. return Ok(JsonView(false, "删除失败"));
  10972. }
  10973. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10974. {
  10975. IsDel = 1,
  10976. DeleteUserId = dto.DeleteUserId,
  10977. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10978. }).ExecuteCommandAsync();
  10979. return Ok(JsonView(true, "删除成功!"));
  10980. }
  10981. catch (Exception ex)
  10982. {
  10983. return Ok(JsonView(false, "程序错误!"));
  10984. throw;
  10985. }
  10986. }
  10987. #endregion
  10988. #region 接团客户名单 PageId 104
  10989. /// <summary>
  10990. /// 接团客户名单
  10991. /// 迁移数据(慎用!)
  10992. /// </summary>
  10993. /// <param name="dto"></param>
  10994. /// <returns></returns>
  10995. [HttpPost]
  10996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10997. public async Task<IActionResult> PostTourClientListChange()
  10998. {
  10999. try
  11000. {
  11001. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11002. //var groupClinetData1
  11003. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11004. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11005. int updateCount = 0;
  11006. if (oldOAClientList.Count > 0)
  11007. {
  11008. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11009. _sqlSugar.BeginTran();
  11010. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11011. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11012. foreach (var item in oldOAClientList)
  11013. {
  11014. int comId = 0;
  11015. string format = "yyyy-MM-dd HH:mm:ss";
  11016. string data11 = "1990-01-01 00:00";
  11017. var data1 = IsValidDate(item.OPdate, format);
  11018. if (data1) data11 = item.OPdate;
  11019. //客户公司验证
  11020. if (!string.IsNullOrEmpty(item.Company))
  11021. {
  11022. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11023. if (clientComInfo == null) // add
  11024. {
  11025. var addInfo = new Crm_CustomerCompany()
  11026. {
  11027. CompanyAbbreviation = "",
  11028. CompanyFullName = item.Company,
  11029. Address = "",
  11030. PostCodes = "",
  11031. LastedOpUserId = item.OPer,
  11032. LastedOpDt = Convert.ToDateTime(data11),
  11033. CreateUserId = item.OPer,
  11034. CreateTime = Convert.ToDateTime(data11),
  11035. IsDel = 0
  11036. };
  11037. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11038. if (comId1 > 0) comId = comId1;
  11039. }
  11040. else comId = clientComInfo.Id;
  11041. }
  11042. //客户人员验证
  11043. int clientId = 0;
  11044. string name = item.LastName + item.Name;
  11045. if (!string.IsNullOrEmpty(name))
  11046. {
  11047. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11048. if (clientInfo == null)
  11049. {
  11050. DateTime? dateTime = null;
  11051. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11052. if (isDt) dateTime = birthDayDt;
  11053. var addInfo1 = new Crm_DeleClient()
  11054. {
  11055. CrmCompanyId = comId,
  11056. DiId = -1,
  11057. LastName = item.LastName,
  11058. FirstName = item.Name,
  11059. OldName = "",
  11060. Pinyin = item.Pinyin,
  11061. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11062. Marriage = 0,
  11063. Phone = item.Phone,
  11064. Job = item.Job,
  11065. BirthDay = dateTime
  11066. };
  11067. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11068. if (clientId1 > 0) clientId = clientId1;
  11069. }
  11070. else clientId = clientInfo.Id;
  11071. }
  11072. if (clientId < 1)
  11073. {
  11074. continue;
  11075. }
  11076. int airType = 0;
  11077. if (item.AirType == "超经舱") airType = 459;
  11078. else if (item.AirType == "公务舱") airType = 458;
  11079. else if (item.AirType == "经济舱") airType = 460;
  11080. else if (item.AirType == "其他") airType = 565;
  11081. else if (item.AirType == "头等舱") airType = 457;
  11082. var _TourClientListEntity = new Grp_TourClientList()
  11083. {
  11084. DiId = item.Diid,
  11085. ClientId = clientId,
  11086. CreateUserId = item.OPer,
  11087. CreateTime = Convert.ToDateTime(data11),
  11088. Remark = item.Remark,
  11089. IsDel = item.Isdel,
  11090. ShippingSpaceTypeId = airType,
  11091. ShippingSpaceSpecialNeeds = item.AirRemark,
  11092. HotelSpecialNeeds = item.RoomType
  11093. };
  11094. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11095. if (_TourClientList > 0)
  11096. {
  11097. updateCount++;
  11098. }
  11099. }
  11100. _sqlSugar.CommitTran();
  11101. }
  11102. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11103. }
  11104. catch (Exception ex)
  11105. {
  11106. _sqlSugar.RollbackTran();
  11107. return Ok(JsonView(false, ex.Message));
  11108. }
  11109. return Ok(JsonView(true));
  11110. }
  11111. private bool IsValidDate(string dateString, string format)
  11112. {
  11113. DateTime dateValue;
  11114. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11115. return valid;
  11116. }
  11117. /// <summary>
  11118. /// 接团客户名单
  11119. /// 根据团组Id查询List
  11120. /// </summary>
  11121. /// <param name="dto"></param>
  11122. /// <returns></returns>
  11123. [HttpPost]
  11124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11125. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11126. {
  11127. #region 参数验证
  11128. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11129. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11130. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11131. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11132. #region 页面操作权限验证
  11133. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11134. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11135. #endregion
  11136. #endregion
  11137. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11138. if (viewData.Code != 0)
  11139. {
  11140. return Ok(JsonView(false, viewData.Msg));
  11141. }
  11142. return Ok(JsonView(viewData.Data));
  11143. }
  11144. /// <summary>
  11145. /// 接团客户名单
  11146. /// 基础数据 Init
  11147. /// </summary>
  11148. /// <param name="_dto"></param>
  11149. /// <returns></returns>
  11150. [HttpPost]
  11151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11152. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11153. {
  11154. #region 参数验证
  11155. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11156. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11157. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11158. #region 页面操作权限验证
  11159. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11160. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11161. #endregion
  11162. #endregion
  11163. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11164. }
  11165. /// <summary>
  11166. /// 接团客户名单
  11167. /// 根据 Id查询 Details
  11168. /// </summary>
  11169. /// <param name="_dto"></param>
  11170. /// <returns></returns>
  11171. [HttpPost]
  11172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11173. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11174. {
  11175. #region 参数验证
  11176. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11177. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11178. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11179. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11180. #region 页面操作权限验证
  11181. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11182. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11183. #endregion
  11184. #endregion
  11185. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11186. if (viewData.Code != 0)
  11187. {
  11188. return Ok(JsonView(false, viewData.Msg));
  11189. }
  11190. return Ok(JsonView(viewData.Data));
  11191. }
  11192. /// <summary>
  11193. /// 接团客户名单
  11194. /// Add Or Edit
  11195. /// </summary>
  11196. /// <param name="_dto"></param>
  11197. /// <returns></returns>
  11198. [HttpPost]
  11199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11200. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11201. {
  11202. #region 参数验证
  11203. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11204. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11205. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11206. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11207. #region 页面操作权限验证
  11208. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11209. if (_dto.Id == 0) //添加
  11210. {
  11211. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11212. }
  11213. else if (_dto.Id >= 0) //修改
  11214. {
  11215. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11216. }
  11217. #endregion
  11218. #endregion
  11219. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11220. if (viewData.Code != 0)
  11221. {
  11222. return Ok(JsonView(false, viewData.Msg));
  11223. }
  11224. return Ok(JsonView(true));
  11225. }
  11226. /// <summary>
  11227. /// 接团客户名单
  11228. /// AddMultiple(添加多个)
  11229. /// </summary>
  11230. /// <param name="_dto"></param>
  11231. /// <returns></returns>
  11232. [HttpPost]
  11233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11234. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11235. {
  11236. #region 参数验证
  11237. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11238. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11239. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11240. #region 页面操作权限验证
  11241. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11242. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11243. #endregion
  11244. #endregion
  11245. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11246. if (viewData.Code != 0)
  11247. {
  11248. return Ok(JsonView(false, viewData.Msg));
  11249. }
  11250. return Ok(JsonView(true));
  11251. }
  11252. /// <summary>
  11253. /// 接团客户名单
  11254. /// Del
  11255. /// </summary>
  11256. /// <param name="_dto"></param>
  11257. /// <returns></returns>
  11258. [HttpPost]
  11259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11260. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11261. {
  11262. #region 参数验证
  11263. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11264. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11265. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11266. #region 页面操作权限验证
  11267. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11268. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11269. #endregion
  11270. #endregion
  11271. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11272. if (viewData.Code != 0)
  11273. {
  11274. return Ok(JsonView(false, viewData.Msg));
  11275. }
  11276. return Ok(JsonView(true));
  11277. }
  11278. /// <summary>
  11279. /// 接团客户名单
  11280. /// 文件下载 客户名单
  11281. /// </summary>
  11282. /// <param name="_dto"></param>
  11283. /// <returns></returns>
  11284. [HttpPost]
  11285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11286. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11287. {
  11288. #region 参数验证
  11289. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11290. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11291. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11292. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11293. #region 页面操作权限验证
  11294. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11295. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11296. #endregion
  11297. #endregion
  11298. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11299. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11300. From Grp_TourClientList tcl
  11301. Left Join
  11302. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11303. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11304. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11305. From Crm_DeleClient dc
  11306. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11307. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11308. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11309. Where dc.IsDel = 0) temp
  11310. On temp.DcId =tcl.ClientId
  11311. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11312. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11313. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11314. //载入模板
  11315. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11316. if (_dto.Language == 1)
  11317. {
  11318. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11319. }
  11320. //载入模板
  11321. var doc = new Document(tempPath);
  11322. DocumentBuilder builder = new DocumentBuilder(doc);
  11323. //获取word里所有表格
  11324. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11325. //获取所填表格的序数
  11326. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11327. var rowStart = tableOne.Rows[0]; //获取第1行
  11328. if (_dto.Language == 0)
  11329. {
  11330. //循环赋值
  11331. for (int i = 0; i < DcList.Count; i++)
  11332. {
  11333. builder.MoveToCell(0, i + 1, 0, 0);
  11334. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11335. builder.MoveToCell(0, i + 1, 1, 0);
  11336. int sex = DcList[i].Sex;
  11337. string sexStr = string.Empty;
  11338. if (sex == 0) sexStr = "男";
  11339. else if (sex == 1) sexStr = "女";
  11340. else sexStr = "未设置";
  11341. builder.Write(sexStr);
  11342. builder.MoveToCell(0, i + 1, 2, 0);
  11343. string birthDay = DcList[i].BirthDay;
  11344. string birthDayStr = string.Empty;
  11345. if (!string.IsNullOrEmpty(birthDay))
  11346. {
  11347. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11348. }
  11349. builder.Write(birthDayStr);
  11350. builder.MoveToCell(0, i + 1, 3, 0);
  11351. string company = "";
  11352. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11353. {
  11354. company = DcList[i].CompanyFullName.ToString();
  11355. }
  11356. builder.Write(company);
  11357. builder.MoveToCell(0, i + 1, 4, 0);
  11358. builder.Write(DcList[i].Job);
  11359. }
  11360. }
  11361. else if (_dto.Language == 1)
  11362. {
  11363. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11364. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11365. List<string> transArrayStr = new List<string>();
  11366. string transStrRes1 = "";
  11367. for (int i = 0; i < DcList.Count; i++)
  11368. {
  11369. var dc = DcList[i];
  11370. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11371. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11372. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11373. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11374. else transStrRes1 += $"{str1}|";
  11375. }
  11376. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  11377. string transStrRes = "";
  11378. if (transStrRes1.Length > 0)
  11379. {
  11380. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11381. }
  11382. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  11383. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11384. //List<string> transArray = new List<string> { };
  11385. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11386. if (transStrRes.Contains("|"))
  11387. {
  11388. string[] transArray1 = transStrRes.Split('|');
  11389. if (transArray1.Length > 0)
  11390. {
  11391. foreach (var item in transArray1)
  11392. {
  11393. if (item.Contains("&"))
  11394. {
  11395. string[] transArray2 = item.Split('&');
  11396. int index = 0;
  11397. string companyName = "", job = "";
  11398. if (transArray2.Length > 0)
  11399. {
  11400. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11401. if (1 < transArray2.Length) companyName = transArray2[1];
  11402. if (2 < transArray2.Length) job = transArray2[2];
  11403. }
  11404. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11405. }
  11406. }
  11407. }
  11408. }
  11409. //循环赋值
  11410. for (int i = 0; i < DcList.Count; i++)
  11411. {
  11412. string PYName = "";
  11413. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11414. {
  11415. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11416. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11417. PYName = PY_First + " " + PY_Last;
  11418. }
  11419. else
  11420. {
  11421. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11422. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11423. PYName = PY_First + " " + PY_Last;
  11424. }
  11425. builder.MoveToCell(0, i + 1, 0, 0);
  11426. builder.Write(PYName);
  11427. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11428. builder.MoveToCell(0, i + 1, 1, 0);
  11429. builder.Write(sex);
  11430. DateTime birthDt;
  11431. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11432. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11433. builder.MoveToCell(0, i + 1, 2, 0);
  11434. builder.Write(birthday);
  11435. string company = string.Empty, job = string.Empty;
  11436. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11437. if (dcTransInfo != null)
  11438. {
  11439. company = dcTransInfo.CompanyName;
  11440. job = dcTransInfo.Job;
  11441. }
  11442. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11443. {
  11444. //查询对照表
  11445. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11446. if (tempCec != null)
  11447. {
  11448. company = tempCec.enName;
  11449. }
  11450. //翻译
  11451. else
  11452. {
  11453. }
  11454. }
  11455. builder.MoveToCell(0, i + 1, 3, 0);
  11456. builder.Write(company);
  11457. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11458. {
  11459. //查询对照表
  11460. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11461. if (tempPec != null)
  11462. {
  11463. job = tempPec.enName;
  11464. }
  11465. //翻译
  11466. else
  11467. {
  11468. }
  11469. }
  11470. builder.MoveToCell(0, i + 1, 4, 0);
  11471. builder.Write(job);
  11472. }
  11473. }
  11474. //删除多余行
  11475. while (tableOne.Rows.Count > DcList.Count + 1)
  11476. {
  11477. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11478. }
  11479. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11480. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11481. doc.Save(fileDir);
  11482. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11483. return Ok(JsonView(true, "操作成功!", Url));
  11484. }
  11485. private class TranslateInfo
  11486. {
  11487. public int Index { get; set; }
  11488. public string CompanyName { get; set; }
  11489. public string Job { get; set; }
  11490. }
  11491. #endregion
  11492. #region 团组倒推表
  11493. /// <summary>
  11494. /// 倒推表基础数据
  11495. /// Init
  11496. /// </summary>
  11497. /// <param name="dto"></param>
  11498. /// <returns></returns>
  11499. [HttpPost]
  11500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11501. public async Task<IActionResult> PostInvertedListInit()
  11502. {
  11503. var viewData = await _invertedListRep._Init();
  11504. if (viewData.Code != 0)
  11505. {
  11506. return Ok(JsonView(false, viewData.Msg));
  11507. }
  11508. return Ok(JsonView(viewData.Data));
  11509. }
  11510. /// <summary>
  11511. /// 倒推表
  11512. /// Info
  11513. /// </summary>
  11514. /// <param name="dto"></param>
  11515. /// <returns></returns>
  11516. [HttpPost]
  11517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11518. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11519. {
  11520. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11521. if (viewData.Code != 0)
  11522. {
  11523. return Ok(JsonView(false, viewData.Msg));
  11524. }
  11525. return Ok(JsonView(viewData.Data));
  11526. }
  11527. /// <summary>
  11528. /// 倒推表
  11529. /// Create
  11530. /// </summary>
  11531. /// <param name="dto"></param>
  11532. /// <returns></returns>
  11533. [HttpPost]
  11534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11535. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11536. {
  11537. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11538. if (viewData.Code != 0)
  11539. {
  11540. return Ok(JsonView(false, viewData.Msg));
  11541. }
  11542. return Ok(JsonView(viewData.Data));
  11543. }
  11544. /// <summary>
  11545. /// 倒推表
  11546. /// Update
  11547. /// </summary>
  11548. /// <param name="dto"></param>
  11549. /// <returns></returns>
  11550. [HttpPost]
  11551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11552. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11553. {
  11554. var viewData = await _invertedListRep._Update(dto);
  11555. if (viewData.Code != 0)
  11556. {
  11557. return Ok(JsonView(false, viewData.Msg));
  11558. }
  11559. return Ok(JsonView(viewData.Data));
  11560. }
  11561. /// <summary>
  11562. /// 倒推表
  11563. /// File Download
  11564. /// </summary>
  11565. /// <param name="dto"></param>
  11566. /// <returns></returns>
  11567. [HttpPost]
  11568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11569. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11570. {
  11571. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11572. if (info2.Code != 0)
  11573. {
  11574. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11575. }
  11576. var info1 = info2.Data as InvertedListInfoView;
  11577. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11578. string teamName = "";
  11579. if (info != null) teamName = info.TeamName;
  11580. //载入模板
  11581. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11582. DocumentBuilder builder = new DocumentBuilder(doc);
  11583. //利用键值对存放数据
  11584. Dictionary<string, string> dic = new Dictionary<string, string>();
  11585. dic.Add("TeamName", teamName);
  11586. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11587. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11588. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11589. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11590. dic.Add("SQRemark", info1.ApprovalRemark);
  11591. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11592. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11593. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11594. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11595. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11596. dic.Add("QZRemark", info1.VisaInformationRemark);
  11597. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11598. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11599. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11600. dic.Add("CQRemark", info1.IssueVisaRemark);
  11601. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11602. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11603. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11604. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11605. #region 填充word模板书签内容
  11606. foreach (var key in dic.Keys)
  11607. {
  11608. builder.MoveToBookmark(key);
  11609. builder.Write(dic[key]);
  11610. }
  11611. #endregion
  11612. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11613. string fileName = $"{teamName}团出行准备流程表.doc";
  11614. string filePath = fileDir + $@"InvertedList/{fileName}";
  11615. doc.Save(filePath);
  11616. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11617. return Ok(JsonView(true, "操作成功!", Url));
  11618. }
  11619. #endregion
  11620. #region 三公签证费用(签证费、代办费)
  11621. /// <summary>
  11622. /// 三公签证费用(签证费、代办费)
  11623. /// List
  11624. /// </summary>
  11625. /// <returns></returns>
  11626. [HttpPost]
  11627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11628. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11629. {
  11630. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11631. if (_view.Code != 0)
  11632. {
  11633. return Ok(JsonView(false, _view.Msg));
  11634. }
  11635. return Ok(JsonView(true, "操作成功!", _view.Data));
  11636. }
  11637. /// <summary>
  11638. /// 三公签证费用(签证费、代办费)
  11639. /// Add Or Update
  11640. /// </summary>
  11641. /// <returns></returns>
  11642. [HttpPost]
  11643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11644. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11645. {
  11646. var _view = await _visaFeeInfoRep._Update(_dto);
  11647. if (_view.Code != 0)
  11648. {
  11649. return Ok(JsonView(false, _view.Msg));
  11650. }
  11651. return Ok(JsonView(true, _view.Msg));
  11652. }
  11653. #endregion
  11654. #region 酒店询价
  11655. /// <summary>
  11656. /// 酒店询价
  11657. /// Init
  11658. /// </summary>
  11659. /// <param name="dto"></param>
  11660. /// <returns></returns>
  11661. [HttpPost]
  11662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11663. public async Task<IActionResult> PostHotelInquiryInit()
  11664. {
  11665. var res = await _hotelInquiryRep._Init();
  11666. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11667. return Ok(JsonView(true, res.Msg, res.Data));
  11668. }
  11669. /// <summary>
  11670. /// 酒店询价
  11671. /// page Item
  11672. /// </summary>
  11673. /// <param name="_dto"></param>
  11674. /// <returns></returns>
  11675. [HttpPost]
  11676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11677. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11678. {
  11679. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11680. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11681. var view = res.Data as PageDataViewBase;
  11682. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11683. }
  11684. /// <summary>
  11685. /// 酒店询价
  11686. /// info
  11687. /// </summary>
  11688. /// <param name="_dto"></param>
  11689. /// <returns></returns>
  11690. [HttpPost]
  11691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11692. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11693. {
  11694. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11695. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11696. return Ok(JsonView(true, res.Msg, res.Data));
  11697. }
  11698. /// <summary>
  11699. /// 酒店询价
  11700. /// Add Or Edit
  11701. /// </summary>
  11702. /// <param name="_dto"></param>
  11703. /// <returns></returns>
  11704. [HttpPost]
  11705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11706. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11707. {
  11708. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11709. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11710. return Ok(JsonView(true, res.Msg, res.Data));
  11711. }
  11712. /// <summary>
  11713. /// 酒店询价
  11714. /// Del
  11715. /// </summary>
  11716. /// <param name="_dto"></param>
  11717. /// <returns></returns>
  11718. [HttpPost]
  11719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11720. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11721. {
  11722. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11723. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11724. return Ok(JsonView(true, res.Msg, res.Data));
  11725. }
  11726. #endregion
  11727. #region 下载匹配op行程单
  11728. /// <summary>
  11729. /// 匹配op行程单
  11730. /// Init
  11731. /// </summary>
  11732. /// <param name="dto">团组列表请求dto</param>
  11733. /// <returns></returns>
  11734. [HttpPost]
  11735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11736. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11737. {
  11738. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11739. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11740. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11741. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11742. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11743. .Where(it => it.IsDel == 0)
  11744. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11745. .OrderByDescending(it => it.CreateUserId)
  11746. .ToList();
  11747. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11748. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11749. var diids = groupInfos.Select(it => it.Id).ToList();
  11750. List<string> countrys = new List<string>();
  11751. foreach (var item in country)
  11752. {
  11753. var data = _groupRepository.FormartTeamName(item);
  11754. var dataArray = _groupRepository.GroupSplitCountry(data);
  11755. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11756. }
  11757. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11758. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11759. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11760. foreach (var item in areaItem)
  11761. {
  11762. string areaStr = item.Value;
  11763. if (!string.IsNullOrEmpty(areaStr))
  11764. {
  11765. string[] str1 = areaStr.Split("-");
  11766. if (str1.Length > 0)
  11767. {
  11768. areaArray.AddRange(str1);
  11769. }
  11770. }
  11771. }
  11772. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11773. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11774. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11775. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11776. .ToList();
  11777. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11778. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11779. .Where(it => countriesIds.Contains(it.Id))
  11780. .Select(it => new { it.Id, Name = it.Name_CN })
  11781. .ToList();
  11782. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11783. .Select(it => it.TeamName).ToList();
  11784. stopwatch.Stop();
  11785. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11786. }
  11787. ///// <summary>
  11788. ///// 匹配op行程单
  11789. ///// Init 查询区域数据
  11790. ///// </summary>
  11791. ///// <param name="dto">团组列表请求dto</param>
  11792. ///// <returns></returns>
  11793. //[HttpPost]
  11794. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11795. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11796. //{
  11797. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11798. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11799. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11800. // if (string.IsNullOrEmpty(countriesDataStr))
  11801. // {
  11802. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11803. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11804. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11805. // }
  11806. // else
  11807. // {
  11808. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11809. // }
  11810. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11811. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11812. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11813. // List<dynamic> childList = new List<dynamic>();
  11814. // int parentId = dto.CountriesId;
  11815. // if (provinceData.Count > 1)
  11816. // {
  11817. // foreach (var item1 in provinceData)
  11818. // {
  11819. // List<dynamic> childList1 = new List<dynamic>();
  11820. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11821. // foreach (var item2 in citiesData1)
  11822. // {
  11823. // List<dynamic> childList2 = new List<dynamic>();
  11824. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11825. // foreach (var item3 in countiesData1)
  11826. // {
  11827. // childList2.Add(new
  11828. // {
  11829. // id = item3.Id,
  11830. // parentId = item2.Id,
  11831. // level = "district",
  11832. // name = item3.Name_CN,
  11833. // });
  11834. // }
  11835. // childList1.Add(new
  11836. // {
  11837. // id = item2.Id,
  11838. // parentId = item1.Id,
  11839. // level = "city",
  11840. // name = item2.Name_CN,
  11841. // childList = childList2
  11842. // });
  11843. // }
  11844. // childList.Add(new
  11845. // {
  11846. // id = item1.Id,
  11847. // parentId = parentId,
  11848. // level = "province",
  11849. // name = item1.Name_CN,
  11850. // childList = childList1
  11851. // });
  11852. // }
  11853. // //城市
  11854. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11855. // foreach (var item2 in citiesData2)
  11856. // {
  11857. // List<dynamic> childList22 = new List<dynamic>();
  11858. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11859. // foreach (var item3 in countiesData1)
  11860. // {
  11861. // childList22.Add(new
  11862. // {
  11863. // id = item3.Id,
  11864. // parentId = item2.Id,
  11865. // level = "district",
  11866. // name = item3.Name_CN,
  11867. // });
  11868. // }
  11869. // childList.Add(new
  11870. // {
  11871. // id = item2.Id,
  11872. // parentId = parentId,
  11873. // level = "city",
  11874. // name = item2.Name_CN,
  11875. // childList = childList22
  11876. // });
  11877. // }
  11878. // }
  11879. // else
  11880. // {
  11881. // foreach (var item2 in citiesData)
  11882. // {
  11883. // string cname = item2.Name_CN;
  11884. // List<dynamic> childList1 = new List<dynamic>();
  11885. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11886. // foreach (var item3 in countiesData1)
  11887. // {
  11888. // childList1.Add(new
  11889. // {
  11890. // Id = item3.Id,
  11891. // parentId = item2.Id,
  11892. // level = "district",
  11893. // name = item3.Name_CN
  11894. // });
  11895. // }
  11896. // childList.Add(new
  11897. // {
  11898. // id = item2.Id,
  11899. // parentId = parentId,
  11900. // level = "city",
  11901. // name = item2.Name_CN,
  11902. // childList = childList1
  11903. // });
  11904. // }
  11905. // }
  11906. // stopwatch.Stop();
  11907. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11908. //}
  11909. /// <summary>
  11910. /// 匹配op行程单
  11911. /// 接团信息列表 Page
  11912. /// </summary>
  11913. /// <param name="dto">团组列表请求dto</param>
  11914. /// <returns></returns>
  11915. [HttpPost]
  11916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11917. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11918. {
  11919. var swatch = new Stopwatch();
  11920. swatch.Start();
  11921. #region 参数验证
  11922. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11923. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11924. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11925. #region 页面操作权限验证
  11926. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11927. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11928. #endregion
  11929. #endregion
  11930. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11931. {
  11932. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11933. string sqlWhere = "";
  11934. if (!string.IsNullOrEmpty(dto.Country))
  11935. {
  11936. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11937. }
  11938. if (!string.IsNullOrEmpty(dto.Area))
  11939. {
  11940. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11941. }
  11942. if (!string.IsNullOrEmpty(dto.TeamName))
  11943. {
  11944. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11945. }
  11946. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11947. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11948. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11949. swatch.Stop();
  11950. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11951. }
  11952. else
  11953. {
  11954. return Ok(JsonView(false, "查询失败"));
  11955. }
  11956. }
  11957. /// <summary>
  11958. /// 匹配op行程单
  11959. /// 行程单下载
  11960. /// </summary>
  11961. /// <param name="dto">团组列表请求dto</param>
  11962. /// <returns></returns>
  11963. [HttpPost]
  11964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11965. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11966. {
  11967. #region 参数验证
  11968. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11969. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11970. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11971. #region 页面操作权限验证
  11972. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11973. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11974. #endregion
  11975. #endregion
  11976. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11977. {
  11978. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11979. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11980. }
  11981. else
  11982. {
  11983. return Ok(JsonView(false, "下载失败!"));
  11984. }
  11985. }
  11986. #endregion
  11987. #region 国家信息 数据 注释
  11988. //[HttpPost]
  11989. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11990. //{
  11991. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11992. // foreach (var item in dto)
  11993. // {
  11994. // infos.Add(new Grp_GroupsTaskAssignment()
  11995. // {
  11996. // DIId = item,
  11997. // CTId = 82,
  11998. // UId = 248,
  11999. // IsEnable = 1,
  12000. // CreateUserId = 233,
  12001. // CreateTime = DateTime.Now,
  12002. // IsDel = 0
  12003. // });
  12004. // infos.Add(new Grp_GroupsTaskAssignment()
  12005. // {
  12006. // DIId = item,
  12007. // CTId = 82,
  12008. // UId = 286,
  12009. // IsEnable = 1,
  12010. // CreateUserId = 233,
  12011. // CreateTime = DateTime.Now,
  12012. // IsDel = 0
  12013. // });
  12014. // }
  12015. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12016. // return Ok("操作成功");
  12017. //}
  12018. //public class paramJsonDto
  12019. //{
  12020. // public List<CountriesInfo> str { get; set; }
  12021. //}
  12022. //[HttpPost]
  12023. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12024. //{
  12025. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12026. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12027. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12028. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12029. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12030. // _sqlSugar.BeginTran();
  12031. // int countitiesIndex = 0;
  12032. // foreach (var item in dto.str)
  12033. // {
  12034. // dynamic data = item.c;
  12035. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12036. // if (data != null)
  12037. // {
  12038. // countitiesIndex++;
  12039. // foreach (var item1 in data)
  12040. // {
  12041. // string cnname = item1.cn;
  12042. // string enname = item1.en;
  12043. // Sys_Cities provinceInfo = new Sys_Cities()
  12044. // {
  12045. // CountriesId = countriesId,
  12046. // Name_CN = cnname,
  12047. // Name_EN = enname,
  12048. // ParentId = 0,
  12049. // IsCapital = 1,
  12050. // CreateUserId = 208,
  12051. // CreateTime = DateTime.Now,
  12052. // IsDel = 0
  12053. // };
  12054. // if (item1.lv == "province") //省份
  12055. // {
  12056. // provinceInfo.Level = 1;
  12057. // int provinceId = 0;
  12058. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12059. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12060. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12061. // var data1 = item1.c;
  12062. // foreach (var item2 in data1)
  12063. // {
  12064. // if (item2.lv == "city")
  12065. // {
  12066. // string citycnname = item2.cn;
  12067. // string cityenname = item2.en;
  12068. // Sys_Cities cityInfo = new Sys_Cities()
  12069. // {
  12070. // CountriesId = countriesId,
  12071. // ParentId = provinceId,
  12072. // Level = 2,
  12073. // Name_CN = citycnname,
  12074. // Name_EN = cityenname,
  12075. // IsCapital = 1,
  12076. // CreateUserId = 208,
  12077. // CreateTime = DateTime.Now,
  12078. // IsDel = 0
  12079. // };
  12080. // if (item2.c != null)
  12081. // {
  12082. // int cityId = 0;
  12083. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12084. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12085. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12086. // foreach (var item3 in item2.c)
  12087. // {
  12088. // if (item3.lv == "district")
  12089. // {
  12090. // var districtInfo = new Sys_Cities()
  12091. // {
  12092. // CountriesId = countriesId,
  12093. // Name_CN = item3.cn,
  12094. // Name_EN = item3.en,
  12095. // Level = 3,
  12096. // ParentId = cityId,
  12097. // IsCapital = 1,
  12098. // CreateUserId = 208,
  12099. // CreateTime = DateTime.Now,
  12100. // IsDel = 0
  12101. // };
  12102. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12103. // //{
  12104. // districts.Add(districtInfo);
  12105. // //}
  12106. // }
  12107. // }
  12108. // }
  12109. // else
  12110. // {
  12111. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12112. // //{
  12113. // cities.Add(cityInfo);
  12114. // //}
  12115. // }
  12116. // }
  12117. // }
  12118. // }
  12119. // else if (item1.lv == "city")//城市
  12120. // {
  12121. // provinceInfo.Level = 2;
  12122. // if (item1.c != null)
  12123. // {
  12124. // int cityId = 0;
  12125. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12126. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12127. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12128. // foreach (var item3 in item1.c)
  12129. // {
  12130. // if (item3.lv == "district")
  12131. // {
  12132. // var districtInfo = new Sys_Cities()
  12133. // {
  12134. // CountriesId = countriesId,
  12135. // Name_CN = item3.cn,
  12136. // Name_EN = item3.en,
  12137. // Level = 3,
  12138. // ParentId = cityId,
  12139. // IsCapital = 1,
  12140. // CreateUserId = 208,
  12141. // CreateTime = DateTime.Now,
  12142. // IsDel = 0
  12143. // };
  12144. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12145. // //{
  12146. // districts.Add(districtInfo);
  12147. // //}
  12148. // }
  12149. // }
  12150. // }
  12151. // else
  12152. // {
  12153. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12154. // //{
  12155. // cities.Add(provinceInfo);
  12156. // //}
  12157. // }
  12158. // }
  12159. // }
  12160. // }
  12161. // }
  12162. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12163. // cities = cities.Distinct().ToList();
  12164. // districts = districts.Distinct().ToList();
  12165. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12166. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12167. // cities.AddRange(districts);
  12168. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12169. // //_sqlSugar.RollbackTran();
  12170. // _sqlSugar.CommitTran();
  12171. // return Ok(JsonView(false, "操作成功!"));
  12172. //}
  12173. //[HttpPost]
  12174. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12175. //{
  12176. // List<CountitiesInfo> infos = dto.MyProperty;
  12177. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12178. // _sqlSugar.BeginTran();
  12179. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12180. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12181. // foreach (var item in infos)
  12182. // {
  12183. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12184. // if (countryInfo != null)
  12185. // {
  12186. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12187. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12188. // if (cityInfo1 != null)
  12189. // {
  12190. // cityInfo1.IsCapital = 0;
  12191. // cityInfos.Add(cityInfo1);
  12192. // }
  12193. // }
  12194. // }
  12195. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12196. // .UpdateColumns(it => it.IsCapital)
  12197. // .WhereColumns(it => it.Id)
  12198. // .ExecuteCommand();
  12199. // //_sqlSugar.RollbackTran();
  12200. // _sqlSugar.CommitTran();
  12201. // return Ok(JsonView(false, "操作成功!"));
  12202. //}
  12203. //public class CounrtiesDto
  12204. //{
  12205. // public List<CountitiesInfo> MyProperty { get; set; }
  12206. //}
  12207. //public class CountitiesInfo
  12208. //{
  12209. // /// <summary>
  12210. // /// 圣约翰
  12211. // /// </summary>
  12212. // public string capital_name_chinese { get; set; }
  12213. // /// <summary>
  12214. // ///
  12215. // /// </summary>
  12216. // public string capital_name { get; set; }
  12217. // /// <summary>
  12218. // ///
  12219. // /// </summary>
  12220. // public string country_type { get; set; }
  12221. // /// <summary>
  12222. // /// 安提瓜和巴布达
  12223. // /// </summary>
  12224. // public string country_name_chinese { get; set; }
  12225. // /// <summary>
  12226. // /// 安提瓜和巴布达
  12227. // /// </summary>
  12228. // public string country_name_chinese_short { get; set; }
  12229. // /// <summary>
  12230. // /// 安提瓜和巴布达
  12231. // /// </summary>
  12232. // public string country_name_chinese_UN { get; set; }
  12233. // /// <summary>
  12234. // ///
  12235. // /// </summary>
  12236. // public string country_name_english_abbreviation { get; set; }
  12237. // /// <summary>
  12238. // ///
  12239. // /// </summary>
  12240. // public string country_name_english_formal { get; set; }
  12241. // /// <summary>
  12242. // ///
  12243. // /// </summary>
  12244. // public string country_name_english_UN { get; set; }
  12245. // /// <summary>
  12246. // ///
  12247. // /// </summary>
  12248. // public string continent_name { get; set; }
  12249. // /// <summary>
  12250. // ///
  12251. // /// </summary>
  12252. // public string subregion_name { get; set; }
  12253. // /// <summary>
  12254. // ///
  12255. // /// </summary>
  12256. // public string country_code2 { get; set; }
  12257. // /// <summary>
  12258. // ///
  12259. // /// </summary>
  12260. // public string country_code3 { get; set; }
  12261. // /// <summary>
  12262. // ///
  12263. // /// </summary>
  12264. // public string phone_code { get; set; }
  12265. //}
  12266. //public class CountriesInfo : BasicInfo
  12267. //{
  12268. // public List<CitiesInfo> c { get; set; }
  12269. //}
  12270. //public class CitiesInfo : BasicInfo
  12271. //{
  12272. // public List<AreaInfo> c { get; set; }
  12273. //}
  12274. //public class AreaInfo : BasicInfo
  12275. //{
  12276. // public List<AreaInfo> c { get; set; }
  12277. //}
  12278. //public class BasicInfo
  12279. //{
  12280. // public string code { get; set; }
  12281. // public string cn { get; set; }
  12282. // public string lv { get; set; }
  12283. // public string en { get; set; }
  12284. //}
  12285. #endregion
  12286. #region 查看邀请方
  12287. /// <summary>
  12288. /// 查看邀请方
  12289. /// 邀请方信息 Init
  12290. /// </summary>
  12291. /// <param name="dto"></param>
  12292. /// <returns></returns>
  12293. [HttpPost]
  12294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12295. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12296. {
  12297. string sqlWhere = string.Empty;
  12298. if (!string.IsNullOrEmpty(dto.Search))
  12299. {
  12300. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12301. }
  12302. string sql = string.Format($@"Select
  12303. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12304. Id,
  12305. UnitName
  12306. From Res_InvitationOfficialActivityData
  12307. Where IsDel = 0
  12308. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12309. RefAsync<int> total = 0;
  12310. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12311. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12312. }
  12313. /// <summary>
  12314. /// 查看邀请方
  12315. /// 国家信息 Init
  12316. /// </summary>
  12317. /// <param name="dto"></param>
  12318. /// <returns></returns>
  12319. [HttpPost]
  12320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12321. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12322. {
  12323. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12324. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12325. var diids = groupInfos.Select(it => it.Id).ToList();
  12326. List<string> countrys = new List<string>();
  12327. foreach (var item in country)
  12328. {
  12329. var data = _groupRepository.FormartTeamName(item);
  12330. var dataArray = _groupRepository.GroupSplitCountry(data);
  12331. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12332. }
  12333. countrys = countrys.Distinct().ToList();
  12334. for (int i = 0; i < countrys.Count; i++)
  12335. {
  12336. string item = countrys[i];
  12337. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12338. {
  12339. countrys.Remove(item);
  12340. i--;
  12341. }
  12342. }
  12343. RefAsync<int> total = 0;
  12344. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12345. .Where(it => countrys.Contains(it.Name_CN))
  12346. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12347. .Select(it => new { id = it.Id, name = it.Name_CN })
  12348. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12349. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12350. }
  12351. /// <summary>
  12352. /// 查看邀请方
  12353. /// 城市信息 Init
  12354. /// </summary>
  12355. /// <param name="dto"></param>
  12356. /// <returns></returns>
  12357. [HttpPost]
  12358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12359. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12360. {
  12361. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12362. RefAsync<int> total = 0;
  12363. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12364. .Where(it => it.CountriesId == dto.CountiesId)
  12365. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12366. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12367. .Select(it => new { id = it.Id, name = it.Name_CN })
  12368. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12369. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12370. }
  12371. /// <summary>
  12372. /// 查看邀请方
  12373. /// 团组名称 Init
  12374. /// </summary>
  12375. /// <param name="dto"></param>
  12376. /// <returns></returns>
  12377. [HttpPost]
  12378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12379. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12380. {
  12381. var watch = new Stopwatch();
  12382. watch.Start();
  12383. RefAsync<int> total = 0;
  12384. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12385. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12386. .Where((oa, di) => oa.IsDel == 0)
  12387. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12388. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12389. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12390. .Distinct()
  12391. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12392. watch.Stop();
  12393. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12394. }
  12395. /// <summary>
  12396. /// 查看邀请方
  12397. /// 团组 & 邀请方信息
  12398. /// </summary>
  12399. /// <param name="dto"></param>
  12400. /// <returns></returns>
  12401. [HttpPost]
  12402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12403. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12404. {
  12405. var watch = new Stopwatch();
  12406. watch.Start();
  12407. RefAsync<int> total = 0;
  12408. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12409. .AS("Grp_DelegationInfo")
  12410. .Includes(x => x.InvitingInfos)
  12411. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12412. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12413. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12414. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12415. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12416. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12417. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12418. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12419. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12420. infos.ForEach(x =>
  12421. {
  12422. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12423. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12424. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12425. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12426. });
  12427. watch.Stop();
  12428. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12429. }
  12430. #endregion
  12431. #region 报批行程
  12432. /// <summary>
  12433. /// 报批行程初始化
  12434. /// </summary>
  12435. /// <param name="dto"></param>
  12436. /// <returns></returns>
  12437. [HttpPost]
  12438. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12439. {
  12440. const int chiNumber = 5;
  12441. var jw = JsonView(false);
  12442. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12443. var group = groupList.First();
  12444. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12445. group = groupList.First(x => x.Id == diid);
  12446. if (group == null)
  12447. {
  12448. jw.Msg = "暂无团组!";
  12449. return Ok(jw);
  12450. }
  12451. var data = new
  12452. {
  12453. groupList = groupList.Select(x => new
  12454. {
  12455. x.TeamName,
  12456. x.Id
  12457. }),
  12458. content = new ArrayList(),
  12459. groupInfo = new
  12460. {
  12461. group.VisitDays,
  12462. group.TourCode,
  12463. group.VisitPNumber,
  12464. group.TeamName,
  12465. group.Id,
  12466. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12467. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12468. },
  12469. };
  12470. var resultArr = new ArrayList();
  12471. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12472. if (content.Count == 0)
  12473. {
  12474. var stay = "-";
  12475. var cityPath = "-";
  12476. //添加城市路径以及住宿地
  12477. //黑屏代码数据
  12478. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12479. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12480. {
  12481. jw = JsonView(true, "黑屏代码有误!", data);
  12482. return Ok(jw);
  12483. }
  12484. foreach (DataRow row in dtBlack.Rows)
  12485. {
  12486. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12487. {
  12488. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12489. return Ok(jw);
  12490. }
  12491. }
  12492. //黑屏代码获取时间区间
  12493. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12494. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12495. _sqlSugar.BeginTran();
  12496. for (int i = 0; i < timeArr.Count; i++)
  12497. {
  12498. stay = "-";
  12499. cityPath = "-";
  12500. DateTime NewData = DateTime.Parse(timeArr[i]);
  12501. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12502. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12503. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12504. if (tbSelect.Length > 0)
  12505. {
  12506. List<string> threeCodeStr = new List<string>();
  12507. foreach (var item in tbSelect)
  12508. {
  12509. var threeCode = item["Three"].ToString() ?? "";
  12510. if (threeCode.Length == 6)
  12511. {
  12512. var start = threeCode.Substring(0, 3);
  12513. var end = threeCode.Substring(3, 3);
  12514. if (threeCodeStr.Count == 0)
  12515. {
  12516. threeCodeStr.Add(start);
  12517. threeCodeStr.Add(end);
  12518. }
  12519. else
  12520. {
  12521. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12522. {
  12523. threeCodeStr.Add(end);
  12524. }
  12525. else
  12526. {
  12527. threeCodeStr.Add(start);
  12528. threeCodeStr.Add(end);
  12529. }
  12530. }
  12531. }
  12532. }
  12533. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12534. var last = threeCodeStr.Last();
  12535. foreach (var item in threeCodeStr)
  12536. {
  12537. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12538. if (item.Equals(last))
  12539. {
  12540. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12541. }
  12542. }
  12543. cityPath = cityPath.Trim('-');
  12544. }
  12545. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12546. appro.Diid = diid ?? -1;
  12547. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12548. appro.Id = thisId;
  12549. appro.CreateUserId = dto.UserId;
  12550. appro.CreateTime = DateTime.Now;
  12551. content.Add(appro);
  12552. }
  12553. _sqlSugar.CommitTran();
  12554. }
  12555. foreach (var x in content)
  12556. {
  12557. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12558. if (chiList.Count < chiNumber)
  12559. {
  12560. for (int i = chiList.Count; i < chiNumber; i++)
  12561. {
  12562. chiList.Add(new Grp_ApprovalTravelDetails());
  12563. }
  12564. }
  12565. resultArr.Add(new
  12566. {
  12567. x.Id,
  12568. x.Date,
  12569. x.Diid,
  12570. chiList = chiList.Select(x1 => new
  12571. {
  12572. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12573. x1.Details,
  12574. x1.ParentId,
  12575. x1.Id
  12576. })
  12577. });
  12578. }
  12579. data = data with
  12580. {
  12581. content = resultArr,
  12582. };
  12583. jw = JsonView(true, "获取成功!", data);
  12584. return Ok(jw);
  12585. }
  12586. /// <summary>
  12587. /// 报批行程删除
  12588. /// </summary>
  12589. /// <param name="dto"></param>
  12590. /// <returns></returns>
  12591. [HttpPost]
  12592. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12593. {
  12594. var jw = JsonView(false);
  12595. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12596. if (group == null)
  12597. {
  12598. jw.Msg = "团组参数有误!";
  12599. return Ok(jw);
  12600. }
  12601. try
  12602. {
  12603. _sqlSugar.BeginTran();
  12604. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12605. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12606. {
  12607. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12608. DeleteUserId = dto.uesrId,
  12609. IsDel = 1
  12610. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12611. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12612. {
  12613. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12614. DeleteUserId = dto.uesrId,
  12615. IsDel = 1
  12616. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12617. _sqlSugar.CommitTran();
  12618. jw = JsonView(true, "删除成功");
  12619. }
  12620. catch (Exception ex)
  12621. {
  12622. jw = JsonView(false, ex.Message);
  12623. }
  12624. return Ok(jw);
  12625. }
  12626. /// <summary>
  12627. /// 报批行程保存
  12628. /// </summary>
  12629. /// <param name="dto"></param>
  12630. /// <returns></returns>
  12631. [HttpPost]
  12632. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12633. {
  12634. var jw = JsonView(false);
  12635. var Find = dto.Arr.Find(x => x.id == 0);
  12636. if (Find != null)
  12637. {
  12638. jw.Msg = "生成的ID为0!";
  12639. return Ok(jw);
  12640. }
  12641. foreach (var item in dto.Arr)
  12642. {
  12643. foreach (var chi in item.chiList)
  12644. {
  12645. if (chi.parentId == 0)
  12646. {
  12647. chi.parentId = item.id;
  12648. }
  12649. }
  12650. }
  12651. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12652. _sqlSugar.BeginTran();
  12653. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12654. {
  12655. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12656. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12657. {
  12658. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12659. DeleteUserId = dto.UserId,
  12660. IsDel = 1
  12661. }).ExecuteCommand();
  12662. }
  12663. try
  12664. {
  12665. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12666. {
  12667. CreateTime = DateTime.Now,
  12668. CreateUserId = dto.UserId,
  12669. Details = x.details,
  12670. ParentId = x.parentId,
  12671. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12672. Remark = "",
  12673. IsDel = 0
  12674. }).ToList()).ExecuteCommand();
  12675. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12676. {
  12677. Id = x.id,
  12678. Details = x.details,
  12679. ParentId = x.parentId,
  12680. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12681. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12682. {
  12683. Details = x.Details,
  12684. ParentId = x.ParentId,
  12685. Time = x.Time
  12686. }).ExecuteCommand();
  12687. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12688. {
  12689. Id = x.id,
  12690. Date = x.date,
  12691. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12692. {
  12693. Date = x.Date
  12694. }).ExecuteCommand();
  12695. _sqlSugar.CommitTran();
  12696. jw = JsonView(true, "保存成功!");
  12697. }
  12698. catch (Exception ex)
  12699. {
  12700. _sqlSugar.RollbackTran();
  12701. jw = JsonView(false, "保存失败!" + ex.Message);
  12702. }
  12703. return Ok(jw);
  12704. }
  12705. /// <summary>
  12706. /// 报批行程生成
  12707. /// </summary>
  12708. /// <param name="dto"></param>
  12709. /// <returns></returns>
  12710. [HttpPost]
  12711. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12712. {
  12713. var jw = JsonView(false);
  12714. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12715. if (group == null)
  12716. {
  12717. jw.Msg = "暂无该团组!";
  12718. return Ok(jw);
  12719. }
  12720. //黑屏代码数据
  12721. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12722. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12723. {
  12724. jw.Msg = "黑屏代码有误!";
  12725. return Ok(jw);
  12726. }
  12727. foreach (DataRow row in dtBlack.Rows)
  12728. {
  12729. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12730. {
  12731. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12732. return Ok(jw);
  12733. }
  12734. }
  12735. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12736. var resultArr = new ArrayList();
  12737. if (officialActivitiesArr.Count == 0)
  12738. {
  12739. jw.Msg = "暂无公务出访信息!";
  12740. return Ok(jw);
  12741. }
  12742. try
  12743. {
  12744. _sqlSugar.BeginTran();
  12745. DeleteApprovalJourney(new
  12746. Domain.Dtos.Groups.DeleteApprovalJourney
  12747. {
  12748. Diid = dto.Diid,
  12749. uesrId = dto.Userid
  12750. });
  12751. var stay = "-";
  12752. var cityPath = "-";
  12753. //添加城市路径以及住宿地
  12754. //黑屏代码获取时间区间
  12755. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12756. var empty = "【未收入该三字码!请机票同事录入】";
  12757. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12758. for (int i = 0; i < timeArr.Count; i++)
  12759. {
  12760. stay = "-";
  12761. cityPath = "-";
  12762. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12763. DateTime NewData = DateTime.Parse(timeArr[i]);
  12764. 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();
  12765. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12766. if (tbSelect.Length > 0)
  12767. {
  12768. List<string> threeCodeStr = new List<string>();
  12769. bool isTrade = false;
  12770. string trip = string.Empty;
  12771. var rowLast = tbSelect.Last();
  12772. var rowFirst = tbSelect.First();
  12773. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12774. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12775. var takeOffTime = DateTime.Parse(timeArr[i]);
  12776. var fallToTime = DateTime.Parse(timeArr[i]);
  12777. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12778. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12779. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12780. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12781. foreach (var item in tbSelect)
  12782. {
  12783. var start = string.Empty;
  12784. var end = string.Empty;
  12785. var threeCode = item["Three"].ToString() ?? "";
  12786. if (threeCode.Length == 6)
  12787. {
  12788. start = threeCode.Substring(0, 3);
  12789. end = threeCode.Substring(3, 3);
  12790. if (threeCodeStr.Count == 0)
  12791. {
  12792. threeCodeStr.Add(start);
  12793. threeCodeStr.Add(end);
  12794. }
  12795. else
  12796. {
  12797. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12798. {
  12799. threeCodeStr.Add(end);
  12800. }
  12801. else
  12802. {
  12803. threeCodeStr.Add(start);
  12804. threeCodeStr.Add(end);
  12805. }
  12806. }
  12807. }
  12808. //处理机票信息
  12809. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12810. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12811. if (start_Object == null)
  12812. {
  12813. start_Object = new Res_ThreeCode()
  12814. {
  12815. AirPort = empty,
  12816. AirPort_En = empty,
  12817. City = empty,
  12818. Country = empty,
  12819. Four = empty,
  12820. Three = empty,
  12821. };
  12822. }
  12823. if (end_Object == null)
  12824. {
  12825. end_Object = new Res_ThreeCode()
  12826. {
  12827. AirPort = empty,
  12828. AirPort_En = empty,
  12829. City = empty,
  12830. Country = empty,
  12831. Four = empty,
  12832. Three = empty,
  12833. };
  12834. }
  12835. //机型判断
  12836. string airModel = item["AirModel"].ToString();
  12837. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12838. string flightTime = item["FlightTime"].ToString();
  12839. if (flightTime!.Contains(":"))
  12840. {
  12841. flightTime = flightTime.Replace(":", "小时");
  12842. flightTime += "分钟";
  12843. }
  12844. if (flightTime.Contains("H"))
  12845. {
  12846. flightTime = flightTime.Replace("H", "小时");
  12847. }
  12848. if (flightTime.Contains("M"))
  12849. {
  12850. flightTime = flightTime.Replace("M", "分钟");
  12851. }
  12852. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12853. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12854. {
  12855. flightTime = flightDataTime.Hour > 0
  12856. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12857. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12858. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12859. }
  12860. //航班号
  12861. string flightcode = item["Fliagtcode"].ToString();
  12862. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12863. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12864. if (aircompany == null)
  12865. {
  12866. aircompany = new Res_AirCompany
  12867. {
  12868. CnName = hsEmpty,
  12869. EnName = hsEmpty,
  12870. ShortCode = hsEmpty,
  12871. };
  12872. }
  12873. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12874. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12875. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12876. if (isTrade)
  12877. {
  12878. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12879. }
  12880. else
  12881. {
  12882. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12883. }
  12884. }
  12885. chiarr.Add(new Grp_ApprovalTravelDetails
  12886. {
  12887. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12888. CreateTime = DateTime.Now,
  12889. CreateUserId = dto.Userid,
  12890. ParentId = 0,
  12891. Details = trip
  12892. });
  12893. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12894. var last = threeCodeStr.Last();
  12895. foreach (var item in threeCodeStr)
  12896. {
  12897. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12898. if (item.Equals(last))
  12899. {
  12900. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12901. }
  12902. }
  12903. cityPath = cityPath.Trim('-');
  12904. }
  12905. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12906. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12907. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12908. appro.Diid = dto.Diid;
  12909. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12910. appro.Id = thisId;
  12911. appro.CreateUserId = dto.Userid;
  12912. appro.CreateTime = DateTime.Now;
  12913. foreach (var item in gwinfo)
  12914. {
  12915. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12916. chi.Details = "拜访" + item.Client;
  12917. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12918. {
  12919. chi.Details += "," + item.ReqSample;
  12920. }
  12921. chi.ParentId = thisId;
  12922. chi.Time = item.Time;
  12923. chiarr.Add(chi);
  12924. }
  12925. if (chiarr.Count < 5)
  12926. {
  12927. for (int j = chiarr.Count; j < 5; j++)
  12928. {
  12929. chiarr.Add(new
  12930. Grp_ApprovalTravelDetails());
  12931. }
  12932. }
  12933. resultArr.Add(new
  12934. {
  12935. appro.Id,
  12936. appro.Date,
  12937. appro.Diid,
  12938. chiList = chiarr.Select(x1 => new
  12939. {
  12940. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12941. x1.Details,
  12942. x1.ParentId,
  12943. x1.Id
  12944. })
  12945. });
  12946. }
  12947. _sqlSugar.CommitTran();
  12948. jw = JsonView(true, "生成成功!", resultArr);
  12949. }
  12950. catch (Exception ex)
  12951. {
  12952. jw.Code = 400;
  12953. jw.Msg = "生成失败!" + ex.Message;
  12954. }
  12955. return Ok(jw);
  12956. }
  12957. /// <summary>
  12958. /// 报批行程word导出
  12959. /// </summary>
  12960. /// <param name="dto"></param>
  12961. /// <returns></returns>
  12962. [HttpPost]
  12963. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12964. {
  12965. var jw = JsonView(false);
  12966. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12967. if (group == null)
  12968. {
  12969. jw.Msg = "暂无该团组!";
  12970. return Ok(jw);
  12971. }
  12972. //模板路径
  12973. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12974. //载入模板
  12975. Document doc = new Document(tempPath);
  12976. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12977. //获取所填表格的序数
  12978. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12979. Aspose.Words.Tables.Row titleRowClone = null;
  12980. Aspose.Words.Tables.Row CenterRowClone = null;
  12981. int index = 0;
  12982. int indexChi = 0;
  12983. int SetIndex = 0;
  12984. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12985. //获取数据,放到datatable
  12986. foreach (var item in ApprovalTravelArr)
  12987. {
  12988. if (index > 0)
  12989. {
  12990. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12991. tableOne.AppendChild(titleRowClone);
  12992. }
  12993. var textTime = item.Date;
  12994. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12995. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12996. SetIndex++;
  12997. if (ChiRep.Count > 0)
  12998. {
  12999. foreach (var itemChi in ChiRep)
  13000. {
  13001. var txtTime = itemChi.Time;
  13002. var txtDetail = itemChi.Details;
  13003. if (indexChi > 0)
  13004. {
  13005. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13006. tableOne.AppendChild(CenterRowClone);
  13007. }
  13008. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13009. {
  13010. SetCells(tableOne, doc, SetIndex, 0, "");
  13011. SetCells(tableOne, doc, SetIndex, 1, "");
  13012. indexChi++;
  13013. SetIndex++;
  13014. break;
  13015. }
  13016. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13017. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13018. indexChi++;
  13019. SetIndex++;
  13020. }
  13021. }
  13022. else
  13023. {
  13024. if (indexChi > 0)
  13025. {
  13026. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13027. tableOne.AppendChild(CenterRowClone);
  13028. }
  13029. SetCells(tableOne, doc, SetIndex, 0, "");
  13030. SetCells(tableOne, doc, SetIndex, 1, "");
  13031. indexChi++;
  13032. SetIndex++;
  13033. }
  13034. index++;
  13035. }
  13036. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13037. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13038. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13039. jw.Code = 200;
  13040. jw.Msg = "";
  13041. return Ok(jw);
  13042. }
  13043. private string intToString(int numberVal)
  13044. {
  13045. string numberval = numberVal.ToString();
  13046. Dictionary<char, string> Number = new Dictionary<char, string>();
  13047. Number.Add('1', "一");
  13048. Number.Add('2', "二");
  13049. Number.Add('3', "三");
  13050. Number.Add('4', "四");
  13051. Number.Add('5', "五");
  13052. Number.Add('6', "六");
  13053. Number.Add('7', "七");
  13054. Number.Add('8', "八");
  13055. Number.Add('9', "九");
  13056. string stringNumberVal = string.Empty;
  13057. for (int i = 0; i < numberval.Length; i++)
  13058. {
  13059. if (i == 0)
  13060. {
  13061. stringNumberVal += Number[numberval[i]];
  13062. }
  13063. else if (i >= 1)
  13064. {
  13065. if (numberval[i] == '0')
  13066. {
  13067. stringNumberVal = "十";
  13068. }
  13069. else
  13070. {
  13071. stringNumberVal += "十" + Number[numberval[i]];
  13072. }
  13073. }
  13074. }
  13075. return stringNumberVal;
  13076. }
  13077. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13078. {
  13079. //获取table中的某个单元格,从0开始
  13080. Cell lshCell = table.Rows[rows].Cells[cells];
  13081. //将单元格中段落移除
  13082. foreach (Node item in lshCell.Paragraphs)
  13083. {
  13084. lshCell.Paragraphs.Remove(item);
  13085. }
  13086. if (val.Contains("\r\n"))
  13087. {
  13088. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13089. foreach (var item in spArr)
  13090. {
  13091. //新建一个段落
  13092. Paragraph p = new Paragraph(doc);
  13093. var r = new Run(doc, item);
  13094. //把设置的值赋给之前新建的段落
  13095. p.AppendChild(r);
  13096. //将此段落加到单元格内
  13097. lshCell.AppendChild(p);
  13098. }
  13099. }
  13100. else
  13101. {
  13102. //新建一个段落
  13103. Paragraph p = new Paragraph(doc);
  13104. var r = new Run(doc, val);
  13105. //把设置的值赋给之前新建的段落
  13106. p.AppendChild(r);
  13107. //将此段落加到单元格内
  13108. lshCell.AppendChild(p);
  13109. }
  13110. }
  13111. [HttpPost]
  13112. public async Task<IActionResult> ServerHttp(string paramStr)
  13113. {
  13114. paramStr = paramStr.TrimEnd('\'');
  13115. paramStr = paramStr.TrimStart('\'');
  13116. JsonView jw = JsonView(false);
  13117. JObject param = JObject.Parse(paramStr);
  13118. if (!param.ContainsKey("url"))
  13119. {
  13120. jw.Msg = "url null";
  13121. return Ok(jw);
  13122. }
  13123. string url = param["url"]!.ToString();
  13124. var methon = "get";
  13125. Dictionary<string, string> headValues = null;
  13126. string bodyStr = string.Empty;
  13127. if (param.ContainsKey("methon"))
  13128. {
  13129. methon = param["methon"]!.ToString().ToLower();
  13130. }
  13131. if (param.ContainsKey("header"))
  13132. {
  13133. var header = param["header"]!.ToString();
  13134. JObject headerJobject = JObject.Parse(header);
  13135. headValues = new Dictionary<string, string>();
  13136. foreach (JProperty item in headerJobject.Properties())
  13137. {
  13138. var value = item.Value.ToString();
  13139. var head = item.Path;
  13140. headValues.Add(head, value);
  13141. }
  13142. }
  13143. HttpClient client = new HttpClient();
  13144. string responseString = string.Empty;
  13145. StringContent content = null;
  13146. if (headValues != null)
  13147. {
  13148. foreach (var item in headValues.Keys)
  13149. {
  13150. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13151. {
  13152. if (param.ContainsKey("body"))
  13153. {
  13154. bodyStr = param["body"]!.ToString();
  13155. }
  13156. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13157. }
  13158. else
  13159. {
  13160. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13161. }
  13162. }
  13163. }
  13164. try
  13165. {
  13166. if (methon == "get")
  13167. {
  13168. responseString = await client.GetStringAsync(url);
  13169. }
  13170. else if (methon == "post")
  13171. {
  13172. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13173. {
  13174. Content = content
  13175. };
  13176. var response = await client.SendAsync(request);
  13177. try
  13178. {
  13179. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13180. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13181. {
  13182. using (StreamReader reader = new StreamReader(gzipStream))
  13183. {
  13184. responseString = await reader.ReadToEndAsync();
  13185. }
  13186. }
  13187. }
  13188. catch (Exception)
  13189. {
  13190. responseString = await response.Content.ReadAsStringAsync();
  13191. }
  13192. }
  13193. else
  13194. {
  13195. responseString = "methon error";
  13196. }
  13197. jw = JsonView(true, "success", responseString);
  13198. }
  13199. catch (Exception ex)
  13200. {
  13201. jw.Msg = "error " + ex.Message;
  13202. jw.Data = ex.StackTrace;
  13203. }
  13204. finally
  13205. {
  13206. client.Dispose();
  13207. }
  13208. return Ok(jw);
  13209. }
  13210. #endregion
  13211. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13212. /// <summary>
  13213. /// 团组接待意见调查 - 信息管理
  13214. /// 基础数据(团组)
  13215. /// </summary>
  13216. /// <param name="dto"></param>
  13217. /// <returns></returns>
  13218. [HttpGet]
  13219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13220. public async Task<IActionResult> OpinionaireInit()
  13221. {
  13222. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13223. .Select(x => new
  13224. {
  13225. x.Id,
  13226. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13227. })
  13228. .OrderByDescending(x => x.Id)
  13229. .ToListAsync();
  13230. return Ok(JsonView(groupData, groupData.Count));
  13231. }
  13232. /// <summary>
  13233. /// 团组接待意见调查 - 信息管理
  13234. /// 信息列表
  13235. /// </summary>
  13236. /// <param name="groupId"></param>
  13237. /// <returns></returns>
  13238. [HttpGet("{groupId}")]
  13239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13240. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13241. {
  13242. if (groupId < 1) Ok(JsonView(false,"请传入有效的diId"));
  13243. var data = await _opinionaireRep.Query(x => x.IsDel == 0 && x.DiId == groupId)
  13244. .LeftJoin<Sys_Users>((x,u) => x.CreateUserId == u.Id)
  13245. .Select((x, u) => new
  13246. {
  13247. x.Id,
  13248. x.TourGuideName,
  13249. x.CityName,
  13250. CreateUserName = u.CnName,
  13251. x.CreateTime
  13252. })
  13253. .OrderByDescending(x => x.Id)
  13254. .ToListAsync();
  13255. return Ok(JsonView(data));
  13256. }
  13257. #endregion
  13258. // /// <summary>
  13259. // ///
  13260. // /// </summary>
  13261. // /// <param name="_dto"></param>
  13262. // /// <returns></returns>
  13263. // [HttpPost]
  13264. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13265. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13266. // {
  13267. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13268. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13269. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13270. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13271. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13272. // dic_psg.Add("客人", 974);
  13273. // dic_psg.Add("司机", 975);
  13274. // dic_psg.Add("导游", 976);
  13275. // dic_psg.Add("公司内部人员", 977);
  13276. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13277. // foreach (var item in list_visa)
  13278. // {
  13279. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13280. // temp.Id = item.Id;
  13281. // temp.DIId = item.DIId;
  13282. // temp.VisaClient = item.VisaClient;
  13283. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13284. // temp.VisaCurrency = item.VisaCurrency;
  13285. // temp.IsThird = item.IsThird;
  13286. // if (dic_psg.ContainsKey(item.PassengerType))
  13287. // {
  13288. // temp.PassengerType = dic_psg[item.PassengerType];
  13289. // }
  13290. // else {
  13291. // temp.PassengerType = -1;
  13292. // }
  13293. // temp.VisaNumber = item.VisaNumber;
  13294. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13295. // temp.CreateUserId = item.Operators;
  13296. // DateTime dt_ct;
  13297. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13298. // if (b_ct)
  13299. // {
  13300. // temp.CreateTime = dt_ct;
  13301. // }
  13302. // else
  13303. // {
  13304. // temp.CreateTime = DateTime.Now;
  13305. // }
  13306. // temp.DeleteTime = "";
  13307. // temp.DeleteUserId = 0;
  13308. // temp.Remark = item.Remark;
  13309. // if (string.IsNullOrEmpty(temp.Remark)) {
  13310. // temp.Remark = "";
  13311. // }
  13312. // temp.IsDel = item.IsDel;
  13313. // temp.VisaDescription = item.VisaAttachment;
  13314. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13315. //([Id]
  13316. // ,[DIId]
  13317. // ,[VisaClient]
  13318. // ,[VisaPrice]
  13319. // ,[VisaCurrency]
  13320. // ,[IsThird]
  13321. // ,[PassengerType]
  13322. // ,[VisaNumber]
  13323. // ,[VisaFreeNumber]
  13324. // ,[CreateUserId]
  13325. // ,[CreateTime]
  13326. // ,[DeleteTime]
  13327. // ,[DeleteUserId]
  13328. // ,[Remark]
  13329. // ,[IsDel]
  13330. // ,[visaDescription])
  13331. // VALUES
  13332. // ({0},{1},'{2}',{3},{4}
  13333. //,{5},{6},{7},{8},{9}
  13334. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13335. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13336. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13337. //);
  13338. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13339. // }
  13340. // return Ok(JsonView(true, "操作成功!"));
  13341. // }
  13342. /// <summary>
  13343. /// 123132123
  13344. /// </summary>
  13345. /// <param name="_dto"></param>
  13346. /// <returns></returns>
  13347. [HttpPost]
  13348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13349. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13350. {
  13351. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13352. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13353. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13354. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13355. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13356. dicDetail.Add(789, 1034);
  13357. dicDetail.Add(790, 1035);
  13358. dicDetail.Add(791, 1036);
  13359. dicDetail.Add(792, 1037);
  13360. dicDetail.Add(793, 1038);
  13361. dicDetail.Add(794, 1039);
  13362. dicDetail.Add(795, 1040);
  13363. dicDetail.Add(796, 1041);
  13364. dicDetail.Add(797, 1042);
  13365. dicDetail.Add(798, 1043);
  13366. dicDetail.Add(801, 1044);
  13367. dicDetail.Add(802, 1045);
  13368. dicDetail.Add(803, 1046);
  13369. Dictionary<int, int> dic = new Dictionary<int, int>();
  13370. dic.Add(806, 1027);
  13371. dic.Add(807, 1028);
  13372. dic.Add(808, 1029);
  13373. dic.Add(809, 1030);
  13374. dic.Add(810, 1031);
  13375. dic.Add(811, 1032);
  13376. dic.Add(812, 1033);
  13377. foreach (var item in list_visa)
  13378. {
  13379. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13380. temp.Coefficient = item.coefficient;
  13381. DateTime dtCrt;
  13382. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13383. if (b1)
  13384. {
  13385. temp.CreateTime = dtCrt;
  13386. }
  13387. else
  13388. {
  13389. temp.CreateTime = DateTime.Now;
  13390. }
  13391. temp.CreateUserId = item.Operators;
  13392. temp.DeleteTime = "";
  13393. temp.DeleteUserId = 0;
  13394. temp.DiId = int.Parse(item.DIID);
  13395. temp.FilePath = item.FilePath;
  13396. temp.IsDel = item.IsDel;
  13397. temp.Price = item.Price;
  13398. temp.PriceCount = 1;
  13399. temp.PriceCurrency = item.Currency;
  13400. int detailId = 0;
  13401. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13402. {
  13403. detailId = dicDetail[item.PriceTypeDetail];
  13404. }
  13405. temp.PriceDetailType = detailId;
  13406. temp.PriceDt = DateTime.Now;
  13407. temp.PriceName = item.PriceName;
  13408. temp.PriceSum = item.Price;
  13409. int tid = 0;
  13410. if (dic.ContainsKey(item.PriceType))
  13411. {
  13412. tid = dic[item.PriceType];
  13413. }
  13414. temp.PriceType = tid;
  13415. temp.Remark = item.Remark;
  13416. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13417. }
  13418. return Ok(JsonView(true, "操作成功!"));
  13419. }
  13420. }
  13421. }